#5
|
|||
|
|||
Hi
Sorry, I am not able to work it ou by myself. I added a small sample, and it should work like this: there are 3 bars in a chain. The bar-body is attached bar1 should rotate araund the vertikal axis (keys "t" and "b") on the end of bar1, bar2 is connected and should rotate like a arm. and on the end of bar2, bar3 is connected and should also rotate like a arm. and then I want to switch the visibility of bar2 The first code is like I want it: Code:
import viz viz.go() viz.clearcolor(0.1,0.1,1) #ground = viz.add('tut_ground.wrl') ANCHOR_POS= (0.6,1.8005,6) bar1 = viz.add('bar2.obj',pos=ANCHOR_POS) bar2 = bar1.add('bar2.obj') bar2.translate([0.0,0.0,-1]) bar3 = bar2.add('bar2.obj') bar3.translate([0.0,0.0,-1]) a = 0 b = 0 c = 0 def mytimer(num): global a,b,c if viz.iskeydown('t'): a = a + 1 if a > 89: a = 89 move() if viz.iskeydown('b'): a = a - 1 if a < -89: a = -89 move() if viz.iskeydown('f'): b = b + 1 if b > 89: b = 89 move() if viz.iskeydown('h'): b = b - 1 if b < -89: b = -89 move() if viz.iskeydown('z'): c = c + 1 if c > 89: c = 89 move() if viz.iskeydown('n'): c = c - 1 if c < -89: c = -89 move() def move(): euler = bar1.getEuler(viz.ABS_GLOBAL) euler[0] = a bar1.setEuler(euler,viz.ABS_GLOBAL) euler = bar2.getEuler(viz.ABS_GLOBAL) euler[1] = b bar2.setEuler(euler,viz.ABS_GLOBAL) euler = bar3.getEuler(viz.ABS_GLOBAL) euler[1] = c bar3.setEuler(euler,viz.ABS_GLOBAL) vizact.onkeydown(' ',bar2.visible,viz.TOGGLE) viz.callback(viz.TIMER_EVENT,mytimer) viz.starttimer(0,0.02,viz.FOREVER) First problem, the bar3 is not at the end of bar2 (you have to navigate back to look for it) this has something to do with the ANCHOR_POS of the first bar. Second problem, bar3 follows bar2, but not the bar1. Code:
import viz viz.go() viz.clearcolor(0.1,0.1,1) #ground = viz.add('tut_ground.wrl') ANCHOR_POS= (0.6,1.8005,6) bar1 = viz.add('bar2.obj',pos=ANCHOR_POS) bar2 = bar1.add('bar2.obj') bar2.translate([0.0,0.0,-1]) group = viz.addGroup() link = viz.link(bar2,group) bar3 = viz.add('bar2.obj',parent=group,pos=[0.0,0.0,-1.0]) a = 0 b = 0 c = 0 def mytimer(num): global a,b,c if viz.iskeydown('t'): a = a + 1 if a > 89: a = 89 move() if viz.iskeydown('b'): a = a - 1 if a < -89: a = -89 move() if viz.iskeydown('f'): b = b + 1 if b > 89: b = 89 move() if viz.iskeydown('h'): b = b - 1 if b < -89: b = -89 move() if viz.iskeydown('z'): c = c + 1 if c > 89: c = 89 move() if viz.iskeydown('n'): c = c - 1 if c < -89: c = -89 move() def move(): euler = bar1.getEuler(viz.ABS_GLOBAL) euler[0] = a bar1.setEuler(euler,viz.ABS_GLOBAL) euler = bar2.getEuler(viz.ABS_GLOBAL) euler[1] = b bar2.setEuler(euler,viz.ABS_GLOBAL) euler = bar3.getEuler(viz.ABS_GLOBAL) euler[1] = c bar3.setEuler(euler,viz.ABS_GLOBAL) vizact.onkeydown(' ',bar2.visible,viz.TOGGLE) viz.callback(viz.TIMER_EVENT,mytimer) viz.starttimer(0,0.02,viz.FOREVER) |
|
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
Vertex shader performance problem | Joran | Vizard | 2 | 11-17-2008 01:29 AM |
export problem | bazelaisr | Vizard | 2 | 05-28-2008 10:19 AM |
5DT Data Glove 5 Ultra Problem | bjgold | Vizard | 1 | 08-08-2006 04:08 PM |
problem with female animations | vmonkey | Vizard | 1 | 10-07-2005 10:36 AM |
PROBLEM: Picture-in-Picture breaks textures?!? | vcarlson | Vizard | 4 | 10-05-2004 04:22 PM |