User:Luysys

Desarrollo de Software
Abi Sistemas

Lighting the Scene One ambient and two directional lights are added to the scene by lightScene. An ambient light reaches every corner of the world, illuminating everything equally: private void lightScene { Color3f white = new Color3f(1.0f, 1.0f, 1.0f); // Set up the ambient light AmbientLight ambientLightNode = new AmbientLight(white); ambientLightNode.setInfluencingBounds(bounds); sceneBG.addChild(ambientLightNode); // Set up the directional lights Vector3f light1Direction = new Vector3f(-1.0f, 1.0f, -1.0f); // light coming from left, up, and back quadrant Vector3f light2Direction = new Vector3f(1.0f, 1.0f, 1.0f); // light coming from right, up, and front quadrant DirectionalLight light1 = new DirectionalLight(white, light1Direction); light1.setInfluencingBounds(bounds); sceneBG.addChild(light1); DirectionalLight light2 = new DirectionalLight(white, light2Direction); light2.setInfluencingBounds(bounds); sceneBG.addChild(light2); } // end of lightScene The color of the light is set and the ambient source is created along with bounds and added to the scene. The Color3f constructor takes red/green/blue (RGB) values between 0.0f and 1.0f (1.0f being “full-on”). A directional light mimics a light from a distant source, hitting the surfaces of objects from a specified direction. The main difference from an ambient light is the requirement for a direction, such as in the following: Vector3f light1Direction = new Vector3f(-1.0f, 1.0f, -1.0f); // light coming from left, up, and back quadrant The direction is the vector starting at the specified coordinate, pointing toward (0, 0, 0); the light can be imagined to be multiple parallel lines with that direction, originating at infinity. Point lights and spotlights are the other forms of Java 3D lighting. Point lights position the light in space, emitting in all directions. Spotlights are focused point lights aimed in a particular direction.