Jump to content
  • Advertisement
Sign in to follow this  
NQ

Problem with isometric blitting order

This topic is 3718 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hi, as the title says, I had a problem with ordering the blitting of objects and tiles in my 2D isometric game. Here's a snapshop to illustrate what I'm talking about: As you can see I use semi-3D terrain, which means that SOMEtimes the tiles should be blitted in front of objects. Such as objects standing behind a hill. So the tiles definitely need depth ordering, to arrange then nicely with all objects around them. But how do I do it?! My current solution doesn't work in all cases. My current solution uses these two points: For objects = the spot the object is standing on (the human character in this case) For tiles = the corner of each tile illustrated by the red dot. It is how far "south" these points are that decides the drawing order. Note that if the tile is elevated, i still use the red point that it WOULD have had if it was still on the ground (the second illustration). The problems which arise are two: 1. If the object sits behind the elevated tile, but south of the tile's red dot, then the object is mistakenly placed above the tile. The human character in the above screenshot is currently doing that. 2. If the object is a cylinder standing 1 foot high but with a huge radius, then it's going to extend so far away from "the point it is standing on" that the southernmost edges of it is going to be blitted over by the tiles over there. It seems like such a simple problem, but I don't get it. How do I solve this?

Share this post


Link to post
Share on other sites
Advertisement
I have a similar problem in my Isometric Flash 'game' (not a game yet).

Anyway, I give each tile type a depth, so all characters are depth 5, floors are 1. Fringe tiles are 2, walls are 5. I then use a combination of the tile's Y position on the map, it's Z position on the map, and finally I sort by depth. (Im not looking at my code at the moment, so I forget which I look for first, second, etc - but this should give you a general idea).

There are some minor glitches with this method, but for the most part scenes are rendered properly - albeit slowly.

Something I was thinking of using (to speed the rendering up) is using a heuristic model to assign a numeric value to each tile, then sorting all tiles based on that number.

I havnt worked out exactly how to come to this number - but I would guess that taking the tiles Y and Z position, multiplying each by a set number then adding the results together.

Order = (YPos * (ZPos * 100)) * TileTypeDepth;

For tile (x,y,z): (ignoring depth at the moment)
(1,1,1) = 100
(1,1,2) = 200
(1,5,1) = 500
(1,5,2) = 1000

Etc....

Share this post


Link to post
Share on other sites
Thanks for the reply, I'm going to investigate that.
I also found this thread where they discuss the same problem, but end up solving it with the OpenGL z-buffer.

I am using OpenGL, but I am currently not blitting them in a way that would be instantly support switching on the z-buffer. I think I would have to redesign my whole blitting system if I were to use that approach.

Arghhh! Maybe it's just time I switch to full 3D, damnit.

Share this post


Link to post
Share on other sites
I'm using Flash for my Client - so I don't have that as an option, but thanks, Ill check that thread out anyway.

Share this post


Link to post
Share on other sites
I am starting to come to a conclusion;
I'm going to flatten my entire landscape so this problem disappears.
Then I'm going to finish the game, all the way to 1.0.
And then I'm going to start working on switching to full 3D in version 2.0.

One step at a time, my game have evolved through all stages of game history.
Once it was only text.
Then it was straight 2D.
Then it switched to 2D pretending to be 3D.
And soon it will switch to actual 3D.

:D

Share this post


Link to post
Share on other sites
In an isometric view where X is top-left, Z is top-right, and Y is vertical, and every object is no bigger than a tile, all you need to do is sort your tiles by decreasing X+Z and render in that order. If several objects have the same X+Z, sort them by increasing Y.

If an object takes up several tiles, then split it up into one-tile sub-objects.

Share this post


Link to post
Share on other sites
I know that is a common solution, but I do not have the freedom to make all objects 1 tile, or divide them up into 1 tile parts. Thanks though.

Share this post


Link to post
Share on other sites
Well, truthfully I DO have the freedom, but it would take so much work it just wouldnt be worth it.

Share this post


Link to post
Share on other sites
Quote:
Original post by NQ
I know that is a common solution, but I do not have the freedom to make all objects 1 tile, or divide them up into 1 tile parts. Thanks though.


In that case, there is no solution. A one-tile very high object would have the same appearance as a two-tile small object (because of the projection) but without slicing the object you have no choice but to render both the same way, leading to unwanted artifacts in at least one of the two cases.

A possible solution, if you're using an API with access to a depth buffer, is to use the depth buffer to sort out the depth of your objects (since hardware has allowed rendering to the depth buffer for a while now).

Share this post


Link to post
Share on other sites
I see. It's kindof nice to find out that it is plain and simple impossible, because that allows me to move on and think about other stuff.

Solution: I have currently flattened the whole map, and I'm working on other things. Hopefully that'll lead to finishing the game sometime soon... Once that is done, I will convert the game to 3D.

The modular structure should allow me to do that without too much effort.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!