Skip to content
Dennis Ippel edited this page Aug 19, 2013 · 15 revisions

(Anchor Steam) Materials

(Just dumping information here at the moment, this will be more coherent)

Creating a color material without using lighting

Material material = new Material();
material.setColor(Color.RED);
// or
material.setColor(0xffff0000); 

Creating a color material with diffuse lighting

Material material = new Material();
material.setColor(Color.RED);
material.enableLighting(true);
material.setLights(lights);
material.setDiffuseMethod(new DiffuseMethod.Lambert());

Creating a color material with diffuse lighting and specular highlights

Material material = new Material();
material.setColor(Color.RED);
material.enableLighting(true);
material.setLights(lights);
material.setDiffuseMethod(new DiffuseMethod.Lambert());
material.setSpecularMethod(new SpecularMethod.Phong());

Using a diffuse texture

Material material = new Material();
// -- The first parameter is compulsory and needs to be unique and
//    has the same restrictions as any Java variable.
material.addTexture(new Texture("earth", R.drawable.earth_diffuse));

Mixing diffuse texture with color

Material material = new Material();
material.addTexture(new Texture("earth", R.drawable.earth_diffuse));
material.setColor(Color.RED);
// -- Use 50% red
material.setColorInfluence(.5f);
Texture texture = new Texture("earth", R.drawable.earth_diffuse);
// -- Use 50% of the texture
texture.setInfluence(.5f);
material.addTexture(texture);

// color influence is only used when textures are used // in this case it specifies that 20% of the color should // be used in the final color material.setColorInfluence(.2f); material.enableLighting(true); material.setLights(lights); material.setDiffuseMethod(new DiffuseMethod.Lambert()); material.setSpecularMethod(new SpecularMethod.Phong());

Texture tex1 = new Texture("earth", R.drawable.earth_diffuse); // this texture's color influence (40%) tex1.setInfluence(.4f); Texture tex2 = new Texture("camden", R.drawable.camden_town_alpha); // this texture's color influence (40%) tex2.setInfluence(.4f);

// you can add as many diffuse textures as you'd like material.addTexture(tex1); material.addTexture(tex2);

sphere.setMaterial(material);

Clone this wiki locally