![]() |
|
|
|
#1
|
|||
|
|||
|
Try using a collideBox for the bar. Does that work?
Code:
barCollideShape = bar.collideBox() bar.disable(viz.DYNAMICS) |
|
#2
|
|||
|
|||
|
I tried the collide box but abandoned it because it made the balance board fall to the ground. I guess i could try using a fulcrum to support the board...
|
|
#3
|
|||
|
|||
|
Code:
bar.disable(viz.DYNAMICS) |
|
#4
|
|||
|
|||
|
thanks, but i'm still having the same problem. the ball passes through the balance board quite easily...
|
|
#5
|
|||
|
|||
|
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)
|
|
#6
|
|||
|
|||
|
i'm going to give this a try.
i was originally having the bar via the wiimote. so as the wiimote moved, the euler of the bar moved accordingly. could that be the reason, or at least one of the reasons why the ball kept falling through? |
|
#7
|
|||
|
|||
|
To make sure the physics engine calculates the collisions correctly you should apply a force or torque to the bar rather than manually setting it's orientation using the setEuler command. You can still use the wiimote data to decide what torque to apply.
|
![]() |
| Thread Tools | |
| Display Modes | Rate This Thread |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Vizard problem | mizutani_jun | Vizard | 4 | 01-09-2011 04:39 PM |
| Physics Problem | Sandro Holzer | Vizard | 4 | 03-29-2009 11:51 PM |
| physics engine exception | ad_astra | Vizard | 3 | 03-25-2009 12:31 PM |
| picking problem... | k_iwan | Vizard | 2 | 07-27-2007 08:57 PM |
| problem with female animations | vmonkey | Vizard | 1 | 10-07-2005 11:36 AM |