com.vwp.j3d.loaders
Class Objects

java.lang.Object
  extended by java.lang.Thread
      extended by com.vwp.j3d.loaders.Objects
All Implemented Interfaces:
Runnable
Direct Known Subclasses:
COBObjects, DXFObjects, OBJObjects, RWXObjects

public abstract class Objects
extends Thread

Base class for all 3D model loaders which are conform to the extended loader interface which includes downloads, local files, caching, defineable quality and so on. As an other difference to the Sun loaders the handed over BranchGroup afterwards contains a more exact BoundingBox instead of a simple BoundingSphere


Nested Class Summary
 
Nested classes/interfaces inherited from class java.lang.Thread
Thread.State, Thread.UncaughtExceptionHandler
 
Field Summary
static int ALLOW_ATTRIBUTES_READ
          Capabilities that are set in the created sub scenegraph: allow reading of attributes
static int ALLOW_COLOR_WRITE
          Capabilities that are set in the created sub scenegraph: allows writing of colors in Attributes
static int ALLOW_MATERIAL_COMPONENT_WRITE
          Capabilities that are set in the created sub scenegraph: allows writing of a Material component
static int ALLOW_MATERIAL_READ
          Capabilities that are set in the created sub scenegraph: allows reading of the Material Attribute
static int ALLOW_POLYGONATTRIBUTES_MODE_WRITE
          Capabilities that are set in the created sub scenegraph: allows writing of the PolygonAttributes mode
static int ALLOW_TEXTURE_ACCESS
          Capabilities that are set in the created sub scenegraph: allows reading and writing of Texture-related properties
static int ALLOW_TRANSFORM_WRITE
          Capabilities that are set in the created sub scenegraph: allows writing of the base TransformGroup
static int FASTEST
          constants which specify the quality settings
static int MEDIUM
          constants which specify the quality settings
 MessagePipe MyMsgPipe
           
static int NICEST
          constants which specify the quality settings
 int Quality
           
 int TextureQuality
           
 Object UserData
           
 
Fields inherited from class java.lang.Thread
MAX_PRIORITY, MIN_PRIORITY, NORM_PRIORITY
 
Constructor Summary
Objects(int Quality, double imgScaleFactor)
          Constructs a new Objects loader class without an DownloadCacheManager and with the default texture searchpath "tex/"
Objects(int Quality, double imgScaleFactor, DownloadCacheManager DownCache)
          Constructs a new Objects loader class with an DownloadCacheManager and with the default texture searchpath "tex/"
Objects(int Quality, double imgScaleFactor, DownloadCacheManager DownCache, String RelativeTexturePath)
          Constructs a new Objects loader class with an DownloadCacheManager and a texture searchpath
Objects(int Quality, double imgScaleFactor, DownloadCacheManager DownCache, String RelativeTexturePath, Object UserData)
          Constructs a new Objects loader class with an DownloadCacheManager and a texture searchpath
Objects(int Quality, double imgScaleFactor, DownloadCacheManager DownCache, String RelativeTexturePath, String RelativeDataPath, Object UserData)
          Constructs a new Objects loader class with an DownloadCacheManager and a texture searchpath
 
