PhysicsFixedJointSpring joint,linear_hertz#,linear_damping#,angular_hertz#,angular_damping#

Parameters

joint - live fixed-joint handle from CreatePhysicsFixedJoint

linear_hertz# - linear channel frequency, Hertz; zero is rigid

linear_damping# - non-negative dimensionless linear spring damping ratio

angular_hertz# - angular channel frequency, Hertz; zero is rigid

angular_damping# - non-negative dimensionless angular spring damping ratio

Description

Configures independent linear and angular spring channels on a fixed (native weld) joint.

All four values must be finite and non-negative. Frequencies use Hertz and damping ratios are dimensionless; 1 is critical damping. ZERO frequency means the channel is rigid, using native constraint tuning. This differs from a zero-frequency ball/distance spring. Creation defaults are zero frequency and zero stored damping in both channels. A rigid channel does not use its stored spring damping ratio. Existing rest frames remain unchanged.

CreatePhysicsFixedJoint captures the initial relative body pose in its rest frames. PhysicsJointFrame can edit either attachment frame. Positive frequencies permit compliant translation and/or rotation; zero frequencies restore rigid channels. Long chains retain finite solver error and can oscillate after changing stiffness. The example uses eight substeps and body damping and shows joint extension with red connectors.

The joint must belong to the matching joint family. All setters validate every argument before mutation and wake connected bodies. Getters do not wake bodies or change physics state. Settings and native wake operations are recorded for deterministic physics replay. Body/entity/world deletion invalidates owned joint handles. Invalid, stale and wrong-kind handles or unsupported joint types raise runtime errors.

Use PhysicsJointForceX/Y/Z and PhysicsJointTorqueX/Y/Z for combined reaction feedback and PhysicsJointThresholds for overload events. Native overloads are sampled during bias solves; final relaxed force/torque getters need not match the event threshold on that step. Events do not automatically break joints.


See also: CreatePhysicsFixedJoint, PhysicsFixedJointLinearHertz, PhysicsFixedJointAngularHertz, PhysicsJointFrame.

Example

; PhysicsFixedJointSpring 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)

; A sign welded to a static post with a springy fixed joint
post=CreateCube()
ScaleEntity post,0.1,1.5,0.1
PositionEntity post,0,1.5,0
EntityColor post,150,150,160
post_body=CreatePhysicsBody(world,post,PHYSICS_STATIC)
post_shape=PhysicsBodyBox(post_body,0.2,3,0.2)
sign=CreateCube()
ScaleEntity sign,1,0.4,0.05
PositionEntity sign,1.1,2.5,0
EntityColor sign,255,120,70
sign_body=CreatePhysicsBody(world,sign,PHYSICS_DYNAMIC)
sign_shape=PhysicsBodyBox(sign_body,2,0.8,0.1,20)
weld=CreatePhysicsFixedJoint(post_body,sign_body)
hertz#=2
PhysicsFixedJointSpring weld,hertz,0.1,hertz,0.1

While Not KeyDown(1)

    ; Space knocks the end of the sign
    If KeyHit(57)
        TFormPoint 1,0,0,sign,0
        PhysicsBodyImpulseAt sign_body,0,-10,10,TFormedX(),TFormedY(),TFormedZ()
    EndIf

    ; [ and ] make the weld softer or stiffer; 0 Hz is perfectly rigid
    If KeyHit(26) And hertz>0 Then hertz=hertz-0.5
    If KeyHit(27) Then hertz=hertz+0.5
    PhysicsFixedJointSpring weld,hertz,0.1,hertz,0.1
    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: knock   [ / ]: stiffness   Esc: exit"
    Text 0,20,"PhysicsFixedJointSpring weld,"+hertz+",0.1,"+hertz+",0.1"
    Text 0,40,"A low frequency lets the sign wobble; 0 holds it rigid"

    Flip

Wend

FreePhysicsWorld world
End

Index