WorldViz User Forum  

Go Back   WorldViz User Forum > Vizard

 
 
Thread Tools Rate Thread Display Modes
Prev Previous Post   Next Post Next
  #1  
Old 03-09-2009, 08:07 AM
Sandro Holzer Sandro Holzer is offline
Member
 
Join Date: Jul 2008
Posts: 19
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)
Attached Files
File Type: zip bar2.zip (1.1 KB, 1032 views)
Reply With Quote
 


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
physics engine exception ad_astra Vizard 3 03-25-2009 11:31 AM
picking problem... k_iwan Vizard 2 07-27-2007 07:57 PM
problem with female animations vmonkey Vizard 1 10-07-2005 10:36 AM
sound problem alaa Vizard 7 09-02-2005 01:13 PM
PROBLEM: Picture-in-Picture breaks textures?!? vcarlson Vizard 4 10-05-2004 04:22 PM


All times are GMT -7. The time now is 07:31 AM.


Powered by vBulletin® Version 3.8.7
Copyright ©2000 - 2024, vBulletin Solutions, Inc.
Copyright 2002-2023 WorldViz LLC