org.jagatoo.loaders.models.cal3d.core
Class CalModel

java.lang.Object
  extended by org.jagatoo.loaders.models.cal3d.core.CalModel

public class CalModel
extends java.lang.Object

An instance of a core model with its own positions for the bones. The Cal3d structure is very open but it is my intention to close this off and move much of the data into native storage so an optimised mechanism can do the bone transforms - either using the vector co-pro or on the graphics hardware with a vertex program. In the meantime avoid manipulating CalBones directly. For multithreading purposes this is usually the object to synchronize on.


Field Summary
protected  CalCoreModel coreModel
           
protected  java.lang.String currentMaterialSet
           
protected  java.util.List<CalMesh> meshes
           
protected  CalMixer mixer
           
protected  CalPhysique physique
           
protected  CalSkeleton skeleton
           
protected  CalSpringSystem springSystem
           
protected  java.lang.Object userData
           
 
Constructor Summary
CalModel(CalCoreModel coreModel)
          Constructs the model instance.
CalModel(CalModel other)
          Constructs a near clone of the supplied model.
 
Method Summary
 void attachMesh(java.lang.String coreMeshId)
          Attachs a mesh.
 void detachAllMeshes()
           
 boolean detachMesh(java.lang.String coreMeshId)
          Detaches a mesh.
 void finalize()
          Destructs the model instance.
 CalCoreModel getCoreModel()
          Provides access to the core model.
 java.lang.String getMaterialSet()
           
 CalMesh getMesh(java.lang.String coreMeshId)
          Provides access to an attached mesh.
 java.util.List<CalMesh> getMeshes()
          Returns the mesh vector.
 CalMixer getMixer()
          Provides access to the mixer.
 CalPhysique getPhysique()
          Provides access to the physique.
 CalSkeleton getSkeleton()
          Provides access to the skeleton.
 CalSpringSystem getSpringSystem()
          Provides access to the spring system.
 java.lang.Object getUserData()
          Provides access to the user data.
 void setCoreSkeleton(CalCoreSkeleton coreSkeleton)
          Sets the skeleton to a new instance of the coreSkeleton.
 void setLodLevel(float lodLevel)
          Sets the LOD level.
 void setMaterialSet(java.util.List<CalCoreMaterial> materials)
           
 void setMaterialSet(java.lang.String setId)
          Sets the material set.
 void setUserData(java.lang.Object userData)
          Stores user data.
 void update(float deltaTime)
          Updates the model instance.
 
Methods inherited from class java.lang.Object
clone, equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

coreModel

protected CalCoreModel coreModel

skeleton

protected CalSkeleton skeleton

mixer

protected CalMixer mixer

physique

protected CalPhysique physique

springSystem

protected CalSpringSystem springSystem

userData

protected java.lang.Object userData

meshes

protected java.util.List<CalMesh> meshes

currentMaterialSet

protected java.lang.String currentMaterialSet
Constructor Detail

CalModel

public CalModel(CalCoreModel coreModel)
Constructs the model instance. This function is the default constructor of the model instance.


CalModel

public CalModel(CalModel other)
Constructs a near clone of the supplied model. The active meshes and current materials will be reproduced but internal state will be back to an initial state.

Method Detail

finalize

public void finalize()
Destructs the model instance. This function is the destructor of the model instance.

Overrides:
finalize in class java.lang.Object

attachMesh

public void attachMesh(java.lang.String coreMeshId)
Attachs a mesh. This function attachs a mesh to the model instance.

Parameters:
coreMeshId - The ID of the mesh that should be attached.

detachMesh

public boolean detachMesh(java.lang.String coreMeshId)
Detaches a mesh. This function detaches a mesh from the model instance.

Parameters:
coreMeshId - The ID of the mesh that should be detached.
Returns:
One of the following values:
  • true if successful
  • false if the mesh was not attached

detachAllMeshes

public void detachAllMeshes()

getCoreModel

public CalCoreModel getCoreModel()
Provides access to the core model. This function returns the core model on which this model instance is based on.

Returns:
One of the following values: \li a pointer to the core model \li \b 0 if an error happend

getMesh

public CalMesh getMesh(java.lang.String coreMeshId)
Provides access to an attached mesh. This function returns the attached mesh with the given core mesh ID.

Parameters:
coreMeshId - The core mesh ID of the mesh that should be returned.
Returns:
One of the following values: \li a pointer to the mesh \li \b null if an error happend

getMixer

public CalMixer getMixer()
Provides access to the mixer. This function returns the mixer.

Returns:
One of the following values: \li a pointer to the mixer \li \b 0 if an error happend

getPhysique

public CalPhysique getPhysique()
Provides access to the physique. This function returns the physique.

Returns:
One of the following values: \li a pointer to the physique \li \b 0 if an error happend

getSkeleton

public CalSkeleton getSkeleton()
Provides access to the skeleton. This function returns the skeleton.

Returns:
One of the following values: \li a pointer to the skeleton \li \b 0 if an error happend

setCoreSkeleton

public void setCoreSkeleton(CalCoreSkeleton coreSkeleton)
Sets the skeleton to a new instance of the coreSkeleton. This method may be of use if a model has several compatible skeletons such as a simple body and a body with full facial rig. Otherwise it is principally of use during the design phase.

Parameters:
coreSkeleton -

getSpringSystem

public CalSpringSystem getSpringSystem()
Provides access to the spring system. This function returns the spring system.

Returns:
One of the following values: \li a pointer to the spring system \li \b 0 if an error happend

getUserData

public java.lang.Object getUserData()
Provides access to the user data. This function returns the user data stored in the model instance.

Returns:
The user data stored in the model instance.

getMeshes

public java.util.List<CalMesh> getMeshes()
Returns the mesh vector. This function returns the vector that contains all attached meshes of the model instance.

Returns:
A reference to the mesh vector.

setLodLevel

public void setLodLevel(float lodLevel)
Sets the LOD level. This function sets the LOD level of all attached meshes.

Parameters:
lodLevel - The LOD level in the range [0.0, 1.0].

setMaterialSet

public void setMaterialSet(java.lang.String setId)
Sets the material set. This function sets the material set of all attached meshes.

Parameters:
setId - The ID of the material set.

setMaterialSet

public void setMaterialSet(java.util.List<CalCoreMaterial> materials)

getMaterialSet

public java.lang.String getMaterialSet()

setUserData

public void setUserData(java.lang.Object userData)
Stores user data. This function stores user data in the model instance.

Parameters:
userData - The user data that should be stored.

update

public void update(float deltaTime)
Updates the model instance. This function updates the model instance for a given amount of time.

Parameters:
deltaTime - The elapsed time in seconds since the last update.