Original Post
Hey guys,
i am now in the middle of animation implementation and have a small query regarding vertexes updating with matrices.
Here is what i have :
- actual vertex position (Vector3) ( object space )
- bone transformation matrix ( consists of a Matrix4 translation/rotation ) - for actual frame ( object space )
Matrix4 Class ( multiplication definition )
What i need to do
is to translate/rotate the vertex that is linked with bone - that has own transformation matrix ( also in object space ).
new vertex position should return Vector3.
Is this what i am supposed to do or it is to late for me and i have lost my mind...
And after that multiply that by MVP of course.
What i have found is that when i multiply vertex position by bone transformation matrix there is no effect at all.
When i do
Is there something i forgot here?
Many many many thanks!
i am now in the middle of animation implementation and have a small query regarding vertexes updating with matrices.
Here is what i have :
- actual vertex position (Vector3) ( object space )
- bone transformation matrix ( consists of a Matrix4 translation/rotation ) - for actual frame ( object space )
Matrix4 Class ( multiplication definition )
friend CVector3 operator*(const CVector3 &lhs, const CMatrix4x4 &rhs);inline CVector3 operator*(const CVector3 &lhs, const CMatrix4x4 &rhs)
{
return CVector3(
(lhs.x * rhs.mtx[0][0]) + (lhs.y * rhs.mtx[1][0]) + (lhs.z * rhs.mtx[2][0]),
(lhs.x * rhs.mtx[0][1]) + (lhs.y * rhs.mtx[1][1]) + (lhs.z * rhs.mtx[2][1]),
(lhs.x * rhs.mtx[0][2]) + (lhs.y * rhs.mtx[1][2]) + (lhs.z * rhs.mtx[2][2]));
}
What i need to do
is to translate/rotate the vertex that is linked with bone - that has own transformation matrix ( also in object space ).
new vertex position should return Vector3.
Is this what i am supposed to do or it is to late for me and i have lost my mind...
iCurrentFrame = actual frame
CVector3 vNewVertexPosition = vVertexOrigin * mat4BoneTransformationMatrix[ iCurrentFrame ];
And after that multiply that by MVP of course.
What i have found is that when i multiply vertex position by bone transformation matrix there is no effect at all.
// No effect at all ( see my operator* definition, is this ok ? )
CVector3 vNewVertexPosition = vVertexOrigin * mat4BoneTransformationMatrix[ iCurrentFrame ];
When i do
// I get translation only but no rotation ( which is obvious as i pick [3][0] to [3][1] from my matrix4 )
CVector3 vNewVertexPosition = vVertexOrigin + CVector3(mat4BoneTransformationMatrix[ iCurrentFrame ][3][0], mat4BoneTransformationMatrix[ iCurrentFrame ][3][1], mat4BoneTransformationMatrix[ iCurrentFrame ][3][2]) ;
Is there something i forgot here?
Many many many thanks!