Isometric Depth

BlitzMax Forums/BlitzMax Beginners Area/Isometric Depth

lukehedman(Posted 2008) [#1]
I'm building an isometric engine. As you probably know, objects further away from the view should be drawn first to have a perspective of being behind other things.

Now, I'm trying to figure out a way to draw images based on depth efficiently. In my dream system, every object would have a "depth" variable which would be based on the object's Y coordinate. Objects would automatically be drawn in order from lowest to highest depth.

How can this be done?

Thanks!


MGE(Posted 2008) [#2]
I have a zorder variable attached to my sprites, but in order to actually use it, you have to sort the sprites based on the zorder property before they are rendered.


Sledge(Posted 2008) [#3]
Not really sure how this would apply to an isometric engine (because I've never done one and I guess you're going to have a lot of static objects in the mix) but if I had to order a lot of objects per frame I would maintain an array of lists, one per scanline, and iterate through all the objects that require drawing once, adding them to the relevant array list based on that depth (or y) variable. Then I would iterate through each array list in turn to actually draw them in order.


MGE(Posted 2008) [#4]
huh... I just looked at an old iso demo I coded a while back. I'm sorting the sprite tiles based on their Y position. So objects that are further down the screen get drawn last. I also had "layers" that I would render. Ground layer 1, buildings layer 2, etc, etc. Each layer would also sort render position based on their Y position.


lukehedman(Posted 2008) [#5]
Now, I'm new to this (which is why I'm posting in the beginners area), so how would I sort the sprites by depth? Would I be using a list or something else?

Thanks for your replies!


lukehedman(Posted 2008) [#6]
Never mind. After searching the forums and doing some experimenting, I've got my own sorting system working.

Thanks for the advice on how to draw based on depth everyone.


Sledge(Posted 2008) [#7]
As this thread is going to pop up whenever someone searches for 'isometric' there are some decent looking tutorials here -- the two by TANSTAAFL appear particularly useful.