Hello,
I want to add multiple lights and be able to re render them when i want but i am giving a close program error everytime i want to add more than one light or if i am re rendering the same light in the scene.
This is my code. I am making an editor and i have a code for reading light properties from a file and then apply the light to the scene. What seems to be the problem here?
Thank You Very Much!
//ADD LIGHTS
if file exist("lighttool") = 1
open to read 1, "lighttool"
if file open(1) = 1
read string 1, lightrange$
read string 1, lightcolorr$
read string 1, lightcolorg$
read string 1, lightcolorb$
endif
close file 1
lightrange = val(lightrange$)
lightcolorr = val(lightcolorr$)
lightcolorg = val(lightcolorg$)
lightcolorb = val(lightcolorb$)
lm clear collision objects
lm clear light map objects
lm clear lights
for objcolshd = 32 to impobj + newobj
if object exist(objcolshd) = 1
LM Add Collision Object objcolshd
endif
NEXT objcolshd
LM Build collision Data
for objlightmap = 32 to impobj + newobj
if object exist(objlightmap) = 1
LM Add Light Map Object objlightmap
endif
NEXT objlightmap
inc lightnum
load object "Media Packs\Models\System\lightbulb.3ds", lightnum
xrotate object lightnum, 180
position object lightnum, camera position x(0), camera position y(0), camera position z(0)
LM Add Point Light object position x(lightnum), object position y(lightnum), object position z(lightnum), lightrange, lightcolorr, lightcolorg, lightcolorb
delete file "lighttool"
endif
//BUILD LIGHTMAPS
if file exist("lightmapcalc") = 1
`LM SET AMBIENT OCCLUSION ON 100, 100, 50
LM Build Light Maps Thread 1024, 16.0, 1
load dll "Kernel32.dll", 1
sync off
while LM Get Complete() = 0
call dll 1, "Sleep", 100
endwhile
sync on
LM Reset
delete dll 1
delete file "lightmapcalc"
ENDIF
Rims Flames