Sign in to follow this  

Decals?

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

i am working on a RTS type game but was wondering how the unit select circles are drawn around the units onto the terrain. Games like World of Warcraft, Warcraft 3, Warhammer DOW, C&C Generals all do this where the circle around the units is like projected onto the terrain so it bends into the shape of terrain under it example 1 example 2 not sure how its done really, initially i thought it was some sort of projected texture but when having hundreds of units on screen at a time doesn't look practical. any idea's how its done? and how one could implement something like that? thanks

Share this post


Link to post
Share on other sites
I am betting they use and alpha test with a texture that is RGBA. Then they locate the texture as a single quad and texture it on top of the terrain based on the units location... HTH

Share this post


Link to post
Share on other sites
what i ment was they map onto the terrain, i.e. taking its shape, i've attached two more images maybe it'll help give a more clearer idea of it.

image 1

image 2

haven't actually been able to find any good information on how this is done or any tutorials, any pointers would be nice, thx

Share this post


Link to post
Share on other sites
I believe they actually find the terrain triangles that are under the unit, and generate a decal for the selection ring, using those triangles. They probably generate all selection rings into a single vertex buffer, and draw it all in one swell foop, to reduce the batching cost.

Share this post


Link to post
Share on other sites
Quote:
Original post by hplus0603
I believe they actually find the terrain triangles that are under the unit, and generate a decal for the selection ring, using those triangles. They probably generate all selection rings into a single vertex buffer, and draw it all in one swell foop, to reduce the batching cost.
For a detailed description of one way you might go about doing this, check out Eric Lengyel's article in GPG I or II (can't remember which).

For the case of selection circles like in the example images, you would most likely clip the input triangles to an axis-aligned square prism (i.e. four axis-aligned planes) centered on the entity.

Share this post


Link to post
Share on other sites
hplus0603 does explain the "proper" way of doing it, but depending on the camera view, you could get away by simply drawing a quad that is rotated rougly to match the terrain, and disable depth testing.

you could also do the same with a triangle fan, and simply getting the height of the terrain at the various edge points.

/Robert

Share this post


Link to post
Share on other sites
As I stated before, depending on what you want to do,

A. unit's location and have decal below it
Since you know the units location you can send this data(xyz of terrain at that point) to a function that renders batches of these decals and it will texture over that quad its on.

B. You click on something and want it
Using gluUnProject you can get the location of the point the use clicked and then use this data to get a (xyz) point on the terrain and update location with the decal you want...

This really isn't that hard. I have already done this in my mapeditor to allow the use to see what quads they are editing...

HTH

Share this post


Link to post
Share on other sites
To put a texture on the same surface without z-fighing problem read this http://www.gamedev.net/reference/articles/article1986.asp

But first you have to project ur selecting something on a terrain somehow, can't help that, it's totaly depends on ur graphic engine.

Share this post


Link to post
Share on other sites

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