Blitz3D+ Command Reference

LightConeAngles light,inner_angle#,outer_angle#

Parameters

light - light handle

inner_angle# - inner angle of cone, in degrees; 0 (default)

outer_angle# - outer angle of cone, in degrees; 90 (default)

Description

Sets the cone angles for a spot light.

A spot light (type 3 in CreateLight) throws a cone of light along its z axis - aim it like any entity with RotateEntity or PointEntity. Inside the inner angle the light is at full strength; between the inner and outer angles it falls off to nothing, giving the cone a soft edge.

Narrow angles (say 10,20) give a tight torch or searchlight beam; wide angles a broad wash. Keep the inner angle comfortably smaller than the outer angle - a small gap between them means a hard-edged spot, a large gap a soft one.

This command only means something for spot lights; directional and point lights have no cone.

See also: CreateLight, LightRange, LightColor.

Example

; LightConeAngles Example
; -----------------------

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

camera=CreateCamera()
PositionEntity camera,0,8,-16
RotateEntity camera,25,0,0

; Keep ambient light low so the spotlight cone is obvious
AmbientLight 16,16,16

; Spotlights need well-tessellated geometry to show their cone,
; so use a subdivided plane
ground=CreatePlane(16)

; A spotlight high above the ground, sweeping in a circle
light=CreateLight(3)
PositionEntity light,0,10,0

; An invisible pivot for the spotlight to track
target=CreatePivot()

outer#=45
angle#=0

While Not KeyDown(1)

    ; Press [ / ] to narrow or widen the spotlight cone
    If KeyDown(26) And outer>4 Then outer=outer-1
    If KeyDown(27) And outer<120 Then outer=outer+1

    ; Apply the cone - light fades between the inner and outer angles
    LightConeAngles light,outer/2,outer

    ; Sweep the spotlight across the ground
    angle=angle+1
    PositionEntity target,Cos(angle)*4,0,Sin(angle)*4
    PointEntity light,target

    ; 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,"[ / ]: change cone angles   Arrow keys: move camera   Esc: exit"
    Text 0,20,"LightConeAngles light,"+(outer/2)+","+outer

    Flip

Wend

End

Index