FileDocCategorySizeDatePackage
Material.javaAPI DocAndroid 1.5 API3611Wed May 06 22:42:00 BST 2009android.opengl

Material

public class Material extends Object
{@hide}

Fields Summary
private Object3D
parent
private String
name
private String
map_kd
private float[]
ka
private float[]
kd
private float[]
ks
private float
ns
private int
illum
private float
d
private static float[]
black
Constructors Summary
public Material(Object3D parent)


       
        this.parent = parent;
    
Methods Summary
public java.lang.StringgetMap_Kd()

        return map_kd;
    
public java.lang.StringgetName()

        return name;
    
public voidload(java.io.DataInputStream dis)

        dis.readInt(); // name length
        this.name = dis.readUTF();

        dis.readInt(); // map_kdLength
        this.map_kd = dis.readUTF();

        if (parent.hasTexcoords() && map_kd.length() > 0) {
            parent.loadTexture(map_kd);
        }

        this.ka[0] = dis.readFloat();
        this.ka[1] = dis.readFloat();
        this.ka[2] = dis.readFloat();
        this.ka[3] = dis.readFloat();

        this.kd[0] = dis.readFloat();
        this.kd[1] = dis.readFloat();
        this.kd[2] = dis.readFloat();
        this.kd[3] = dis.readFloat();

        this.ks[0] = dis.readFloat();
        this.ks[1] = dis.readFloat();
        this.ks[2] = dis.readFloat();
        this.ks[3] = dis.readFloat();

        this.ns = dis.readFloat();
        this.illum = dis.readInt();
        this.d = dis.readFloat();
    
public voidsetMaterialParameters(javax.microedition.khronos.opengles.GL10 gl)

        gl.glMaterialfv(gl.GL_FRONT_AND_BACK, gl.GL_AMBIENT, kd, 0);
        gl.glMaterialfv(gl.GL_FRONT_AND_BACK, gl.GL_DIFFUSE, kd, 0);
        gl.glMaterialfv(gl.GL_FRONT_AND_BACK, gl.GL_SPECULAR, ks, 0);
        gl.glMaterialf(gl.GL_FRONT_AND_BACK, gl.GL_SHININESS,
                Math.min(Math.max(ns, 0), 128));

//      if (illum == 0) {
//      gl.glMaterialfv(gl.GL_FRONT_AND_BACK, gl.GL_AMBIENT, kd, 0);
//      } else {
//      gl.glMaterialfv(gl.GL_FRONT_AND_BACK, gl.GL_AMBIENT, ka, 0);
//      gl.glMaterialfv(gl.GL_FRONT_AND_BACK, gl.GL_DIFFUSE, kd, 0);
//      }

//      if (illum > 1) {
//      gl.glMaterialfv(gl.GL_FRONT_AND_BACK, gl.GL_SPECULAR, ks, 0);
//      gl.glMaterialf(gl.GL_FRONT_AND_BACK, gl.GL_SHININESS,
//      Math.min(Math.max(ns, 0), 128));
//      } else {
//      gl.glMaterialfv(gl.GL_FRONT_AND_BACK, gl.GL_SPECULAR, black, 0);
//      }
    
public java.lang.StringtoString()

        return "Material[" +
        "name=\"" + name + "\"," +
        "ka={" + ka[0] + "," + ka[1] + "," + ka[2] + "}," +
        "kd={" + kd[0] + "," + kd[1] + "," + kd[2] + "}," +
        "ks={" + ks[0] + "," + ks[1] + "," + ks[2] + "}," +
        "ns=" + ns + "," +
        "map_kd=\"" + 
        (map_kd == null ? "" : map_kd) +
        "\"," +
        "illum=" + illum + "," +
        "d=" + d +
        "]";