Re[3]: Помогите, замучился
От: tokaplan Россия  
Дата: 29.03.04 19:06
Оценка:
CX>Код покажи мы разберёмся

Да собственно и показывать нечего. В D3DXVECTOR3 AnglesDir[0] храню углы поворота вокруг осей, при движении мыши приращиваю их. А дальше — стандартная операция, по-моему, из MSDN скопировал ( стиль комментариев ихний )...

D3DXMATRIX matTrans;
D3DXMatrixIdentity( &matTrans );
D3DXMATRIX MatTemp; // Temp matrix for rotations.
D3DXMATRIX MatRot; // Final rotation matrix, applied to
// pMatWorld.

// Using the left-to-right order of matrix concatenation,
// apply the translation to the object's world position
// before applying the rotations.
D3DXMATRIX *pMatWorld = new D3DXMATRIX;
D3DXMatrixIdentity(&MatRot);
D3DXMatrixIdentity(pMatWorld);

// Now, apply the orientation variables to the world matrix
if(AnglesDir[0].x || AnglesDir[0].y|| AnglesDir[0].z) {
// Produce and combine the rotation matrices.
D3DXMatrixRotationX(&MatTemp, ( D3DX_PI/180 )*(AnglesDir[0].x)); // Pitch
D3DXMatrixMultiply(&MatRot, &MatRot, &MatTemp);
D3DXMatrixRotationY(&MatTemp, ( D3DX_PI/180 )*(AnglesDir[0].y)); // Yaw
D3DXMatrixMultiply(&MatRot, &MatRot, &MatTemp);
D3DXMatrixRotationZ(&MatTemp, ( D3DX_PI/180 )*(AnglesDir[0].z)); // Roll
D3DXMatrixMultiply(&MatRot, &MatRot, &MatTemp);

// Apply the rotation matrices to complete the world matrix.
D3DXMatrixMultiply(pMatWorld, &MatRot, pMatWorld);
}

//Move ourselves
D3DXMatrixTranslation( &matTrans, Point.x, Point.y, Point.z );
D3DXMatrixMultiply( pMatWorld, pMatWorld, &matTrans );
m_pd3dDevice->SetTransform( D3DTS_WORLD, pMatWorld);
 
Подождите ...
Wait...
Пока на собственное сообщение не было ответов, его можно удалить.