Decals?

Started by
7 comments, last by Centurion 17 years, 8 months ago
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
Advertisement
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
First when you say bend, I dont see the circles actual bend. Are you talking about how they are ellipses instead of circles?

NBA2K, Madden, Maneater, Killing Floor, Sims http://www.pawlowskipinball.com/pinballeternal

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
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.
enum Bool { True, False, FileNotFound };
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.
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
"Game Maker For Life, probably never professional thou." =)
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
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.

This topic is closed to new replies.

Advertisement