Package com.jme.scene.state

Examples of com.jme.scene.state.MaterialState


        // create the sphere object
        sphere = new Sphere("sphere", Vector3f.ZERO, 32, 32, 5f);
        // create the materials for the sphere
        // step 1
        MaterialState materialState = display.getRenderer().createMaterialState();
        materialState.setAmbient(NO_COLOR);
        materialState.setDiffuse(DIFFUSE_COLOR);
        materialState.setSpecular(NO_COLOR);
        materialState.setShininess(NO_SHININESS);
        materialState.setEmissive(NO_COLOR);
        materialState.setEnabled(true);
        // assign the material to the sphere
        sphere.setRenderState(materialState);
        // and update the geometry
        sphere.updateRenderState();
        information.add("diffuse reflection only; no ambient no specular");
        materials.add(materialState);
        // step 2
        materialState = display.getRenderer().createMaterialState();
        materialState.setAmbient(NO_COLOR);
        materialState.setDiffuse(DIFFUSE_COLOR);
        materialState.setSpecular(SPECULAR_COLOR);
        materialState.setShininess(LOW_SHININESS);
        materialState.setEmissive(NO_COLOR);
        materialState.setEnabled(true);
        information.add("diffuse and specular reflection; low shininess; no ambient");
        materials.add(materialState);
        // step 3
        materialState = display.getRenderer().createMaterialState();
        materialState.setAmbient(NO_COLOR);
        materialState.setDiffuse(DIFFUSE_COLOR);
        materialState.setSpecular(SPECULAR_COLOR);
        materialState.setShininess(HIGH_SHININESS);
        materialState.setEmissive(NO_COLOR);
        materialState.setEnabled(true);
        information.add("diffuse and specular reflection; high shininess; no ambient");
        materials.add(materialState);
        // step 4
        materialState = display.getRenderer().createMaterialState();
        materialState.setAmbient(NO_COLOR);
        materialState.setDiffuse(DIFFUSE_COLOR);
        materialState.setSpecular(NO_COLOR);
        materialState.setShininess(NO_SHININESS);
        materialState.setEmissive(EMISSIVE_COLOR);
        materialState.setEnabled(true);
        information.add("diffuse reflection; emission; no ambient or specular reflection");
        materials.add(materialState);
        // step 5
        materialState = display.getRenderer().createMaterialState();
        materialState.setAmbient(AMBIENT_GRAY_COLOR);
        materialState.setDiffuse(DIFFUSE_COLOR);
        materialState.setSpecular(NO_COLOR);
        materialState.setShininess(NO_SHININESS);
        materialState.setEmissive(NO_COLOR);
        materialState.setEnabled(true);
        information.add("ambient (gray) and diffuse reflection; no specular");
        materials.add(materialState);
        // step 6
        materialState = display.getRenderer().createMaterialState();
        materialState.setAmbient(AMBIENT_GRAY_COLOR);
        materialState.setDiffuse(DIFFUSE_COLOR);
        materialState.setSpecular(SPECULAR_COLOR);
        materialState.setShininess(LOW_SHININESS);
        materialState.setEmissive(NO_COLOR);
        materialState.setEnabled(true);
        information.add("ambient (gray), diffuse and specular reflection; low shininess");
        materials.add(materialState);
        // step 7
        materialState = display.getRenderer().createMaterialState();
        materialState.setAmbient(AMBIENT_GRAY_COLOR);
        materialState.setDiffuse(DIFFUSE_COLOR);
        materialState.setSpecular(SPECULAR_COLOR);
        materialState.setShininess(HIGH_SHININESS);
        materialState.setEmissive(NO_COLOR);
        materialState.setEnabled(true);
        information.add("ambient (gray), diffuse and specular reflection; high shininess");
        materials.add(materialState);
        // step 8
        materialState = display.getRenderer().createMaterialState();
        materialState.setAmbient(AMBIENT_GRAY_COLOR);
        materialState.setDiffuse(DIFFUSE_COLOR);
        materialState.setSpecular(NO_COLOR);
        materialState.setShininess(NO_SHININESS);
        materialState.setEmissive(EMISSIVE_COLOR);
        materialState.setEnabled(true);
        information.add("ambient (gray) and diffuse reflection; emission; no specular");
        materials.add(materialState);
        // step 9
        materialState = display.getRenderer().createMaterialState();
        materialState.setAmbient(AMBIENT_COLORED_COLOR);
        materialState.setDiffuse(DIFFUSE_COLOR);
        materialState.setSpecular(NO_COLOR);
        materialState.setShininess(NO_SHININESS);
        materialState.setEmissive(NO_COLOR);
        materialState.setEnabled(true);
        information.add("colored ambient and diffuse reflection; no specular");
        materials.add(materialState);
        // step 10
        materialState = display.getRenderer().createMaterialState();
        materialState.setAmbient(AMBIENT_COLORED_COLOR);
        materialState.setDiffuse(DIFFUSE_COLOR);
        materialState.setSpecular(SPECULAR_COLOR);
        materialState.setShininess(LOW_SHININESS);
        materialState.setEmissive(NO_COLOR);
        materialState.setEnabled(true);
        information.add("colored ambient, diffuse and specular reflection; low shininess");
        materials.add(materialState);
        // step 11
        materialState = display.getRenderer().createMaterialState();
        materialState.setAmbient(AMBIENT_COLORED_COLOR);
        materialState.setDiffuse(DIFFUSE_COLOR);
        materialState.setSpecular(SPECULAR_COLOR);
        materialState.setShininess(HIGH_SHININESS);
        materialState.setEmissive(NO_COLOR);
        materialState.setEnabled(true);
        information.add("colored ambient, diffuse and specular reflection; high shininess");
        materials.add(materialState);
        // step 12
        materialState = display.getRenderer().createMaterialState();
        materialState.setAmbient(AMBIENT_COLORED_COLOR);
        materialState.setDiffuse(DIFFUSE_COLOR);
        materialState.setSpecular(NO_COLOR);
        materialState.setShininess(NO_SHININESS);
        materialState.setEmissive(EMISSIVE_COLOR);
        materialState.setEnabled(true);
        information.add("colored ambient and diffuse reflection; emission; no specular");
        materials.add(materialState);
        // attach the sphere to the root node of our scenegraph
