# Scenery Depth

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

## 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 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 on other sites

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 on other sites
This problem pops up every now and then, I had the same problem with using sprites. I found out that using 3D boxes was the way to go for me. I project my 2D graphics onto them, that way the z-buffer still handles the sorting.

1. 1
2. 2
Rutin
21
3. 3
4. 4
A4L
15
5. 5
khawk
14

• 13
• 26
• 10
• 11
• 9
• ### Forum Statistics

• Total Topics
633737
• Total Posts
3013609
×