![]() |
|
#1
|
|||
|
|||
I modified your script to work with the built-in relative transform modes. Hopefully this should work better:
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') MOVE_SPEED = 60 # degrees/sec def UpdateBars(): if viz.iskeydown('t'): bar.setEuler([0,MOVE_SPEED*viz.elapsed(),0],viz.REL_LOCAL) if viz.iskeydown('b'): bar.setEuler([0,-MOVE_SPEED*viz.elapsed(),0],viz.REL_LOCAL) if viz.iskeydown('f'): bar2.setEuler([MOVE_SPEED*viz.elapsed(),0,0],viz.REL_PARENT) if viz.iskeydown('h'): bar2.setEuler([-MOVE_SPEED*viz.elapsed(),0,0],viz.REL_PARENT) vizact.ontimer(0,UpdateBars) |
#2
|
|||
|
|||
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) |
![]() |
Thread Tools | |
Display Modes | Rate This Thread |
|
|