|
line_list - a line-list entity created with CreateLineList mode (optional) - how the list's lines interact with scene depth 0: overlay - drawn after the scene with depth testing and writing off, so lines show through everything 1: depth test (default) - drawn after opaque scene geometry, hidden behind closer surfaces, never writes depth 2: depth write - drawn before ordinary scene geometry with depth testing and writing on 3: always write - drawn before ordinary scene geometry, always passes the depth test and writes depth |
|
Sets how a line list's lines interact with the scene's depth buffer. Most of the time the default mode 1 is right: lines behave like solid objects and hide behind walls, but never block anything themselves. Mode 0 turns the list into a pure overlay that shows through all geometry - ideal for a selection outline or a path the player must never lose sight of. Modes 2 and 3 make the lines write depth, so scene geometry drawn afterwards can be occluded by them, and they render before the ordinary scene rather than after it. Mode 3 additionally always passes its own depth test. Its special trick is editor-style ground grids: a grid drawn exactly in a floor plane normally flickers with z-fighting, but an always-write grid lays its depth down first and later geometry occludes it cleanly, with no need to nudge the grid above the floor. A mode outside 0-3 stops the program with a runtime error, as does passing an entity that is not a line list. The setting covers every line in the list; use separate lists for mixed behaviour. See also: LineWidth, CreateLineList, DebugLine. |
; LineDepthMode Example
; ---------------------
Graphics3D 640,480,0,2
SetBuffer BackBuffer()
camera=CreateCamera()
PositionEntity camera,0,1,-7
light=CreateLight()
RotateEntity light,45,45,0
; A spinning crate with a targeting line passing straight through it
crate=CreateCube()
PositionEntity crate,0,0,2
EntityColor crate,180,130,70
lines=CreateLineList()
AddLine lines,-4,0,2,4,0,2
EntityColor lines,255,210,40
LineWidth lines,4
mode=1
While Not KeyDown(1)
; [ and ] cycle through the four depth modes
If KeyHit(26) Then mode=(mode+3) Mod 4
If KeyHit(27) Then mode=(mode+1) Mod 4
; LineDepthMode controls how the line interacts with scene depth
LineDepthMode lines,mode
TurnEntity crate,0,1,0
; A short label for each documented mode
Select mode
Case 0
label$="overlay - ignores depth, always on top"
Case 1
label$="default - hidden inside the crate, drawn after the scene"
Case 2
label$="early - depth tested and written before the scene"
Case 3
label$="grid - always passes, writes depth for later geometry"
End Select
; 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 [ / ] : depth mode Esc: exit"
Text 0,20,"LineDepthMode lines,"+mode+" ("+label+")"
Flip
Wend
End