Method Summary
 javax.media.j3d.Appearance createAppearance(int CullingFlag)
          Creates and preinitializes a new Appearance object.
 int getCapabilityFlags()
          Returns the currently used capability flags
 byte[] getDataFile(String FileName)
          Tries to load a data file using the disk cache or the download location
 String getFileName()
          Returns the name of the object which is actually processed
 int getQuality()
          Returns the actual model quality settings
 LinkedList getTransformList()
          Returns a list of all transformations within a scene / object
 Object getUserData()
          Returns data whic hhave been attached to this Objects object by using setUserData()
 byte[] loadDataFile(String FileName)
          Tries to load a texture file using the TextureCache, the disk cache or the download location and sets this texture for the given Appearance object.
 boolean loadFile(MessagePipe MyMsgPipe, URL FileURL, XBranchGroup ModelBranch, DataCache MyTextureCache, DataCache MyModelCache, javax.media.j3d.Group ModelBranchParent)
          Invokes downloading of a remote file and interpretion of the loaded data.
 boolean loadFile(String FileName, XBranchGroup ModelBranch, DataCache MyTextureCache)
          Invokes loading of a local file and interpretion of the loaded data
 boolean loadFile(URL FileURL, XBranchGroup ModelBranch, DataCache MyTextureCache)
          Invokes downloading of a remote file and interpretion of the loaded data
 boolean loadFileInBackground(MessagePipe MyMsgPipe, URL FileURL, XBranchGroup ModelBranch, DataCache MyTextureCache, DataCache MyModelCache, javax.media.j3d.Group ModelBranchParent)
          Invokes downloading of a remote file and interpretion of the loaded data using a separate Thread.
 void run()
           
 void setCapabilityFlags(int CapabilityFlags)
          Allowes setting and resetting of the Object-Capability flags defined here using the ALLOW_xxx-constants.
 void setDownloadCacheManager(DownloadCacheManager DownCache)
          Sets a new DownloadCacheManager used for -file-accesses via an URL
 void setMessagePipe(MessagePipe MsgPipe)
          Sets a new MessagePipe
 void setQuality(int Quality, double imgScaleFactor)
          Changes the actual model quality settings
 void setRelativeTexturePath(String RelativeTexturePath)
          Sets a new RelativeTexturePath which is used for textures defined in a file
 boolean setTexture(String FileName, javax.media.j3d.Appearance UseApp, int TexLoaderFlags)
          Tries to load a texture file using the TextureCache, the disk cache or the download location and sets this texture for the given Appearance object.
 void setTextureQuality(int TextureQuality)
          Changes the actual texture quality settings, this value influences the minification and maxification texture filter
 void setUserData(Object UserData)
          Attaches user defineable data to the Objects object.
 void stopThread()
          Replaces the stop() method to implement an abort condition.
 
Methods inherited from class java.lang.Thread
activeCount, checkAccess, countStackFrames, currentThread, destroy, dumpStack, enumerate, getAllStackTraces, getContextClassLoader, getDefaultUncaughtExceptionHandler, getId, getName, getPriority, getStackTrace, getState, getThreadGroup, getUncaughtExceptionHandler, holdsLock, interrupt, interrupted, isAlive, isDaemon, isInterrupted, join, join, join, resume, setContextClassLoader, setDaemon, setDefaultUncaughtExceptionHandler, setName, setPriority, setUncaughtExceptionHandler, sleep, sleep, start, stop, stop, suspend, toString, yield
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

FASTEST

public static final int FASTEST
constants which specify the quality settings

See Also:
Constant Field Values

MEDIUM

public static final int MEDIUM
constants which specify the quality settings

See Also:
Constant Field Values

NICEST

public static final int NICEST
constants which specify the quality settings

See Also:
Constant Field Values

ALLOW_ATTRIBUTES_READ

public static final int ALLOW_ATTRIBUTES_READ
Capabilities that are set in the created sub scenegraph: allow reading of attributes

See Also:
Constant Field Values

ALLOW_POLYGONATTRIBUTES_MODE_WRITE

public static final int ALLOW_POLYGONATTRIBUTES_MODE_WRITE
Capabilities that are set in the created sub scenegraph: allows writing of the PolygonAttributes mode

See Also:
Constant Field Values

ALLOW_COLOR_WRITE

public static final int ALLOW_COLOR_WRITE
Capabilities that are set in the created sub scenegraph: allows writing of colors in Attributes

See Also:
Constant Field Values

ALLOW_TRANSFORM_WRITE

public static final int ALLOW_TRANSFORM_WRITE
Capabilities that are set in the created sub scenegraph: allows writing of the base TransformGroup

See Also:
Constant Field Values

