Blitz3D+ Command Reference

EntityConvex entity[,source_entity]

Parameters

entity - entity that receives the convex collision definition

source_entity (optional) - mesh whose vertices define the hull; entity itself (default)

Description

Cooks a Box3D convex hull from mesh vertices and stores it on an entity.

Convex colliders take effect in the Box3D backend, selected with SetCollisionBackend 1. Use collision method 4 to collide a source against a convex destination. Because primitive and convex destinations are kinematic in backend 1, the ordinary entity can translate and rotate before UpdateWorld and carry capsule characters through real solver contacts.

When source_entity is supplied, its vertices are transformed into entity's local space before cooking. This lets an invisible pivot carry collision geometry copied from a visible child or helper mesh. Vertices must be finite and form at least four non-coplanar points; Box3D cooks at its pinned 64-hull-vertex limit.

A convex hull wraps the outside of all supplied points: it fills holes, bridges indentations, and cannot reproduce a concave room or arch. Use static polygon method 2 for an exact unmoving mesh. Convex contacts report CollisionSurface and CollisionTriangle as zero because generated hull faces do not correspond to render triangles.

Calling EntityConvex again replaces the definition and safely rebuilds hidden shapes on the next UpdateWorld. CopyEntity shares immutable input data but owns a separate body in each world.

Requires Extended mode.

See also: EntityCapsule, Collisions, SetCollisionBackend, DebugEntityCollider.

Example

; EntityConvex Example - requires Extended mode
Graphics3D 800,450,0,2:SetBuffer BackBuffer():SetCollisionBackend 1
camera=CreateCamera():PositionEntity camera,0,5,-10
light=CreateLight():RotateEntity light,55,-30,0
character=CreatePivot():mesh=CreateCylinder(16,True,character):ScaleEntity mesh,.4,.8,.4
EntityCapsule character,.4,1.6:EntityType character,1:PositionEntity character,1,1.1,0
platform=CreateCylinder(8,True):ScaleEntity platform,2.5,.25,2.5:EntityConvex platform:EntityType platform,2
Collisions 1,2,4,1:ResetEntity character
While Not KeyDown(1)
    TurnEntity platform,0,.6,0:TranslateEntity character,0,-.03,0
    UpdateWorld:DebugEntityCollider character,0:DebugEntityCollider platform,4
    RenderWorld:Text 8,8,"Box3D convex hull (purple) rotates under the capsule   Esc exits":Flip
Wend
End

Index