Package com.jme.light

Examples of com.jme.light.DirectionalLight


    }
   

    public LightNode toLightNode() {
        LightNode node = new LightNode();
        DirectionalLight light = new DirectionalLight();
        light.setAmbient(ambient);
        light.setDiffuse(diffuse);
        light.setSpecular(specular);
        light.setShadowCaster(castShadows);
        light.setDirection(direction);
       
        node.setLight(light);
        node.setLocalTranslation(translation);
       
        return node;
View Full Code Here


    public void showLight(final LightNode lightNode, final String name) {
  if (rootNode != null) {
      dispose();
  }
       
        DirectionalLight directionalLight = (DirectionalLight)lightNode.getLight();

        rootNode = new Node("Light Viewer Node");
        RenderManager rm = ClientContextJME.getWorldManager().getRenderManager();
        RenderComponent rc = rm.createRenderComponent(rootNode);
        this.addComponent(RenderComponent.class, rc);
       
        // Set the Z-buffer state on the root node
        ZBufferState zbuf = (ZBufferState)rm.createRendererState(StateType.ZBuffer);
        zbuf.setEnabled(true);
        zbuf.setFunction(ZBufferState.TestFunction.LessThanOrEqualTo);
       
        rootNode.setRenderState(zbuf);

        // Set the wireframe state on the root node
//        WireframeState wf = (WireframeState)rm.createRendererState(StateType.Wireframe);
//        wf.setEnabled(true);
//        rootNode.setRenderState(wf);
        MaterialState ms = (MaterialState)rm.createRendererState(StateType.Material);
        ms.setAmbient(new ColorRGBA(0.25f, 0, 0.5f, 0.40f));
        ms.setDiffuse(new ColorRGBA(0.25f, 0, 0.5f, 0.40f));
        ms.setMaterialFace(MaterialState.MaterialFace.FrontAndBack);;
        //ms.setSpecular(new ColorRGBA(1f, 1, 1f, 1f));
       
        ms.setEnabled(true);
        rootNode.setRenderState(ms);
       
        BlendState bs = (BlendState)rm.createRendererState(StateType.Blend);
        bs.setEnabled(true);
        bs.setBlendEnabled(true);
        bs.setSourceFunction(BlendState.SourceFunction.SourceAlpha);
        bs.setDestinationFunction(BlendState.DestinationFunction.OneMinusSourceAlpha);
        bs.setTestEnabled(true);
        bs.setTestFunction(BlendState.TestFunction.GreaterThan);
        rootNode.setRenderState(bs);

        CellTransform transform = cell.getWorldTransform();
        // Draw an arrow that mimics the light position --direction still under
        //construction.
        TextLabel2D label = new TextLabel2D(name,
                                            Color.black, Color.white, 1.0f, true, Font.getFont("SANS_SERIF"));
       
        Vector3f direction = directionalLight.getDirection();
        Vector3f position = lightNode.getLocalTranslation();
        Vector3f labelPosition = new Vector3f(position.x, position.y + 3, position.z);
       
        Arrow arrow = new Arrow("Arrow", 3, 0.5f);
        Node rotatedOnX = new Node("Rotated For Arrow");
View Full Code Here

            }
          
        }
       
        private LightNode buildLightFromState(SharedDirectionLight state) {
            DirectionalLight light = new DirectionalLight();
            LightNode lightNode = new LightNode();
           
            light.setAmbient(state.getAmbient());
            light.setDiffuse(state.getDiffuse());
            light.setSpecular(state.getSpecular());
            light.setDirection(state.getDirection());
            light.setShadowCaster(state.isCastShadows());
            lightNode.setLight(light);
            lightNode.setLocalTranslation(state.getTranslation());
           
            return lightNode;
        }
View Full Code Here

       
        this.lightNode = lightNode;
        this.cell = cell;
        this.name = name;
        this.editor = editor;
        DirectionalLight light = (DirectionalLight)lightNode.getLight();
        initializeButtonIcons(light.getAmbient(),
                              light.getDiffuse(),
                              light.getSpecular());
       
        initializeSpinners(lightNode.getLocalTranslation().x,
                           lightNode.getLocalTranslation().y,
                           lightNode.getLocalTranslation().z,
                           light.getDirection().x,
                           light.getDirection().y,
                           light.getDirection().z);
        castShadowsBox.setSelected(lightNode.getLight().isShadowCaster());
       
        originalAmbient = light.getAmbient();
        originalDiffuse = light.getDiffuse();
        originalSpecular = light.getSpecular();
        originalCast = light.isShadowCaster();
        originalPosition = lightNode.getLocalTranslation();
        originalDirection = light.getDirection();
       
        ambient = originalAmbient;
        diffuse = originalDiffuse;
        specular = originalSpecular;
        castShadows = originalCast;
