object selection indicator on terrain...

Started by
3 comments, last by mackatack 19 years, 4 months ago
Hi all... Im working on a DX9 project wich involves a terrain and some 3d animals walking that terrain. I got the picking working but i would like to render some indication on the terrain below the object that the object is selected. For those playing strategy games like Warcraft or C&C, you've prolly seen what i want. It's the little red or green circle on the terrain below the selected object. Here's a screenshot... Notice how the circle follows the terrain height. How would i render such a thing? Thanks in advance. -MackatacK [Edited by - mackatack on December 16, 2004 6:49:08 AM]
Advertisement
Quote:Notice how the circle follows the terrain height.

How would i render such a thing?
It's actually more a case of mathematics than any clever graphics technique...

You say you've got picking to work, so you should be familiar with ray-triangle/ray-object intersection tests?

The way I made a similar thing work is by using standard 2D coordinates to work out which tile I was over (my terrain heightmap was a classical evenly distributed grid), then to find the height I calculated which triangle the point was in, then using the plane equation (aX+bY+cZ+d=0) to find the missing value.

Once you have a coordinate on the terrain you can draw the indicator. Bare in mind that for some slopes a trivial use of this algorithm will see your indicator disappear behind other geometry; so you might want to align the sprite to the direction of the normal and/or offset it from the ground slightly.

hth
Jack

<hr align="left" width="25%" />
Jack Hoxley <small>[</small><small> Forum FAQ | Revised FAQ | MVP Profile | Developer Journal ]</small>

Thanks for your reply... but i already got the location where to draw the indicator. Its right below the object...

The question is how to draw the indicator in such a manner that
it forms another layer on the terrain. it should appear as another blended
texture on the terrain mesh.
Quote:Original post by mackatack
Thanks for your reply... but i already got the location where to draw the indicator. Its right below the object...

The question is how to draw the indicator in such a manner that
it forms another layer on the terrain. it should appear as another blended
texture on the terrain mesh.

Okay, I'm with you.

You might want to look at "decal" rendering (Try this article) - the common usage is putting gun-shot marks on walls in FPS's... but you could easily decal your location texture onto the terrain in a similar manner.

I'd personally pick this one as the ideal option, as it also presents you with some re-usable code for your engine such that you could easily add decals for foot-steps where your animals have walked...

Also depending on your geometry setup, you could do a multi-pass approach and render the particular quad/group of triangles where they marker would be over the top (disable Z-writes and enable alpha blending), however this gets tricky when your marker crosses boundaries...

Jack

<hr align="left" width="25%" />
Jack Hoxley <small>[</small><small> Forum FAQ | Revised FAQ | MVP Profile | Developer Journal ]</small>

Thanks... i'll check it out

This topic is closed to new replies.

Advertisement