Sign in to follow this  
Quaid Tseng

MAYA to DX, Joint orient, bone offset and anim rotation keys?

Recommended Posts

I'm working to export skinning animations from MAYA to DirectX. And for the codes of my MAYA exporter, I consult Robthebloke's site. Some codes make me confused. Here I show some relevant lines. In OutputTransform()
BoneIT it = g_Bones.begin();
for( ; it != g_Bones.end(); ++it ){
    MFnTransform fnX(bone.path);
    MQuaternion RO(0,0,0,1);
    MQuaternion R(0,0,0,1);
    //BaseMatrix
    MMatrix mat = fnX.transformation().asMatrix();
    //Rotation
    fnX.getRotation(R);
    //Rotation/Joint Orientation
    RO = fnX.rotateOrientation(MSpace::kObject);
}


Can anyone tell me what should I do with the Joint orientation and baseMatrix when I export them to directX? And in OutputAnimation()
BoneIT it = g_Bones.begin();
for( ; it != g_Bones.end(); ++it ){
    for(int i = StartTime; i <= EndTime; ++i){
        MAnimControl::setCurrentTime(MTime(i, MTime::kPALFrame));
        MQuaternion quat;
        fnX.getRotation(quat);
    }
}


I saw that with the exporter in DXSDK, the outputted rotation keys(w,x,y,z) is different than the quaternion here. And there's one more bone offset matrix. I know how to render a .X file. I already read Jim Adams' book. And I've already successfully implement a .X renderer. But here I don't know how to get the bone offset matrix in my MAYA exporter, I guess it's related to the joint orientation, but how? And it seems an additional converting is needed to convert the rotation quaternion keys, coz its quat keys are different than the ones using the exporter in DXSDK. Or without the converting to .X form, how can I render the anim with the rot keys directly from my MAYA exporter? Any idea is welcome :) And thanks.

Share this post


Link to post
Share on other sites
After some search I found this
http://www.gamedev.net/community/forums/topic.asp?topic_id=517946
And I've tried Rotation = RO * R * JO
That's Rotation = Rotate Orient * Rotation * Joint Orient

And the codes are like

BoneIT it = g_Bones.begin();
for( ; it != g_Bones.end(); ++it ){
MQuaternion JO(0,0,0,1);
MQuaternion RO(0,0,0,1);
MQuaternion Rcomb;
MMatrix RcombMat;

if( fnX.object().hasFn(MFn::kJoint) ){
// Joint Orientation
MFnIkJoint fnJ(fnX.object());
fnJ.getOrientation(JO);
}
// Rotate Orientation
RO = fnX.rotateOrientation(MSpace::kObject);
for(int i = StartTime; i <= EndTime; ++i){
MAnimControl::setCurrentTime(MTime(i, MTime::kPALFrame));
// get rotation
MQuaternion quat;
fnX.getRotation(quat);
RcombMat = RO.asMatrix() * quat.asMatrix();
RcombMat = RcombMat * JO.asMatrix();
Rcomb = RcombMat;
}
}





But the rot quat "Rcomb" is still different than what I saw in the .X file exported with the official exporter. Sometimes its very close, but most of time they are differnet.

Hope anybody can help me. Thanks~

[Edited by - Quaid Tseng on December 24, 2009 12:27:19 PM]

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this