WorldViz User Forum  

Go Back   WorldViz User Forum > Vizard

Reply
 
Thread Tools Rate Thread Display Modes
  #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, 998 views)
Reply With Quote
  #2  
Old 03-12-2009, 10:00 AM
Jeff Jeff is offline
WorldViz Team Member
 
Join Date: Aug 2008
Posts: 2,471
Thanks for the post. You question has not been overlooked.
Reply With Quote
  #3  
Old 03-20-2009, 12:53 AM
Sandro Holzer Sandro Holzer is offline
Member
 
Join Date: Jul 2008
Posts: 19
Thank you Jeff.

Just to make my thing a little bit clearer.
In the end I want to model something like a forklift, just with a different way to move the forks.
And I donīt want to use the physic engine to move the parts on the machine (no Physic Joints), just to model the interaction between the forks and the load.
So all parts that are attached to the machine should not be affected by forces, they should just act as collideable bodies, and are moved with setEuler() and so on, every 0,02 seconds, like in the small code I posted.
The only parts that should be affected by forces are the loads, which you can lift or shift around.

I hope this makes it easier for you to understand my purpose.

Sandro
Reply With Quote
  #4  
Old 03-20-2009, 01:07 PM
Gladsomebeast Gladsomebeast is offline
Member
 
Join Date: Mar 2005
Location: Isla Vizta, CA
Posts: 397
Sound like you want to call forklift.disable(viz.DYNAMICS). With this function the forklift collide shapes will push/lift the boxes, but no dynamic forces will move the forklift.

Also, from your code I see that you are creating collide shapes on "bars" that are not children of viz.WORLD. This is a problem. The physics engine assumes collide shapes live on nodes that are children of viz.WORLD. If the collide shapes are not associated with direct children of viz.WORLD, then the collide shapes will not be properly positioned on the nodes if the nodes are not at position (0,0,0).

To fix, set up your forklift geometry, making sub-nodes children of some common parent node, we'll call ''forklift''. Then call forklift.collideMesh(), assuming "forklift" is a child of viz.WORLD. With the collideMesh command you can also forgo the disable(viz.DYNAMICS) command because the physics engine does not support dynamic forces on collideMesh shapes so they will not be applied anyway.
__________________
Paul Elliott
WorldViz LLC
Reply With Quote
  #5  
Old 03-29-2009, 10:51 PM
Sandro Holzer Sandro Holzer is offline
Member
 
Join Date: Jul 2008
Posts: 19
Thank You Gladsomebeast

I will try to work with the suggestions you made.

Sandro
Reply With Quote
Reply

Thread Tools
Display Modes Rate This Thread
Rate This Thread:

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 06:58 PM.


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