Blitz3D+ Command Reference

DebugBox x#,y#,z#,width#,height#,depth#[,red][,green][,blue][,depth_test]

Parameters

x#, y#, z# - world-space centre of the box

width# - full size along X; must be positive

height# - full size along Y; must be positive

depth# - full size along Z; must be positive

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

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

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

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

Description

Queues a wireframe axis-aligned box for the next RenderWorld.

DebugBox draws the twelve edges of a box centred on x,y,z. It is the quickest way to visualise anything box-shaped in your game: a trigger zone, a spawn area, a room volume you are blocking out, or a bounding box you computed yourself.

The box is always axis-aligned - it does not rotate. To see the bounds of an entity, oriented by that entity's own transform, use DebugEntityBounds instead; to see collision shapes set with EntityBox, use DebugEntityCollider.

Like every Debug command, the box lives for exactly one RenderWorld: the queue is drawn by the next RenderWorld and then cleared, so call DebugBox every frame for as long as you want it on screen. A zero or negative dimension stops the program with a runtime error.

With depth_test True (the default) nearby geometry hides the box; pass False to draw it through walls, which is usually what you want for trigger zones the player stands inside.

Requires Extended mode.

See also: DebugSphere, DebugEntityBounds, DebugLine, ClearDebugDraw.

Example

; DebugBox Example
; ----------------
; Requires Extended mode.

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

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

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

; A patrolling enemy for the debug overlay to track
enemy=CreateCube()
EntityColor enemy,220,60,60

show=True

While Not KeyDown(1)

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

    ; The enemy patrols left and right while spinning
    angle#=angle+2
    PositionEntity enemy,4*Sin(angle),0,2
    TurnEntity enemy,0,3,0

    ; DebugBox queues a wireframe box around the enemy for the next RenderWorld
    If show Then DebugBox EntityX(enemy),EntityY(enemy),EntityZ(enemy),3,3,3,255,220,0

    ; 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 overlay   Esc: exit"
    If show Then Text 0,20,"DebugBox tracks the enemy every frame" Else Text 0,20,"Overlay off - press Space"

    Flip

Wend

End

Index