![]() |
|
#1
|
|||
|
|||
|
Physics Problem
Hello Everybody
I have a problem with the Physic Engine. In the following code I want to push away the red box (seesaw from tutorial) with the last of the 3 bars, which are moveable by pressing the keys. Is this possible with the moving of the bars controlled by their angles? Code:
import viz
viz.go()
viz.phys.enable()
viz.clearcolor(0.1,0.1,1)
ground = viz.add('tut_ground.wrl')
ground.collidePlane()
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])
bar3.collideBox()
bar3.disable(viz.DYNAMICS)
seesaw = viz.add( 'box.wrl' )
seesaw.scale( 1, 1, 1 )#
seesaw.translate(0,3,5)
seesaw.collideBox(bounce=0.8)
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)
viz.callback(viz.TIMER_EVENT,mytimer)
viz.starttimer(0,0.02,viz.FOREVER)
|
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| physics engine exception | ad_astra | Vizard | 3 | 03-25-2009 12:31 PM |
| picking problem... | k_iwan | Vizard | 2 | 07-27-2007 08:57 PM |
| problem with female animations | vmonkey | Vizard | 1 | 10-07-2005 11:36 AM |
| sound problem | alaa | Vizard | 7 | 09-02-2005 02:13 PM |
| PROBLEM: Picture-in-Picture breaks textures?!? | vcarlson | Vizard | 4 | 10-05-2004 05:22 PM |