Blitz3D+ Command Reference

PhysicsShapeWind shape,x#,y#,z#[,drag#][,lift#][,max_speed#][,wake]

Parameters

shape - live sphere, capsule or convex-hull physics shape; meshes and terrain are rejected

x# - wind velocity X in world metres per second
y# - wind velocity Y in world metres per second
z# - wind velocity Z in world metres per second

drag# (optional) - non-negative body-velocity feedback coefficient; 1 (default)

lift# (optional) - signed transverse-force coefficient, ignored for spheres; 0 (default)

max_speed# (optional) - non-negative relative-speed cap used in the force calculation, in m/s; 10 (default)

wake (optional) - True wakes a sleeping dynamic body (default); False skips it; disabled bodies remain disabled

Description

Adds a native air-force contribution for this shape to its body’s next physics step.

It uses projected geometry area and a fixed air density of 1.225 kg/m3. Sphere and capsule calculations use shape-centre velocity, including angular motion around the body centre of mass; hull calculations integrate over front-facing face triangles. Forces at offsets also generate torque.

Call once for each affected shape before each StepPhysics call while wind is active. The force is integrated through that whole step, including its internal substeps, then cleared. Repeated calls before one step add forces. No time-step multiplier is needed in this command. A zero wind vector can still resist a moving body; stop calling the command to disable this contribution.

The pinned native model defines relative velocity as wind minus drag times surface-point velocity. drag is therefore a feedback coefficient, not a multiplier on the final force: drag=0 does not turn wind off. With drag=1, an object moving with the wind has no relative flow. max_speed caps the relative-speed magnitude before its square is used in force calculation; it does not cap body speed or direction.

lift adds a force perpendicular to the relative-flow direction for capsules and hulls; negative lift reverses that contribution. Spheres ignore lift. This is a geometry-based native force approximation, not a fluid, buoyancy or full aerodynamic solver. It does not check collision masks, occlusion or shelter.

The wind vector is in world axes and is not multiplied by entity scale. The physical collider geometry controls area. Static and kinematic bodies receive no force. Disabled bodies stay disabled and accumulate no force. Sleeping bodies are skipped when wake=False; the default True wakes them and applies the force in that step. Sensors on dynamic bodies are supported.

Inputs must be finite; drag and max_speed must be non-negative. Vector/coefficient products, relative speed and conservative force/torque bounds must be representable for this shape and its current motion. Invalid input raises a runtime error before native mutation. The shape must be live, in a world that is not stepping.

Wind calls are recorded. The pinned native wake path is corrected to fetch body simulation data after waking, so the force reaches the live body. Recordings made with the earlier native wake bug can diverge when replayed with the corrected implementation. Replay restores native physics, not the script’s wind controls or visual assets.

For a borrowed EntityPhysicsBody shape, use the canonical physical collider of an enabled free dynamic entity. Compatibility shapes and Collisions-controlled movers reject wind. The command checks pending geometry, mass, motion and locks before committing scene edits or accepting the request. Invalid wind or an allocation failure retains the committed scene and earlier queued input; authored edits remain pending. A successful recook can invalidate the shape handle used to issue the call, so reacquire it with PhysicsBodyShape.

Managed wind is queued for the next positive UpdateWorld and reapplied to the current collider on every native slice; do not call StepPhysics on its borrowed world. UpdateWorld 0 and hidden intervals retain accepted wind, while a clearing reset or movement-role change discards it. Queue storage is reused. wake=False skips a body that remains asleep after reconciliation; a pending collider or property edit can itself wake the body. These managed calls do not support recording/replay.

Requires Extended mode.

See also: PhysicsExplosion, PhysicsShapeFilter, PhysicsBodyForceAt, PhysicsBodyImpulseAt, StepPhysics, StartPhysicsRecording.

Example

; PhysicsShapeWind 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

    ; Hold Space for an 8 m/s wind towards the camera; wind lasts one step
    If KeyDown(57) Then PhysicsShapeWind plank_shape,0,0,-8
    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   R: reset   Hold Space: wind   Esc: exit"
    Text 0,20,"PhysicsShapeWind plank_shape,0,0,-8 while Space is held"
    Text 0,40,"The wind pushes on the plank's broad side, blowing it towards you"

    Flip

Wend

FreePhysicsWorld world
End

Index