複数のオブジェクトが 3D 空間内を動き回っており、ボタンを押すと、カメラがスナップして選択したオブジェクトを追跡する方法を探しています。
各オブジェクトの worldMatrix を利用する方法はありますか? (以下は 1 つのオブジェクトの例です。これは、回転および周回する惑星です)
//set up matrices for rendering
D3DXMATRIX worldMatrixMer, viewMatrixMer, projectionMatrixMer;
m_Camera->GetViewMatrix(viewMatrixMer);
m_D3D->GetWorldMatrix(worldMatrixMer);
m_D3D->GetProjectionMatrix(projectionMatrixMer);
D3DXMatrixRotationX( &matRotateX, rx/65.0f);
//Rotate about Y axis
D3DXMatrixRotationY( &matRotateY, rotation * 15.0f);
D3DXMatrixRotationZ( &matRotateZ, rz/65.0f);
//Collate Rot Matrices
D3DXMATRIX rotMatrixMer = matRotateX * matRotateY * matRotateZ;
D3DXVECTOR3 newVecDirMer;
D3DXVec3TransformCoord(&newVecDirMer, &initVecDirMer, &rotMatrixMer);
D3DXVec3Normalize( ¤tVecDirMer, &newVecDirMer );
//Create the size of the object
D3DXMATRIX matScaleMer;
D3DXMatrixScaling(&matScaleMer, 0.1f, 0.1f, 0.1f);
//Starting position of object
D3DXMatrixTranslation(&matTranslateMer, 0.0f, 0.0f, 3.5983f * 3);
//Rotate about it's own axis
D3DXMatrixRotationY(&worldMatrixMer, rotation);
worldMatrixMer *= rotMatrixMer * matScaleMer * matTranslateMer;
//'Orbit'
D3DXMatrixRotationY( &matOrbit, (-1000.0f * rotation) / 88);
worldMatrixMer *= matOrbit;
私は本当にこれを実現するエレガントな方法を見つけようとしているので、どんな提案でも大歓迎です。
ありがとう