The thing I'm triying to do is rotate 2 bones(frames).
The bones are layed out like this.
|BaseBone offset from the root
__ root bone
these bone also have animation as well that play fine(working)
what I do first is.
UpdateMeshSkinned(&identity); this does 2 things it
Recurse down the tree and generate a frame's toRoot transform from the updated pose.
Premultiply the offset-transform to transform the vertices to the bone's local
coordinate system first, before applying the other transforms.(world and stuff)
and this data is stored in a MATRIX pBoneMatrices[MaxBones];
the pBoneMatrices is what gets sent to the shader for skinning(works)
Now here is what I want to do after the updatemeshskinned which transforms all the Matrices in pBoneMatrices
to bones local coordinates.
First both bones are found in the array these are turretbase, turretelevation,
then both bones are decomposed into its pos, scale and rotation.Each bone hase a combined matrix
this is the offset to the centre of the mesh(what I use to offset the matrix to rotate them on.
so for the turrets base the rotation is about the Y axis here is what I do
Matrix offset = combined;
matrix final = turretbase->pBoneMatrices[turretbase];
matrix Yspin = D3DXMatrixRotationY();
//addoffset so we can rotate about centre
final *= offset;
final *= Yspin;
//add the offset back
final *= -offset;
//add the original transform again
if I dont do this again its offset a bit for some reason;?????????
//add the original transform
//Incerted in to the matrix now
turretbase->pBoneMatrices[turretbase] = final;
this works for the turretElevation in the Y only as soon as I add in the X axis rotation its offsets(orbits again how)
all Im doing here is createing a X axis rotation matrix at 45 and changing the line here
final *= Yspin; to final *= Xspin *Yspin; or this final *= Yspin * Xspin;
and the turrets elevation will rotate at the original offset it orbits whats the X axis rotation doing to the Y axises rotation
I hope I have explained this correct, as I don't know what Im doing with this as it is Thanks.