jme.geometry.model.ms
Class MilkshapeModel

java.lang.Object
  extended byjme.geometry.model.ms.MilkshapeModel
All Implemented Interfaces:
Geometry, Model

public class MilkshapeModel
extends java.lang.Object
implements Model

A MilkshapeModel represents a Milkshape 3D model. Currently, it can only load the exported ascii text version of an MD3D model. In the future, the binary version may be supported, but there really is no need for it because it does not matter how long it takes to load the animation. Loading should take place at game startup. If speed becomes extremely important in the future, the binary loader may be an option, or serialized models is another option. Unless someone contributes a binary loader or add the nehe lwjgl port of the binary loader that actually loads multiple texture correctly :) The model can also draw itself, fully textured, to OpenGL through lwjgl. Bone animation is also supported. EDIT: Mark Powell 9/5/03 - heavily updated class to make calls to exisiting jme math (Matrix, Vector, etc). Altered update to take a time interval to allow for frame rate independant animation. SPECIAL THANKS: Animation method was ported by naj from a MSVC++ Model Viewer tutorial written by Mete Ciragan (creator of Milkshape).

Version:
$Id: MilkshapeModel.java,v 1.9 2003/09/08 20:29:27 mojomonkey Exp $
Author:
naj, Mark Powell

Constructor Summary
MilkshapeModel(java.lang.String filename)
           
MilkshapeModel(java.lang.String filename, boolean animated)
           
 
Method Summary
 Vector[] getPoints()
          getPoints returns an array of Vectors that represents each point that makes up the piece of geometry.
 void initialize()
          Loads an ascii text model exported from MS3D.
 boolean isAnimated()
          Determine is the model is going to run animations, if it has them.
 void render()
          Draws the model to OpenGL via lwjgl.
 void setAnimated(boolean animated)
          Set the new animation mode.
 void setColor(float r, float g, float b, float a)
          setColor sets the color of the geometry.
 void setTexture(java.lang.String texture)
          setTexture sets the associated texture of this geometry to the passed texture file.
 void update(float time)
          Set the final matrix of all of the joints to be part way between the previous keyframe and the next keyframe, depending on how much time has passed since the last keyframe.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

MilkshapeModel

public MilkshapeModel(java.lang.String filename)

MilkshapeModel

public MilkshapeModel(java.lang.String filename,
                      boolean animated)
Method Detail

render

public void render()
Draws the model to OpenGL via lwjgl. Also advances the animation frames along if there are animations for the model.

Specified by:
render in interface Geometry

update

public void update(float time)
Set the final matrix of all of the joints to be part way between the previous keyframe and the next keyframe, depending on how much time has passed since the last keyframe.

Specified by:
update in interface Model

initialize

public void initialize()
Loads an ascii text model exported from MS3D.

Specified by:
initialize in interface Geometry

setColor

public void setColor(float r,
                     float g,
                     float b,
                     float a)
Description copied from interface: Geometry
setColor sets the color of the geometry. This uses a RGBA color. Where alpha of 1 is opaque and 0 is clear.

Specified by:
setColor in interface Geometry
Parameters:
r - the red color of the geometry.
g - the green color of the geometry;
b - the green color of the geometry.
a - the transparency of the geometry.

setTexture

public void setTexture(java.lang.String texture)
Description copied from interface: Geometry
setTexture sets the associated texture of this geometry to the passed texture file.

Specified by:
setTexture in interface Geometry
Parameters:
texture - the image file to use as the texture for this geometry object.

getPoints

public Vector[] getPoints()
Description copied from interface: Geometry
getPoints returns an array of Vectors that represents each point that makes up the piece of geometry.

Specified by:
getPoints in interface Geometry
Returns:
the array of vectors for the points.

isAnimated

public boolean isAnimated()
Determine is the model is going to run animations, if it has them.

Returns:
the animation mode.

setAnimated

public void setAnimated(boolean animated)
Set the new animation mode.

Parameters:
animated - the new animation mode.