org.xith3d.loaders.models
Class Model

java.lang.Object
  extended by org.xith3d.scenegraph.SceneGraphObject
      extended by org.xith3d.scenegraph.Node
          extended by org.xith3d.scenegraph.GroupNode
              extended by org.xith3d.scenegraph.Group
                  extended by org.xith3d.loaders.models.Model
All Implemented Interfaces:
org.jagatoo.datatypes.NamableObject, org.jagatoo.datatypes.NamedObject, org.openmali.spatial.SpatialNode, UpdatableNode
Direct Known Subclasses:
Cal3dModel, DaeModel

public class Model
extends Group
implements UpdatableNode

This class represents a Model loaded from some model file formats. This class is responsible for both the storage and retrieval of data from the Model. The storage methods (used only by Loader writers) are all of the add*() routines. The retrieval methods (used primarily by Loader users) are all of the get*() routines.


Field Summary
 
Fields inherited from class org.xith3d.scenegraph.GroupNode
children, hostGroup, numChildren, totalNumChildren, totalNumShapes
 
Fields inherited from class org.xith3d.scenegraph.Node
bounds, boundsAutoCompute, boundsDirty, globalIgnoreBounds, instanceBoundsTypeHint, transformGroup, untransformedBounds
 
Fields inherited from class org.xith3d.scenegraph.SceneGraphObject
XITH3D_USERDATAKEY_OLDUSERDATA
 
Constructor Summary
Model()
           
 
Method Summary
 void addAnimationListener(AnimationListener l)
           
protected  void addNamedObject(java.lang.String name, org.jagatoo.datatypes.NamedObject object)
          Adds the given String/Object pair to the table of named objects.
 void dumpAnimations()
          Dumps all animations contained in the model.
 void dumpNamedObjects(boolean printValues)
           
protected  void fireOnAnimationFinished(ModelAnimation anim)
           
protected  void fireOnAnimationStarted(ModelAnimation anim)
           
 ModelAnimation getAnimation(int index)
           
 ModelAnimation getAnimation(java.lang.String name)
           
 ModelAnimation[] getAnimations()
           
 int getAnimationsCount()
           
 View getCamera(int index)
           
 View[] getCameras()
           
 int getCamerasCount()
           
 ModelAnimation getCurrentAnimation()
           
static boolean getDefaultPickHost()
           
 Fog getFog(int index)
           
 Fog[] getFogs()
           
 int getFogsCount()
           
 Light getLight(int index)
           
 Light[] getLights()
           
 int getLightsCount()
           
 GroupNode getMainGroup()
           
 ModelMetaData getMetaData()
           
 TransformGroup getMountTransform(int index)
           
 TransformGroup getMountTransform(java.lang.String name)
           
 TransformGroup[] getMountTransforms()
           
 int getMountTransformsCount()
           
 org.jagatoo.datatypes.NamedObject getNamedObject(java.lang.String name)
           
 java.util.Map<java.lang.String,org.jagatoo.datatypes.NamedObject> getNamedObjects()
           
 int getNamedObjectsCount()
           
 TransformGroup getNestedTransform(int index)
           
 TransformGroup[] getNestedTransforms()
           
 Shape3D getShape(int index)
           
 Shape3D[] getShapes()
           
 int getShapesCount()
           
 Model getSharedInstance()
           
 SkyBox getSkyBox()
           
 Sound getSound(int index)
           
 Sound[] getSounds()
           
 int getSoundsCount()
           
 org.openmali.vecmath2.Matrix4f getSpawnTransform(int index)
           
 org.openmali.vecmath2.Matrix4f[] getSpawnTransforms()
           
 int getSpawnTransformsCount()
           
 boolean hasAnimations()
           
 void interpolateAnimation(float animStartTime, float absAnimTime)
          Interpolates the animations towards the next frame.
 void removeAnimationListener(AnimationListener l)
           
 void setAnimations(ModelAnimation[] anims)
           
protected  void setCameras(View[] cameras)
           
 void setCurrentAnimation(int index)
          Sets the current animation being used.
 void setCurrentAnimation(ModelAnimation anim)
          Sets the current animation being used.
 void setCurrentAnimation(java.lang.String name)
          Sets the current animation being used.
static void setDefaultPickHost(boolean value)
          Sets the initial (default) value for a new Model's pick-host flag.
protected  void setFogs(Fog[] fogs)
           
protected  void setLights(Light[] lights)
           
protected  void setMainGroup(GroupNode mainGroup)
           
 void setMetaData(ModelMetaData metaData)
          Sets the meta data for this object.
 void setMountTransforms(TransformGroup[] mountTransforms)
           
protected  void setNestedTransforms(TransformGroup[] nestedTransforms)
           
protected  void setShapes(Shape3D[] shapes)
           
protected  void setSkyBox(SkyBox skyBox)
           
protected  void setSounds(Sound[] sounds)
           
