DebugSphere x#,y#,z#,radius#[,segments][,red][,green][,blue][,depth_test]
Parameters
|
x#, y#, z# - world-space centre of the sphere radius# - radius in world units; must be positive segments (optional) - smoothness of each circle, clamped to 6-64; 16 (default) 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 sphere behind closer geometry, False draws it through everything; True (default) |
Description
|
Queues a wireframe debug sphere made of three great circles for the next RenderWorld. DebugSphere draws three circles - one in each axis plane - that together read clearly as a sphere from any angle. Reach for it whenever a radius matters in your game: an explosion's blast range, an enemy's aggro distance, a pickup's collection radius, or the area a sound or light should cover. Like every Debug command, the sphere lives for exactly one RenderWorld: the queue is drawn by the next RenderWorld and then cleared, so call DebugSphere every frame for as long as you want it visible. A zero or negative radius stops the program with a runtime error. With depth_test True (the default) the wireframe hides behind closer geometry; pass False to see the full sphere through walls - usually clearer for ranges the player is standing inside. Higher segment counts give rounder circles at the cost of more lines from the shared 65,536-line debug budget. To visualise the ellipsoid an entity actually collides with (set by EntityRadius), use DebugEntityCollider instead. Requires Extended mode. See also: DebugBox, DebugPoint, DebugEntityCollider, ClearDebugDraw. |
Example
; DebugSphere 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 ; An orbiting pickup coin with a collection radius coin=CreateCylinder() ScaleEntity coin,0.6,0.1,0.6 EntityColor coin,255,210,40 show=True While Not KeyDown(1) ; Space toggles the debug overlay If KeyHit(57) Then show=Not show ; The coin orbits the centre of the arena angle#=angle+1.5 PositionEntity coin,3*Cos(angle),1,3*Sin(angle)+2 TurnEntity coin,0,4,0 ; The pickup radius pulses so the player can spot it radius#=1+0.3*Sin(angle*4) ; DebugSphere queues a wireframe sphere showing the pickup range If show Then DebugSphere EntityX(coin),EntityY(coin),EntityZ(coin),radius,16,80,200,255 ; 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,"DebugSphere radius = "+radius Else Text 0,20,"Overlay off - press Space" Flip Wend End
Index