2D 'selection' cirlce in 3D
Hi all, I am wondering how to implement a selection circle at the base of my units in the game / learning experience I am working on. I want a 2D circle projected on the mesh that the unit is on. I imagine that this is either done through either the stencil buffer or splatting, perhaps?
some examples of what I am taking about:
http://www.eatmybomb.com/wp-content/uploads/2006/12/nomercy.jpg
http://pcmedia.gamespy.com/pc/image/article/568/568494/world-of-warcraft-20041123014836173.jpg
http://www.evolutionvault.net/galactic_dream/media/screenshots/v5_2.jpg
http://static.flickr.com/95/229537745_3987e8db65_o.jpg
(the circles at the base of the models)
my levels are currently all 1 mesh so I feel like it should be fairly simple to implement, but splatting seems far more involved than what I need. Any help would be great.
If your terrain isn't a reasonably smooth '2.5-dimensional' surface then you'll need something a little fancier, but this rough approximation should work for a wide range of heightmap-based and similar situations:
Create a quad (or a pair of triangles) that sits at the base of the character, with the appropriate translucent texture mapped to it. Each time the character (or floor) moves, project the four corners of this quad down to their respective ground levels, in the same way you perform collision tests against the floor. Provided the floor is reasonably smooth, this polygon will serve as a decent approximation to a projection to the floor. One problem remains:
When the character is standing in a concave region, all is well. But when the ground has some convexity, the 'selection circle' will be underground. You can fix this by disabling depth-testing, with a little care. Here's my method:
1. Render the ground with depth-testing and writing enabled.
2. Render the selection circles with depth-testing and writing disabled.
3. Render the remaining level geometry.
Admiral
Create a quad (or a pair of triangles) that sits at the base of the character, with the appropriate translucent texture mapped to it. Each time the character (or floor) moves, project the four corners of this quad down to their respective ground levels, in the same way you perform collision tests against the floor. Provided the floor is reasonably smooth, this polygon will serve as a decent approximation to a projection to the floor. One problem remains:
When the character is standing in a concave region, all is well. But when the ground has some convexity, the 'selection circle' will be underground. You can fix this by disabling depth-testing, with a little care. Here's my method:
1. Render the ground with depth-testing and writing enabled.
2. Render the selection circles with depth-testing and writing disabled.
3. Render the remaining level geometry.
Admiral
What TheAdmiral said is pretty much how it's done. However, instead of creating new quads for the selection circle, what you can do is detect which existing terrain quads will contain the circle and just render them again with the appropriate texture coordinates for the selection texture. This will allow your selection circle to smoothly follow the terrain.
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement