🔒 Locked
Decals?
Advertisement
Original Post
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
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.
Quote: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).
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 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
you could also do the same with a triangle fan, and simply getting the height of the terrain at the various edge points.
/Robert
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
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
Topic Locked
This topic has been locked by a moderator. New replies are not allowed.
Sign in to reply to this topic.
Advertisement