Original Post
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