PDA

View Full Version : hierarchical models / physic shapes problem in Viz4


Andy
11-21-2011, 03:41 AM
Hi, I would like to build a hierarchical model with some 3d model files. This construct should be part of the physic engine. Each node should have his own collide shape.


import viz
import vizact
viz.go()

viz.MainView.setPosition(0,1.5,-5)
ground = viz.add('tut_ground.wrl') # Add ground
ground.collidePlane() # Make collideable plane
box = viz.add('box.wrl', pos = [2,2, 0], scale=[0.2, 0.2, 0.2])
box.collideBox()

MainNode = viz.add("tut_cone.wrl")
MainNode.collideBox()

subNode1 = viz.add("tut_cone.wrl",pos = [0, 0.5, 0])
subNode1.collideBox()
subNode1.disable(viz.PHYSICS)
subNode1.parent(MainNode)

subNode2 = viz.add("tut_cone.wrl",pos = [0, 1.0, 0])
subNode2.collideBox()
subNode2.disable(viz.PHYSICS)
subNode2.parent(subNode1)


MainNode.setPosition(-2,2,0)
vizact.onkeydown('1', viz.phys.enable) # Enable physics


If I set a new position I see the hierarchical model is ok, but if I put the physic engine on only the “MainNode” take part on the physic-simulation. That’s a problem of Vizard4, in Vizard3 this script works like it should!

Has anyone an idea or a solution?

Jeff
11-21-2011, 06:06 PM
For nodes to react correctly in the physics simulation they should be children of the world. This is the case for both Vizard 3 and Vizard 4 and you'll see a strange result if you enable viz.PHYSICS for the subNodes. If you remove the subNodes' collide shapes they will fall with the mainNode just as they do with the current script when run in Vizard 3.

Andy
11-22-2011, 12:56 AM
Thanks for your answer; I only wonder why in Vizard3 the hierarchical model still works. In my original script I only enable viz.COLLIDE_NOTIFY but I don’t know if it works correctly. I will use joints for my script; I think that’s a better solution for this problem.