WorldViz User Forum  

Go Back   WorldViz User Forum > Vizard

Reply
 
Thread Tools Rate Thread Display Modes
  #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
  #2  
Old 12-13-2016, 05:14 PM
Jeff Jeff is offline
WorldViz Team Member
 
Join Date: Aug 2008
Posts: 2,471
Quote:
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?
You could set up a callback function for the grabber's release event. In the callback function, apply the falling action to the object.

Quote:
Also how do I make it stop falling whenever it collides with another object?
This seems like it could get complicated. You could try using collision detection to detect if the collision has occured. Then use the node.endAction command to end the falling action and have the object stop immediately.
Reply With Quote
Reply


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
Gravity changes with angle of view in mid-drop?! GregEnj Vizard 1 08-07-2013 11:42 AM
Identify a class via its mesh EnvisMJ Vizard 1 02-15-2012 08:43 AM
Collide mesh on child objects Enlil Vizard 1 08-31-2010 05:52 PM
chain mesh collisions mkmatlock Vizard 1 08-31-2010 12:44 PM
Multiple Mesh Avatar Texturing v-jbinney Vizard 6 11-13-2007 11:00 AM


All times are GMT -7. The time now is 04:41 PM.


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