pyfbsdk looping time and setting keyframe, please help


#1

ok, this is what am trying to do:
Basically I need to build a skeleton off an actor selected by the user, and transfer the animation from the actor to this skeleton.
I am able to build the skeleton from the actor without any problem, but transfering the animation is where am getting stuck. Could anyone tell me where am going wrong please.

 CODE PROBLEMS:
 1. When for-looping through time, it seems to take ages.
 2. The code sets keyframes on the skeleton in the current time range, but its not copying the animation over from the actor.
   
thanks for looking :)
# Build Skeleton from Actor and transfer anim over to it.
 
        from pyfbsdk import *
       
       # This function fills up 2 arrays, one theActorList, which stores all the bodyparts of the
       # actor and then theSkelList, which stores the corresponding new skeleton parts :
 
       def makeSkelNode(actorNode,theParent,theSkelList,theActorList):
       		mtx = FBMatrix()
       		actorNode.GetMatrix(mtx)
       		theActorList.append(actorNode)
       		newSkelNode = FBModelSkeleton(("newSkel" + actorNode.Name))
       		theSkelList.append(newSkelNode)
       		newSkelNode.Show = True
       		newSkelNode.Parent = theParent
       		newSkelNode.SetMatrix(mtx)
       		if (len(actorNode.Children) != 0):
       				theChildren = actorNode.Children
       				for child in theChildren:
       						makeSkelNode(child,newSkelNode,theSkelList,theActorList)
       		return theSkelList				
       		
       
       theSkelList = []
       theActorList = []
       theSelection = FBModelList()
       FBGetSelectedModels(theSelection,None,True)
       theHip = theSelection[0]
       theNewSkels = makeSkelNode(theHip,None,theSkelList,theActorList)
       
  
       # Next, we try to loop thro time, get transform from the actor part and set the transform 
       # on the skeleton part :
       
       theScene = FBSystem().Scene
       startFrame = int(FBPlayerControl().ZoomWindowStart.GetFrame(True))
  endFrame = int(FBPlayerControl().ZoomWindowStop.GetFrame(True))
       theMatrix = FBMatrix()
       
       for t in range(startFrame,(endFrame + 1)):
       		for i in range(0,len(theSkelList)):
       				theTime = FBTime(0,0,0,t,0)
       				FBPlayerControl().Goto(theTime)
       				theScene.Evaluate()
       				theActorList[i].GetMatrix(theMatrix)
       				theSkelList[i].Selected = True
       				theSkelList[i].SetMatrix(theMatrix)
       				FBPlayerControl().Key()
       				theScene.Evaluate()
 
 
 # End

#2

Hi,

U have to look to the Christopher Evans blog http://www.chrisevans3d.com/pub_blog/?cat=3. It’s really great resource, where you can find method’s for working with per-frame operations

P.S. Actor nodes are passive objects, so scene needs to be recalculated at every frame. This operation takes a lot of time… may be in MB2009 this situation will be change.


#3

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.