View Single Post
  #4  
Old 07-25-2006, 02:29 PM
farshizzo farshizzo is offline
WorldViz Team Member
 
Join Date: Mar 2003
Posts: 2,849
Quote:
I just tried the script for R2.5 as shown below which was given by Farshid, but it doesn't work with R3. Could anyone tell what's wrong with it, please?
The spin actions work fine on viewpoints. The problem is that the STOP_EVENT has been modified in 3.0. Replace your onstop function with the following:
Code:
def onstop(e):
	if e.action == viz.MOVE:
		#Viewpoint is done moving, translate it to the final value just to be sure
		view.translate(final)
		view.animating = 0
	elif e.action == viz.SPIN:
		#Viewpoint is done spinning, rotate it to the final value just to be sure
		view.rotate(final,viz.BODY_ORI)
		view.animating = 0
Quote:
You may probably find that you have a similar error ("TypeError: spaceturn() takes exactly 2 argumemts (1 given)") when you use SpaceBall. I'd appreciate it if you could fix it. Thanks!
The spaceball callbacks have also been modified. Here is an example script for 3.0 that uses the spaceball:
Code:
import viz
import vizspace
viz.go()

viz.add('gallery.ive')

viz.mouse(viz.OFF)

def spacemove(e):
	viz.MainView.move(viz.Vector(e.pos)*e.elapsed)
	
def spacerot(e):
	viz.MainView.rotate(1,0,0,e.ori[0]*e.elapsed,viz.HEAD_ORI,viz.RELATIVE_LOCAL)
	viz.MainView.rotate(0,1,0,e.ori[1]*e.elapsed,viz.HEAD_ORI,viz.RELATIVE_LOCAL)
	viz.MainView.rotate(0,0,1,e.ori[2]*e.elapsed,viz.HEAD_ORI,viz.RELATIVE_LOCAL)

def spacebuttondown(button):
	print 'Button',button,'pressed'
	
def spacebuttonup(button):
	print 'Button',button,'released'
	
viz.callback(vizspace.TRANSLATE_EVENT,spacemove)
viz.callback(vizspace.ROTATE_EVENT,spacerot)
viz.callback(vizspace.BUTTONDOWN_EVENT,spacebuttondown)
viz.callback(vizspace.BUTTONUP_EVENT,spacebuttonup)
Reply With Quote