Zooming out

Screen Shot 2013-02-10 at 11.06.04 AMSo I’m in the middle of building full seamless zoom in/out functionality for MMORPG Tycoon 2.  This was really one of the key interface features of MMORPG Tycoon 1, and being honest with myself, it’s just as important for MMORPG Tycoon 2.  I’d originally thought I could get away without it, by presenting separate “close-up” and “distant” map modes the way that every other Tycoon game does.

But in practice, this was one of the defining features of the original game.  I really can’t just ignore it.  So I’ve started on implementation.

Here’s what it looks like right now, with the camera pulled about a kilometer up from the ground, with the camera at the southeast corner of the game world.  We can see several regions right now, and we can see out into terrain which doesn’t yet have renderable models in memory.  We can also see that I’ve cheated, and haven’t placed water around the game world, yet (you’re seeing off the eastern side of the world, there on the right).

But more than that, we can see a bunch of other issues;  issues which I’ll need to solve.  Here’s a list:

  1. We can see a very visible repeating pattern in the heightmap.  This is caused by my having put a repeating pattern in the initial computer-generated heightmap, on the theory that nobody’d ever be using this view and therefore noticing the repeats.  Well, now that I’m putting in this view, people are going to notice.  So I need a smarter base heightmap generation algorithm.
  2. From this view, it’s suddenly extremely obvious that the whole game world is very flat.  I really need to give the base heightmap some variation on a much, much higher area.  In practice, doing this might solve the problem in #1, above, as well.  Need to think about this, though.  Right now, the base terrain is generated by using the “grass” brush over the whole world, and then drawing lines with the “mountain” brush around each region.  Need to decide whether the “grass” and “mountain” brushes should always be operating with respect to some underlying “terrain shape” heightmap, or whether that’ll cause problems for users editing the terrain later  (Or whether *not* doing so will cause problems).
  3. Elephant in the room:  The whole screenshot isn’t full of terrain — terrain that should be visible from this view is missing, leaving empty black areas visible on the screen.  Right now there simply isn’t enough terrain model being generated to fill the whole screen;  I’m currently only generating enough terrain model data to guarantee that you’ll be able to see the entirety of a single region, but from this vantage point we really need to be able to see several regions at once.  And honestly, this isn’t even close to a full zoom out.  A full zoom out will probably have the camera about ten times further up than this, which (according to math) would require us to draw about 100x as much terrain geometry as we can see here.  I have serious doubts that I’ll be able to actually render that much geometry at a nice frame rate on most computers (although I should try it before I say it’s not possible).  This means that for the furthest out view, I’m going to need to render lower-resolution terrain.  Probably substantially lower-resolution terrain!  Of course, I won’t be able to use that low-resolution terrain when we’re at ground level;  it’d be much too chunky to look nice!  This means that I really need to have not just one type of terrain chunking going on, as I do now;  I’m going to need to have two or more “layers” of chunking going on, so that I can switch between them as the user zooms in and out.  At this point, I’m really glad that I’ve already set up terrain generation to occur in background threads, so generating these different terrain resolutions shouldn’t affect frame rate too much!
  4. Like #1 above, another consequence of an optimisation is visible here.  The region which is visible in the top left corner of the screen is the region containing my AI test area.  There’s a graveyard, a few questing zones, a few NPCs, an Inn, and some monsters in there.  And none of them are visible, because I’ve told the game not to bother drawing anything that’s inside a different zone than the camera.  Just on the theory that the mountainous region borders would screen off other zones from view.  This assumption is no longer valid;  I’m going to have to drop it, and potentially draw the contents of every zone, if they’re within view.  I may need to simplify, of course, and at a certain height, there’s no point to actually drawing players or monsters any more, since they’d be far too small to actually see.  In MMORPG Tycoon 1 and 1.1, I artificially scaled up buildings as you zoomed out, so they’d remain visible.  Maybe I’ll do something similar here.  Although now that a third dimension is involved, that may not actually work so well.  Will need to experiment with that a bit, and maybe switch to rendering icons instead of actual building models if it becomes problematic.