well I cant seem to get it to work
I have to go to work. So I cant work on this for 8 more hours. anyways this isnt for me. Im trying to help someone else. But if I can get this figured out, I can turn it into a lighting and lightmapping system, using only software and an unlimited number of lights.
here is the full code so far.
sync on
sync rate 60
set camera range 0,1,50000
autocam off
global vertex_indicator = 1000
load object "C:\testmesh\testmesh.dbo",1
color object 1, rgb(100,200,100)
temp = make vector3(11)
`scale object 1,10000,10000,10000
convert object fvf 1, 338
`set object normals
make mesh from object 1,1
delete object 1
make object 1,1,0
`set object smoothing 1,100
`set object normals 1
load image "c:\tile.jpg",1
texture object 1,1
`save mesh "c:\test.x",1
set object cull 1, 0
`point camera 0,0,0
set ambient light 0
hide light 0
set object light 1,0
make object sphere vertex_indicator,100
`exclude object on vertex_indicator
`make light 2
`set light range 2, 15000
`color light 2, rgb(200,100,100)
`position light 2,8000,4500,-7000
light = 998
lightx# = 8000
lighty# = 4500
lightz# = -7000
range = 5000
red = 100
green = 50
blue = 50
`make_software_light(obj,lightx#,lighty#,lightz#,range)
make_software_light(light,lightx#,lighty#,lightz#,range,red,green,blue)
light = 999
lightx# = 4000
lighty# = 4500
lightz# = -7000
range = 5000
red = 50
green = 50
blue = 100
`make_software_light(obj,lightx#,lighty#,lightz#,range)
make_software_light(light,lightx#,lighty#,lightz#,range,red,green,blue)
`point camera 0,-120,0
`Timeer
global frameTime# = 1.0
global startTime = timer()
global timer#
position camera 0,1000,5500,1000
do
set cursor 1,1
print camera position x()
print camera position y()
print camera position z()
print object size x(1)
print object size y(1)
print object size z(1)
print a
`Time based movement
frameTime#=(frameTime#*0.5)+((timer()-startTime)*0.5)
startTime = timer()
timer#=frameTime#/15
`Control Camera
cr#=0:cf#=0
if rightkey()=1 or KEYSTATE(32)=1 then cr#=cr#-(33*timer#)
if leftkey()=1 or KEYSTATE(30)=1 then cr#=cr#+(33*timer#)
if upkey()=1 or KEYSTATE(17)=1 then cf#=cf#+(33*timer#)
if downkey()=1 or KEYSTATE(31)=1 then cf#=cf#-(33*timer#)
ncr#=curvevalue(cr#,ncr#,5)
ncf#=curvevalue(cf#,ncf#,5)
cx#=cx#+mousemovey()*0.2
cy#=cy#+mousemovex()*0.2
if cx#>80 then cx#=80
if cx#<-80 then cx#=-80
ncx#=curveangle(cx#,ncx#,2)
ncy#=curveangle(cy#,ncy#,2)
move camera ncf#
rotate camera 0,wrapvalue(ncy#-90),0
move camera ncr#
rotate camera 0,wrapvalue(ncy#+90),0
rotate camera ncx#,ncy#,0
sync
loop
function make_software_light(light,lightx#,lighty#,lightz#,range,red,green,blue)
if object exist(light) = 0
make object sphere light, 50
endif
position object light,lightx#,lighty#,lightz#
land = 1
LOCK VERTEXDATA FOR limb land,0,2
for a=0 to get vertexdata vertex count()-1
get_x# = object position x(land) + get vertexdata position x(a)
get_y# = object position y(land) + get vertexdata position y(a)
get_z# = object position z(land) + get vertexdata position z(a)
`get_x# = get vertexdata position x(a)
`get_y# = get vertexdata position y(a)
`get_z# = get vertexdata position z(a)
position object vertex_indicator, get_x#,get_y#,get_z#
if distance(light, vertex_indicator) < range
old_color = get vertexdata diffuse(a)
old_red = rgbr(old_color)
old_green = rgbg(old_color)
old_blue = rgbb(old_color)
`new_red = red + old_red
`new_green = red + old_green
`new_blue = red + old_blue
`if old_red > red
`new_red = old_red + red
`else
`new_red = red - old_red
`endif
`if old_green > green
`new_green = old_green + green
`else
`new_green = green - old_green
`endif
`if old_blue > blue
`new_blue = old_blue + blue
`else
`new_blue = blue - old_blue
`endif
`temp_red = old_red - red
`temp_green = old_green - green
`temp_blue = old_blue - blue
`new_red = temp_red - red + old_red
`new_green = temp_green - green + old_green
`new_blue = temp_blue - blue + old_blue
new_red = red + old_red/2
new_green = green + old_green/2
new_blue = blue + old_blue/2
`new_red = Tweencolor(red,old_red,2)
`new_green = Tweencolor(green,old_green,2)
`new_blue = Tweencolor(blue,old_blue,2)
SET VERTEXDATA diffuse a, rgb(new_red,new_green,new_blue)
endif
next a
unlock vertexdata
endfunction
Function Tweencolor(ColorA,ColorB,Mul#)
AR=RGBR(ColorA)
AG=RGBG(ColorA)
AB=RGBB(ColorA)
BR=RGBR(ColorB)
BG=RGBG(ColorB)
BB=RGBB(ColorB)
DR=BR-AR
DG=BG-AG
DB=BB-AB
Tweencolor=RGB(AR+(DR*mul#),AG+(DG*mul#),AB+(DB*mul#))
Endfunction Tweencolor
function distance(obja,objb)
`object data
x1#=object position x(obja)
y1#=object position y(obja)
z1#=object position z(obja)
x2#=object position x(objb)
y2#=object position y(objb)
z2#=object position z(objb)
`calculations
xdist# = x1#-x2#
ydist# = y1#-y2#
zdist# = z1#-z2#
set vector3 11,xdist#,ydist#,zdist#
distance# = length vector3(11)
endfunction distance#
and the model is attached
thank you.