Geometry

See Javadoc

Definition

Geometry defines the leaf node of a scene graph. This is the end point of a particular path along the tree starting from the root. This leaf contains the geometric data used for actual rendering and intersection operations. Geometry contains a number of subclasses, where the most common is TriMesh. Geometry defines FloatBuffer objects that contain the information for a geometric object. This buffer includes: color, vertices, normals and texture coordinates.

Geometry defines a local model bounds as well, this is used to generate the world bounds for each level of the scene graph. This is discussed in more detail below.

Maintaining Data

Geometric objects in jME are defined by a collection of points in 3D space. These points can maintain a number of attributes. Geometry keeps track of these attributes in a number of FloatBuffers. The only required buffer to be filled is the buffer defining the vertices of the points. That is, the point's positions. All other attributes are optional.

BufferUtils can be used to ease the use of the buffers. However, a general understanding of what each buffer is and it's relative size will aid usage.

NOTE: P - number of points in the Geometry.

  1. get/setVertexBuffer - Gets/sets the vertices (position) of each point. The size of the buffer is P * 3.
  2. get/setNormalBuffer - Gets/sets the normals of the buffer. The normal defines a vector that is perpendicular to the surface of the object. The size of the buffer is P * 3.
  3. get/setColorBuffer - Gets/sets the color values for each point. The size of the buffer is P * 4.
  4. get/setTextureBuffer - Gets/sets the texture coordinate for each point. The size of the buffer is P * 2.

TextureBuffer is a bit of a special case due to the fact that is can contain any number of buffers. This is used for multitexturing and is discussed there.

Model Boundings

The model bounds defines the BoundingVolume that contains the geometric data about its origin. That is, the model bounds is not translated into world space, but kept in the Geometry's space. This bound is used to calculate the world bound of the Geometry, and subsequently the world bounds of the Node objects of the scene graph.

See BoundingVolume for more information.

Final RenderStates

Geometry maintains a list of RenderStates that are the compiled final version that will be used during rendering. This list is built upon a call to updateRenderStates.

Drawing

Geometry does not actually do any drawing itself. This is taken care of by any subclasses that use Geometry. It does, however, apply the states that are in the compiled list to prepare OpenGL for rendering the data appropriately.

Helper Methods

  • setSolidColor - will fill the color float buffer with a supplied color value.
  • setRandomColors - will fill the color float buffer with randomly selected color values.
  • copyTextureCoordinates - will copy a float buffer from one unit to another.
  • randomVertice - will return a random point in the Geometry as a Vector3f.

/var/www/wiki/data/pages/geometry.txt · Last modified: 2009/07/28 18:44 (external edit)  
Recent changes · Show pagesource · Login

Recent changes RSS feed Creative Commons License Donate Powered by PHP Valid XHTML 1.0 Valid CSS Driven by DokuWiki

subscribe to jME latest jme headlines


site design by bleedcrimson designs © 2008