md3.md3view
Class MD3GLModelDrawModelVisitor

java.lang.Object
  |
  +--md3.md3model.MD3ModelVisitor
        |
        +--md3.md3view.MD3GLModelVisitor
              |
              +--md3.md3view.MD3GLModelDrawModelVisitor
Direct Known Subclasses:
MD3GLModelCachingDrawModelVisitor

public class MD3GLModelDrawModelVisitor
extends MD3GLModelVisitor

An MD3GLModel visitor that walks through an MD3GLModel structure and draws all meshes of the current frame of the encountered models on a specified OpenGL canvas. Interpolation is done if necessary, as specified by the interpolationFraction data member of the MD3GLModel class.

Author:
Erwin Vervaet (erwin@cs.kuleuven.ac.be)
See Also:
MD3GLModel

Constructor Summary
MD3GLModelDrawModelVisitor(MD3GLCanvas md3canvas)
          Create a new visitor that will draw on the specified OpenGL canvas.
 
Method Summary
protected  void drawBoneFrame(MD3BoneFrame bf)
          Draw a given bone frame (bounding box) on the canvas.
protected  void drawMesh(MD3Mesh mesh, Vec3[] frame)
          Draw a given animation frame of a specified mesh on the canvas.
protected  void drawVertexNormals(Vec3[] frame, int[][] normals)
          Draw the given vertex normals of the given vertices on the canvas.
protected  MD3BoneFrame interpolateBoneFrame(MD3BoneFrame currBoneFrame, MD3BoneFrame nextBoneFrame, float frac)
          Interpolate a bone frame between 2 given bone frames.
protected  Vec3[] interpolateMeshFrame(Vec3[] currMeshFrame, Vec3[] nextMeshFrame, float frac)
          Interpolate a mesh animation frame between 2 given mesh animation frames.
protected  float[] interpolateTransformation(MD3Tag currFrameTag, MD3Tag nextFrameTag, float frac)
          Interpolate an OpenGL transformation array between the transformations of 2 given tags.
protected  int[][] interpolateVertexNormals(int[][] currNormals, int[][] nextNormals, float frac)
          Interpolate a set of vertex normals between the 2 given sets.
 void visit(MD3GLModel model)
          Renders a model on the canvas.
 
Methods inherited from class md3.md3view.MD3GLModelVisitor
visit
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

MD3GLModelDrawModelVisitor

public MD3GLModelDrawModelVisitor(MD3GLCanvas md3canvas)

Create a new visitor that will draw on the specified OpenGL canvas.

Parameters:
md3canvas - The OpenGL canvas to draw on.
Method Detail

visit

public void visit(MD3GLModel model)

Renders a model on the canvas.

Overrides:
visit in class MD3GLModelVisitor
Parameters:
model - The model to render.

interpolateBoneFrame

protected MD3BoneFrame interpolateBoneFrame(MD3BoneFrame currBoneFrame,
                                            MD3BoneFrame nextBoneFrame,
                                            float frac)

Interpolate a bone frame between 2 given bone frames.

Parameters:
currBoneFrame - Start bone frame.
nextBoneFrame - End bone frame.
frac - Interpolation fraction, in [0,1].

interpolateMeshFrame

protected Vec3[] interpolateMeshFrame(Vec3[] currMeshFrame,
                                      Vec3[] nextMeshFrame,
                                      float frac)

Interpolate a mesh animation frame between 2 given mesh animation frames.

Parameters:
currMeshFrame - Start mesh animation frame.
nextMeshFrame - End mesh animation frame.
frac - Interpolation fraction, in [0,1].

interpolateVertexNormals

protected int[][] interpolateVertexNormals(int[][] currNormals,
                                           int[][] nextNormals,
                                           float frac)

Interpolate a set of vertex normals between the 2 given sets.

Parameters:
currNormals - Start normal set.
nextNormals - End normal set.
frac - Interpolation fraction, in [0,1].

interpolateTransformation

protected float[] interpolateTransformation(MD3Tag currFrameTag,
                                            MD3Tag nextFrameTag,
                                            float frac)

Interpolate an OpenGL transformation array between the transformations of 2 given tags.

Parameters:
currFrameTag - Tag with start transformation.
nextFrameTag - Tag with end transformation.
frac - Interpolation fraction, in [0,1].
Returns:
An OpenGL compatible transformation array of length 16.

drawBoneFrame

protected void drawBoneFrame(MD3BoneFrame bf)

Draw a given bone frame (bounding box) on the canvas.

Parameters:
bf - The bone frame to draw.

drawMesh

protected void drawMesh(MD3Mesh mesh,
                        Vec3[] frame)

Draw a given animation frame of a specified mesh on the canvas.

Parameters:
mesh - The MD3Mesh that is being rendered.
vecs - The animation frame data to be rendered.

drawVertexNormals

protected void drawVertexNormals(Vec3[] frame,
                                 int[][] normals)

Draw the given vertex normals of the given vertices on the canvas.

Parameters:
frame - The animation frame vertex data for wich the normals are drawn.
normals - The vertex normal data.