ALLOW_MATERIAL_COMPONENT_WRITE

public static final int ALLOW_MATERIAL_COMPONENT_WRITE
Capabilities that are set in the created sub scenegraph: allows writing of a Material component

See Also:
Constant Field Values

ALLOW_TEXTURE_ACCESS

public static final int ALLOW_TEXTURE_ACCESS
Capabilities that are set in the created sub scenegraph: allows reading and writing of Texture-related properties

See Also:
Constant Field Values

ALLOW_MATERIAL_READ

public static final int ALLOW_MATERIAL_READ
Capabilities that are set in the created sub scenegraph: allows reading of the Material Attribute

See Also:
Constant Field Values

UserData

public Object UserData

MyMsgPipe

public MessagePipe MyMsgPipe

Quality

public int Quality

TextureQuality

public int TextureQuality
Constructor Detail

Objects

public Objects(int Quality,
               double imgScaleFactor)
Constructs a new Objects loader class without an DownloadCacheManager and with the default texture searchpath "tex/"

Parameters:
Quality - quality setting for all subsequent objects
imgScaleFactor - specifies by which the textures have to be prescaled, values > 0.0 and <= 1.0 are meaningful here to save graphics memory on systems with less powerful hardware

Objects

public Objects(int Quality,
               double imgScaleFactor,
               DownloadCacheManager DownCache)
Constructs a new Objects loader class with an DownloadCacheManager and with the default texture searchpath "tex/"

Parameters:
Quality - quality setting for all subsequent objects
imgScaleFactor - specifies by which the textures have to be prescaled, values > 0.0 and <= 1.0 are meaningful here to save graphics memory on systems with less powerful hardware
DownCache - specifies a caching manager object which handles caching of 3D objects which are downloaded from network and not directly from a local disk

Objects

public Objects(int Quality,
               double imgScaleFactor,
               DownloadCacheManager DownCache,
               String RelativeTexturePath)
Constructs a new Objects loader class with an DownloadCacheManager and a texture searchpath

Parameters:
Quality - quality setting for all subsequent objects
imgScaleFactor - specifies by which the textures have to be prescaled, values > 0.0 and <= 1.0 are meaningful here to save graphics memory on systems with less powerful hardware
DownCache - specifies a caching manager object which handles caching of 3D objects which are downloaded from network and not directly from a local disk
RelativeTexturePath - specifies where textures of downloaded 3D objects can be found relative to the location of the object, default is "tex/"

Objects

public Objects(int Quality,
               double imgScaleFactor,
               DownloadCacheManager DownCache,
               String RelativeTexturePath,
               Object UserData)
Constructs a new Objects loader class with an DownloadCacheManager and a texture searchpath

Parameters:
Quality - quality setting for all subsequent objects
imgScaleFactor - specifies by which the textures have to be prescaled, values > 0.0 and <= 1.0 are meaningful here to save graphics memory on systems with less powerful hardware
DownCache - specifies a caching manager object which handles caching of 3D objects which are downloaded from network and not directly from a local disk
RelativeTexturePath - specifies where textures of downloaded 3D objects can be found relative to the location of the object, default is "tex/"
UserData - special user data which are appended to the new object

Objects

public Objects(int Quality,
               double imgScaleFactor,
               DownloadCacheManager DownCache,
               String RelativeTexturePath,
               String RelativeDataPath,
               Object UserData)
Constructs a new Objects loader class with an DownloadCacheManager and a texture searchpath

Parameters:
Quality - quality setting for all subsequent objects
imgScaleFactor - specifies by which the textures have to be prescaled, values > 0.0 and <= 1.0 are meaningful here to save graphics memory on systems with less powerful hardware
DownCache - specifies a caching manager object which handles caching of 3D objects which are downloaded from network and not directly from a local disk
RelativeTexturePath - specifies where textures of downloaded 3D objects can be found relative to the location of the object, default is "tex/"
RelativeDataPath - specifies where special data like animation information, material libs etc. for the downloaded 3D objects can be found relative to the location of the object, default is "dat/"
UserData - special user data which are appended to the new object
Method Detail

setCapabilityFlags

public void setCapabilityFlags(int CapabilityFlags)
Allowes setting and resetting of the Object-Capability flags defined here using the ALLOW_xxx-constants. Comparing to the Java3D standard capabilities these ones are real flags that have to be set and unset all together using one function call

Parameters:
CapabilityFlags - the flags that have to be set, use the OR-concatenated ALLOW_xxx constants here to enable a capability

getCapabilityFlags

public int getCapabilityFlags()
Returns the currently used capability flags

Returns:
an OR-concatenated combination of the ALLOW_xxx capability flags

setUserData

public void setUserData(Object UserData)
Attaches user defineable data to the Objects object. This method can be used e.g. to attach data which allow identifying of specific Objects after it was executed in background. The data can be fetched using @see getUserData()

Parameters:
UserData - the data which have to be attached to this object

getUserData

public Object getUserData()
Returns data whic hhave been attached to this Objects object by using setUserData()


getFileName

public String getFileName()
Returns the name of the object which is actually processed


setQuality

public void setQuality(int Quality,
                       double imgScaleFactor)
Changes the actual model quality settings

Parameters:
Quality - specifies the quality of the object which has to be loaded using the constants FASTEST, MEDIUM or NICEST
imgScaleFactor - specifies by which the textures have to be prescaled, values > 0.0 and <= 1.0 are meaningful here to save graphics memory on systems with less powerful hardware

getQuality

public int getQuality()
Returns the actual model quality settings

Returns:
the quality of the object which has to be loaded using the constants FASTEST, MEDIUM or NICEST

setTextureQuality

public void setTextureQuality(int TextureQuality)
Changes the actual texture quality settings, this value influences the minification and maxification texture filter

Parameters:
TextureQuality - specifies the texture quality of the object which has to be loaded using the constants FASTEST, MEDIUM or NICEST

stopThread

public void stopThread()
Replaces the stop() method to implement an abort condition. When stopThread is true, the main loop wil be left as soon as possible


setDownloadCacheManager

public void setDownloadCacheManager(DownloadCacheManager DownCache)
Sets a new DownloadCacheManager used for -file-accesses via an URL

Parameters:
DownCache - specifies a caching manager object which handles caching of 3D objects which are downloaded from network and not directly from a local disk

setMessagePipe

public void setMessagePipe(MessagePipe MsgPipe)
Sets a new MessagePipe

Parameters:
MsgPipe - the new MessagePipe

setRelativeTexturePath

public void setRelativeTexturePath(String RelativeTexturePath)
Sets a new RelativeTexturePath which is used for textures defined in a file

Parameters:
RelativeTexturePath - specifies where textures of downloaded 3D objects can be found relative to the location of the object, default is "tex/"

createAppearance

public javax.media.j3d.Appearance createAppearance(int CullingFlag)
Creates and preinitializes a new Appearance object. The Coloring- or Texture-Attributes are removed within addObjectFragment() if they aren't needed

Parameters:
CullingFlag - specifies which culling shall be performed; here CULL_NONE, CULL_BACK or CULL_FRONT from PolygonAttributes has to be set
Returns:
the preinitialized Appearance-Object

getDataFile

public byte[] getDataFile(String FileName)
Tries to load a data file using the disk cache or the download location

Parameters:
FileName - name/file name of the data file
Returns:
the (down)loaded data or null if this method failed

setTexture

public boolean setTexture(String FileName,
                          javax.media.j3d.Appearance UseApp,
                          int TexLoaderFlags)
Tries to load a texture file using the TextureCache, the disk cache or the download location and sets this texture for the given Appearance object.

Parameters:
FileName - name/file name of the texture
UseApp - Appearance object which requires this texture
Returns:
specifies if the function has been executed successfully

loadDataFile

public byte[] loadDataFile(String FileName)
Tries to load a texture file using the TextureCache, the disk cache or the download location and sets this texture for the given Appearance object.

Parameters:
FileName - name/file name of the texture
Returns:
specifies if the function has been executed successfully

loadFile

public boolean loadFile(MessagePipe MyMsgPipe,
                        URL FileURL,
                        XBranchGroup ModelBranch,
                        DataCache MyTextureCache,
                        DataCache MyModelCache,
                        javax.media.j3d.Group ModelBranchParent)
Invokes downloading of a remote file and interpretion of the loaded data. Because the given BranchGroup object can contain an object and / or can be live or compiled the handling is tricky. Together with the code in method run() the parameters are used for following purposes:

Parameters:
MyMsgPipe - MessagePipe object to transfer error or other messages from the thread to the main program; if this isn'd neccessary this parameter can be set to 0
FileURL - URL of the object to download
ModelBranch - the BranchGroup where to append the object, this BranchGroup is used in run() and replaced by an other, internal object until then
MyTextureCache - used to cache objects textures
MyModelCache - used in run() to insert this object into the cache for later usage
ModelBranchParent - the parent Group object of the ModelBranch object (typically an TransformGroup object), this already live / compiled object is used to detach the temporarily ModelBranch and to add the new created BranchGroup object which contains the loaded object

loadFileInBackground

public boolean loadFileInBackground(MessagePipe MyMsgPipe,
                                    URL FileURL,
                                    XBranchGroup ModelBranch,
                                    DataCache MyTextureCache,
                                    DataCache MyModelCache,
                                    javax.media.j3d.Group ModelBranchParent)
Invokes downloading of a remote file and interpretion of the loaded data using a separate Thread. Because the given BranchGroup object can contain an object and / or can be live or compiled the handling is a little bit tricky. Together with the code in method run() the parameters are used for following purposes:

Parameters:
MyMsgPipe - MessagePipe object to transfer error or other messages from the thread to the main program; if this isn'd neccessary this parameter can be set to 0
FileURL - URL of the object to download
ModelBranch - the BranchGroup where to append the object, this BranchGroup is used in run() and replaced by an other, internal object until then
MyTextureCache - used to cache objects textures
MyModelCache - used in run() to insert this object into the cache for later usage
ModelBranchParent - the parent Group object of the ModelBranch object (typically an TransformGroup object), this already live / compiled object is used to detach the temporarily ModelBranch and to add the new created BranchGroup object which contains the loaded object

run

public void run()
Specified by:
run in interface Runnable
Overrides:
run in class Thread

loadFile

public boolean loadFile(URL FileURL,
                        XBranchGroup ModelBranch,
                        DataCache MyTextureCache)
Invokes downloading of a remote file and interpretion of the loaded data

Parameters:
FileURL - URL of the object to download
ModelBranch - the BranchGroup where to append the object, this BranchGroup is used in run() and replaced by an other, internal object until then
MyTextureCache - used to cache objects textures

loadFile

public boolean loadFile(String FileName,
                        XBranchGroup ModelBranch,
                        DataCache MyTextureCache)
Invokes loading of a local file and interpretion of the loaded data

Parameters:
FileName - pathname of the object which has to be loaded from disk
ModelBranch - the BranchGroup where to append the object, this BranchGroup is used in run() and replaced by an other, internal object until then
MyTextureCache - used to cache objects textures

getTransformList

public LinkedList getTransformList()
Returns a list of all transformations within a scene / object

Returns:
A LinkedList which contains all relevant TransfromGroups of the loaded model. All relevant TransfromGroups means that only these are listed within the LinkedList which influence visible parts of the model. Axises and other means are not shown and so their transformations aren't listed here.
The TransfromGroups contained in the returned LinkedList can be identified using the object returned by getUserData(). This object is a String which is equal to the models identifier of the related transformation.