protected  void setSpawnTransforms(org.openmali.vecmath2.Matrix4f[] spawnTransforms)
           
 boolean update(View view, org.openmali.spatial.bodies.Frustum frustum, long nanoTime, long nanoStep)
          
 
Methods inherited from class org.xith3d.scenegraph.Group
moveTo, newInstance, traverse
 
Methods inherited from class org.xith3d.scenegraph.GroupNode
absorbDetails, addChild, addChild, checkChild, dump, dump, ensureCapacity, expandBounds, findAll, findAll, findFirst, findFirst, freeOpenGLResources, getChild, getChildren, getChildren, getClipper, getPickHost, getScissorRect, getTotalNumChildren, getTotalNumShapes, indexOf, isPickHost, mergeInheritedClipper, mergeInheritedNodes, mergeInheritedScissorRect, numChildren, removeAllChildren, removeChild, removeChild, setBoundsDirty, setBoundsDirtyUpward, setChild, setClipper, setLive, setPickHost, setPickHost, setScissorRect, setShowBounds, sharedCopy, sharedCopy, traverse, unmergeInheritedFog, unmergeInheritedLight, unmergeInheritedNodes, updateBounds, updateBoundsCheap
 
Methods inherited from class org.xith3d.scenegraph.Node
cloneNode, detach, duplicateNode, freeOpenGLResources, getBounds, getBoundsAutoCompute, getBoundsType, getBoundsTypeHint, getDefaultPickable, getIndentString, getInheritedNodeAttributes, getModListener, getOrderedChild, getOrderedState, getParent, getRoot, getShadowAttachment, getShowBounds, getTransformGroup, getTreeCell, getWorldBounds, getWorldTransform, getWorldTransform, isBillboard, isIgnoreBounds, isOccluder, isPickable, isRenderable, isUpdatableNode, popGlobalIgnoreBounds, printBounds, pushGlobalIgnoreBounds, setBounds, setBoundsAutoCompute, setBoundsTypeHint, setDefaultPickable, setGlobalIgnoreBounds, setIgnoreBounds, setIsOccluder, setModListener, setOrderedChild, setParent, setPickable, setPickableRecursive, setPickableRecursive, setRenderable, setShadowAttachment, setShowBounds, setTransformGroup, setTreeCell, updateOrderedChild, updateTransformGroup, updateWorldTransform
 
Methods inherited from class org.xith3d.scenegraph.SceneGraphObject
getName, getUserData, getUserData, getUserDataMap, isLive, setName, setUserData, setUserData, setUserDataRecursive, setUserDataRecursive, toString
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

Model

public Model()
Method Detail

setDefaultPickHost

public static void setDefaultPickHost(boolean value)
Sets the initial (default) value for a new Model's pick-host flag.

Parameters:
value -

getDefaultPickHost

public static boolean getDefaultPickHost()
Returns:
the initial (default) value for a new Model's pick-host flag.

setNestedTransforms

protected void setNestedTransforms(TransformGroup[] nestedTransforms)

getNestedTransform

public final TransformGroup getNestedTransform(int index)
Parameters:
index -
Returns:
the nested TransformGroup by the given index.

getNestedTransforms

public final TransformGroup[] getNestedTransforms()
Returns:
the list of nested TransformGroups in this model.

setShapes

protected void setShapes(Shape3D[] shapes)

getShapesCount

public final int getShapesCount()
Returns:
the number of Shape nodes defined in the file.

getShape

public final Shape3D getShape(int index)
Parameters:
index -
Returns:
a Shape contained in the model.

getShapes

public final Shape3D[] getShapes()
Returns:
an array of all Shapes contained in the model.

setLights

protected void setLights(Light[] lights)

getLightsCount

public final int getLightsCount()
Returns:
the number of Light nodes defined in the file.

getLight

public final Light getLight(int index)
Returns:
a Light defined in the file.

getLights

public final Light[] getLights()
Returns:
an array of all Lights defined in the file (may be null).

setFogs

protected void setFogs(Fog[] fogs)

getFogsCount

public final int getFogsCount()
Returns:
the number of Fog nodes defined in the file.

getFog

public final Fog getFog(int index)
Returns:
a Fog defined in the file.

getFogs

public final Fog[] getFogs()
Returns:
an array of all Fogs defined in the file (may be null).

setSounds

protected void setSounds(Sound[] sounds)

getSoundsCount

public final int getSoundsCount()
Returns:
the number of Sound nodes defined in the file.

getSound

public final Sound getSound(int index)
Returns:
a Sound node defined in the file.

getSounds

public final Sound[] getSounds()
Returns:
an array of all the Sound nodes defined in the file (may be null).

setCameras

protected void setCameras(View[] cameras)

getCamerasCount

public final int getCamerasCount()
Returns:
the number of cameras defined in the file.

getCamera

public final View getCamera(int index)
Returns:
a camera defined in the file.

getCameras

public final View[] getCameras()
Returns:
an array of all the cameras defined in the file (may be null).

