md3.md3model
Class MD3Model

java.lang.Object
  |
  +--md3.md3model.MD3Model
Direct Known Subclasses:
MD3GLModel

public class MD3Model
extends java.lang.Object
implements java.io.Serializable

The MD3Model class contains data structures to hold all information contained in an MD3 model file.

MD3Model really is a 1 class composite pattern: you can link models to a model and iterate over the linked models. Normally you link an object to an MD3Model if that object represents a submodel of the model at a certain tag position.

MD3Model objects support visitor objects to do certain operations on/with the information contained in an MD3Model.

Author:
Erwin Vervaet (erwin@cs.kuleuven.ac.be)
See Also:
MD3Tag, MD3ModelVisitor, Serialized Form

Field Summary
 int boneFrameNum
          Number of animation key frames in the model.
 MD3BoneFrame[] boneFrames
          Array of bone frames size boneFrameNum.
 int boneFrameStart
          Starting position of bone frame data structures.
 java.lang.String filename
          Filename as recorded in the .md3 file.
 int fileSize
           
 java.lang.String id
           
protected  java.util.SortedMap linkedModels
          Map used to store the models linked to this model.
 java.lang.String loadFilename
          Filename of actual file from which data was loaded.
 int maxTextureNum
          Maximum number of unique textures used in an md3 file.
 MD3Mesh[] meshes
          Array of meshes in the model size meshNum.
 int meshNum
           
 int meshStart
          Starting position of mesh structures.
 int tagNum
           
 int tagStart
          Starting position of tag-structures.
 int version
           
 
Constructor Summary
protected MD3Model()
          Constructor for use in subclasses that creates a new, uninitialized MD3Model object.
protected MD3Model(java.lang.String filename)
          Constructor for use in subclasses that reads an MD3 model from a file.
protected MD3Model(java.lang.String loadFilename, java.io.InputStream in)
          Constructor for use in subclasses that reads an MD3 model from the specified input stream.
 
Method Summary
 void accept(MD3ModelVisitor v)
          MD3Model objects can be visited, according to the visitor pattern, by MD3ModelVistor objects.
 void addLinkedModel(int tagIndex, MD3Model child)
          Link a model at the specified tag position to this model.
 boolean animated()
          Return wether or not this model contains animation data.
 MD3Model getParent()
          Return the parent model of this model, or null if none.
 int getParentTagIndex()
          Return the index of the tag this model is linked to in it's parent's tags array.
 int getTagIndexByName(java.lang.String tagName)
          Return the index of the tag with the given name for this model.
 java.util.Iterator linkedModels()
          Request an iterator to step through all models linked to this model.
 void removeLinkedModel(int tagIndex)
          Remove the model linked to this model at the specified tag position.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

id

public java.lang.String id

version

public int version

filename

public java.lang.String filename

Filename as recorded in the .md3 file. This might be empty.


loadFilename

public java.lang.String loadFilename

Filename of actual file from which data was loaded.


boneFrameNum

public int boneFrameNum

Number of animation key frames in the model.


tagNum

public int tagNum

meshNum

public int meshNum

maxTextureNum

public int maxTextureNum

Maximum number of unique textures used in an md3 file.


boneFrameStart

public int boneFrameStart

Starting position of bone frame data structures.


tagStart

public int tagStart

Starting position of tag-structures.


meshStart

public int meshStart

Starting position of mesh structures.


fileSize

public int fileSize

boneFrames

public MD3BoneFrame[] boneFrames

Array of bone frames size boneFrameNum. The contains the metadata (bounding box, tags, ..,) for each of the bone animation frames in the model.


meshes

public MD3Mesh[] meshes

Array of meshes in the model size meshNum. Each mesh contains the data of that mesh for each of the animation frames in the model.


linkedModels

protected java.util.SortedMap linkedModels

Map used to store the models linked to this model. The map is indexed by tag index number and also ordered by index number.

Constructor Detail

MD3Model

protected MD3Model(java.lang.String filename)
            throws java.io.IOException

Constructor for use in subclasses that reads an MD3 model from a file.


MD3Model

protected MD3Model(java.lang.String loadFilename,
                   java.io.InputStream in)
            throws java.io.IOException

Constructor for use in subclasses that reads an MD3 model from the specified input stream. The given loadFilename is stored in the corresponding data member.


MD3Model

protected MD3Model()

Constructor for use in subclasses that creates a new, uninitialized MD3Model object.

Method Detail

addLinkedModel

public void addLinkedModel(int tagIndex,
                           MD3Model child)

Link a model at the specified tag position to this model. If the position is allready occupied, the old submodel will be replaced.

Parameters:
tagIndex - Tag to link the submodel to.
child - The submodel that should be linked to this model.

removeLinkedModel

public void removeLinkedModel(int tagIndex)

Remove the model linked to this model at the specified tag position.


linkedModels

public java.util.Iterator linkedModels()

Request an iterator to step through all models linked to this model.

Returns:
An iterator looping through the linked models.

getParentTagIndex

public int getParentTagIndex()

Return the index of the tag this model is linked to in it's parent's tags array. This can be used to figure out the position of this model relative to that of it's parent.

This will return -1 if there is no parent model.


getTagIndexByName

public int getTagIndexByName(java.lang.String tagName)

Return the index of the tag with the given name for this model.

This will return -1 if their is no such tag.


getParent

public MD3Model getParent()

Return the parent model of this model, or null if none.


accept

public void accept(MD3ModelVisitor v)

MD3Model objects can be visited, according to the visitor pattern, by MD3ModelVistor objects.

Parameters:
v - The visitor.

animated

public boolean animated()

Return wether or not this model contains animation data.