Original Post
Ok... I''m getting quite desperate...
I had this question already in another form. But the question was written in very difficult way so I cleaned the function a little bit so it could be readen a little bit more easier...
The problem is in rotation with translation. The rotation works independent (rotation doesn''t cause translation) even if you define the starting point for the obejct different than (0,0,0). But if you chance later the position of the object the rotation doesn''t work anymore (rotation causes translation). And I just don''t get it why. Please could someone give me a solution. I''d like to use this function also in my other classes so I''d like this to work perfectly.
Info about the function:
m_vectPos stores the object''s positio
m_vectRot stores the objects rotation
What the function should do:
pos should change the position. If the vector is(5,0,0) the object moves 5 units to right.
rot should rotate the object but should not cause translation of any kind.
scale should scale the object in any direction.
void Transform(LPDIRECT3DDEVICE7 device, D3DVECTOR pos, D3DVECTOR rot, D3DVECTOR scale)
{
D3DMATRIX matTrans1, matTrans2, matRotateY, matRotateZ, matRotateX, matScale, view;
D3DUtil_SetTranslateMatrix(matTrans1, -1.0f*m_vectPos);
// update position info
m_vectPos+=pos;
D3DUtil_SetTranslateMatrix(matTrans2, m_vectPos);
// update rotation info
m_vectRot+=rot;
D3DUtil_SetRotateYMatrix(matRotateY, m_vectRot.dvY);
D3DUtil_SetRotateXMatrix(matRotateX, m_vectRot.dvX);
D3DUtil_SetRotateZMatrix(matRotateZ, m_vectRot.dvZ);
SetScaleMatrix(matScale, scale);
D3DMath_MatrixMultiply(m_matTrans, matTrans1, matRotateX);
D3DMath_MatrixMultiply(m_matTrans, m_matTrans, matRotateZ);
D3DMath_MatrixMultiply(m_matTrans, m_matTrans, matRotateY);
D3DMath_MatrixMultiply(m_matTrans, m_matTrans, matScale);
D3DMath_MatrixMultiply(m_matTrans, m_matTrans, matTrans2);
device->SetTransform(D3DTRANSFORMSTATE_WORLD, &m_matTrans);
}
Floru