com.jmex.model.ogrexml
Class SceneLoader

java.lang.Object
  extended by com.jmex.model.ogrexml.SceneLoader

public class SceneLoader
extends java.lang.Object

Loads dotScene files.

Note that multiple load invocations will add to the scene node managed by this instance. Therefore, if you want to obtain separate scene nodes for multiple dotScene files, you must use a separate SceneLoader instance for each load()+getScene().

See Also:
Ogre's dotScene format page.

Constructor Summary
SceneLoader()
           
 
Method Summary
 void addMaterials(java.util.Map<java.lang.String,Material> newMaterials)
          Reuse an existing Materials collection.
 Camera getCamera()
          Deprecated. This class no longer manages cameras.
 java.util.Map<java.lang.String,Material> getMaterials()
          Use this method to re-use the Materials loaded by this SceneLoader for other purposes, such as to load other dotScene or Mesh files.
 Node getScene()
           
 boolean isModelsOnly()
           
 void load(java.io.InputStream in)
          Adds data from the specified dotScene file onto a scene node (which may then be retrieved with getScene().
 void load(org.w3c.dom.Node sceneXmlNode)
           
 void load(java.net.URI uri)
          Convenience wrapper
 void load(java.net.URL url)
          Adds contents of dotScene file at specified URI onto a scene node, automatically adding the containing directory to the resource locator paths for the duration of the load.
 void loadEnvironment(org.w3c.dom.Node env)
           
 void loadExternals(org.w3c.dom.Node externals)
           
 void loadNode(Node targetJmeNode, org.w3c.dom.Node sourceXmlNode)
          Populates the specified jME Node with data from the specified XML Node.
 void setModelsOnly(boolean modelsOnly)
          Specify whether you want to load just models from the dotScene file.
 void setName(java.lang.String newName)
          This method is provided so that users can import multiple dotScene files and have unique top-level nodes for each load; or if you just want to specify your own top-level node name.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

SceneLoader

public SceneLoader()
Method Detail

getCamera

@Deprecated
public Camera getCamera()
Deprecated. This class no longer manages cameras.

This method just returns null.


isModelsOnly

public boolean isModelsOnly()
See Also:
setModelsOnly(boolean)

setModelsOnly

public void setModelsOnly(boolean modelsOnly)
Specify whether you want to load just models from the dotScene file. Default behavior is to load lights and environment form the dotScene file (i.e., modesOnly false).

If you set modelsOnly to true before running a load() method, then

This setter must be called between SceneLoader instantiation and .load() invocation.


loadNode

public void loadNode(Node targetJmeNode,
                     org.w3c.dom.Node sourceXmlNode)
              throws java.io.IOException,
                     ModelFormatException
Populates the specified jME Node with data from the specified XML Node.

The Ogre exporter and Blender generally use node-type-specific name spaces for node names. Consequently, the Ogre dotScene exporter generates the same name for nodes and for the first entity child thereof. To maintain jME-preferred scene Spatial name uniqueness, we append the suffix "DotNode" to the node names in the dotScene file.

Parameters:
targetJmeNode - An unpopulated com.jme.scene.Node. We will consitute the node and add its descendants.
sourceXmlNode - XML node which children will be reaped from.
Throws:
java.io.IOException
ModelFormatException

loadExternals

public void loadExternals(org.w3c.dom.Node externals)
                   throws java.io.IOException
Throws:
java.io.IOException

loadEnvironment

public void loadEnvironment(org.w3c.dom.Node env)

load

public void load(org.w3c.dom.Node sceneXmlNode)
          throws java.io.IOException,
                 ModelFormatException
Throws:
java.io.IOException
ModelFormatException

getScene

public Node getScene()
Returns:
a com.jme.scene.Node populated with the aggregation of all load() calls that have been applied to this instance.

load

public void load(java.io.InputStream in)
          throws java.io.IOException,
                 ModelFormatException
Adds data from the specified dotScene file onto a scene node (which may then be retrieved with getScene().

Throws:
java.io.IOException
ModelFormatException
See Also:
getScene()

load

public void load(java.net.URI uri)
          throws java.io.IOException,
                 ModelFormatException
Convenience wrapper

Throws:
java.io.IOException
ModelFormatException
See Also:
load(URL)

load

public void load(java.net.URL url)
          throws java.io.IOException,
                 ModelFormatException
Adds contents of dotScene file at specified URI onto a scene node, automatically adding the containing directory to the resource locator paths for the duration of the load. The scene node may then be retrieved with getScene().

An example of invoking this method for a filesystem file:

  ogreSceneLoader.load(file.toURL());
  

Throws:
java.io.IOException
ModelFormatException
See Also:
getScene(), RelativeResourceLocator

setName

public void setName(java.lang.String newName)
This method is provided so that users can import multiple dotScene files and have unique top-level nodes for each load; or if you just want to specify your own top-level node name.

This method is not necessary for uniqueness purposes if you use the load(URL) method, unless your target URLs happen to have the same file base name (without the preceding path and following suffix).

This setter must be called between SceneLoader instantiation and .load() invocation.


getMaterials

public java.util.Map<java.lang.String,Material> getMaterials()
Use this method to re-use the Materials loaded by this SceneLoader for other purposes, such as to load other dotScene or Mesh files.


addMaterials

public void addMaterials(java.util.Map<java.lang.String,Material> newMaterials)
Reuse an existing Materials collection. Materials files referred to by the dotScene will still be loaded.