# Getting joint animation data for skeletal animation(Pymel)

 05 May 2013 Simon A lot of nothing to say.   portfolio Simon Roth Games developer Oxford, United Kingdom Getting joint animation data for skeletal animation(Pymel) I'm a bit stuck with a Pymel animation exporter I'm writing for my game. Seems to work with a single bone, but complex rigs get rotations at weird angles. I'm a bit unsure about how the SRT data is supposed to be used for skeletal. Whether in relative space or not. `````` ... key = array("f") for i in range (minTime,maxTime): print ' *********** frame:' + str(i) #for each Joint get rotation quat and transform vector. for s in influences: newJoint= PyNode(s) currentTime(i) rotationQuat = newJoint.getRotation(quaternion=True) parents = listRelatives(newJoint, parent=True) trans = newJoint.getTranslation() if(len(parents) != 0 ): if(type(parents[0]) is nt.Joint ): parentWorldMatrix = parents[0].attr("worldInverseMatrix").get() jointWorldMatrix = newJoint.attr("worldMatrix").get() #Get the joints local space transformation transMat = jointWorldMatrix * parentWorldMatrix rotationQuat = Quaternion((transMat)) translation = transMat.translate.get() print "reltrans:" + str(trans) print "rotQuat" + str(rotationQuat) key.extend(rotationQuat) key.extend( translation ) ... `````` Any suggestions would be a real help. I touch on Maya scripting so little that I do things a bit backwards. __________________ MaiaGame.com Linkedin Twitter Last edited by Simon : 05 May 2013 at 09:54 PM. share quote
 05 May 2013 julian.mann New Member Hi there, This may help, or maybe not... I once had to construct a matrix from joint attributes using the Maya C++ API. You may be able to translate this to pymel. The important thing is to factor in the orientation attribute. Apologies if I missed the point. ``````MStatus getJointMat( const MObject & dagNode, MMatrix & mat ) { MStatus st; MFnIkJoint jointFn(dagNode, &st ); if (st.error()) return st; // build the matrix which represents the joint in it's current angle ///////////////////////////////////////////////////// MTransformationMatrix::RotationOrder rOrder = jointFn.rotationOrder(&st); double3 scale ; st = jointFn.getScale(scale); double3 scaleOrientation ; st = jointFn.getScaleOrientation(scaleOrientation,rOrde r) ; double3 rotation; st = jointFn.getRotation(rotation,rOrder); ert; double3 orientation; st = jointFn.getOrientation(orientation, rOrder); // changed from translation due to deprecation MVector trans = jointFn.getTranslation(MSpace::kTransform ,&st); MTransformationMatrix mtxmat; MMatrix Smat; MMatrix ROmat; MMatrix Rmat; MMatrix JOmat; MMatrix Tmat; Smat(0,0) = scale[0]; Smat(1,1) = scale[1]; Smat(2,2) = scale[2]; mtxmat.setRotation(scaleOrientation , rOrder); ROmat = mtxmat.asMatrix(); mtxmat.setRotation(rotation , rOrder); Rmat = mtxmat.asMatrix(); mtxmat.setRotation(orientation, rOrder); JOmat = mtxmat.asMatrix(); Tmat(3,0) = trans.x; Tmat(3,1) = trans.y; Tmat(3,2) = trans.z; mat = Smat*ROmat*Rmat*JOmat*Tmat; return MS::kSuccess; }`````` share quote
 05 May 2013 julian.mann New Member Maybe a better way to get those transforms is to point and orient constrain locators to each joint and then query the transforms of the locators for every frame. Or even use the xform command. julian share quote
 05 May 2013 CGTalk Moderation Expert Thread automatically closed This thread has been automatically closed as it remained inactive for 12 months. If you wish to continue the discussion, please create a new thread in the appropriate forum. __________________ CGTalk Policy/Legalities Note that as CGTalk Members, you agree to the terms and conditions of using this website. share quote

 Posting Rules You may not post new threads You may not post replies You may not post attachments You may not edit your posts vB code is On Smilies are On [IMG] code is On HTML code is Off CGSociety Society of Digital Artists www.cgsociety.org Powered by vBulletinCopyright ©2000 - 2006, Jelsoft Enterprises Ltd.