View Single Post
  #1  
Old 12-12-2016, 05:23 AM
handerson11 handerson11 is offline
Member
 
Join Date: Nov 2016
Posts: 6
Applying Gravity to a Mesh

Hi,

I am looking to use a mesh on a box and I need it to fall as if being acted on by gravity. What is the best way to trigger the fall action after the box has been picked up and keep the action occurring over a certain height? Also how do I make it stop falling whenever it collides with another object?

This is the simple setup I have at the moment:

Code:
import viz
import vizact
import vizconnect
import vizshape

viz.fov(60)
viz.go()

#fall action
fallAction=vizact.fall(0.75,gravity=9.81)

#adding ground
ground = viz.add('ground.osgb')
ground.collidePlane()

#add cubes
cube1=vizshape.addCube(size=0.5)
cube1.collidemesh()
cube1.setPosition(0,1,1)
cube1.add(fallAction)

cube2=viz.shape.addCube(size=0.5)
cube2.collidemesh()
cube2.setPosition(0,0.5,1)

#define grabbable parts
parts=[cube1]

#using vizconnect
vizconnect.go('vizconnect_config.py')
#grabber
grabber=vizconnect.getRawTool('grabber')
grabber.setItems(parts)
from tools import grabber
tool = grabber.Grabber(usingPhysics=True, usingSprings=True)
tool.setItems(parts)
The technique will later be applied to more complex shapes which is why I am using the mesh instead of the box method.

Thanks
Reply With Quote