setSpawnTransforms

protected void setSpawnTransforms(org.openmali.vecmath2.Matrix4f[] spawnTransforms)

getSpawnTransformsCount

public final int getSpawnTransformsCount()
Returns:
the number of spawn transforms.

getSpawnTransform

public final org.openmali.vecmath2.Matrix4f getSpawnTransform(int index)
Returns:
a spawn transform defined in this scene.

getSpawnTransforms

public final org.openmali.vecmath2.Matrix4f[] getSpawnTransforms()
Returns:
an array of all spawn transforms defined in this scene.

setMainGroup

protected void setMainGroup(GroupNode mainGroup)

getMainGroup

public final GroupNode getMainGroup()
Returns:
the main group of this model. This may be the model itself of a nested BSPTreeGroup, OcTreeGroup, etc.

setSkyBox

protected void setSkyBox(SkyBox skyBox)

getSkyBox

public final SkyBox getSkyBox()
Returns:
this scene's SkyBox (if any, null otherwise).

addNamedObject

protected void addNamedObject(java.lang.String name,
                              org.jagatoo.datatypes.NamedObject object)
Adds the given String/Object pair to the table of named objects.


getNamedObjectsCount

public final int getNamedObjectsCount()
Returns:
the number of named objects in this model file.

getNamedObjects

public final java.util.Map<java.lang.String,org.jagatoo.datatypes.NamedObject> getNamedObjects()
Returns:
a Map, which contains a list of all named objects in the file and their associated scene graph objects. The naming scheme for file objects is file-type dependent, but may include such names as the DEF names of Vrml or filenames of objects (as in Lightwave 3D).

getNamedObject

public final org.jagatoo.datatypes.NamedObject getNamedObject(java.lang.String name)
Parameters:
name - the name of the named object to retrieve
Returns:
the named object with the given name. The naming scheme for file objects is file-type dependent, but may include such names as the DEF names of Vrml or filenames of subjects (as in Lightwave 3D).

dumpNamedObjects

public void dumpNamedObjects(boolean printValues)

setMetaData

public void setMetaData(ModelMetaData metaData)
Sets the meta data for this object. Primalaly used by MetaLoader


getMetaData

public final ModelMetaData getMetaData()
Returns:
the meta data associated with this object. Usualy only objects loaded from the MetaLoader have meta data. For objects without meta data this returns null.

setMountTransforms

public void setMountTransforms(TransformGroup[] mountTransforms)

getMountTransformsCount

public final int getMountTransformsCount()

getMountTransforms

public final TransformGroup[] getMountTransforms()

getMountTransform

public final TransformGroup getMountTransform(int index)

getMountTransform

public final TransformGroup getMountTransform(java.lang.String name)

addAnimationListener

public void addAnimationListener(AnimationListener l)

removeAnimationListener

public void removeAnimationListener(AnimationListener l)

fireOnAnimationStarted

protected final void fireOnAnimationStarted(ModelAnimation anim)

fireOnAnimationFinished

protected final void fireOnAnimationFinished(ModelAnimation anim)

setAnimations

public void setAnimations(ModelAnimation[] anims)

hasAnimations

public final boolean hasAnimations()
Returns:
true, if the Model contains at least one animation.

getAnimationsCount

public final int getAnimationsCount()
Returns:
the number of animations for this model.

getAnimations

public ModelAnimation[] getAnimations()
Returns:
a List of all animations contained in the model

getAnimation

public ModelAnimation getAnimation(int index)
Returns:
an animation by index

getAnimation

public ModelAnimation getAnimation(java.lang.String name)
Returns:
an animation by name

dumpAnimations

public final void dumpAnimations()
Dumps all animations contained in the model.


setCurrentAnimation

public void setCurrentAnimation(ModelAnimation anim)
Sets the current animation being used.

Parameters:
anim - the animation to use

setCurrentAnimation

public final void setCurrentAnimation(java.lang.String name)
Sets the current animation being used.

Parameters:
name - the animation to use

setCurrentAnimation

public final void setCurrentAnimation(int index)
Sets the current animation being used.

Parameters:
index - the animation to use

getCurrentAnimation

public final ModelAnimation getCurrentAnimation()
Returns:
the current animation being used.

interpolateAnimation

public void interpolateAnimation(float animStartTime,
                                 float absAnimTime)
Interpolates the animations towards the next frame.

Parameters:
animStartTime - the game-time, at which the current loop of the animation started
absAnimTime - the amount of game-time, the current loop of the current animation runs

update

public boolean update(View view,
                      org.openmali.spatial.bodies.Frustum frustum,
                      long nanoTime,
                      long nanoStep)

Specified by:
update in interface UpdatableNode
Parameters:
view - the view that's currently used for rendering
frustum - view frustum
Returns:
True if this should be rendered, false if it should not.

getSharedInstance

public Model getSharedInstance()
Returns:
a new Instance of this Model. It will at least share it's Geometry and animation data with this one.