ZHaDoom
Newcomer
I am rendering multiple X Meshes. Each requires me to move the world and rotate before I Render the object. I can rotate and move back to the center of the world for my point of referance, but eventualy i get a roundering error with a visual byproduct.
They must be an easier way to recenter the object world. What am i missing?
Thanks
ZHaDoom
They must be an easier way to recenter the object world. What am i missing?
Thanks
ZHaDoom
Code:
void cXObject::Render(D3DXVECTOR3 m_dvPosition,D3DXVECTOR3 m_dvRotation)
{
D3DXMATRIXA16 matWorld;
D3DXMATRIXA16 matWorldY;
//Move to object location
D3DXMatrixTranslation(&matWorld,m_dvPosition.x,m_dvPosition.y,m_dvPosition.z);
l_pd3dDevice->MultiplyTransform(D3DTS_WORLD, &matWorld);
//Rotate object
D3DXMatrixRotationY( &matWorldY, m_dvRotation.y );
l_pd3dDevice->MultiplyTransform(D3DTS_WORLD, &matWorldY);
//Render Object
for( DWORD i=0; i<NumMaterials; i++ )
{
// Set the material and texture for this subset
l_pd3dDevice->SetMaterial( &Materials[i] );
l_pd3dDevice->SetTexture( 0, Textures[i] );
// Draw the mesh subset
Mesh->DrawSubset( i );
}
//Unrotate
D3DXMatrixRotationY( &matWorldY, -m_dvRotation.y );
l_pd3dDevice->MultiplyTransform(D3DTS_WORLD, &matWorldY);
//Move back to center of world space
D3DXMatrixTranslation(&matWorld,-m_dvPosition.x,-m_dvPosition.y,-m_dvPosition.z);
l_pd3dDevice->MultiplyTransform(D3DTS_WORLD, &matWorld);
return;
}