WorldViz User Forum

WorldViz User Forum (https://forum.worldviz.com/index.php)
-   Vizard (https://forum.worldviz.com/forumdisplay.php?f=17)
-   -   Collision questions (https://forum.worldviz.com/showthread.php?t=1508)

rubberpimple 05-23-2008 10:06 AM

Collision questions
 
Hi,
I'm currently using collision detection in my code, but I'd like to keep the intersecting object from passing though each other. I've read lots of posts but cannot get the right combination of physics, intersection and collision settings. Here's a sample of what I'm doing:
# Some Basics
viz.phys.enable()

viz.collision(1)

# Import a hand object
sensor = viz.add('MonkeyGlove.dls')

myHand = hand.add(sensor,hand.MONKEYGLOVE)
myHand.collidebox()
myHand.enable(viz.DYNAMICS)
myHand.disable(viz.INTERSECTION) myHand.enable(viz.COLLIDE_NOTIFY)

# Import a cylinder object
Cylinder = viz.add('cylinder2.wrl')
Cylinder.collidebox()
Cylinder.enable(viz.DYNAMICS)
Cylinder.disable(viz.INTERSECTION)
Cylinder.enable(viz.COLLIDE_NOTIFY)

I would like both objects to NOT be subject to gravitational forces, but would like for the hand to stop when it contacts the object, and for the object to stay in place as well.

Collisions are detected using the viz.phys.intersectNode(myHand) command

Any help is appreciated!

farshizzo 05-27-2008 11:43 PM

From what you described it seems like you just need to disable dynamics on both objects. This will remove the affect of gravity. If you are manually checking for collisions using the viz.phys.intersectNode command, then move the hand to its previous position when it intersects with the object. Let me know if I misunderstood your question.

rubberpimple 05-28-2008 12:46 PM

The gravity isn't the problem, just the collisions. I would like for the hand object to stop when it intersects the cylinder object, instead of passing into it.

rubberpimple 05-28-2008 12:54 PM

sorry, just a clarification...

I thought that the physics engine would have a method by which it would prevent two solid objects from occupying the same physical space, perhaps depending on some user-defined physical parameter such as density, hardness, etc....

From your reply I guess this isn't the case? Avoiding such overlaps must be done programatically?

farshizzo 05-29-2008 09:46 PM

Ok, it sounds like you want to have a dynamic object whose position is controlled by a tracker? If so, then you will need to use a physics spring. You tell the spring the desired position/rotation of the object and the physics engine will apply the necessary forces to get the object to that position, but it will stop if it collides with other objects in the environment. Search the docs for addSpring, it is documented under the Forces section of the Physics engine reference.

We use this technique for scripts where a person uses their hand to interactive with a physics environment.


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

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