#### Archived

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

# Bullet Holes Correct?

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

## Recommended Posts

My current method for creating bullet holes is kind of hokie looking, so I'm turning to everyone here for advice. As of now I'm using billboards, which I believe is my largest mistake. Anyway, I may as well throw some code out there:
D3DXVECTOR3 HitPos;
BOOL bHit;
DWORD dwFace;
FLOAT fBary1, fBary2, fDist = -1.0f;
DWORD count;
D3DXIntersect(g_Room.m_pMesh, &g_Player.GetPosition(), &LPos, &bHit, &dwFace, &fBary1, &fBary2, &fDist, 0, &count);
if(fDist != -1.0f)
{
HitPos = g_Player.GetPosition() + Normalize(LPos) * fDist;
D3DXVECTOR3 verts[4];
D3DXVECTOR3 pos = HitPos;
verts[0] = D3DXVECTOR3(pos.x - 0.1f, pos.y+0.1f, pos.z);
verts[1] = D3DXVECTOR3(pos.x + 0.1f, pos.y+0.1f, pos.z);
verts[2] = D3DXVECTOR3(pos.x - 0.1f, pos.y-0.1f, pos.z);
verts[3] = D3DXVECTOR3(pos.x + 0.1f, pos.y-0.1f, pos.z);
g_BulletHoles.push_back(new BILLBOARD("images//bullethole.bmp", verts));

}
}

So I'm using D3DXIntersect to get the distance, and then getting the position and the vertices, which in turn, create the BILLBOARD. I believe that what I SHOULD be doing is, instead of creating a BILLBOARD, I should create a series of rotation matrices to align the image with the plane of the wall. Something like this?
D3DXMATRIXA16 matTemp, matRot;
D3DXVECTOR3 pos, normal, axis;
//Assume pos is the position of the bullet hole (a point on the wall)

//Assume normal is the normal to the wall's plane

D3DXMatrixRotationAxis(&matRot, axis, AngleBetween(normal, pos - g_Player.GetPosition());

So, correct me if I'm wrong, but this is what I think I should do, but I have no idea how to calculate the variable axis. Any ideas? Edit: Why in the world is the whole thing red?! Please pardon the odd coloring. [edited by - ms291052 on December 15, 2003 11:00:45 PM] [edited by - ms291052 on December 16, 2003 7:43:20 AM] [edited by - ms291052 on December 16, 2003 7:43:52 AM]

##### Share on other sites
it seems that the double slash ends the command (first set of code), and so it doesnt see a closing quote... if u look closly the last two brackets are red...

g_BulletHoles.push_back(new BILLBOARD("images//bullethole.bmp", verts)); } }

[edited by - Pirosan on December 15, 2003 11:43:54 PM]

##### Share on other sites
Well I just tried to fix it but noooo, it took away one of my source blocks (???) and stayed red, so I suppose I''ll just have to deal.

bump