|
camera - camera whose view frustum to draw red (optional) - red part of the colour, 0-255; 80 (default) green (optional) - green part of the colour, 0-255; 200 (default) blue (optional) - blue part of the colour, 0-255; 255 (default) depth_test (optional) - True hides the frustum behind closer geometry, False draws it through everything; True (default) |
|
Queues a camera's actual view frustum as a wireframe for the next RenderWorld. DebugCameraFrustum draws the near plane, the far plane and the four connecting edges of everything the camera can see, built from the camera's live settings: its CameraRange near and far distances, its CameraZoom, and its projection mode (a perspective camera draws the familiar pyramid, an orthographic one a box). Looked at through the camera itself the frustum is exactly the screen edge, so the command shines when viewed from a second camera: fly a free debug camera around while the gameplay camera's frustum shows precisely what the player can see. That makes it easy to tune CameraRange (is the far plane cutting the level off too early?), to check what should or should not be culled, and to line up split-screen or minimap cameras. Like every Debug command, the frustum lives for exactly one RenderWorld: the queue is drawn by the next RenderWorld and then cleared, so call it every frame for as long as you want it visible. See also: CameraRange, CameraZoom, DebugEntityBounds, ClearDebugDraw. |
; DebugCameraFrustum Example
; --------------------------
Graphics3D 640,480,0,2
SetBuffer BackBuffer()
; The main camera views the whole scene
camera=CreateCamera()
PositionEntity camera,0,4,-10
light=CreateLight()
RotateEntity light,45,45,0
; A security camera that pans across the room, shown in a small monitor inset
scout=CreateCamera()
PositionEntity scout,0,2,0
CameraRange scout,1,8
CameraViewport scout,470,10,160,120
CameraClsColor scout,10,20,30
; A drone for the security camera to watch
drone=CreateCube()
ScaleEntity drone,0.5,0.5,0.5
EntityColor drone,80,200,255
show=True
While Not KeyDown(1)
; Space toggles the frustum overlay
If KeyHit(57) Then show=Not show
; Pan the security camera while the drone circles it
angle#=angle+1.5
RotateEntity scout,10,60*Sin(angle*0.5),0
PositionEntity drone,4*Cos(angle),1.5,4*Sin(angle)
; DebugCameraFrustum queues the security camera's actual view volume
If show Then DebugCameraFrustum scout
; Arrow keys move the main 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 frustum Esc: exit"
If show Then Text 0,20,"The wireframe is the inset camera's frustum (CameraRange 1,8)" Else Text 0,20,"Frustum off - press Space"
Flip
Wend
End