Hello,
Well today was my first time trying Dark Lights out. I had looked at several code examples and mine was almost identical. Though when the light maps built the object turned completely white.
I thought maybe I was doing something wrong, so I ran the .exes from the Dark Lights examples and they seemed to work fine, but when I compiled their sources they all had the "object turning white" issue.
I soon discovered that there is a solution, but a very odd solution, after building the light maps if you save your "light mapped" objects and reload them then the light maps are properly applied. I've also found that when doing this the camera position changes (either that or the objects are scaled down).
Also if you try to build light maps more than once the application will crash.
Below is some code show all of these issues. If you set SaveObjectsAndReload=0 this will show the objects turning white issue. Setting SaveObjectsAndReload=1 will show the camera moving/object scaling issue (this method uses the odd save and reload object method).
Press enter to build the light maps, if you try to build the light maps a second time you will see the application crash.
Sync Rate 60 : Sync Off
LM Start
Rem WHEN SaveObjectsAndReload=0 OBJECT(S) TURN WHITE
REM WHEN SaveObjectsAndReload=1 CAMERA POSITION CHANGES AND OBJECT(S) HAS TO RELOAD
Global SaveObjectsAndReload : SaveObjectsAndReload=1
`Load Image "Brick.jpg",1
Make Object box 1,5,50,5
`Texture Object 1,1
Make Object Box 2,250,5,250
`Texture Object 2,1
LM Add Collision Object 1
LM Add Collision Object 2
LM Build Collision Data
LM Add Light Map Object 1
LM Add Light Map Object 2
LM Add Point Light 0,10,-30,50,255,0,0
Make Object Sphere 3,5 : Position Object 3,0,10,-30
Move Camera -75
Sync On
`
Ink RGB(0,255,0),0
`
Do
`
Center Text Screen Width()/2.0,0,"Press Enter To Build Light Maps"
`
speed#=1
if shiftkey() then speed#=2.5
Control Camera Using ArrowKeys 0,speed#,speed#
`
REM ATTEMPTING TO RUN A SECOND TIME CRASHES APPLICATION
if keystate(28) and enterkey=0 then Build_Light_Maps()
enterkey=keystate(28)
`
sync
Loop
REM ATTEMPTING TO RUN A SECOND TIME CRASHES APPLICATION
Function Build_Light_Maps()
`
LM Build Light Maps Thread 512,40/100.0,1,-1
if dll exist(1)=0 then load dll "Kernel32.dll",1
while LM Get Complete()=0
set cursor 0,0
Print LM Get Status()+" "+str$(int(LM Get Percent()))+"%"
call dll 1,"Sleep",1
sync
endwhile
if SaveObjectsAndReload=1
for i=1 to 2
if file exist("obj"+str$(i)+".dbo") then Delete File "obj"+str$(i)+".dbo"
Save Object "obj"+str$(i)+".dbo",i : Delete Object i
Load Object "obj"+str$(i)+".dbo",i
next i
endif
LM Reset
Endfunction
Hopefully someone whose used Dark Lights before can help.