#### Archived

This topic is now archived and is closed to further replies.

# Decal Verts

This topic is 5419 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

## Recommended Posts

Hello, I''m trying to create decals on my walls from them being shot. So far my code''s working on most surfaces but some odd surfaces. It specifically appears to dislike non-axial planes (as in not XY, YZ, or XZ planes). Also, it often seems to dislike changes in the y-coordinate between the decal''s position and the player''s position. Anyway, here''s some psuedocode:
Vector HitPos //Center of the decal

Vector PlayerPos //The position of the player

Vector PlayerOrientation //Orientation is offsetted by a random amount to emulate inaccuracy

Vector Normal //Normal to the plane

Vector DecalVerts[4] //Four vertices of the decal

Plane  plane //Plane of the tri that the decal is to be placed on

Real  size //size of the decal

if(Dot(Plane, PlayerPos))
normal = -normal

Vector tempvec = Cross( PlayerPos - HitPos, (0, 1,0) )
Vector PlaneY = Cross( tempvec, Normal)
Vector PlaneX = Cross( Normal, PlaneY )

DecalVerts[0] = HitPos - PlaneX*size + PlaneY*size + normal*0.001f; //Offset by the normal a little to avoid Z-Fighting

DecalVerts[1] = HitPos + PlaneX*size + PlaneY*size + normal*0.001f;
DecalVerts[2] = HitPos - PlaneX*size - PlaneY*size + normal*0.001f;
DecalVerts[3] = HitPos + PlaneX*size - PlaneY*size + normal*0.001f;

Is this the proper method for doing this? Thanks, ms

1. 1
2. 2
Rutin
19
3. 3
4. 4
5. 5

• 9
• 9
• 9
• 14
• 12
• ### Forum Statistics

• Total Topics
633283
• Total Posts
3011209
• ### Who's Online (See full list)

There are no registered users currently online

×