View Full Version : Rotate Viewpoint 360 Around Point/Object

01-24-2012, 12:39 PM
I am looking at a vizshape.addBox in my Vizard environment and would like to smoothly rotate the viewpoint 360 degrees around this point to show the user all sides. I am not that familiar with 3D rotations, but I believe I only want to change the yaw for this to happen correctly. I have tried all sorts of different spin, goto, and setEuler combinations but nothing works as I would like.

I can get the position of the object with the getPosition function, so I am hoping to use a combination of this position and another function to solve this problem.

Any assistance would be greatly appreciated. Also, please feel free to ask for more information.


01-24-2012, 04:52 PM
I found this example on the worldviz website:

It is very similar to what I am looking for, but is there a way to make the transition between pressing 1-4 smooth, i.e. the center of the pivot object is the axis and the user is making a smooth 360 degree rotation around the center leaving a small radius of space between the camera and the object as the rotation happens?

Also, I keep running into quaternion rotation when I google this topic, but I do not see any examples of setQuad on the Viz website. Is there a good reference to learning what this function can do?


01-25-2012, 11:56 AM
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.import viz
import vizact
import vizshape
import viztask

box = vizshape.addBox(color=viz.GREEN,pos=(0,2,0))

def LookAtBox(yaw,distance):
pos = box.getPosition()

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() )

01-25-2012, 05:36 PM
Works perfectly! Thanks again for the help.