List of usage examples for javax.media.j3d DirectionalLight DirectionalLight
public DirectionalLight(boolean lightOn, Color3f color, Vector3f direction)
From source file:Demo3D.java
/** * Create the subgraph #1//from w w w .ja v a 2s. com * * @return javax.media.j3d.BranchGroup brGr1 - the root of the subgraph #1 */ public BranchGroup mySubGraph1() { // Create the BranchGroup brGr1 of the subgraph #1. brGr1 = new BranchGroup(); // Create and attach the coordinate system to the brGr1. coordSyst = new CoordSyst(1.0f, 1.0f, 0.0f, // Color of the x-axis 0.0f, 0.0f, 1.0f, // Color of the y-axis 1.0f, 0.0f, 0.0f, // Color of the z-axis 0.75f); // Lenght of the 3 axes brGr1.addChild(coordSyst); // Background setting for the scene. newTextureLoader = new NewTextureLoader("Images/Ciel_Out.jpg"); newTextureLoader.setImageObserver(newTextureLoader.getImageObserver()); backGr = new Background(newTextureLoader.getImage()); backGr.setImageScaleMode(Background.SCALE_FIT_ALL); boundsBackGr = new BoundingSphere(new Point3d(0.0, 0.0, 0.0), 1000.0); backGr.setApplicationBounds(boundsBackGr); brGr1.addChild(backGr); // A BoundingSphere instance as general bounding region. boundsGen = new BoundingSphere(new Point3d(0.0, 0.0, 0.0), 100.0); // Lighting of the scene. // Create and attach an ambient light. ambientLight = new AmbientLight(true, new Color3f(0.2f, 0.2f, 0.2f)); ambientLight.setInfluencingBounds(boundsGen); brGr1.addChild(ambientLight); // Create and attach a point light. pointLight = new PointLight(true, new Color3f(1.0f, 1.0f, 0.3f), new Point3f(-100.0f, 0.0f, 100.0f), new Point3f(0.0f, 0.05f, 0.1f)); pointLight.setInfluencingBounds(boundsGen); brGr1.addChild(pointLight); // Create and attach a directional light. directionalLight = new DirectionalLight(true, new Color3f(0.8f, 1.0f, 1.0f), new Vector3f(-0.5f, -0.5f, -0.5f)); directionalLight.setInfluencingBounds(boundsGen); brGr1.addChild(directionalLight); // Create the borders of the virtual universe for the inside view of the // scene. bordersIn = new BordersIn(dimUniverse); brGr1.addChild(bordersIn.myInternalUniverse()); // Create the borders of the virtual universe for the outside view of // the scene. bordersOut = new BordersOut(dimUniverse); brGr1.addChild(bordersOut.myExternalUniverse()); // Compile the subgraph to optimize the performances. brGr1.compile(); // Return the final version of the BranchGroup node brGr1 return brGr1; }