PhysicsShapeFramePitch# ( shape )
Parameters
| shape - live physics shape handle |
Description
|
Returns the stored body-local authoring frame's pitch component. Position components use metres; pitch/yaw/roll use radians and retain the authored values. Supported for spheres, boxes, hulls and meshes. Spheres report their centre and zero angles. Legacy PhysicsBodyBox remembers its centre; legacy hull/mesh constructors use an identity frame. Frame readback does not include baked source scale or vertex edits, and is not the body's world pose. Capsule and terrain arguments raise a runtime error; use capsule endpoints or local bounds instead. This is read-only. Wrong-kind/stale handles and unsupported typed inspections raise runtime errors. Frame/dimension authoring metadata is wrapper state; native geometry effects are recorded, but physics replay does not reconstruct editable source entities. Requires Extended mode. See also: PhysicsShapeSphere, PhysicsShapeCapsule, PhysicsShapeBox, RefreshPhysicsHull, RefreshPhysicsMesh, PhysicsShapeRadius. |
Example
; PhysicsShapeFramePitch 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,-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) ; An empty pivot carries the body; a child mesh shows its collider root=CreatePivot() body=CreatePhysicsBody(world,root,PHYSICS_DYNAMIC) ; A box collider set 0.5 m to one side of the body's origin tilt#=0 model=CreateCube(root) ScaleEntity model,0.5,0.5,0.5 PositionEntity model,0.5,0,0 EntityColor model,255,120,70 shape=PhysicsBodyBox(body,1,1,1,1,0.5,0,0) ResetPhysicsBody body,0,2,0,0,0,0 While Not KeyDown(1) ; Space tosses the body, R drops it again If KeyHit(57) PhysicsBodyImpulse body,0,5,0 PhysicsBodyAngularImpulse body,0.5,0,0.5 EndIf If KeyHit(19) Then ResetPhysicsBody body,0,2,0,0,0,0 ; [ and ] tilt the box inside the body; roll is in radians for physics change=KeyHit(27)-KeyHit(26) If change<>0 tilt=tilt+change*15 PhysicsShapeBox shape,1,1,1,0.5,0,0,0,0,tilt*Pi/180 RotateEntity model,0,0,tilt 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: toss R: reset [ / ]: tilt Esc: exit" Text 0,20,"PhysicsShapeFramePitch(shape) = "+PhysicsShapeFramePitch(shape) Text 0,40,"(position "+PhysicsShapeFrameX(shape)+", "+PhysicsShapeFrameY(shape)+", "+PhysicsShapeFrameZ(shape)+" angles "+PhysicsShapeFramePitch(shape)+", "+PhysicsShapeFrameYaw(shape)+", "+PhysicsShapeFrameRoll(shape)+")" Flip Wend FreePhysicsWorld world End
Index