예제 #1
0
 private Material getMaterial(ColorRGBA color) {
   Material mat = new Material(main.getAssetManager(), "Common/MatDefs/Light/Lighting.j3md");
   mat.setColor("Diffuse", color);
   ColorRGBA clone = color.clone();
   clone.multLocal(0.8f);
   clone.a = 1f;
   mat.setColor("Ambient", clone);
   mat.setBoolean("UseMaterialColors", true);
   return mat;
 }
예제 #2
0
  protected void createMaterial() {
    Material material;

    if (alpha < 1f && transparent) {
      diffuse.a = alpha;
    }

    if (shadeless) {
      material = new Material(assetManager, "Common/MatDefs/Misc/Unshaded.j3md");
      material.setColor("Color", diffuse.clone());
      material.setTexture("ColorMap", diffuseMap);
      // TODO: Add handling for alpha map?
    } else {
      material = new Material(assetManager, "Common/MatDefs/Light/Lighting.j3md");
      material.setBoolean("UseMaterialColors", true);
      material.setColor("Ambient", ambient.clone());
      material.setColor("Diffuse", diffuse.clone());
      material.setColor("Specular", specular.clone());
      material.setFloat("Shininess", shininess); // prevents "premature culling" bug

      if (diffuseMap != null) material.setTexture("DiffuseMap", diffuseMap);
      if (specularMap != null) material.setTexture("SpecularMap", specularMap);
      if (normalMap != null) material.setTexture("NormalMap", normalMap);
      if (alphaMap != null) material.setTexture("AlphaMap", alphaMap);
    }

    if (transparent) {
      material.setTransparent(true);
      material.getAdditionalRenderState().setBlendMode(BlendMode.Alpha);
      material.getAdditionalRenderState().setAlphaTest(true);
      material.getAdditionalRenderState().setAlphaFallOff(0.01f);
    }

    material.setName(matName);
    matList.put(matName, material);
  }