View Single Post
  #10  
Old 05-23-2005, 11:13 AM
farshizzo farshizzo is offline
WorldViz Team Member
 
Join Date: Mar 2003
Posts: 2,849
Hi,

If you wanted to create something that is easy to use and reusable then I would suggest creating your own vizact Action. Here is a basic template for creating the action:
Code:
class MyHeadAction(viz.ActionClass):

	def begin(self,object):
		#Get the list of ori data
		self.oridata = self._actiondata_.data
		
		#Get the head bone and lock it
		self.bone = object.getbone('skel_Head')
		self.bone.lock()

	def update(self,elapsed,object):
		#Called every frame to update action
		if self.finished():
			return

		#Update the head rotation
		self.bone.rotate(x,y,z)
		
		#When the action is finished call the following
		self.end(object)
		
def animatehead(filename):
	action = viz.ActionData()
	#Read orientation data from file and add it to action data
	action.data.append([x,y,z])
	action.actionclass = MyHeadAction
	return action
Now you would use the following code to perform your custom action:
Code:
headAction = animatehead('headdata.txt')

avatar.add(headAction)
Let me know if you need anymore help with this
Reply With Quote