CGTalk > Software Specific Forums > Autodesk Maya > Maya Programming
Login register
Thread Closed share thread « Previous Thread | Next Thread »  
 
Thread Tools Search this Thread Display Modes
Old 05-07-2013, 06:46 PM   #1
Simon
A lot of nothing to say.
 
Simon's Avatar
portfolio
Simon Roth
Games developer
Oxford, United Kingdom
 
Join Date: May 2003
Posts: 2,641
Send a message via MSN to Simon
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.

Code:
... 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-07-2013 at 09:54 PM.
 
Old 05-07-2013, 09:18 PM   #2
julian.mann
New Member
 
Join Date: Feb 2005
Posts: 9
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.

Code:
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; }
 
Old 05-08-2013, 08:43 PM   #3
julian.mann
New Member
 
Join Date: Feb 2005
Posts: 9
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
 
Old 05-08-2013, 08:43 PM   #4
CGTalk Moderation
Lord of the posts
CGTalk Forum Leader
 
Join Date: Sep 2003
Posts: 1,066,481
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.
 
Thread Closed share thread


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

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 vBulletin
Copyright 2000 - 2006,
Jelsoft Enterprises Ltd.
Minimize Ads
Forum Jump
Miscellaneous

All times are GMT. The time now is 12:55 AM.


Powered by vBulletin
Copyright ©2000 - 2016, Jelsoft Enterprises Ltd.