org.deegree.rendering.r3d.opengl.rendering.model.geometry
Class RenderableGeometry

java.lang.Object
  extended by org.deegree.rendering.r3d.opengl.rendering.model.geometry.RenderableGeometry
All Implemented Interfaces:
Serializable, MemoryAware, QualityModelPart, JOGLRenderable, RenderableQualityModelPart
Direct Known Subclasses:
BOXGeometry, RenderableTexturedGeometry

public class RenderableGeometry
extends Object
implements RenderableQualityModelPart

The RenderableGeometry class uses VertexArrays to render the coordinates of it's geometry in an openGL context. For this to work the coordinates are expected to be organized as defined by the given openGLType.

Normally you might want to use a set of geometries for a single object (for example to create walls of a house). In this case the easiest way to create a RenderableQualityModel (containing RenderableGeometry(ies)) is the usage of the Tesselator. The Tesselator class can be used to create a sole RenderableGeometry as well.

Version:
$Revision: 29127 $, $Date: 2011-01-10 16:13:35 +0100 (Mon, 10 Jan 2011) $
Author:
Rutger Bezema, last edited by: $Author: aschmitz $
See Also:
Serialized Form

Constructor Summary
RenderableGeometry(float[] vertices, int openGLType, float[] vertexNormals, boolean useDirectBuffers)
           
RenderableGeometry(float[] vertices, int openGLType, float[] vertexNormals, SimpleGeometryStyle style, boolean useDirectBuffers)
           
RenderableGeometry(FloatBuffer vertices, int openGLType, FloatBuffer vertexNormals, SimpleGeometryStyle style)
           
RenderableGeometry(int coordPosition, int vertexCount, int openGLType, int normalPosition, SimpleGeometryStyle style)
           
 
Method Summary
 void disableArrays(RenderContext glRenderContext)
           
protected  void enableArrays(RenderContext glRenderContext, DirectGeometryBuffer geomBuffer)
          Load the float buffers and enable the client state.
 FloatBuffer getCoordBuffer()
           
 int getCoordPosition()
           
 FloatBuffer getNormalBuffer()
           
 int getNormalPosition()
           
 int getOpenGLType()
           
 int getOrdinateCount()
           
 FloatBuffer getReadOnlyCoordBuffer()
           
 SimpleGeometryStyle getStyle()
           
 int getTextureOrdinateCount()
           
 int getVertexCount()
           
 FloatBuffer getVertexNormals()
           
 void render(RenderContext glRenderContext)
          Called to render this object to an OpenGL context.
 void renderPrepared(RenderContext glRenderContext, DirectGeometryBuffer geomBuffer)
          This method is a more specific render method than the JOGLRenderable.render(RenderContext), it defines a contract that the geometryBuffer holds the geometry for the implementation and the implementation holds indizes which are valid for the given buffer.
 void setCoordPosition(int coordPosition)
           
 void setNormPosition(int normalPosition)
           
 void setVertexNormals(float[] vertexNormals)
           
 void setVertices(float[] vertices, int openGLType)
           
 long sizeOf()
           
 String toString()
           
 boolean useDirectBuffers()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

RenderableGeometry

public RenderableGeometry(float[] vertices,
                          int openGLType,
                          float[] vertexNormals,
                          SimpleGeometryStyle style,
                          boolean useDirectBuffers)
Parameters:
vertices -
openGLType -
vertexNormals -
style -
useDirectBuffers - to use direct buffers instead of heap buffers.

RenderableGeometry

public RenderableGeometry(float[] vertices,
                          int openGLType,
                          float[] vertexNormals,
                          boolean useDirectBuffers)
Parameters:
vertices -
openGLType -
vertexNormals -
useDirectBuffers - to use direct buffers instead of heap buffers.

RenderableGeometry

public RenderableGeometry(FloatBuffer vertices,
                          int openGLType,
                          FloatBuffer vertexNormals,
                          SimpleGeometryStyle style)
Parameters:
vertices -
openGLType -
vertexNormals -
style -

RenderableGeometry

public RenderableGeometry(int coordPosition,
                          int vertexCount,
                          int openGLType,
                          int normalPosition,
                          SimpleGeometryStyle style)
Parameters:
coordPosition -
vertexCount -
openGLType -
normalPosition -
style -
Method Detail

render

public void render(RenderContext glRenderContext)
Description copied from interface: JOGLRenderable
Called to render this object to an OpenGL context.

The following pre-conditions hold:

Specified by:
render in interface JOGLRenderable
Parameters:
glRenderContext - TODO

renderPrepared

public void renderPrepared(RenderContext glRenderContext,
                           DirectGeometryBuffer geomBuffer)
Description copied from interface: RenderableQualityModelPart
This method is a more specific render method than the JOGLRenderable.render(RenderContext), it defines a contract that the geometryBuffer holds the geometry for the implementation and the implementation holds indizes which are valid for the given buffer.

Specified by:
renderPrepared in interface RenderableQualityModelPart
Parameters:
glRenderContext - holding all relevant data for the current gl context.
geomBuffer - holding the vertices, normals and texture coordinates for an instance of an implementation.

enableArrays

protected void enableArrays(RenderContext glRenderContext,
                            DirectGeometryBuffer geomBuffer)
Load the float buffers and enable the client state.

Parameters:
glRenderContext -
geomBuffer - for which the coord/normal Positions are valid for.

disableArrays

public void disableArrays(RenderContext glRenderContext)
Parameters:
glRenderContext -

setVertices

public final void setVertices(float[] vertices,
                              int openGLType)
Parameters:
vertices - the vertices to set
openGLType -

getVertexNormals

public final FloatBuffer getVertexNormals()
Returns:
the vertexNormals

setVertexNormals

public final void setVertexNormals(float[] vertexNormals)
Parameters:
vertexNormals - the vertexNormals to set

getOpenGLType

public final int getOpenGLType()
Returns:
the openGLType

toString

public String toString()
Overrides:
toString in class Object

sizeOf

public long sizeOf()
Specified by:
sizeOf in interface MemoryAware
Returns:
the bytes this geometry occupies

getStyle

public final SimpleGeometryStyle getStyle()
Returns:
the style

getVertexCount

public final int getVertexCount()
Returns:
number of vertices of this renderable geometry.

getCoordBuffer

public final FloatBuffer getCoordBuffer()
Returns:
the coordBuffer

getReadOnlyCoordBuffer

public FloatBuffer getReadOnlyCoordBuffer()
Returns:
the coordinate buffers as readonly

useDirectBuffers

public boolean useDirectBuffers()
Returns:
true if direct buffers should be used, false otherwise.

getNormalBuffer

public FloatBuffer getNormalBuffer()
Returns:
a floatbuffer containing the normals or null if normals are not loaded.

setCoordPosition

public void setCoordPosition(int coordPosition)
Parameters:
coordPosition -

setNormPosition

public void setNormPosition(int normalPosition)
Parameters:
normalPosition -

getOrdinateCount

public int getOrdinateCount()
Specified by:
getOrdinateCount in interface RenderableQualityModelPart
Returns:
the number of ordinates in the implementation.

getTextureOrdinateCount

public int getTextureOrdinateCount()
Specified by:
getTextureOrdinateCount in interface RenderableQualityModelPart
Returns:
the number of texture ordinates in this quality model part

getCoordPosition

public final int getCoordPosition()
Returns:
the coordPosition

getNormalPosition

public final int getNormalPosition()
Returns:
the normalPosition


Copyright © 2011. All Rights Reserved.