PhysicsBodyPointVelocityY# ( body,x#,y#,z# )
Parameters
|
body - live explicit physics body handle x# - world-space coordinate or vector component; see units below y# - world-space coordinate or vector component; see units below z# - world-space coordinate or vector component; see units below |
Description
|
Returns the Y velocity of a point on a body. Returns the world Y component of velocity at the supplied world-space point, in metres per second. Includes both centre-of-mass translation and angular motion around the centre. The point need not lie inside a collider; every coordinate must be finite. Ordinary accessors and setters reject stale or wrong-kind handles. Physics objects are owned by their world; deleting a body, entity tree or world also invalidates its dependent handles. Requires Extended mode. See also: CreatePhysicsBody, PhysicsBodyImpulseAt, StepPhysics. |
Example
; PhysicsBodyPointVelocityY 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 orange plank to push around plank=CreateCube() ScaleEntity plank,1.5,0.25,0.5 EntityColor plank,255,120,70 plank_body=CreatePhysicsBody(world,plank,PHYSICS_DYNAMIC) plank_shape=PhysicsBodyBox(plank_body,3,0.5,1) ResetPhysicsBody plank_body,0,1,0,0,0,0 While Not KeyDown(1) ; R puts the plank back in the middle If KeyHit(19) Then ResetPhysicsBody plank_body,0,1,0,0,0,0 ; Space spins the plank If KeyHit(57) Then PhysicsBodyAngularImpulse plank_body,0,6,0 StepPhysics world,1.0/60.0,4 ; Velocity of the plank's right-hand end, including its spin TFormPoint 1,0,0,plank,0 end_x#=TFormedX() end_y#=TFormedY() end_z#=TFormedZ() tip_x#=PhysicsBodyPointVelocityX(plank_body,end_x,end_y,end_z) tip_y#=PhysicsBodyPointVelocityY(plank_body,end_x,end_y,end_z) tip_z#=PhysicsBodyPointVelocityZ(plank_body,end_x,end_y,end_z) ; 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 R: reset Space: spin Esc: exit" Text 0,20,"PhysicsBodyPointVelocityY at the right-hand end = "+tip_y+" m/s" Text 0,40,"(X "+tip_x+", Z "+tip_z+")" Text 0,60,"The centre moves at Y "+PhysicsBodyVelocityY(plank_body)+" m/s" Flip Wend FreePhysicsWorld world End
Index