Try this:
set display mode desktop width(), desktop height(), 32
sync on : sync rate 60 : sync
cls rgb(50,50,50)
box 50, 50, 250, 250, rgb(255,255,0), rgb(255, 0, 255), rgb(0, 255, 255), rgb(255, 255, 255)
get image 1, 0, 0, 512, 512 ` pretend this is the lightmap
cls rgb(255, 255, 255)
ink rgb(255, 0, 255), 0
box 0, 100, 400, 150
get image 2, 0, 0, 512, 512 ` pretend this is the main texture
make object cube 1, 200
convert object fvf 1, 0x002 + 0x010 + 0x200 ` give the object a second set of UV coords as in lightmapped objects
lock vertexdata for limb 1, 0
nv = get vertexdata vertex count() - 1
for v = 0 to nv
` copy and modify the stage 0 UVs
set vertexdata UV v, 1, get vertexdata u(v, 0)*2, get vertexdata v(v, 0)*3
next v
unlock vertexdata
` now apply the "lightmap" to stage 0 and the main texture to stage 1
` using blend mapping
set blend mapping on 1, 0, 1, 0, 4 ` use MODULATE because the colour is initialised to the lighting by default
set blend mapping on 1, 1, 2, 0, 4 ` use MODULATE again
repeat
xrotate object 1, object angle x(1)+0.5
sync
until spacekey()
end
You may need to switch the roles of the texture stages depending which stages have the lightmap and main texture in your object.
In my demo the first blending command "modulates" the lighting value with the lightmap and the result is then "modulated" with the main texture using the second blending command. Here "modulate" simply means multiply.