example code is err.
/Help/examples/camera/camera2-example.dba
rem Camera Functionality
autocam on
gosub _setupmatrix
gosub _simplecamera
gosub _freeflightcamera
gosub _mouselookcamera
gosub _modifycamera
gosub _trackercamera
gosub _followcamera
gosub _usingvectors
gosub _cameradata
rem End of program
autocam off
end
_setupmatrix:
make matrix 1,1000,1000,100,100
set matrix height 1,50,50,500
update matrix 1
return
_simplecamera:
while mouseclick()<>1
set cursor 0,0 : print "SIMPLE CAMERA (EULER) (Left Mouse Button To Continue)"
print "USE ARROW KEYS TO MOVE / A+Z XRotate / S+X ZRotate"
print "SPACE/RETURN To Toggle Rotation Order"
if upkey()=1 then move camera 5.0
if downkey()=1 then move camera -5.0
if leftkey()=1 then y#=y#-1
if rightkey()=1 then y#=y#+1
if inkey$()="a" then x#=x#-1
if inkey$()="z" then x#=x#+1
if inkey$()="s" then z#=z#-1
if inkey$()="x" then z#=z#+1
if spacekey()=1 then set camera rotation zyx
if returnkey()=1 then set camera rotation xyz
xrotate camera x#
yrotate camera y#
zrotate camera z#
endwhile
while mouseclick()=1 : endwhile
return
_freeflightcamera:
while mouseclick()<>1
set cursor 0,0 : print "FREE FLIGHT CAMERA (Left Mouse Button To Continue)"
print "USE ARROW KEYS TO ROTATE / A+Z Roll Camera"
if upkey()=1 then pitch camera up 1
if downkey()=1 then pitch camera down 1
if leftkey()=1 then turn camera left 1
if rightkey()=1 then turn camera right 1
if inkey$()="a" then roll camera left 1
if inkey$()="z" then roll camera right 1
endwhile
while mouseclick()=1 : endwhile
return
_mouselookcamera:
backdrop off
point camera 0,0,0
while mouseclick()<>1
set cursor 0,0 : print "MOUSELOOK CAMERA (Left Mouse Button To Continue)"
x#=x#+mousemovey() : y#=y#+mousemovex() : z#=z#+mousemovez()
rotate camera x#,y#,z#
endwhile
while mouseclick()=1 : endwhile
color backdrop rgb(128,0,0)
backdrop on
return
_modifycamera:
rem 22 Degrees Field of View
set camera fov 22
set camera range 1,750
set camera view 10,10,640-10,480-130
return
_trackercamera:
set camera rotation xyz
position camera 0,100,-500
while mouseclick()<>1
center text 320,30,"TRACKER CAMERA (Left Mouse Button To Continue)"
x#=cos(a#)*500 : z#=sin(a#)*500
a#=a#+1.0 : if a#>359 then a#=a#-360
position camera x#,100,z#
point camera 500,0,500
endwhile
while mouseclick()=1 : endwhile
return
_followcamera:
make object sphere 1,10
set camera rotation xyz
set camera range 1,3000
while mouseclick()<>1
center text 320,30,"FOLLOW CAMERA (Left Mouse Button To Continue)"
a#=a#+1 : if a#>359 then a#=a#-360
x#=500+(cos(a#)*100) : z#=500+(sin(a#)*500)
distance#=200.0 : height#=100.0 : smooth#=25.0
dx#=x#-camera position x()
dz#=z#-camera position z()
angle#=atanfull(dx#,dz#)
set camera to follow x#,0,z#,angle#,distance#,height#,smooth#,0
set camera to object orientation 1
endwhile
while mouseclick()=1 : endwhile
return
_usingvectors:
VectorNumber=1 : CameraNumber=0
result==make vector3(VectorNumber)
set vector3 VectorNumber, 500, 10, 500
position camera CameraNumber, VectorNumber
set vector3 VectorNumber, 0, 45, 0
rotate camera CameraNumber, VectorNumber
set vector3 to camera position VectorNumber, CameraNumber
set vector3 to camera rotation VectorNumber, CameraNumber
x#=x vector3(VectorNumber)
y#=y vector3(VectorNumber)
result=delete vector3(VectorNumber)
return
_cameradata:
while inkey$()<>"x"
set cursor 0,0 : print : print " CAMERA DATA (Press X to Exit)" : print
print " angle x:";camera angle x()
print " angle y:";camera angle y()
print " angle z:";camera angle z()
print " position x:";camera position x()
print " position y:";camera position y()
print " position z:";camera position z()
x#=x#+mousemovey() : y#=y#+mousemovex() : rotate camera x#,y#,0
endwhile
return
/Help/examples/light/light2-example.dba
rem Light Functionality
sync on
rem Call subroutines
gosub _createscene
gosub _usingvectors
gosub _lightshow
gosub _deletescene
rem End of program
end
_createscene:
rem Create Scene
load image "ground.jpg",1
make matrix 1,1000,1000,100,100
prepare matrix texture 1,1,1,1
position matrix 1,-500,0,-500
position camera 0,100,0
rem Set Ambient light
set ambient light 20
color ambient light rgb(64,64,128)
rem Set Default Light As Sun
set directional light 0,0,-1,0
color light 0,192,192,192
rem Create Moving Light
LightNumber=1 : z#=500
make light LightNumber
set point light LightNumber,0,100,0
color light LightNumber,512,512,256
set light range LightNumber,200
rem Create Lighthouse light
make light 2
set spot light 2,45,90
color light 2,512,100,100
position light 2,0,50,400
rem Follow Light
make light 3
set spot light 3,15,30
color light 3,-512,-512,0
rem Set up Fog
fog on
fog distance 500
fog color rgb(255,128,64)
set normalization off
color backdrop rgb(255,128,64)
rem Setup camera
rotate camera 20,0,0
return
_deletescene:
if light exist(1)=1 then delete light 1
if light exist(2)=1 then delete light 2
if light exist(3)=1 then delete light 3
set normalization on
fog off
return
_usingvectors:
VectorNumber=1 : LightNumber=2
result==make vector3(VectorNumber)
set vector3 VectorNumber, 0, 50, 200
position light LightNumber, VectorNumber
set vector3 VectorNumber, 0, 45, 0
rotate light LightNumber, VectorNumber
set vector3 to light position VectorNumber, LightNumber
set vector3 to light rotation VectorNumber, LightNumber
a#=y vector3(VectorNumber)
result=delete vector3(VectorNumber)
return
_lightshow:
while inkey$()<>"x"
set cursor 0,0 : print "LIGHT COMMANDS (X to Exit)"
print "USE ARROW KEYS TO MOVE LIGHT"
print "A+Z TO SWITCH SUN OFF/ON"
print
print "LIGHT DATA"
print
if rnd(5)=1 then LightNumber=rnd(3)
print "number:";LightNumber
print "exist:";light exist(LightNumber)
print "type:";light type(LightNumber)
print "range:";light range(LightNumber)
print "visible:";light visible(LightNumber)
print "position x:";light position x(LightNumber)
print "position y:";light position y(LightNumber)
print "position z:";light position z(LightNumber)
print "direction x:";light direction x(LightNumber)
print "direction y:";light direction y(LightNumber)
print "direction z:";light direction z(LightNumber)
rem Mouselook Camera
mx=mousemovex() : my=mousemovey()
rotate camera camera angle x()+my,camera angle y()+mx,0
rem Control Sun
if inkey$()="a" then hide light 0
if inkey$()="z" then show light 0
rem Control Moving Light
if leftkey()=1 then x#=x#-10
if rightkey()=1 then x#=x#+10
if upkey()=1 then z#=z#+10
if downkey()=1 then z#=z#-10
LightNumber=1 : ObjectNumber=1
set light to object orientation LightNumber,ObjectNumber
set light to object position LightNumber,ObjectNumber
position light 1,x#,100,z#
rem Control Lighthouse light
a#=a#+1 : if a#>359 then a#=a#-360
rotate light 2,0,a#,0
rem Control Beam Of Light
position light 3,x#,150,z#
point light 3,0,0,0
rem Update screen
sync
endwhile
return
/Help/examples/matrix/matrix2-example.dba