Friday, February 11, 2011

26 – Bye Bye Beautiful

I am talking of course about the isometric engine. It has served me very well. It was fast and slick. But now it is gone. The 3D engine is ready to be included in production code, so in order to symbolically confirm my commitment to 3D, I deleted all isometric code. Don’t worry, I still have backups with it. I doubt I’ll ever need it, but it is there.
But before I continue, let me tell you a short story. It began with me working late into the night and applying the finishing touches to the 3D engine. In the prototype state, it was a total mess that maybe had the potential to one day be called a proper engine. By Monday, when I last posted, it was a chaotic blob of hacks that worked surprisingly well. And by 2-3 AM, it was pretty much production ready. Code was in very good shape and technically there was very little to object (I don’t have yet enough meshes and did not implement lighting, but that is a different story).
In the morning I selected all folders and wanted to create a backup archive. I noticed that the backups are getting quite numerous, so I selected a few and hit delete. Without deselecting my code! I noticed that it was deleting to many files and realized my mistake, but I decided not to hit cancel and revert the delete after it finished, since most of the files were deleted already. I would like to stop here and congratulate Window 7 Recycle Bin for being a total piece of crap. In the past it was a useful tool. Now it greats you with a list of all your files, and after restoring, it screwed up and restored different versions of my files. And most of them old. Oh well, shit happens. I managed to rewrite 99% of the changes and merged with a different backup that had all the new features that are not related to the 3D engine.
I really need to start using a repository. But a local repository wouldn’t have helped, since it would have gotten deleted. I don’t want to set up an online repository server on my machines. Most free hosting is for open-source, and anyway I don’t trust such services not to steal my code. Sigh…
Let us get back to the change log.

New 3D engine now in production code

And let me tell you, I am really starting to like it. There are still a few issues, like tilt and zoom are very restrictive because I can’t figure out how to make them more flexible without killing performance. Rotate is not implemented yet. But still, combining zoom, tilt and old fashioned scrolling makes for a pleasant interaction with the map and obstructed items can be easily brought into view. And speaking about performance, the engine is a little bit slow. Of course, when I am claiming that something is slow and don’t give explicit numbers, you should always take that with a grain of salt. I am somewhat of an elitist and perfectionist. The engine runs at around 150 minimal FPS and it can get up  to over 600 when rendering a barren landscape. But it is not enough!
The new tweaks to the engine have made it more “center” centric. I don’t want to get into technical details. Suffice to say the math is simpler now and I am happy. There is a problem though. Since the camera is now centered on the viewport it did not look that good with the interface taking up half of the screen. Anyway, such huge panels are a thing of the past. I’ll talk about this later.
I think I managed to recode everything that was lost in the little delete incident.

Interface takes up less space

Because of the above mentioned centering, I’ve made the interface smaller. Now it is harder to use at first, but no worries. In the future I’ll add proper graphics for these buttons and when mouseing over them a little panel will open up telling you what the button does. In the next screenshot you can see the interface in its new minimalistic look. I won’t show you the new engine though. Even if it is technically very sound, I haven’t gotten around to making it less ugly. So enjoy a brown screen and the interface (better than a blue screen, am I right?):

Moving the cursor with keyboard

This feature was requested on YouTube. Some people are more comfortable with a keyboard than a mouse. DwarvesH allows you to do everything with a keyboard except move the cursor and do selections. I implemented the moving of the cursor by keyboard, but this change was lost in the incident. I’ll silently patch this back in. It is only a few lines of code.

Stress testing items

I have begun both adding items and really stress testing the system. I added 2000-3000 items and by the end of the month I’ll try to get as close as possible to 20000 unique items. Creating so many items out of scratch is time consuming, so I’ll use again Dwarf Fortress data as a test bed. There are three parts to this. First, the items must be created and represented in the game. Here is a terribly outdated tree made yesterday with the item available:

Items in red are the general root categories, entities in their raw form as they appear in nature, like plants, animals, minerals… Grey items are forms in which these entities may appear which you do not own, but interact with them. So you may have a cow and 7 axes, but you do not have 10 walls and 5 floors. Items I bold are final products, in blue are the process though which they were obtained and normal text items are categories.
The second part of this process is the actual stress test. Adding these items in large numbers and seeing if everything works fine and consumes few resources.
The third part is creating and interface for managing these stockpiles. This interface must be able to handle huge quantities of items but no feel barren or obtuse when you only have a few. Here is the first iteration of the item manager. It is not that smart yet, but it will get better:


  1. So, i read your post about not being able to see what's behind some things like walls and other objects, so, i have a sugestion.
    If you played Age of Empires 2(everyone played it) you should be able to remember that when there was a unit behind a building, the building didn't became transparent, instead, a line was draw around the unit and over the building, so, it was clear and fast to see what kind of unit was there.
    It would be perfect to see what's behind what in the isometric engine, but, seeing that you have gone 100% to making the 3d engine(and it's n times better and flexible than the isometric), i think that my sugestion would still be able to implement on the 3d engine, seeing that making the obstructing object transparent, sometimes confuses you even more, so a mix of line draw and transparency, would be the best option.

    I don't know exactly how to code it, but i'm better at ideas than coding.

  2. I think I remember me using this for another project a long time ago. It is harder to do here since behind a wall you can have a full stockpile, but it is still doable. But with 3D engine, drawing borders is basically cell shading and I don’t want to do that right now.

    I personally love the way Fallout 1 & 2 handled wall transparency.

  3. So, I Forgot that the technique used in age of empires 2 works best in 2d engines, cause, if I ain't wrong, you need to use a texture or sprite, whatever, with only the outline to show anytime that the unit is behind a building, and this only works good in 2d engines, in 3d the only good way would really be with cell shading, and that doesn't even work in some old graphics cards.

    Well I remember the transparency on fallout 1 and 2, cause i was playing them some months ago, but it's more focused on the player, and not on the environment, sometimes there was a item or something you needed to use, and you searched like crazy and it was right there on the corner hidden by a wall, and not to say that it would work best again in a 2d engine.

    You could make it fully transparent, like in dungeon siege and other games like that, it would be easier and more friendly, I used the 3d tool Blender for some time to get the feel of creating 3d and how it works behind the scenes, and if you put a texture and the normals were pointing to the front, and you looked from the back, it was fully transparent, like when the camera gets crazy in some games, and it enters some walls and you could see all the scenario from the transparent back of the wall, if all engines work like that because, if you need to point in the code what quad or tri have a 2 sided texture and the 1 sided texture is transparent from the back, you wouldn't even need to implement a lot.

    Again, I'm good at ideas not code, what seems easy in my mind, could be insanely hard to code.

    And I recently saw your last post, the thing about people thinking that it's a DF clone, it's because it's a game about dwarves that build a fortress, in concept, it's the same thing, but as everyone talked about Minecraft being a clone of the (now dead) Infiniminer, with time everyone learns to see the difference, i thought about that a while ago, and i have some ideas for a game i will start doing when i have more time, and strangely, it's almost the same ideas that you have for dwarvesh, but i thought about adding another atmosphere, like something in the future or anything like that. And people only think that you're copying things, but they are the same people that gives the life for another game like god of war or devil may cry.

    We need another place to talk, the comments are getting bigger.

  4. Well, this thread exists: It has a different subject but it may be able to house some other type of comments.