use matrix multiplication operator
This commit is contained in:
parent
2477f849c7
commit
3451ca26c7
20
main.cpp
20
main.cpp
@ -573,8 +573,7 @@ void Animate(float t)
|
|||||||
}
|
}
|
||||||
*/
|
*/
|
||||||
|
|
||||||
static inline void MatrixTRS(D3DXMATRIX * transform,
|
static inline D3DXMATRIX MatrixTRS(const D3DXVECTOR3 * translation,
|
||||||
const D3DXVECTOR3 * translation,
|
|
||||||
const D3DXQUATERNION * rotation,
|
const D3DXQUATERNION * rotation,
|
||||||
const D3DXVECTOR3 * scaling)
|
const D3DXVECTOR3 * scaling)
|
||||||
{
|
{
|
||||||
@ -587,8 +586,7 @@ static inline void MatrixTRS(D3DXMATRIX * transform,
|
|||||||
D3DXMATRIX mScaling;
|
D3DXMATRIX mScaling;
|
||||||
D3DXMatrixScaling(&mScaling, scaling->x, scaling->y, scaling->z);
|
D3DXMatrixScaling(&mScaling, scaling->x, scaling->y, scaling->z);
|
||||||
|
|
||||||
D3DXMatrixMultiply(transform, &mRotation, &mTranslation);
|
return mScaling * mRotation * mTranslation;
|
||||||
D3DXMatrixMultiply(transform, transform, &mScaling);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline float fract(float f)
|
static inline float fract(float f)
|
||||||
@ -640,21 +638,13 @@ void Animate(float t)
|
|||||||
const Node * node = skin->joints[1];
|
const Node * node = skin->joints[1];
|
||||||
|
|
||||||
// T * R * S
|
// T * R * S
|
||||||
|
D3DXMATRIX global_transform = MatrixTRS(&node->translation, &rotation, &node->scale);
|
||||||
D3DXMATRIX global_transform;
|
|
||||||
MatrixTRS(&global_transform, &node->translation, &rotation, &node->scale);
|
|
||||||
|
|
||||||
D3DXMatrixIdentity(&mJoints[0]);
|
D3DXMatrixIdentity(&mJoints[0]);
|
||||||
D3DXMatrixIdentity(&mJoints[1]);
|
|
||||||
|
|
||||||
const D3DXMATRIX * inverse_bind_matrix = &skin->inverse_bind_matrices[1];
|
const D3DXMATRIX& inverse_bind_matrix = skin->inverse_bind_matrices[1];
|
||||||
//D3DXMatrixMultiply(&mJoints[1], &global_transform, inverse_bind_matrix);
|
|
||||||
//D3DXMatrixIdentity(&mJoints[1]);
|
|
||||||
//g_World1 = global_transform;
|
|
||||||
|
|
||||||
D3DXMatrixMultiply(&mJoints[1], inverse_bind_matrix, &global_transform);
|
mJoints[1] = inverse_bind_matrix * global_transform;
|
||||||
//mJoints[1] = global_transform;
|
|
||||||
//g_World1 = *inverse_bind_matrix;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void Render()
|
void Render()
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user