Archived

This topic is now archived and is closed to further replies.

Mr DirectX

Fast Isometric Rendering

Recommended Posts

This is a somewhat lengthy question, but I a have not been able to find any solution to it listed in the past questions. I am having problems designing a fast rendering routine for my isometric engine. My idea for drawing fast is to prerender the ENTIRE game world to a huge offscreen surface and then to copy the segment currently within view to the screen during each frame. On this huge surface, I draw only static objects and terrain that will not change or move during game play. I don't draw any objects (characters, monsters, etc.) that will be moving throughout the game to this offscreen surface. I am quite confident that this is how SimCity 3000 does it; I watched the game load up/initialize many times and it looks this way to me! So here is what I am doing: First I drew the entire world (4000x3000 pixels) as a set of large bitmaps in PaintShopPro and using my own map editor and saved them as bitmap files. Game Initialization: - Copy these bitmaps to a huge offscreen surface. Main Rendering Routine (executed every frame): -Maintain a "focus" rectangle that "floats" over this huge offscreen surface -Copy pixels within the "focus" rectangle to an 800x600 backbuffer -Scan through the tiles currently within focus and draw the objects contained within those tiles to the backbuffer, IN THE CORRECT Z-ORDER and WITHOUT SEVERLY MESSING UP ANY OBJECTS AND ANY TERRAIN ALREADY DRAWN ON THE BACKBUFFER. -Flip backbuffer to screen Rendering the land without drawing any objects on it is EXTREMLY FAST! (*)Here is the problem: When I draw sprites/objects to the backbuffer, it takes a long time to draw them in the correct position (behind other objects, behind hills, mountains). Is there any algorithm (a z-buffer type algorithm for instance) that will allow me to draw the objects (characters, forts, cities, monsters) onto the backbuffer, in the correct position, behind/partially behind other monsters, hills, etc, that are already drawn on the backbuffer? My whole purpose in this huge offscreen surface was to make the rendering of the static objects (hills, trees and water) very fast, just copy the current view rect to the screen. But I still cannot think of anyway to draw the moving objects onto the backbuffer without severely messing it up and/or taking about 2-5 seconds to properly draw them because they may be partially concealed by hills and other objects. How can I speed up the drawing of objects to the backbuffer? Edited by - Mr DirectX on March 19, 2001 5:45:38 PM

Share this post


Link to post
Share on other sites
Here''s the method that I had been using in VB to do a tile engine for an RTS game. It works, though it won''t be as fast as one blit from an offscreen surface. However, it runs at 75 fps in _VB_ on my PIII550 (mainstream nowadays), so it must be fast enough.

Blit each tile to the screen from a "tile source" surface in this order:

01-02-03-04-05
06-07-08-09-10
11-12-13-14-15
16-17-18-19-20
21-22-23-24-25

And, after each tile is drawn but before the next one is, draw the appropriate unit on top of it. This will mean that if the screen is filled with units, they will draw in the order tiles are drawn in, as I described above.

