View Single Post
  #7  
Old 10-21-2008, 05:01 AM
Sandro Holzer Sandro Holzer is offline
Member
 
Join Date: Jul 2008
Posts: 19
Hi

Thanks for answers.

The relative transform mode is a bit a problem with my application, but I tryed to do it ABS with the transform-matrix and it looks very good.

The code is the following, and it seems to work also in my big script.

Sandro



Code:
import viz
viz.go()
 
viz.clearcolor(0.1,0.1,1)
ground = viz.add('tut_ground.wrl')
ANCHOR_POS= (0.5,1.8005,6)
bar2 = viz.add('bar.obj',pos=ANCHOR_POS)
bar = bar2.add('bar.obj')

a = 0
b = 0

def mytimer(num):
	global a,b
	if viz.iskeydown('t'):
		a = a + 1
		move()
	if viz.iskeydown('b'):
		a = a - 1
		move()
		
	if viz.iskeydown('f'):
		b = b + 1
		move()
	if viz.iskeydown('h'):
		b = b - 1
		move()

def move():

	X = bar.getMatrix(viz.ABS_PARENT)
	X.setAxisAngle(1,0,0,a)
	bar.update(X)
	
	
	X = bar2.getMatrix(viz.ABS_GLOBAL)
	X.setAxisAngle(0,1,0,b)
	bar2.update(X)
	
	

viz.callback(viz.TIMER_EVENT,mytimer)
viz.starttimer(0,0.02,viz.FOREVER)
Reply With Quote