de.rico.engine.geometry
Class MeshVA

java.lang.Object
  extended by de.rico.engine.geometry.AbstractMesh
      extended by de.rico.engine.geometry.MeshVA
Direct Known Subclasses:
ModelMD2, ModelMS3DAscii

public class MeshVA
extends AbstractMesh

This class represents a mesh. The mesh uses the vertex array technology.

Author:
Frank Bruns

Constructor Summary
MeshVA(boolean smooth)
          Creates a new mesh object, optionally smooth shaded.
MeshVA(boolean smooth, BoundingVolume type)
          Creates a new mesh object, optionally smooth shaded.
 
Method Summary
 void addAnimation(Animation anim)
          Adds an animation object to the mesh.
 void addFaces(int index, Triangle[] faces)
          Adds a set of faces (array of triangles) to the vertex array mesh
 void destroy()
          Destroys the mesh.
 void draw(javax.media.opengl.GL gl)
          Call this method to draw the mesh.
 void finishModel()
          This method finishes important remaining work to finish the construction of the model.
 Animation getAnimation(java.lang.String name)
          Returns the animation that corresponds to the specied name.
 java.util.List<Animation> getAnimations()
          Returns a list of all animations of the mesh
 Animation getCurrentAnimation()
          Return the animation object for the current animation.
 java.util.List<Triangle> getFaces()
          Returns the faces of the currently indexed vertex array
 java.util.List<Triangle> getFacesTransformed()
          Returns the face with coordinates that are correctly transformed (translation, rotation, scale factor) according to the current transformation state of the mesh.
 int getTotalFrameCount()
          Returns the number of frames of the mesh.
 void removeAnimation(Animation anim)
          Removes an animation from the mesh.
 void setAnimation(java.lang.String name)
          Sets the current animation to the one that corresponds to the specified name.
 void specializedDraw(javax.media.opengl.GL gl)
          Helper method to extract the specialised things just fitting to drawing of vertex arrays.
 void update(long elapsedTime)
          Updates the mesh.
 
Methods inherited from class de.rico.engine.geometry.AbstractMesh
addShader, drawShaders, getBoundingVolume, getHeightOffset, getMaterial, getMouseOverMesh, getName, getPosition, getPosX, getPosY, getPosZ, getRotation, getRotX, getRotY, getRotZ, getScaleX, getScaleY, getScaleZ, getTex0Path, getTex1Path, getText0XMovement, getText0YMovement, getText1XMovement, getText1YMovement, getTexUnit0, getTexUnit1, isCollidable, isDrawingEnabled, isEnabledOcclusionCulling, isMouseOverMesh, isOccluded, isPickable, isShadowEnabled, isSmoothShaded, isTex0Flipped, isTex0MipMapped, isTex0Rotated, isTex1Flipped, isTex1MipMapped, isTex1Rotated, moveBackwardsGlobal, moveBackwardsLocal, moveDownGlobal, moveForwardGlobal, moveForwardLocal, moveLeftGlobal, moveLeftLocal, moveRightGlobal, moveRightLocal, moveTo, moveUpGlobal, performTransformations, rotateDown, rotateLeft, rotateRight, rotateUp, scale, setAttachedGround, setBlendDestFactor, setBlendFunction, setBlendSourceFactor, setCollidable, setDrawingEnabled, setEnabledOcclusionCulling, setEnvironmentMap, setMaterial, setName, setPickable, setPosition, setPosition, setPosX, setPosY, setPosZ, setRotation, setRotation, setRotX, setRotY, setRotZ, setScaleX, setScaleY, setScaleZ, setShadowEnabled, setShowBoundingVolume, setTex0Movement, setTex0TexEnvirMode, setTex0XMovement, setTex0YMovement, setTex1Movement, setTex1TexEnvirMode, setTex1XMovement, setTex1YMovement, setTexUnit0, setTexUnit0, setTexUnit1, setTexUnit1, setTransparency, showWireFrame, translateX, translateY, translateZ
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

MeshVA

public MeshVA(boolean smooth)
Creates a new mesh object, optionally smooth shaded. A word of advice: If you decide to enable smooth shading the creation of the mesh will take more time than without smooth shading, because smooth normals need to be calculated beforehand, which is pretty time consuming depending on the amount of triangles in the mesh.

Parameters:
smooth - shade mesh smoothly? --> true=yes, false=no

MeshVA

public MeshVA(boolean smooth,
              BoundingVolume type)
Creates a new mesh object, optionally smooth shaded. You can specifiy the type of the used bounding volume, too.
A word of advice: If you decide to enable smooth shading the creation of the mesh will take more time than without smooth shading, because smooth normals need to be calculated beforehand, which is pretty time consuming depending on the amount of triangles in the mesh.

Parameters:
smooth - shade mesh smoothly? --> true=yes, false=no
type - value from the BoundingVolume enumeration
Method Detail

addFaces

public void addFaces(int index,
                     Triangle[] faces)
Adds a set of faces (array of triangles) to the vertex array mesh

Parameters:
index - number of the frame
faces - frame (array of triangles)

getFaces

public java.util.List<Triangle> getFaces()
Returns the faces of the currently indexed vertex array

Specified by:
getFaces in class AbstractMesh
Returns:
faces of the currently index vertex array

getFacesTransformed

public java.util.List<Triangle> getFacesTransformed()
Description copied from class: AbstractMesh
Returns the face with coordinates that are correctly transformed (translation, rotation, scale factor) according to the current transformation state of the mesh.

Specified by:
getFacesTransformed in class AbstractMesh
Returns:
correctly transformed faces of the mesh

finishModel

public void finishModel()
This method finishes important remaining work to finish the construction of the model.
It does the following: It is essentiell to call this method after every face has been added to mesh object.


addAnimation

public void addAnimation(Animation anim)
Adds an animation object to the mesh.

Parameters:
anim - animation object to add

setAnimation

public void setAnimation(java.lang.String name)
Sets the current animation to the one that corresponds to the specified name.

Parameters:
name - name of the animation to set

getAnimation

public Animation getAnimation(java.lang.String name)
Returns the animation that corresponds to the specied name.

Parameters:
name - name of the animation to find
Returns:
animation that corresponds to the specied name

getAnimations

public java.util.List<Animation> getAnimations()
Returns a list of all animations of the mesh

Returns:
list of the meshes animations

getCurrentAnimation

public Animation getCurrentAnimation()
Return the animation object for the current animation.

Returns:
current animation

removeAnimation

public void removeAnimation(Animation anim)
Removes an animation from the mesh.

Note: This does only remove the animation's information. The triangle data for the animation frames itself is not influenced.

Parameters:
anim - animation to remove

getTotalFrameCount

public int getTotalFrameCount()
Returns the number of frames of the mesh.

Returns:
total number of mesh frames

destroy

public void destroy()
Description copied from class: AbstractMesh
Destroys the mesh.

Specified by:
destroy in class AbstractMesh

update

public void update(long elapsedTime)
Description copied from class: AbstractMesh
Updates the mesh. Subclasses should override this method.

Overrides:
update in class AbstractMesh
Parameters:
elapsedTime - time between two frames

draw

public void draw(javax.media.opengl.GL gl)
Description copied from class: AbstractMesh
Call this method to draw the mesh.

Specified by:
draw in class AbstractMesh

specializedDraw

public void specializedDraw(javax.media.opengl.GL gl)
Helper method to extract the specialised things just fitting to drawing of vertex arrays. This method is also used by shadow drawing.

Specified by:
specializedDraw in class AbstractMesh
Parameters:
gl -