; CreateLight Example ; ------------------- Graphics3D 640,480,0,2 SetBuffer BackBuffer() camera=CreateCamera() PositionEntity camera,0,1,-6 ; Keep ambient light low so the created light does the work AmbientLight 30,30,30 ; A row of spheres to catch the light For i=-1 To 1 sphere=CreateSphere(16) PositionEntity sphere,i*2.5,0,2 Next ; Create a directional light to start with light_type=1 light=CreateLight(light_type) PositionEntity light,0,3,-3 RotateEntity light,45,0,0 While Not KeyDown(1) ; Keys 1-3 recreate the light: 1=directional 2=point 3=spot new_type=light_type If KeyHit(2) Then new_type=1 If KeyHit(3) Then new_type=2 If KeyHit(4) Then new_type=3 If new_type<>light_type light_type=new_type FreeEntity light light=CreateLight(light_type) PositionEntity light,0,3,-3 RotateEntity light,45,0,0 ; Point and spot lights fade with distance, so give them a short range If light_type>1 Then LightRange light,10 EndIf ; 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 type_name$="directional" If light_type=2 Then type_name$="point" If light_type=3 Then type_name$="spot" Text 0,0,"1/2/3: light type Arrow keys: move camera Esc: exit" Text 0,20,"CreateLight("+light_type+") - "+type_name$ Flip Wend End