need help with D3DXVec3TransformCoord on second mesh
when i got to use this in render loop , Mesh2 gets the same converted x,y,z as Mesh 1 , both meshs are placed next to each other so i dont know why they get the same values after D3DXVec3TransformCoord
do you have to create a new matrix where you draw the mesh?
http://img136.imageshack.us/my.php?image=shipsbi5.jpg
Code:
void CreateBoundingBox2(LPD3DXMESH Mesh2){
if(Mesh2) //if its valid
{
BYTE* pVertices=NULL;
HRESULT hr=Mesh2->LockVertexBuffer(D3DLOCK_READONLY, (LPVOID*)&pVertices);
D3DXComputeBoundingBox((D3DXVECTOR3*)pVertices,
Mesh2->GetNumVertices(),
D3DXGetFVFVertexSize(Mesh2->GetFVF()),
&minBounds2,
&maxBounds2);
Mesh2->UnlockVertexBuffer();
}
//put each corner to worldspace
// We have min and max values, use these to get the 8 corners of the bounding box
m_objectBounds2[0] = D3DXVECTOR3( minBounds2.x, minBounds2.y, minBounds2.z ); // xyz
m_objectBounds2[1] = D3DXVECTOR3( maxBounds2.x, minBounds2.y, minBounds2.z ); // Xyz
m_objectBounds2[2] = D3DXVECTOR3( minBounds2.x, maxBounds2.y, minBounds2.z ); // xYz
m_objectBounds2[3] = D3DXVECTOR3( maxBounds2.x, maxBounds2.y, minBounds2.z ); // XYz
m_objectBounds2[4] = D3DXVECTOR3( minBounds2.x, minBounds2.y, maxBounds2.z ); // xyZ
m_objectBounds2[5] = D3DXVECTOR3( maxBounds2.x, minBounds2.y, maxBounds2.z ); // XyZ
m_objectBounds2[6] = D3DXVECTOR3( minBounds2.x, maxBounds2.y, maxBounds2.z ); //
m_objectBounds2[7] = D3DXVECTOR3( maxBounds2.x, maxBounds2.y, maxBounds2.z ); // XYZ
// Transform the 8 corners of our object space bounding box into world space
//sprintf(data , "%s %f\n" , "m_objectBounds[0].x", m_objectBounds[0].x);
//WriteConsole(Console,data, sizeof(data) , &written, NULL);
//convert
for( int i = 0; i < 8; i++ ){
D3DXVec3TransformCoord( &worldBounds2[i], &m_objectBounds2[i], &matTrans );
}
Sleep(50);
}