You may want to keep a 2d array of unit numbers AND a 1d array or linked list containing info about each unit number (Unit #213 is a green footman with 30 health, for example). This would make the system MUCH more efficient. If you want per-map-pixel an not per-tile movement, also store x and y tile offsets in this list. However, be warned that offsets can only be above and to the right of a tile. That shouldn''t be a problem, though. The "mod" operator and a little multiiplication is about all you need.

This still doesn''t deal too well with mountains and other things that rise form the terrain.

If your mountains are individual sprites, then that''s no big deal. Just blit them after the tiles and units "underneath" or "behind" them are. If your mountains are tiles, however, it might be a larger problem. YOu''d have to blit them at a time that takes into accounts Z as well as X and Y coordinates. Higher Z coordinates would move it more towards the end of the list of what tile is drawn when. You could get it to work.

All this would involve some trial and error, and a not insignificant amount of coding.

What, then, should you do? You can dive in with these techniques, or try some sort of bubble sort or quick sort to take into account all units and tiles within the viewing rectangle (a 2d frustrum) OR you could move to isometric 3D in OpenGL. From what you''re saying 3D does seem to be the soluution.

Share this post


Link to post
Share on other sites
Well you can definately tell the JR developers from the seniors and so far all I have seen on this board is a bunch of JR''s. Not to discourage anyone, but the first thing you need to do is forget whatever you have read and what you think you know. I will try to give you a very high view of game development so that you can get on the right track. (I remember the days before I started developing professionally, so take this as a sign from god and read on.)

First off, you need to break game development into a lot of small tasks. Games, are very tough and require alot of thinking. The most important aspect of any game is NOT the graphics. Rather, the formulas and calculations and ideas that go into the character development. This should be done before you attempt to write a single line of code.

I will address your more direct question. You have part of the idea but a horrible design - that is why it''s taking so long for you to render. I don''t really care what language you use, I prefer C++ but VB is fine with DirectX support as long as your using VB6 with true native compiling.

First thing to consider ALWAYS is memory constraints and CPU. Now I''m not going to go into the math that calculates the figures, but storing graphics into memory is generally a BAD idea. Usually you want to swap a portion of the map from file, and maintain only viewable screen data in memory with a small amout of memory used for unseen map buffering to avoid flickering.
1) Basically store your map as a big binary file with some sort of algorythm that shows tile, size etc..
2)Calculate your resolution 1024X768 or whatever and divide your tile pixel height and width to get the amount of viewable tiles.
3)figure out your map position, then seek the top portion X,Y out of your map file
4)figure out how much minimal viewdata you want to buffer into memory, store that and display your viewable portion.
5)As you move rendor memory buffer screen, and go back to the map and redo step 3.

This should take care of your rendering problem and speed up the movement - now there is a HUGE section on theory in game development I suggest you pick up a book and read up on Windows BLT (DirectX Rendoring) and back swaping this will help you with your initial calulations.

Remember POLYGONS and GRAPHICS DO NOT I REPEAT DO NOT make a good game, it''s the concept and thoughtfulness in putting the game rules and play together that makes it enjoyable.

I hoped I helped some.

Regards,
Evolution Arts, LLC

Share this post


Link to post
Share on other sites
quote:
Original post by Evolution_Arts

Well you can definately tell the JR developers from the seniors and so far all I have seen on this board is a bunch of JR''s.
...



...He says this with a yahoo email address...
...He spells "definately" wrong...

There''s nothing wrong with JR developers (eg Me which is perhaps not a very good example of ''nothing wrong'') - they are enthusiastic and can be employed for lower rates but trained to be top class.
Don''t diss us.

Share this post


Link to post
Share on other sites
First of all...
Ever here of spam!!?? Maybe you havnt had that fun chance yet. Someone who knows better always supplies a spam mail account to the internet world so all your crap mail goes there and only private mail from friends go to your real account....so dont get a cocky attitude about what email this or that is.

As for the JR thing, yeah he was a little rough about it, but the main point should be that there are definite improvements too map rendering, so try th advice and do with it what you will.

Oh, and we all mis-psell ocne ni a whlie.


Visit my planet: Planet John
Capt. James Tiberious Kirk -- hmm, didnt know ole Capn was a tiberia fan.

Share this post


Link to post
Share on other sites
This pertains to my initial posting.

I am well aware of how to render an isometric scene in the "traditional" method. You start at the upper-left tile and render left to right and then back to front, painting the tiles and the objects on them. Yes, and this does give a very fast frame rate. However, if you look at how SimCity 3000 initializes/gets started, you will see that that game uses a different approach. I was wishing to try to duplicate their process. However, in the end, the simple method of rendering each tile and their objects each frame is still faster. My engine will therefore be based upon that model.

* Thanks to all those who read my initial question.

Share this post


Link to post
Share on other sites
quote:
Original post by GalaxyQuest

First of all...
Ever here of spam!!?? Maybe you havnt had that fun chance yet. Someone who knows better always supplies a spam mail account to the internet world so all your crap mail goes there and only private mail from friends go to your real account....so dont get a cocky attitude about what email this or that is.

As for the JR thing, yeah he was a little rough about it, but the main point should be that there are definite improvements too map rendering, so try th advice and do with it what you will.

Oh, and we all mis-psell ocne ni a whlie.



Ok, fair enough, I agree. But He could try to look more proffessional though . And I thank him for the advice.

As for spam, the spammers can get your address through DNS records and other devious means anyway.

Share this post


Link to post
Share on other sites