View Full Code Here



        axisRoot=new Node("axnode");
        axisRoot.setLocalTranslation(0, 0, 0);

        MaterialState materialp = display.getRenderer().createMaterialState();
        materialp.setShininess( 128 );
        ColorRGBA color = new ColorRGBA( 0.5f, 0.5f, 0.5f, 0.1f );
        materialp.setDiffuse( color );
        materialp.setAmbient( color.mult( new ColorRGBA( 0.5f, 0.5f, 0.5f, 0.1f ) ) );
        planeXY=new Box("planeXY",new Vector3f(0.05f,0,0.05f),0.1f,0.0001f,0.1f);
        planeXY.setRenderState(materialp);

        MaterialState materialx = display.getRenderer().createMaterialState();
        materialx.setShininess( 128 );
        color = new ColorRGBA( 1f, 0f, 0f, 0.1f );
        materialx.setDiffuse( color );
        materialx.setAmbient( color.mult( new ColorRGBA( 1f, 0.1f, 0.1f, 1 ) ) );



        axisXArrow=new Arrow("ax",0.1f,0.01f);
        axisXArrow.setLocalTranslation(new Vector3f(0.05f,0,0));
        axisXArrow.rotateUpTo(new Vector3f(1,0,0));
        axisXArrow.setRenderState(materialx);

        MaterialState materialy = display.getRenderer().createMaterialState();
        materialy.setShininess( 128 );
        color = new ColorRGBA( 0f, 1f, 0f, 0.5f );
        materialy.setDiffuse( color );
        materialy.setAmbient( color.mult( new ColorRGBA( 0.1f, 1f, 0.1f, 0.5f ) ) );

        axisYArrow=new Arrow("ay",0.1f,0.01f);
        axisYArrow.setLocalTranslation(new Vector3f(0,0.05f,0));
        axisYArrow.rotateUpTo(new Vector3f(0,1,0));
        axisYArrow.setRenderState(materialy);

        MaterialState materialz = display.getRenderer().createMaterialState();
        materialz.setShininess( 128 );
        color = new ColorRGBA( 0f, 0f, 1f, 0.5f );
        materialz.setDiffuse( color );
        materialz.setAmbient( color.mult( new ColorRGBA( 0.1f, 0.1f, 1f, 0.5f ) ) );

        axisZArrow=new Arrow("az",0.1f,0.01f);
        axisZArrow.setLocalTranslation(new Vector3f(0,0,0.05f));
        axisZArrow.rotateUpTo(new Vector3f(0,0,1));
        axisZArrow.setRenderState(materialz);
