Sign in to follow this  

Scenery Depth

This topic is 3321 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

Hey all, In my isometric grid (C++/OpenGL), 'scenery' such as trees are currently drawn as alpha-ed quads (square) with a given depth so that the character can walk behind them and in front of them realistically. This was fine when all I had was trees. There is a horizontal cut-off line at the base of the tree. If you go above it, the Z sorting draws your character behind the scenery. Now I'm trying to implement things like diagonal walls, where this cutoff method wont work. The character can be above the cut-off line, but still physically in front of the wall. Rotating the scenery quads so theyre diagonal would seem to me to make proper-looking texture creation quite difficult. Are there any standard ways of dealing with this kind of thing? A nudge in the right direction would be greatly appreciated! Thanks Matt

Share this post


Link to post
Share on other sites
If you think about what you do for the trees, you've basically got a horizontal line where if the played is on one side of the line, they're "in front" of the tree, and if they're on the other side of the line, they're "behind" the tree. It was easy for this case, because it was simply a matter of testing "if (player.Z < tree.Z) { ... }" (or something).

With a diagonal, it's still basically the same, except that the line you're testing against is no longer horizontal. You just need to generalize your algorithm to handle non-horizontal lines and then the items can store the "angle" of their line as one their properties -- most items will have an angle of zero, so you could optimize a bit for that case.

Share this post


Link to post
Share on other sites
Thanks for the reply Codeka.

At the moment I have no algorithm at all, the scenery just has a Z position in 3D space and OpenGL's Z-sorting takes care of the rest.

Your answer makes perfect sense, I'll try to write my own function to handle the sorting then.

Share this post


Link to post
Share on other sites

This topic is 3321 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.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this