Blitz3D+ Command Reference

DebugSkeleton entity[,red][,green][,blue][,depth_test]

Parameters

entity - entity with a bone-skinned mesh

red (optional) - red part of the colour, 0-255; 80 (default)

green (optional) - green part of the colour, 0-255; 255 (default)

blue (optional) - blue part of the colour, 0-255; 140 (default)

depth_test (optional) - True hides the skeleton behind closer geometry, False draws it through everything; True (default)

Description

Queues an animated model's live bone skeleton as stick-figure lines for the next RenderWorld.

DebugSkeleton draws a line from each bone that skins the entity's mesh to its nearest bone ancestor, and a small cross at each root bone. Because the lines use the bones' current world positions, you see the pose exactly as the animation system computes it each frame - great for checking that an Animate call is really playing, spotting a bone left behind by a bad export, or lining up a weapon attached with FindChild.

The entity must carry a bone-skinned mesh, such as a model loaded with LoadAnimMesh from a format with skinned bones. If it does not - a plain mesh, or an MD2 model, which animates by morphing vertices rather than moving bones - the command quietly draws nothing rather than raising an error. So if no skeleton appears, that is the first thing to check.

Pass False for depth_test to see the skeleton through the model's own skin, which is usually what you want.

Like every Debug command, the skeleton lives for exactly one RenderWorld: the queue is drawn by the next RenderWorld and then cleared, so call DebugSkeleton every frame for as long as you want it visible.

Requires Extended mode.

See also: LoadAnimMesh, Animate, DebugEntityAxes, ClearDebugDraw.

Example

; DebugSkeleton Example
; ---------------------
; Requires Extended mode.

Graphics3D 640,480,0,2
SetBuffer BackBuffer()

camera=CreateCamera()
PositionEntity camera,0,2,-7

light=CreateLight()
RotateEntity light,45,45,0

; Load the rigged fox that ships with the glTF samples
fox=LoadAnimMesh("../../../samples/glTF/assets/Fox/Fox.glb")
If fox=0 Then RuntimeError "Could not load Fox.glb: "+ModelLoadError()

; The source model is about 150 units long, so scale it down
ScaleEntity fox,0.03,0.03,0.03
Animate fox,1,0.5,FindAnimSeq(fox,"Walk")

show=True

While Not KeyDown(1)

    ; Space toggles the skeleton overlay
    If KeyHit(57) Then show=Not show

    ; Turn the fox slowly and advance its walk animation
    TurnEntity fox,0,0.5,0
    UpdateWorld

    ; DebugSkeleton queues bone-to-parent links; depth_test False shows them through the mesh
    If show Then DebugSkeleton fox,80,255,140,False

    ; 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: toggle skeleton   Esc: exit"
    If show Then Text 0,20,"DebugSkeleton draws the "+CountBones(fox)+" animated bones inside the mesh" Else Text 0,20,"Skeleton off - press Space"

    Flip

Wend

End

Index