jme.geometry.model.md3
Class Md3Model

java.lang.Object
  extended byjme.geometry.model.md3.Md3Model
All Implemented Interfaces:
Geometry

public class Md3Model
extends java.lang.Object
implements Geometry

Md3Model handles loading and rendering a Quake 3 MD3 format model. Animation is fully supported, where setTorsoAnimation and setLegsAnimation determine the animation used for the two major parts of the model. These animations are defined as:

BOTH_DEATH1
BOTH_DEAD1
BOTH_DEATH2
BOTH_DEAD2
BOTH_DEATH3
BOTH_DEAD3

TORSO_GESTURE
TORSO_ATTACK
TORSO_ATTACK2
TORSO_DROP
TORSO_RAISE
TORSO_STAND
TORSO_STAND2

LEGS_WALKCR
LEGS_WALK
LEGS_RUN
LEGS_BACK
LEGS_SWIM
LEGS_JUMP
LEGS_LAND
LEGS_JUMPB
LEGS_LANDB
LEGS_IDLECR
LEGS_IDLE
LEGS_TURN

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

Field Summary
static int HEAD
          HEAD defines the head section of the model.
static int LOWER
          LOWER defines the legs section of the model.
static int UPPER
          UPPER defines the torso section of the model.
static int WEAPON
          WEAPON defines the weapon of the model.
 
Constructor Summary
Md3Model(java.lang.String path, java.lang.String model, java.lang.String weapon)
          Constructor instantiates a new Md3Model object.
 
Method Summary
 jme.geometry.model.md3.Md3Model.Model3D getModel(int part)
          getModel returns a Model3D object of the specified model part.
 Vector[] getPoints()
          getPoints returns all the points of the MD3 model.
 void initialize()
          initialize loads the model and weapon then sets up the bounding volumes for the model.
 boolean loadModel()
          loadModel loads the currently defined model file and sets the appropriate data structures for rendering and animating.
 boolean loadWeapon()
          loadWeapon loads the currently defined weapon file and sets the appropriate data structures for rendering and animating.
 void render()
          render handles rendering the model to the screen.
 void setColor(float r, float g, float b, float a)
          setColor sets the overall shade of the model.
 void setLegsAnimation(java.lang.String animationName)
          setLegsAnimation sets the current animation of the lower model.
 void setModelString(java.lang.String model)
          setModelString sets the new model to be used.
 void setPath(java.lang.String path)
          setPath sets the path to the model.
 void setScale(Vector scale)
          setScale sets the scale factor for the model.
 void setTexture(java.lang.String texture)
          setTexture is not used as the MD3 Model's texture is defined in the skin data of the model.
 void setTorsoAnimation(java.lang.String animationName)
          setTorsoAnimation sets the current animation of the upper model.
 void setWeaponString(java.lang.String weapon)
          setWeaponString sets the new model to be used for the weapon.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

LOWER

public static final int LOWER
LOWER defines the legs section of the model.

See Also:
Constant Field Values

UPPER

public static final int UPPER
UPPER defines the torso section of the model.

See Also:
Constant Field Values

HEAD

public static final int HEAD
HEAD defines the head section of the model.

See Also:
Constant Field Values

WEAPON

public static final int WEAPON
WEAPON defines the weapon of the model.

See Also:
Constant Field Values
Constructor Detail

Md3Model

public Md3Model(java.lang.String path,
                java.lang.String model,
                java.lang.String weapon)
Constructor instantiates a new Md3Model object. During creation, the model is loaded and initialized.

Parameters:
path - the path to the base level of the model directory.
model - the model file.
weapon - the current weapon file. May be null.
Throws:
MonkeyGLException - if the OpenGL context has not been created.
MonkeyRuntimeException - if path or model is null.
Method Detail

setModelString

public void setModelString(java.lang.String model)
setModelString sets the new model to be used. This should be followed by a call to loadModel to complete the change of the model data.

Parameters:
model - the new model to use.

setWeaponString

public void setWeaponString(java.lang.String weapon)
setWeaponString sets the new model to be used for the weapon. This should be followed by a call to loadWeapon to complete te change of the model data.

Parameters:
weapon - the new weapon model to use.

setPath

public void setPath(java.lang.String path)
setPath sets the path to the model.

Parameters:
path - the new path to the models.

getModel

public jme.geometry.model.md3.Md3Model.Model3D getModel(int part)
getModel returns a Model3D object of the specified model part. Either LOWER, UPPER, HEAD or WEAPON.

Parameters:
part - the part requested.
Returns:
the model information for the model part.

initialize

public void initialize()
initialize loads the model and weapon then sets up the bounding volumes for the model.

Specified by:
initialize in interface Geometry

render

public void render()
render handles rendering the model to the screen. This occurs recursively starting with the legs, then torso and lastly the head. Due to the make up of the MD3 vertices, culling is turned to front.

Specified by:
render in interface Geometry

setTorsoAnimation

public void setTorsoAnimation(java.lang.String animationName)
setTorsoAnimation sets the current animation of the upper model. The string that denotes the animation is defined and denoted at the top of this javadoc.

Parameters:
animationName - the animation to set for the torso.

setLegsAnimation

public void setLegsAnimation(java.lang.String animationName)
setLegsAnimation sets the current animation of the lower model. The string that denotes the animation is defined and denoted at the top of this javadoc.

Parameters:
animationName - the animation to set for the legs.

setTexture

public void setTexture(java.lang.String texture)
setTexture is not used as the MD3 Model's texture is defined in the skin data of the model. It is here to provide continuity with the Geometry interface.

Specified by:
setTexture in interface Geometry
Parameters:
texture - not used.

setColor

public void setColor(float r,
                     float g,
                     float b,
                     float a)
setColor sets the overall shade of the model.

Specified by:
setColor in interface Geometry
Parameters:
r - the red component of the color.
g - the green component of the color.
b - the blue component of the color.
a - the alpha component of the color.

setScale

public void setScale(Vector scale)
setScale sets the scale factor for the model.

Parameters:
scale - the scale of the model.

getPoints

public Vector[] getPoints()
getPoints returns all the points of the MD3 model.

Specified by:
getPoints in interface Geometry
Returns:
the list of points.

loadModel

public boolean loadModel()
loadModel loads the currently defined model file and sets the appropriate data structures for rendering and animating.

Returns:
true if the model loaded correctly, false otherwise.

loadWeapon

public boolean loadWeapon()
loadWeapon loads the currently defined weapon file and sets the appropriate data structures for rendering and animating.

Returns:
true if the weapon loaded correctly, false otherwise.