Blitz3D+ Command Reference

SetLine line_list,index,x1#,y1#,z1#,x2#,y2#,z2#

Parameters

line_list - a line-list entity created with CreateLineList

index - segment to replace, from 0 through CountLines(line_list)-1

x1#, y1#, z1# - new start of the segment, in the line list's local space

x2#, y2#, z2# - new end of the segment, in the line list's local space

Description

Replaces one existing segment of a line list with new coordinates.

SetLine moves a segment that already exists, keeping the list's size the same. It is the tool for animating retained lines: a radar sweep, a grappling-hook rope between two moving entities, an aim line that tracks the mouse. Store the index AddLine returned when you created the segment, then update it every frame.

Indexes are zero-based: valid values run from 0 through CountLines(line_list)-1. An index out of that range stops the program with a runtime error, as does passing an entity that is not a line list. Coordinates must be finite and are local to the entity, so they combine with the entity's own position, rotation and scale.

Requires Extended mode.

See also: AddLine, CountLines, ClearLines, CreateLineList.

Example

; SetLine Example
; ---------------
; Requires Extended mode.

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

camera=CreateCamera()
PositionEntity camera,0,0,-7

; A radar display built from one line list
radar=CreateLineList()
EntityColor radar,70,255,120
LineWidth radar,2

; The outer ring is a set of fixed segments
For n=0 To 35
    AddLine radar,2.5*Cos(n*10),2.5*Sin(n*10),0,2.5*Cos(n*10+10),2.5*Sin(n*10+10),0
Next

; AddLine returns the new segment's index - keep it so we can update the sweep
sweep=AddLine(radar,0,0,0,2.5,0,0)

While Not KeyDown(1)

    ; SetLine replaces the sweep segment in place every frame
    angle#=angle+2
    SetLine radar,sweep,0,0,0,2.5*Cos(angle),2.5*Sin(angle),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   Esc: exit"
    Text 0,20,"SetLine radar,"+sweep+",0,0,0,x,y,0 rotates the sweep without rebuilding the ring"

    Flip

Wend

End

Index