PhysicsJointCollideConnected joint,enabled
Parameters
|
joint - a current physics joint handle enabled - True to enable; False to disable |
Description
|
Sets whether the two connected bodies are eligible to collide and wakes them. False is the joint-creation default. True still obeys shape masks and group filtering: matching positive groups override masks, matching negative groups exclude collision. A positive group cannot override a joint that excludes the pair. Other joints between the same bodies can also exclude the pair. Collision changes appear on subsequent steps; this does not resize or move shapes. Invalid, stale or wrong-kind handles raise a runtime error. Requires Extended mode. See also: PhysicsJointSpring, PhysicsJointFrame, PhysicsJointThresholds, PhysicsJointEventJoint, StepPhysics. |
Example
; PhysicsJointCollideConnected Example ; ------------------------------------ ; Requires Extended mode. Graphics3D 640,480,0,2 SetBuffer BackBuffer() Const PHYSICS_STATIC=0 Const PHYSICS_DYNAMIC=2 camera=CreateCamera() PositionEntity camera,0,3,-10 RotateEntity camera,0,0,0 light=CreateLight() RotateEntity light,45,-30,0 AmbientLight 60,60,60 ; An independent Box3D world with standard gravity world=CreatePhysicsWorld() ; Blue static floor ground=CreateCube() ScaleEntity ground,6,0.5,6 PositionEntity ground,0,-0.5,0 EntityColor ground,80,160,255 ground_body=CreatePhysicsBody(world,ground,PHYSICS_STATIC) ground_shape=PhysicsBodyBox(ground_body,12,1,12) ; A static beam, and a heavy ball hanging from its left end on a springy rope beam=CreateCube() ScaleEntity beam,1.5,0.15,0.3 PositionEntity beam,0,5,0 EntityColor beam,150,150,160 beam_body=CreatePhysicsBody(world,beam,PHYSICS_STATIC) beam_shape=PhysicsBodyBox(beam_body,3,0.3,0.6) ball=CreateSphere(16) ScaleEntity ball,0.3,0.3,0.3 PositionEntity ball,-1.5,3,0 EntityColor ball,255,120,70 ball_body=CreatePhysicsBody(world,ball,PHYSICS_DYNAMIC) ball_shape=PhysicsBodySphere(ball_body,0.6,20) rope=CreatePhysicsDistanceJoint(beam_body,ball_body,-1.5,5,0,-1.5,3,0) PhysicsJointSpring rope,True,1.5,0.1 collide=False While Not KeyDown(1) ; Space throws the ball sideways, so it swings up past the beam If KeyHit(57) Then PhysicsBodyImpulse ball_body,25,0,0 ; C lets the ball and the beam collide, or pass through each other If KeyHit(46) collide=Not collide PhysicsJointCollideConnected rope,collide EndIf StepPhysics world,1.0/60.0,4 ; Arrow keys move the camera If KeyDown(200) Then MoveEntity camera,0,0,0.1 If KeyDown(208) Then MoveEntity camera,0,0,-0.1 If KeyDown(203) Then TurnEntity camera,0,1,0 If KeyDown(205) Then TurnEntity camera,0,-1,0 RenderWorld ; Draw the rope CameraProject camera,-1.5,5,0 beam_x=ProjectedX() beam_y=ProjectedY() CameraProject camera,EntityX(ball),EntityY(ball),EntityZ(ball) Line beam_x,beam_y,ProjectedX(),ProjectedY() Text 0,0,"Arrow keys: move camera Space: throw C: collide Esc: exit" Text 0,20,"PhysicsJointCollideConnected rope,"+collide Text 0,40,"Joined bodies pass through each other unless allowed to collide" Flip Wend FreePhysicsWorld world End
Index