hmi.graphics.opengl
Class GLBasicMesh

java.lang.Object
  extended by hmi.graphics.opengl.GLBasicMesh
All Implemented Interfaces:
GLRenderObject
Direct Known Subclasses:
GLSkinnedMesh

public class GLBasicMesh
extends Object
implements GLRenderObject

A GLBasicMesh ...


Field Summary
private  ArrayList<GLVertexAttribute> attributeList
           
(package private)  int geometryType
           
private  String id
           
private  IntBuffer indexBuffer
           
private  int indexBufferId
           
private  boolean indexBufferModified
           
private  int indexByteBufferSize
           
private  int nrOfIndices
           
protected  int nrOfVertices
           
private  int vertexBufferId
           
 
Constructor Summary
GLBasicMesh()
          Creates a new GLBasicMesh.
 
Method Summary
 int addGLVertexAttribute(VertexAttribute va)
          Adds a new vertex attribute, and returns its index number.
 void bindShaderProg(GLRenderContext gl, int prog)
          Binds the attribute indices, and defines the OGL Array Buffer for the specified OGL Shader program
 String getId()
           
 float[] getVertexData(int attrNum, float[] vertexData)
          Fills and returns the vertexData float array with the current contents of the vertex data for the specified attribute.
 void glInit(GLRenderContext gl)
          initializes the OpenGL ARRAY and ELEMENT_ARRAY buffers.
 void glRender(GLRenderContext gl)
          renders the mesh, using the vertexBuffer data.
 void setGeometryType(int type)
          sets the type of geometry, like GLC.GL_TRIANGLE_STRIP, or GLC.GL_TRIANGLES.
 void setId(String id)
           
 void setIndexData(int[] indexData)
          Allocates and sets the index buffer, defining the mesh topology, by copying the data from indexData to an internal index buffer.
private  void setNrOfVertices(int nvert)
           
 void setVertexData(int attrNum, float[] vertexData)
          Sets the vertex data for an attribute, identified by its index number The data will be copied.
 String toString()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

indexBuffer

private IntBuffer indexBuffer

nrOfIndices

private int nrOfIndices

indexByteBufferSize

private int indexByteBufferSize

indexBufferModified

private boolean indexBufferModified

nrOfVertices

protected int nrOfVertices

attributeList

private ArrayList<GLVertexAttribute> attributeList

vertexBufferId

private int vertexBufferId

indexBufferId

private int indexBufferId

geometryType

int geometryType

id

private String id
Constructor Detail

GLBasicMesh

public GLBasicMesh()
Creates a new GLBasicMesh.

Method Detail

setId

public void setId(String id)

getId

public String getId()

setGeometryType

public void setGeometryType(int type)
sets the type of geometry, like GLC.GL_TRIANGLE_STRIP, or GLC.GL_TRIANGLES. (The latter is the default)


setIndexData

public void setIndexData(int[] indexData)
Allocates and sets the index buffer, defining the mesh topology, by copying the data from indexData to an internal index buffer. When indexData is null, the call has no effect at all.


setNrOfVertices

private void setNrOfVertices(int nvert)

addGLVertexAttribute

public int addGLVertexAttribute(VertexAttribute va)
Adds a new vertex attribute, and returns its index number.


setVertexData

public void setVertexData(int attrNum,
                          float[] vertexData)
Sets the vertex data for an attribute, identified by its index number The data will be copied.


getVertexData

public float[] getVertexData(int attrNum,
                             float[] vertexData)
Fills and returns the vertexData float array with the current contents of the vertex data for the specified attribute. The passed in vertexData array can be null, in which case a new float array is allocated.


glInit

public void glInit(GLRenderContext gl)
initializes the OpenGL ARRAY and ELEMENT_ARRAY buffers. Calculates the buffer offsets for coordinates, normals. colors etc. inside vertexBuffer

Specified by:
glInit in interface GLRenderObject

bindShaderProg

public void bindShaderProg(GLRenderContext gl,
                           int prog)
Binds the attribute indices, and defines the OGL Array Buffer for the specified OGL Shader program


glRender

public void glRender(GLRenderContext gl)
renders the mesh, using the vertexBuffer data.

Specified by:
glRender in interface GLRenderObject

toString

public String toString()
Overrides:
toString in class Object