| world - live explicit physics world |
|
Returns the current world continuous-collision policy. New worlds default to True. Per-body bullet flags remain separate and unchanged by this setting. Reading the policy has no simulation side effects. Ordinary world/body arguments must be live handles of the correct kind; invalid or stale handles raise a runtime error. Mutations are rejected while the owning world is stepping. See also: PhysicsWorldContinuous, PhysicsBodyIsBullet. |
; PhysicsWorldIsContinuousEnabled Example
; ---------------------------------------
Graphics3D 640,480,0,2
SetBuffer BackBuffer()
Const PHYSICS_STATIC=0
Const PHYSICS_DYNAMIC=2
camera=CreateCamera()
PositionEntity camera,7,2,-1
RotateEntity camera,5,80,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 thin glass pane, only 4 cm thick
pane=CreateCube()
ScaleEntity pane,1.5,1.5,0.02
PositionEntity pane,0,1.5,0
EntityColor pane,150,220,255
EntityAlpha pane,0.6
pane_body=CreatePhysicsBody(world,pane,PHYSICS_STATIC)
pane_shape=PhysicsBodyBox(pane_body,3,3,0.04)
; A small ball that ignores gravity
ball=CreateSphere(8)
ScaleEntity ball,0.1,0.1,0.1
EntityColor ball,255,120,70
ball_body=CreatePhysicsBody(world,ball,PHYSICS_DYNAMIC)
ball_shape=PhysicsBodySphere(ball_body,0.2)
PhysicsBodyGravityScale ball_body,0
ResetPhysicsBody ball_body,0,1.5,-4,0,0,0
While Not KeyDown(1)
; Space fires the ball at the pane at 100 m/s
If KeyHit(57)
ResetPhysicsBody ball_body,0,1.5,-4,0,0,0
PhysicsBodyVelocity ball_body,0,0,100
EndIf
; C switches the world's continuous collision on or off
If KeyHit(46) Then PhysicsWorldContinuous world,Not PhysicsWorldIsContinuousEnabled(world)
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
Text 0,0,"Arrow keys: move camera Space: fire C: continuous Esc: exit"
Text 0,20,"PhysicsWorldIsContinuousEnabled(world) = "+PhysicsWorldIsContinuousEnabled(world)
Text 0,40,"Ball Z: "+EntityZ(ball)+" (the pane is at Z 0; above 0 means it went through)"
Flip
Wend
FreePhysicsWorld world
End