View Full Code Here

                   
    }
   
    public LightNode reconstructLight() {
        LightNode node = new LightNode();
        DirectionalLight light = new DirectionalLight();
       
        light.setAmbient(ambient);
        light.setDiffuse(diffuse);
        light.setSpecular(specular);
        light.setShadowCaster(castShadows);
        light.setDirection(direction);
       
        node.setLight(light);
        node.setLocalTranslation(position);
       
        return node;
View Full Code Here

        editor.setPanelDirty(DefaultEnvironmentProperties.class, isDirty());
       
        SceneWorker.addWorker(new WorkCommit() {

            public void commit() {
                DirectionalLight dl = (DirectionalLight)lightNode.getLight();
               
               
                dl.setAmbient(ambient);
                dl.setDiffuse(diffuse);
                dl.setSpecular(specular);
                dl.setShadowCaster(castShadows);
                dl.setDirection(direction);
                lightNode.setLocalTranslation(position);
                showLight();
            }
        });
    }
View Full Code Here

    }
   
    public void updateLight(final LightNode lightToBeUpdated, final LightNode updatedLightInfo) {
//        removeLightFromRenderer(lightToBeReplaced);
//        addLightToRenderer(lightToBeInserted);
        final DirectionalLight originalLight = (DirectionalLight)lightToBeUpdated.getLight();
        final DirectionalLight freshLight = (DirectionalLight)updatedLightInfo.getLight();
       
        SceneWorker.addWorker(new WorkCommit() {
            public void commit() {
                originalLight.setAmbient(freshLight.getAmbient());
                originalLight.setDiffuse(freshLight.getDiffuse());
                originalLight.setSpecular(freshLight.getSpecular());
                originalLight.setShadowCaster(freshLight.isShadowCaster());
                originalLight.setDirection(freshLight.getDirection());
                lightToBeUpdated.setLocalTranslation(updatedLightInfo.getLocalTranslation());
            }
        });
    }
View Full Code Here

   * Assemble the lighting.
   *
   */
  protected void buildLighting() {
    // Set up a basic, default light.
    DirectionalLight light = new DirectionalLight();
    light.setDiffuse(new ColorRGBA(1.0f, 1.0f, 1.0f, 1.0f));
    light.setAmbient(new ColorRGBA(0.5f, 0.5f, 0.5f, 1.0f));
    light.setDirection(new Vector3f(1, -1, 0).normalize());
    light.setEnabled(true);

    // Attach the light to a lightState and the lightState to root.
    LightState lightState = display.getRenderer().createLightState();
    lightState.setEnabled(true);
    lightState.attach(light);
View Full Code Here

    public CellStatus getStatus() {
        return status;
    }

    private LightNode buildLightFromState(SharedDirectionLight state) {
            DirectionalLight light = new DirectionalLight();
            LightNode lightNode = new LightNode();
           
            light.setAmbient(state.getAmbient());
            light.setDiffuse(state.getDiffuse());
            light.setSpecular(state.getSpecular());
            light.setDirection(state.getDirection());
            light.setShadowCaster(state.isCastShadows());
            lightNode.setLight(light);
            lightNode.setLocalTranslation(state.getTranslation());
           
            return lightNode;
        }
View Full Code Here

    }

    private LightNode createLight(float x, float y, float z) {
        LightNode lightNode = new LightNode();
        DirectionalLight light = new DirectionalLight();
        light.setDiffuse(new ColorRGBA(0.5f, 0.5f, 0.5f, 1.0f));
        light.setAmbient(new ColorRGBA(0.1f, 0.1f, 0.1f, 1.0f));
        light.setSpecular(new ColorRGBA(0.4f, 0.4f, 0.4f, 1.0f));
        light.setEnabled(true);
        lightNode.setLight(light);
        lightNode.setLocalTranslation(x, y, z);
        light.setDirection(new Vector3f(-x, -y, -z));
        return (lightNode);
    }
View Full Code Here

TOP

Related Classes of com.jme.light.DirectionalLight

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.