View Full Code Here

        earthSphere1.setLocalTranslation(gEarth1.getPosition());

        //System.out.println(cam.getDirection().toString());


        MaterialState ms = display.getRenderer().createMaterialState();
        ms.setColorMaterial(ColorMaterial.AmbientAndDiffuse);
        rootNode.setRenderState(ms);



View Full Code Here

            int index = r.nextInt(5);
            SharedMesh sharedMesh = new SharedMesh(triMesh[index].getName() + "_" + i, triMesh[index]);
            sharedMesh.setLocalTranslation(r.nextInt(boxSize) - halfBoxSize + center.x, r.nextInt(boxSize) - halfBoxSize + center.y, r.nextInt(boxSize) - halfBoxSize + center.z);
            sharedMesh.setLocalRotation(sharedMesh.getLocalRotation().fromAngles(r.nextInt(100), r.nextInt(100), r.nextInt(100)));
            sharedMesh.setLocalScale(r.nextInt(50) * 0.1f);
            MaterialState ms = renderer.createMaterialState();
            linesPoint.add(sharedMesh.getLocalTranslation());

            if (useTransparency) {
                ms.setDiffuse(new ColorRGBA(r.nextInt(100) * 0.01f, r.nextInt(100) * 0.01f, r.nextInt(100) * 0.01f, (r.nextInt(40) + 60) * 0.01f));
            } else {
                ms.setDiffuse(new ColorRGBA(r.nextInt(100) * 0.01f, r.nextInt(100) * 0.01f, r.nextInt(100) * 0.01f, 1));
            }
            sharedMesh.setRenderState(ms);
            sharedMesh.updateModelBound();
            //sharedMesh.lock();
            subNode[index].attachChild(sharedMesh);
View Full Code Here

    protected void simpleUpdate() {

        super.simpleUpdate();
        //gEarth.WritePosition();

        MaterialState ms = display.getRenderer().createMaterialState();
        ms.setColorMaterial(ColorMaterial.AmbientAndDiffuse);
        rootNode.setRenderState(ms);



View Full Code Here

              display.setVSyncEnabled(true);                            

              buildTerrain();
                          
                
              MaterialState ms = display.getRenderer().createMaterialState();
              ms.setEmissive(new ColorRGBA(1.0f,1.0f,1.0f,0.5f));
              tc.setRenderState(ms);

              tc.setLocalTranslation(0,0,-10000);
              rootNode.attachChild(tc);             
  }              
View Full Code Here

     * Print render states that are commonly of interest.
     */
    public static void printCommonRenderStates(Spatial spatial) {

        System.err.println("Material State =");
        MaterialState ms = (MaterialState) spatial.getRenderState(RenderState.RS_MATERIAL);
        if (ms == null) {
            System.err.println("null");
        } else {
            GraphicsUtils.printRenderState(ms);
        }
View Full Code Here

    /**
     * Specify a new ambient-and-diffuse color of this quad.
     */
    public void setColor (ColorRGBA color) {
  MaterialState ms = (MaterialState) getRenderState(RenderState.RS_MATERIAL);
  if (ms == null) {
      ms = DisplaySystem.getDisplaySystem().getRenderer().createMaterialState();
      setRenderState(ms);
  }
  ms.setAmbient(new ColorRGBA(color));
  ms.setDiffuse(new ColorRGBA(color));
    }
View Full Code Here

    /**
     * Returns the ambient-and-diffuse color of this quad.
     */
    public ColorRGBA getColor () {
  MaterialState ms = (MaterialState) getRenderState(RenderState.RS_MATERIAL);
  if (ms == null) {
      return new ColorRGBA(1f, 1f, 1f, 1f);
  } else {
      return ms.getDiffuse();
  }
    }
View Full Code Here

    /**
     * For debug: Print the contents of this object's render state.
     */
    public void printRenderState () {
  MaterialState ms = (MaterialState) getRenderState(RenderState.RS_MATERIAL);
  GraphicsUtils.printRenderState(ms);
  TextureState ts = (TextureState) getRenderState(RenderState.RS_TEXTURE);
  GraphicsUtils.printRenderState(ts);
    }   
View Full Code Here

TOP

Related Classes of com.jme.scene.state.MaterialState

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.