ObjectList.push_back(loInc);
int iThisObj = ObjectList.size() - 1;
D3DXMatrixIdentity( &ObjectList[iThisObj].matObjectToWorld );
D3DXMatrixScaling( &ObjectList[iThisObj].matObjectToWorld, ObjectList[iThisObj].vecScale.x, ObjectList[iThisObj].vecScale.y, ObjectList[iThisObj].vecScale.z );
D3DXMatrixRotationYawPitchRoll( &ObjectList[iThisObj].matObjectToWorld, ObjectList[iThisObj].vecRotation.x, ObjectList[iThisObj].vecRotation.y, ObjectList[iThisObj].vecRotation.z );
D3DXMatrixTranslation( &ObjectList[iThisObj].matObjectToWorld, ObjectList[iThisObj].vecTranslation.x, ObjectList[iThisObj].vecTranslation.y, ObjectList[iThisObj].vecTranslation.z );
D3DXVECTOR3 test1, test2;
D3DXQUATERNION test3;
D3DXMatrixDecompose(&test1, &test3, &test2, &ObjectList[iThisObj].matObjectToWorld);
ObjectList[iThisObj].iMaterialIndex = (MeshList[ObjectList[iThisObj].iMeshIndex].VertexList[0].iMaterialID - START_MATERIAL);
return;
D3DXMatrixRotationYawPitchRoll(...) not working?
Yea I found that using 3 different matricies works after multiplying them together. But isnt that a waste of space?
Whenever you use a function like MatrixTranslation or MatrixRotationYawPitchRoll, the function erases whatever was in the destination matrix. That is, the function doesn't multiply the destination by a new transformation, it sets the destination matrix to the new transformation.
You don't have to "waste space" in your class to do this properly, you can use temp variables. So you'd do something like
You don't have to "waste space" in your class to do this properly, you can use temp variables. So you'd do something like
D3DXMATRIX matRotate, matTranslate, matScale;D3DXMatrixRotationYawPitchRoll(&matRotate,...);D3DXMatrixTranslation(&matTranslate,...);D3DXMatrixScaling(&matScale,...);D3DXMatrixMultiply(&ObjectList[iThisObj].matObjectToWorld,&matScale,&matRotate);D3DXMatrixMultiply(&ObjectList[iThisObj].matObjectToWorld,&ObjectList[iThisObj].matObjectToWorld,&matTranslate);
Quote:Original post by Drakex
You don't have to "waste space" in your class to do this properly, you can use temp variables. So you'd do something like
Right That I know, but it is still taking up space, temp or not. In which multiply them against 4 floats takes alot less. Anywho it works I guess I shouldnt bitch too much about 16 * 3 extra floats.
Lol, it's not like computers today (especially gaming computers) are exactly running short on memory :) In just 1MB, you could store 16,384 matrices, a number which I doubt you'll be approaching any time soon; and temp mats go away when the function returns anyway.
Take a look at these improvements:
ObjectList.push_back(loInc); Object & object = ObjectList.back(); D3DXMATRIX temp; D3DXMatrixIdentity( &object.matObjectToWorld ); D3DXMatrixScaling( &temp, object.vecScale.x, object.vecScale.y, object.vecScale.z ); D3DXMatrixMultiply( &object.matObjectToWorld, &temp, &object.matObjectToWorld ); D3DXMatrixRotationYawPitchRoll( &temp, object.vecRotation.x, object.vecRotation.y, object.vecRotation.z ); D3DXMatrixMultiply( &object.matObjectToWorld, &temp, &object.matObjectToWorld ); D3DXMatrixTranslation( &temp, object.vecTranslation.x, object.vecTranslation.y, object.vecTranslation.z ); D3DXMatrixMultiply( &object.matObjectToWorld, &temp, &object.matObjectToWorld ); D3DXVECTOR3 test1, test2; D3DXQUATERNION test3; D3DXMatrixDecompose(&test1, &test3, &test2, &object.matObjectToWorld); object.iMaterialIndex = (MeshList[object.iMeshIndex].VertexList[0].iMaterialID - START_MATERIAL);
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement