Sweet Home 3D 4.1

com.eteks.sweethome3d.j3d
Class ModelManager

java.lang.Object
  extended by com.eteks.sweethome3d.j3d.ModelManager

public class ModelManager
extends Object

Singleton managing 3D models cache. This manager supports 3D models with an OBJ, DAE, 3DS or LWS format by default. Additional classes implementing Java 3D Loader interface may be specified in the com.eteks.sweethome3d.j3d.additionalLoaderClasses (separated by a space or a colon :) to enable the support of other formats.
Note: this class is compatible with Java 3D 1.3.

Author:
Emmanuel Puybaret

Nested Class Summary
static interface ModelManager.ModelObserver
          An observer that receives model loading notifications.
 
Field Summary
static String LIGHT_SHAPE_PREFIX
          Shape3D user data prefix for lights.
static String MIRROR_SHAPE_PREFIX
          Shape3D user data prefix for mirror shapes.
static String WINDOW_PANE_SHAPE_PREFIX
          Shape3D user data prefix for window pane shapes.
 
Method Summary
 void checkAppearancesName(Node node)
          Ensures that all the appearance of the children shapes of the given node have a name.
 void clear()
          Shutdowns the multithreaded service that load textures.
 Node cloneNode(Node node)
          Returns a clone of the given node.
 Area getAreaOnFloor(HomePieceOfFurniture staircase)
          Returns the area on the floor of the given staircase.
 Area getAreaOnFloor(Node node)
          Returns the 2D area of the 3D shapes children of the given node projected on the floor (plan y = 0).
 BoundingBox getBounds(Node node)
          Returns the bounds of the 3D shapes of node.
 BoundingBox getBounds(Node node, Transform3D transformation)
          Returns the bounds of the 3D shapes of node with an additional transformation.
static ModelManager getInstance()
          Returns an instance of this singleton.
 HomeMaterial[] getMaterials(Node node)
          Returns the materials used by the children shapes of the given node.
 Transform3D getNormalizedTransform(Node node, float[][] modelRotation, float width)
          Returns a transform that will transform the model node to let it fill a box of the given width centered on the origin.
 TransformGroup getNormalizedTransformGroup(Node node, float[][] modelRotation, float width)
          Returns a transform group that will transform the model node to let it fill a box of the given width centered on the origin.
 Vector3f getSize(Node node)
          Returns the size of 3D shapes of node.
 Vector3f getSize(Node node, Transform3D transformation)
          Returns the size of 3D shapes of node after an additional transformation.
 BranchGroup loadModel(Content content)
          Returns the node loaded synchronously from content with supported loaders.
 void loadModel(Content content, boolean synchronous, ModelManager.ModelObserver modelObserver)
          Reads a 3D node from content with supported loaders and notifies the loaded model to the given modelObserver once available.
 void loadModel(Content content, ModelManager.ModelObserver modelObserver)
          Reads asynchronously a 3D node from content with supported loaders and notifies the loaded model to the given modelObserver once available.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

WINDOW_PANE_SHAPE_PREFIX

public static final String WINDOW_PANE_SHAPE_PREFIX
Shape3D user data prefix for window pane shapes.

See Also:
Constant Field Values

MIRROR_SHAPE_PREFIX

public static final String MIRROR_SHAPE_PREFIX
Shape3D user data prefix for mirror shapes.

See Also:
Constant Field Values

LIGHT_SHAPE_PREFIX

public static final String LIGHT_SHAPE_PREFIX
Shape3D user data prefix for lights.

See Also:
Constant Field Values
Method Detail

getInstance

public static ModelManager getInstance()
Returns an instance of this singleton.


clear

public void clear()
Shutdowns the multithreaded service that load textures.


getSize

public Vector3f getSize(Node node)
Returns the size of 3D shapes of node. This method computes the exact box that contains all the shapes, contrary to node.getBounds() that returns a bounding sphere for a scene.


getSize

public Vector3f getSize(Node node,
                        Transform3D transformation)
Returns the size of 3D shapes of node after an additional transformation. This method computes the exact box that contains all the shapes, contrary to node.getBounds() that returns a bounding sphere for a scene.


getBounds

public BoundingBox getBounds(Node node)
Returns the bounds of the 3D shapes of node. This method computes the exact box that contains all the shapes, contrary to node.getBounds() that returns a bounding sphere for a scene.


getBounds

public BoundingBox getBounds(Node node,
                             Transform3D transformation)
Returns the bounds of the 3D shapes of node with an additional transformation. This method computes the exact box that contains all the shapes, contrary to node.getBounds() that returns a bounding sphere for a scene.


getNormalizedTransformGroup

public TransformGroup getNormalizedTransformGroup(Node node,
                                                  float[][] modelRotation,
                                                  float width)
Returns a transform group that will transform the model node to let it fill a box of the given width centered on the origin.

Parameters:
node - the root of a model with any size and location
modelRotation - the rotation applied to the model before normalization or null if no transformation should be applied to node.
width - the width of the box

getNormalizedTransform

public Transform3D getNormalizedTransform(Node node,
                                          float[][] modelRotation,
                                          float width)
Returns a transform that will transform the model node to let it fill a box of the given width centered on the origin.

Parameters:
node - the root of a model with any size and location
modelRotation - the rotation applied to the model before normalization or null if no transformation should be applied to node.
width - the width of the box

loadModel

public void loadModel(Content content,
                      ModelManager.ModelObserver modelObserver)
Reads asynchronously a 3D node from content with supported loaders and notifies the loaded model to the given modelObserver once available.

Parameters:
content - an object containing a model
modelObserver - the observer that will be notified once the model is available or if an error happens
Throws:
IllegalStateException - if the current thread isn't the Event Dispatch Thread.

loadModel

public void loadModel(Content content,
                      boolean synchronous,
                      ModelManager.ModelObserver modelObserver)
Reads a 3D node from content with supported loaders and notifies the loaded model to the given modelObserver once available.

Parameters:
content - an object containing a model
synchronous - if true, this method will return only once model content is loaded
modelObserver - the observer that will be notified once the model is available or if an error happens. When the model is loaded synchronously, the observer will be notified in the same thread as the caller, otherwise the observer will be notified in the Event Dispatch Thread and this method must be called in Event Dispatch Thread too.
Throws:
IllegalStateException - if synchronous is false and the current thread isn't the Event Dispatch Thread.

cloneNode

public Node cloneNode(Node node)
Returns a clone of the given node. All the children and the attributes of the given node are duplicated except the geometries and the texture images of shapes.


loadModel

public BranchGroup loadModel(Content content)
                      throws IOException
Returns the node loaded synchronously from content with supported loaders. This method is threadsafe and may be called from any thread.

Parameters:
content - an object containing a model
Throws:
IOException

checkAppearancesName

public void checkAppearancesName(Node node)
Ensures that all the appearance of the children shapes of the given node have a name.


getMaterials

public HomeMaterial[] getMaterials(Node node)
Returns the materials used by the children shapes of the given node.


getAreaOnFloor

public Area getAreaOnFloor(Node node)
Returns the 2D area of the 3D shapes children of the given node projected on the floor (plan y = 0).


getAreaOnFloor

public Area getAreaOnFloor(HomePieceOfFurniture staircase)
Returns the area on the floor of the given staircase.


Sweet Home 3D 4.1

© Copyrights 2006-2013 eTeks - All rights reserved
Distributed under GNU General Public License