PhysicsBodyAllowsFastRotation ( body )

Parameters

body - live physics body

Description

Returns True if a body was created with CreatePhysicsFastBody.

Returns True for a body created by CreatePhysicsFastBody and False for one created by CreatePhysicsBody. This reports the immutable creation policy, not whether a particular frame exceeded the ordinary angular-speed cap.

The flag persists through reset, disable/re-enable and body-type changes. It does not override motion locks, damping or constraints and does not make fast non-circular rotation collision-safe.

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: CreatePhysicsFastBody, PhysicsBodyAngularVelocityZ.

Example

; PhysicsBodyAllowsFastRotation Example
; -------------------------------------

Graphics3D 640,480,0,2
SetBuffer BackBuffer()

Const PHYSICS_STATIC=0
Const PHYSICS_DYNAMIC=2

camera=CreateCamera()
PositionEntity camera,0,3,-7
RotateEntity camera,20,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)

; Two floating rotors: an ordinary body, and a fast-rotation body
slow=CreateCube()
ScaleEntity slow,1.5,0.05,0.2
PositionEntity slow,-2,2,0
EntityColor slow,120,200,140
slow_body=CreatePhysicsBody(world,slow,PHYSICS_DYNAMIC)
fast=CreateCube()
ScaleEntity fast,1.5,0.05,0.2
PositionEntity fast,2,2,0
EntityColor fast,255,120,70
fast_body=CreatePhysicsFastBody(world,fast,PHYSICS_DYNAMIC)
PhysicsBodyGravityScale slow_body,0
PhysicsBodyGravityScale fast_body,0
slow_shape=PhysicsBodyBox(slow_body,3,0.1,0.4)
fast_shape=PhysicsBodyBox(fast_body,3,0.1,0.4)

While Not KeyDown(1)

    ; Space asks both rotors to spin at 300 radians per second
    If KeyHit(57)
        PhysicsBodyAngularVelocity slow_body,0,300,0
        PhysicsBodyAngularVelocity fast_body,0,300,0
    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

    Text 0,0,"Arrow keys: move camera   Space: spin   Esc: exit"
    Text 0,20,"PhysicsBodyAllowsFastRotation: green "+PhysicsBodyAllowsFastRotation(slow_body)+", orange "+PhysicsBodyAllowsFastRotation(fast_body)
    Text 0,40,"Green, ordinary body: "+PhysicsBodyAngularVelocityY(slow_body)+" rad/s"
    Text 0,60,"Orange, fast body: "+PhysicsBodyAngularVelocityY(fast_body)+" rad/s"

    Flip

Wend

FreePhysicsWorld world
End

Index