Director 3D > Lighting

Controlling lights with Lingo

Here is a sample file illustrating how lights can be added and controlled using Lingo. Note that, for the purpose of highlighting the movement of the lights, they are represented by 3D objects (usually lights are INVISIBLE in the scene).

Further tutorials on the subject of cameras in Director 3D can be found at Macromedia’s tutorial pages and here.

Here we'll show you how to control and add lights. You can download the source file from here. Notice that there are two light sources, both rotating around the model, lighting it as they go.

If you look at the Behaviour script in the cast called "Light Rotate" you'll see the following code:

And here's what it does...

This property is used to define the default light in the scene (light[1]):

pLight = pScene.light[1]

We also create a new (#point) light and define this as pPointLight:

pPointLight = pScene.newLight("point", #point)
pPointLight.worldPosition = pLight.worldPosition
- this moves the light to the same position as the default world light.
pPointLight.pointAt(pModel.worldPosition)
- this points the light at the model (defined as pModel in the scene)

To rotate the lights around the object the following code is used:

on enterFrame

pLight.rotate(0,0,1, pModel) - ths rotates the fist light on the z axis around the model

pPointLight.rotate(0,3,0, pModel) - this rotates the second, point light on the y axis around the model

end

 

< Previous | Next >

July 2003