WorldViz User Forum  

Go Back   WorldViz User Forum > Vizard

 
 
Thread Tools Rate Thread Display Modes
Prev Previous Post   Next Post Next
  #6  
Old 03-03-2011, 04:13 PM
Jeff Jeff is offline
WorldViz Team Member
 
Join Date: Aug 2008
Posts: 2,471
In order to get the bar and the ball to collide correctly you'll need to move the bar by applying a force or torque to it:
Code:
import viz
import vizact
viz.go()

viz.phys.enable()

bar = viz.add('box.wrl')  # Add a box
bar.setScale(20,1,1) # Make it look more door like
shape = bar.collideBox() # Enable physics on the box
shape.setDensity(0.1)

ball = viz.add('ball.wrl')
ball.setScale([1.5,1.5,1.5])
ball.setPosition([0, 2, 0])
ballCollideShape = ball.collideSphere()

joint = viz.phys.addHingeJoint(bar,None,pos=[0,0,0],axis0=[0,0,1]) # Hinge joint attached to world

def push():
    bar.applyTorque([0,0,20],duration=0.2)
vizact.onkeydown('1',push)

def pushBack():
    bar.applyTorque([0,0,-20],duration=0.2)
vizact.onkeydown('2',pushBack) 

def resetSimulation():
    if ball.getPosition()[1] < -5:         
        ball.reset()
        ball.setPosition([0, 2, 0])
        bar.reset()
        bar.setEuler([0,0,0])
    
vizact.ontimer(1,resetSimulation)

import vizcam
vizcam.PivotNavigate(center=[0,0,0],distance=30)
Reply With Quote
 


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
Vizard problem mizutani_jun Vizard 4 01-09-2011 03:39 PM
Physics Problem Sandro Holzer Vizard 4 03-29-2009 10:51 PM
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


All times are GMT -7. The time now is 10:26 AM.


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