|
entity - entity whose bounds to draw recursive (optional) - True also draws bounds for every descendant of the entity; False (default) red (optional) - red part of the colour, 0-255; 255 (default) green (optional) - green part of the colour, 0-255; 220 (default) blue (optional) - blue part of the colour, 0-255; 0 (default) depth_test (optional) - True hides the box behind closer geometry, False draws it through everything; True (default) |
|
Queues a wireframe box around an entity's current mesh bounds for the next RenderWorld. DebugEntityBounds takes the mesh's local bounding box and transforms it by the entity's live world transform, so the box moves, rotates and scales with the entity. It shows you at a glance how big a model really is, whether its origin sits where you expect (a model whose box floats away from its position was exported off-centre), and what volume the renderer considers when culling it. With recursive True every descendant mesh gets its own box too - useful for a loaded animated model made of many child meshes. Entities with no mesh geometry of their own (pivots, cameras, lights) draw nothing, though their children still can. Like every Debug command, the box lives for exactly one RenderWorld: the queue is drawn by the next RenderWorld and then cleared, so call DebugEntityBounds every frame for as long as you want it visible. Note this is the render bounding box, not the collision shape - to see what the collision system uses, call DebugEntityCollider. See also: DebugEntityCollider, DebugEntityAxes, DebugBox, ClearDebugDraw. |
; DebugEntityBounds Example
; -------------------------
Graphics3D 640,480,0,2
SetBuffer BackBuffer()
camera=CreateCamera()
PositionEntity camera,0,2,-8
light=CreateLight()
RotateEntity light,45,45,0
; A power crystal that spins and pulses in size
crystal=CreateSphere(12)
EntityColor crystal,120,220,255
show=True
While Not KeyDown(1)
; Space toggles the debug overlay
If KeyHit(57) Then show=Not show
; Spin the crystal and make it breathe so its render bounds keep changing
angle#=angle+2
TurnEntity crystal,1,2,0
ScaleEntity crystal,1+0.5*Sin(angle),1,1+0.5*Cos(angle)
PositionEntity crystal,2*Sin(angle*0.5),1,2
; DebugEntityBounds queues the entity's current world-space render bounds
If show Then DebugEntityBounds crystal
; 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,"DebugEntityBounds follows the crystal as it moves and stretches" Else Text 0,20,"Overlay off - press Space"
Flip
Wend
End