Blitz3D+ Command Reference

PhysicsJointIsCollideConnected ( joint )

Parameters

joint - a current physics joint handle

Description

Returns this joint's configured connected-collision flag.

True grants eligibility only: other joints, shape masks, groups and body types can still prevent collision. Newly created joints default to False.

Invalid, stale or wrong-kind handles raise a runtime error.

Requires Extended mode.

See also: PhysicsJointSpring, PhysicsJointFrame, PhysicsJointThresholds, PhysicsJointEventJoint, StepPhysics.

Example

; PhysicsJointIsCollideConnected 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

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) Then PhysicsJointCollideConnected rope,Not PhysicsJointIsCollideConnected(rope)
    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,"PhysicsJointIsCollideConnected(rope) = "+PhysicsJointIsCollideConnected(rope)

    Flip

Wend

FreePhysicsWorld world
End

Index