You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.
Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.
set display mode 800,600,32
sync rate 60
rem make matrix for ground reference
make matrix 1,1000,1000,25,25
rem make a few objects
for obj=1 to 20
make object sphere obj,25
position object obj,rnd(1000),13,rnd(1000)
you could control the objects light intensity with
a variable or something. This intensity could be a
color or maybe a heat index - the hotter the brighter or the
more red or something.
For this example, I'm just going to set a random diffuse.
Diffuse is a material setting that controls what color of
light is spread out on the surface of an object. It's the
color the object reflects back. If the object has 0 diffuse,
the object will look like a sillouette - without any detail.
If you want the object to eminate a particular color -
that is sort of glow even when there is no light, use
Emissive. Emissive controls the innate intensity/color
of light from the object. It doesn't need a light source
to reflect back.
I'm only going to control Diffuse in this example because I
want the object to respond to the light that I shine on it.
rem varying intensities of green
set object diffuse obj,rgb(0,rnd(192)+63,0)
rem create an object with which to control a directional light
make object plain litobj,1,1
hide object litobj
rem make sure object shares the camera's rotation order
set object rotation zyx litobj
rem just make it dark so the lighting can be seen on the objects
color ambient light 0
rem light 0 is the default directional light for the scene
rem so we can change it's color or leave it alone.
rem I'll make sure it's at 100% intensity
color light 0,255,255,255
yang#=wrapvalue(camera angle y()+mousemovex())
yrotate camera yang#
move camera (upkey()-downkey())*5
camx#=camera position x()
camz#=camera position z()
rem position the directional light control object
position object litobj,camx#,camy#,camz#
set object to camera orientation litobj
move object litobj,10
rem position a directional light based on the vector of litobj
vx#=object position x(litobj)-camx#
vy#=object position y(litobj)-camy#
vz#=object position z(litobj)-camz#
set directional light 0,vx#,vy#,vz#
Login to post a reply