Hi everyone,
How do I calculate the billboard transformation to make a bullet hole at certain point on a mesh?
The mesh can be complicated (building, vehicle, interiors, etc...), so I'm looking for a way to place the bullet hole billboard on the mesh at the point the player is shooting.
Creating Bullet Holes
I'm not looking to use shader now, is there is anyway to calculate the billboard position and vertex position information to set the billboard transformation according to that?
1- "p" is your intersected point
2- "v1,v2,v3" are your intersected face vertices
3- "N" is your face normal or you can calculate it from your vertices
{
A = v2 - v1
B = v3 - v1
N = normalize( cross( A , B ) )
}
4- Calculate your Up and Right vector
{
up = normalize( p - v1 )
right = cross( up , N )
}
5- "Q1,Q2,Q3,Q4" are your Quad vertices and can calculate like this
{
Q1 = p + up * scale
Q2 = p - up * scale
Q3 = p + right * scale
Q4 = p - right * scale
}
2- "v1,v2,v3" are your intersected face vertices
3- "N" is your face normal or you can calculate it from your vertices
{
A = v2 - v1
B = v3 - v1
N = normalize( cross( A , B ) )
}
4- Calculate your Up and Right vector
{
up = normalize( p - v1 )
right = cross( up , N )
}
5- "Q1,Q2,Q3,Q4" are your Quad vertices and can calculate like this
{
Q1 = p + up * scale
Q2 = p - up * scale
Q3 = p + right * scale
Q4 = p - right * scale
}
this is a d3d10 sample, why is do you give him d3d10 code?, plus its not even the full source code...
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement