PhysicsMotorJointAngularVelocity joint,x#,y#,z#,maximum_torque#
Parameters
|
joint - a live general motor-joint handle x# - world X target velocity component; units described below y# - world Y target velocity component; units described below z# - world Z target velocity component; units described below maximum_torque# - finite non-negative vector torque cap, N m |
Description
|
Sets the relative spin a motor joint drives towards. Sets desired world-space relative angular velocity B minus A in radians per second, plus its non-negative torque cap in N m. Components follow the world axes and the right-hand rule, regardless of either attachment frame's rotation. The vector must be finite with a representable squared length. A zero vector with positive cap is an angular velocity brake. A zero cap disables this channel and clears its cached impulse; the independent angular spring can still act. Setters validate every argument before mutation and wake connected bodies. Getters read configured settings, including those of disabled channels; they do not wake bodies or change physics. Invalid/stale/wrong-kind handles, unsupported joint families and non-finite or out-of-range arguments raise runtime errors. Freeing either body, its entity or the world also frees the joint. Use FreePhysicsJoint to release it without changing the body's pose or velocity. The four channels have independent vector-magnitude caps. If a velocity drive and spring act together, the combined force or torque can reach the sum of their respective caps, or their efforts can oppose each other. They do not guarantee that a target speed or pose will be reached against collision, gravity or another constraint. PhysicsJointForceX/Y/Z and PhysicsJointTorqueX/Y/Z read combined reaction on body B; torque excludes the moment from force at the attachment point. Overload events are sampled in native bias solves, while public feedback describes the final substep's cached reaction. Use PhysicsJointFrame joint,1,x,y,z,pitch,yaw,roll to edit the target frame relative to body A. Side 2 edits the driven attachment frame. Its component getters inspect either frame. Positions are in the body's unscaled local metres; rotations use physics radians in Blitz Euler order. Velocity targets remain world vectors. These settings, frame edits and native wake operations participate in physics recording/replay; recordings are not complete render-scene or input saves. Requires Extended mode. See also: CreatePhysicsMotorJoint, PhysicsMotorJointLinearSpring, PhysicsMotorJointLinearVelocity, PhysicsMotorJointAngularSpring, PhysicsJointFrame. |
Example
; PhysicsMotorJointAngularVelocity 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) ; A kinematic "hand" you steer, and a crate it holds with a motor joint hand=CreateSphere(12) ScaleEntity hand,0.2,0.2,0.2 PositionEntity hand,0,2.5,0 EntityColor hand,255,230,60 hand_body=CreatePhysicsBody(world,hand,1) crate=CreateCube() ScaleEntity crate,0.4,0.4,0.4 PositionEntity crate,1.5,0.4,0 EntityColor crate,255,120,70 crate_body=CreatePhysicsBody(world,crate,PHYSICS_DYNAMIC) crate_shape=PhysicsBodyBox(crate_body,0.8,0.8,0.8) grab=CreatePhysicsMotorJoint(hand_body,crate_body) ; A position spring pulls the crate's origin to the hand PhysicsMotorJointLinearSpring grab,3,0.7,200 ; (no orientation spring, so the spin drive can turn the crate) While Not KeyDown(1) ; A and D move the hand sideways, W and S move it up and down If KeyDown(30) Then MoveEntity hand,-0.05,0,0 If KeyDown(32) Then MoveEntity hand,0.05,0,0 If KeyDown(17) Then MoveEntity hand,0,0.05,0 If KeyDown(31) Then MoveEntity hand,0,-0.05,0 ; [ and ] set a spin about Y for the crate, relative to the hand If KeyHit(26) Then spin=spin-1 If KeyHit(27) Then spin=spin+1 PhysicsMotorJointAngularVelocity grab,0,spin,0,20 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 A / D / W / S: move the hand [ / ]: spin" Text 0,20,"Esc: exit" Text 0,40,"PhysicsMotorJointAngularVelocity grab,0,"+spin+",0,20" Text 0,60,"The crate turns at this rate relative to the hand" Flip Wend FreePhysicsWorld world End
Index