May 27

Moving on

Tag: Full Games,MMORPG Tycoontrevor @ 11:21 pm

So I’ve finished up with terrain for the moment;  I’m pretty happy with the system and the general look that I have now.  I found some pretty major optimisations today, which means that I’m now able to render the terrain with the ground clutter in less time than it took yesterday to draw just the terrain without the clutter.

(For any programmers in the audience, the key thing was to pay attention to memory access patterns;  if you have an array of 65,000 vertices arranged in 256 rows of 256 vertices each, then it’s faster to draw triangles along the rows than down the columns, because the rows are organised close to each other in memory, whereas the columns are spaced widely apart)

So I’m now pretty happy with the basic terrain system and rendering.  There’s still a lot of stuff I could do to tweak it, but I’m going to leave that sort of tuning until everything else is in place.  I believe that the next thing I’ll work on will be “picking”.. that is, determining what object or bit of heightmap is under the cursor.  This will be essential for tasks like letting the player place roads and buildings onto the undulating heightmap.  The system I had in place in MMORPG Tycoon 1.x only worked in 2D, and the picking I wrote for Lord was an ugly hack that wouldn’t scale to the size of worlds I’m using here — you could fit about 500  of the “Lord” maps into the screenshots which I’ve been showing;   Lord’s game world was only 60 x 60 vertices in size, after all.

Once picking is working, then I’ll start on placements;  placements of buildings, and of an interface to make terrain adjustments.  There’s so much stuff to implement!  :)

5 Responses to “Moving on”

  1. Wickedgenius says:

    Keep the blog posts and delicious screenshots coming. ;)

  2. Dan Haraj says:

    Ah yes. Cache coherency is a real big thing to look out for when your algorithm works on a large chunk of memory.

  3. trevor says:

    My mistake was in thinking that the driver would magically optimise things for me when I compiled the OpenGL display list. Of course, that’s not actually the case! :)

  4. Dan Haraj says:

    Shame on you for making positive assumptions about your tools :p

    I wonder. Do you think you would get a performance boost if you implemented the engine in DX9/10?

  5. trevor says:

    That’s an interesting question, Dan. As you can tell from the screenshots, I’m doing my main development on a Mac and porting over to Win32 afterwards (and potentially Linux or other OSes), which means that DX9/10 isn’t a practical option for me. Also, I’ve no experience with DirectX programming, so it’d take me time to come up to speed with it.

    But with that said, my understanding is that DX9/10 guarantees particular 3D features to exist, which is not the case with OpenGL (this means that under DirectX, I wouldn’t have to spend time worrying about how to do a bloom effect on systems which don’t support shaders or render targets, for example). Certainly in Win32, my understanding is that the Direct3D drivers for the major cards tend to be much better-written than the OpenGL drivers, and provide far better performance. But with that said, the current build of MMORPG Tycoon 2 has no trouble running at a capped 60fps on my several-years-old Windows laptop, which has a heavily underclocked ATI 3D card.

    Once I have a few more features implemented (primarily, making the cursor behaviour a little nicer), I’ll probably post a tech demo and ask people to let me know how well it runs for them on their own computers.