Moving a mesh
Posted on 2003-11-04
HI, I'm probably going to sound as thick as a TV weather girl asking this one.. but here goes.
I've loaded a mesh into memory and I am rendering it...
I have a rotation and a translation in place for the mesh, and this is fine.
However, when I translate then after rotate the mesh, it is still rotating about it's origin when it loaded (0,0,0) not the new object center... anyone know how I can reset the object center after my translation had taken place:
I create the object center upon loading the mesh, thusly:
hr = D3DXComputeBoundingSphere ( (D3DXVECTOR3*)pVertices, MeshSysMem->GetNumVertices(), D3DXGetFVFVertexSize (MeshSysMem->GetFVF()), &ObjectCenter, &ObjectRadius );
And my translation and rotation matrices are applied thusly:
D3DXMATRIX rot_matrix = Rotate (pitch,roll,yaw);
D3DXMATRIX trans_matrix = Translate (x, y, z);
d3d_device->SetTransform(D3DTS_WORLD, &( trans_matrix * rot_matrix ) );
But I can not call the ComputeBoundingSphere as the matrices are applied in my render, and the vertices are not to be changed....
(this question is so inspecific ain't it... sorry).