View Single Post
  #3  
Old 01-25-2012, 11:56 AM
farshizzo farshizzo is offline
WorldViz Team Member
 
Join Date: Mar 2003
Posts: 2,849
Here is an example that shows one way of accomplishing this. I created a simple function LookAtBox that places the viewpoint at a specific distance and yaw from the box. I then use a task function to continually call the function for a 360 degree spin.
Code:
import viz
import vizact
import vizshape
import viztask
viz.go()

box = vizshape.addBox(color=viz.GREEN,pos=(0,2,0))
vizshape.addGrid(color=[0.3]*3)

def LookAtBox(yaw,distance):
	pos = box.getPosition()
	viz.MainView.setPosition(pos)
	viz.MainView.setEuler([yaw,0,0])
	viz.MainView.move([0,0,-distance])

def SpinAroundBoxTask():

	# Create mix parameter for yaw (0-360) for 5 seconds
	yawAnimate = vizact.mix(0,360,time=5.0)

	# Animate viewpoint spinning around box at 8 meters away
	yield viztask.waitCall( LookAtBox , yawAnimate, 8.0 )

	print 'Finished spinning'

viztask.schedule( SpinAroundBoxTask() )
Reply With Quote