//The different light sources are added to the scene here.
public void addLight(SimpleUniverse su)
{
BranchGroup bgLight = new BranchGroup();
BoundingSphere bounds = new BoundingSphere(new Point3d(0.0,0.0,0.0), Double.MAX_VALUE);
//Light no. 1: directional light.
Color3f lightColour1 = new Color3f(0.8f, 0.8f, 0.8f);
Vector3f lightDir1 = new Vector3f(0.0f, 4.0f, -1.0f);
DirectionalLight light1 = new DirectionalLight(lightColour1, lightDir1);
light1.setInfluencingBounds(bounds);
bgLight.addChild(light1);
//Light no. 2: a point light.
Color3f lightColour2 = new Color3f(0.3f, 0.3f, 0.3f);
PointLight light2 = new PointLight(lightColour2,
new Point3f(1.0f,1.0f,1.0f),
new Point3f(0.2f,0.01f,0.01f));
light2.setInfluencingBounds(bounds);
bgLight.addChild(light2);
//Light no. 3: a spotlight.
Color3f lightColour3 = new Color3f(0.3f, 0.3f, 0.3f);
SpotLight light3 = new SpotLight(lightColour3,
new Point3f(0.0f,0.0f,1.0f),
new Point3f(0.1f,0.1f,0.01f),
new Vector3f(0.0f,0.0f,-1.0f),
(float) (Math.PI/20),
0.0f);
light3.setInfluencingBounds(bounds);
bgLight.addChild(light3);
//Light no. 4: ambient light.
Color3f lightColour4 = new Color3f(0.2f, 0.2f, 0.2f);
AmbientLight light4 = new AmbientLight(lightColour4);
light4.setInfluencingBounds(bounds);
bgLight.addChild(light4);
su.addBranchGraph(bgLight);
}