Hi.
Moving along, I made it possible to have colored shadows and lights.
Remember that there is only one light in this scene.
Anyway another screenie:
and the new source:
Set Display Mode 1024, 768, 32
Sync On
Sync Rate 0
Autocam off
set text to bold
color backdrop 0
set ambient light 15
` make floor
make matrix 1, 2000, 2000, 100, 100
position matrix 1, -1000, 0, -1000
`for x = 1 to 100:for y = 1 to 100:inc stepper, 2:set matrix height 1, x, y, cos(stepper) * 15:next y:next x
`update matrix 1
set matrix wireframe off 1
` make object to cast shadow
make object cube 1, 100
position object 1, 100, 50, 100
set shadow shading on 1, -1, 1000, 1
make object cube 2, 100
position object 2, -250, 50, -250
set shadow shading on 2, -1, 1000, 1
` lights
GoSub setup
add_Shadow_Light( 500, 100, 500, RGB(255,0,0), 600 )
add_Shadow_Light( 424, 150, -424, RGB(0,255,0), 800 )
add_Shadow_Light( -182, 429, 120, RGB(0,0,255), 800 )
` camera
position camera -200, 100, -200
do
` debug
set cursor 0,0
print screen fps()
print int(camera position x()), "/", int(camera position y()), "/", int(camera position z())
` camera
move camera (upkey()-downkey())*2.0
rotate camera camera angle x()+mousemovey(), camera angle y()+mousemovex(), 0.0
` object 2
Inc increaser#, 0.5
Position Object 2, Object Position X(2)+(Sin(Increaser#)*5), 50, Object Position Z(2)+(Cos(Increaser#)*5)
` lights
For a = 1 To Array Count(Light(0))
rotate camera Light(a).CameraID, camera angle x(), camera angle y(), camera angle z()
position camera Light(a).CameraID, camera position x(), camera position y(), camera position z()
color light 0, Light(a).color
Position Light 0,light(a).xpos, light(a).ypos, light(a).zpos
Set Light Range 0, Light(a).range
set global shadow color RGBR(Light(a).color)/8, RGBG(Light(a).color)/8, RGBB(Light(a).color)/8, 100
set shadow position -1, light(a).xpos, light(a).ypos, light(a).zpos
sync mask 2^Light(a).CameraID
fastsync
next a
sync mask 2^0
For x = 1 To Array Count(Light(0))
sprite Light(x).ImageID, 0, 0, Light(x).ImageID
size sprite Light(x).ImageID, screen width(), screen height()
set sprite alpha Light(x).ImageID, 127.5
Next x
` Update
Sync
loop
setup:
Type t_Lights
xPos As Float
yPos As Float
zPos As Float
Color As dWord
Range As Float
CameraID As Integer
ImageID As Integer
EndType
Dim light(0) As t_Lights
set point light 0, 0,0,0
RETURN
Function add_Shadow_Light( xpos as float, ypos as float, zpos as float, color as dword, range as float )
Array Insert At Bottom Light(0)
pos = Array Count(Light(0))
Light(pos).xpos = xpos
Light(pos).ypos = ypos
Light(pos).zpos = zpos
Light(pos).color = color
Light(pos).range = range
Light(pos).CameraID = FindFreeCamera()
Light(pos).ImageID = Find Free Image()
make camera Light(pos).CameraID : set camera to image Light(pos).CameraID, Light(pos).ImageID, 1024, 768
EndFunction
Function FindFreeCamera()
repeat : inc returnVal, 1 : Until Not Camera Exist(returnVal)
Endfunction returnVal
So, anything to comment on? Have you made something better, which hopefully runs faster? This one runs at about 300fps.
I'd be happy to have a look at some other examples.
edit:
oh ya, if you don't have the matrix1 dll your dbpro probably won't recognize the command "Find Free Image()".
Just replace that command call with a function like this:
Function FindFreeImage()
repeat : inc returnVal, 1 : Until Not Image Exist(returnVal)
Endfunction returnVal