FileDocCategorySizeDatePackage
GLFace.javaAPI DocAndroid 1.5 API2241Wed May 06 22:41:08 BST 2009com.example.android.apis.graphics.kube

GLFace

public class GLFace extends Object

Fields Summary
private ArrayList
mVertexList
private GLColor
mColor
Constructors Summary
public GLFace()

		
	
public GLFace(GLVertex v1, GLVertex v2, GLVertex v3)

		addVertex(v1);
		addVertex(v2);
		addVertex(v3);
	
public GLFace(GLVertex v1, GLVertex v2, GLVertex v3, GLVertex v4)

		addVertex(v1);
		addVertex(v2);
		addVertex(v3);
		addVertex(v4);
	
Methods Summary
public voidaddVertex(GLVertex v)

		mVertexList.add(v);
	
public intgetIndexCount()

		return (mVertexList.size() - 2) * 3;
	
public voidputIndices(java.nio.ShortBuffer buffer)

		int last = mVertexList.size() - 1;

		GLVertex v0 = mVertexList.get(0);
		GLVertex vn = mVertexList.get(last);
		
		// push triangles into the buffer
		for (int i = 1; i < last; i++) {
			GLVertex v1 = mVertexList.get(i);
			buffer.put(v0.index);
			buffer.put(v1.index);
			buffer.put(vn.index);
			v0 = v1;
		}
	
public voidsetColor(GLColor c)

		
		int last = mVertexList.size() - 1;
		if (last < 2) {
			Log.e("GLFace", "not enough vertices in setColor()");
		} else {
			GLVertex vertex = mVertexList.get(last);
			
			// only need to do this if the color has never been set
			if (mColor == null) {
				while (vertex.color != null) {
					mVertexList.add(0, vertex);
					mVertexList.remove(last + 1);
					vertex = mVertexList.get(last);
				}
			}
			
			vertex.color = c;
		}

		mColor = c;