• Create Account

We're offering banner ads on our site from just \$5!

### #Actualbelfegor

Posted 19 April 2013 - 03:08 AM

I am not good at math either, but try this:

D3DXVECTOR3 GetTriNormal(const D3DXVECTOR3& v0, const D3DXVECTOR3& v1, const D3DXVECTOR3& v2)
{
D3DXVECTOR3 edge1 = v1 - v0;
D3DXVECTOR3 edge2 = v2 - v0;
D3DXVECTOR3 normal;
D3DXVec3Cross(&normal, &edge1, &edge2);
return normal;
}
...
D3DXVECTOR3 up = triangleV1 - intersectedPoint;
D3DXVECTOR3 nrm = GetTriNormal(triangleV1, triangleV2, triangleV13);
D3DXVECTOR3 right;
D3DXVec3Cross(&right, &nrm, &up);
D3DXVec3Normalize(&up, &up);
D3DXVec3Normalize(&nrm, &nrm);
D3DXVec3Normalize(&right, &right);
...
float size = 0.3f;
D3DXVECTOR3 horizontal = right * size;
D3DXVECTOR3 vertical = up * size;
bulletBillboardV1 = intersectedPoint - horizontal + vertical; // up-left
bulletBillboardV2 = intersectedPoint + horizontal + vertical; // up-right
bulletBillboardV3 = intersectedPoint + horizontal - vertical; // down-right
bulletBillboardV4 = intersectedPoint - horizontal - vertical; // down-left


no guarantee that it will work. Maybie someone could correct me if i am wrong.

EDIT: It works actually, just tried it with my old "triangle picking" project. Here on the image i just draw lines around "billboards":

If it doesn't show for you or triangles are missing, make sure you got your winding/indices right.

### #4belfegor

Posted 19 April 2013 - 03:07 AM

I am not good at math either, but try this:

D3DXVECTOR3 GetTriNormal(const D3DXVECTOR3& v0, const D3DXVECTOR3& v1, const D3DXVECTOR3& v2)
{
D3DXVECTOR3 edge1 = v1 - v0;
D3DXVECTOR3 edge2 = v2 - v0;
D3DXVECTOR3 normal;
D3DXVec3Cross(&normal, &edge1, &edge2);
return normal;
}
...
D3DXVECTOR3 up = triangleV1 - intersectedPoint;
D3DXVECTOR3 nrm = GetTriNormal(triangleV1, triangleV2, triangleV13);
D3DXVECTOR3 right;
D3DXVec3Cross(&right, &nrm, &up);
D3DXVec3Normalize(&up, &up);
D3DXVec3Normalize(&nrm, &nrm);
D3DXVec3Normalize(&right, &right);
...
float size = 0.3f;
D3DXVECTOR3 horizontal = right * size;
D3DXVECTOR3 vertical = up * size;
bulletBillboardV1 = intersectedPoint - horizontal + vertical; // up-left
bulletBillboardV2 = intersectedPoint + horizontal + vertical; // up-right
bulletBillboardV3 = intersectedPoint + horizontal - vertical; // down-right
bulletBillboardV4 = intersectedPoint - horizontal - vertical; // down-left


no guarantee that it will work. Maybie someone could correct me if i am wrong.

EDIT: It works actually, just tried it with my old "triangle picking" project. Draw lines around "billboards":

If it doesn't show for you or triangles are missing, make sure you got your winding/indices right.

### #3belfegor

Posted 19 April 2013 - 02:37 AM

I am not good at math either, but try this:

D3DXVECTOR3 GetTriNormal(const D3DXVECTOR3& v0, const D3DXVECTOR3& v1, const D3DXVECTOR3& v2)
{
D3DXVECTOR3 edge1 = v1 - v0;
D3DXVECTOR3 edge2 = v2 - v0;
D3DXVECTOR3 normal;
D3DXVec3Cross(&normal, &edge1, &edge2);
return normal;
}
...
D3DXVECTOR3 up = triangleV1 - intersectedPoint;
D3DXVECTOR3 nrm = GetTriNormal(triangleV1, triangleV2, triangleV13);
D3DXVECTOR3 right;
D3DXVec3Cross(&right, &nrm, &up);
D3DXVec3Normalize(&up, &up);
D3DXVec3Normalize(&nrm, &nrm);
D3DXVec3Normalize(&right, &right);
...
float size = 0.3f;
D3DXVECTOR3 horizontal = right * size;
D3DXVECTOR3 vertical = up * size;
bulletBillboardV1 = intersectedPoint - horizontal + vertical; // up-left
bulletBillboardV2 = intersectedPoint + horizontal + vertical; // up-right
bulletBillboardV3 = intersectedPoint + horizontal - vertical; // down-right
bulletBillboardV4 = intersectedPoint - horizontal - vertical; // down-left


no guarantee that it will work. Maybie someone could correct me if i am wrong.

### #2belfegor

Posted 19 April 2013 - 02:20 AM

I am not good at math either, but try this:

D3DXVECTOR3 GetTriNormal(const D3DXVECTOR3& v0, const D3DXVECTOR3& v1, const D3DXVECTOR3& v2)
{
D3DXVECTOR3 edge1 = v1 - v0;
D3DXVECTOR3 edge2 = v2 - v0;
D3DXVECTOR3 normal;
D3DXVec3Cross(&normal, &edge1, &edge2);
return normal;
}
...
D3DXVECTOR3 up = triangleV1 - intersectedPoint;
D3DXVECTOR3 nrm = GetTriNormal(triangleV1, triangleV2, triangleV13);
D3DXVECTOR3 right;
D3DXVec3Cross(&right, &nrm, &up);
D3DXVec3Normalize(&up, &up);
D3DXVec3Normalize(&nrm, &nrm);
D3DXVec3Normalize(&right, &right);
...
float size = 0.3f;
D3DXVECTOR3 horizontal = right * size;
D3DXVECTOR3 vertical = up * size;
bulletBillboardV1 = intersectedPoint - horizontal + vertical; // up-left
bulletBillboardV2 = intersectedPoint + horizontal + vertical; // up-right
bulletBillboardV4 = intersectedPoint + horizontal - vertical; // down-right
bulletBillboardV3 = intersectedPoint - horizontal - vertical; // down-left


no guarantee that it will work. Maybie someone could correct me if i am wrong.

### #1belfegor

Posted 19 April 2013 - 02:19 AM

I am not good at math either, but try this:

D3DXVECTOR3 GetTriNormal(const D3DXVECTOR3& v0, const D3DXVECTOR3& v1, const D3DXVECTOR3& v2)
{
D3DXVECTOR3 edge1 = v1 - v0;
D3DXVECTOR3 edge2 = v2 - v0;
D3DXVECTOR3 normal;
D3DXVec3Cross(&normal, &edge1, &edge2);
return normal;
}
...
D3DXVECTOR3 up = triangleV1 - intersectedPoint;
D3DXVECTOR3 nrm = GetTriNormal(triangleV1, triangleV2, triangleV13);
D3DXVECTOR3 right;
D3DXVec3Cross(&right, &nrm, &up);
D3DXVec3Normalize(&up, &up);
D3DXVec3Normalize(&nrm, &nrm);
D3DXVec3Normalize(&right, &right);
...
float size = 0.3f;
D3DXVECTOR3 horizontal = right * size;
D3DXVECTOR3 vertical = up * size;
bulletBillboardV1 = intersectedPoint - horizontal + vertical; // up-left
bulletBillboardV2 = intersectedPoint + horizontal + vertical; // up-right
bulletBillboardV3 = intersectedPoint - horizontal - vertical; // down-left
bulletBillboardV4 = intersectedPoint + horizontal - vertical; // down-right


no guarantee that it will work. Maybie someone could correct me if i am wrong.

PARTNERS