@ -31,6 +31,16 @@
* /
* /
package com.jme3.scene.plugins.blender ;
package com.jme3.scene.plugins.blender ;
import java.io.IOException ;
import java.util.ArrayList ;
import java.util.EmptyStackException ;
import java.util.HashMap ;
import java.util.List ;
import java.util.Map ;
import java.util.Stack ;
import java.util.logging.Level ;
import java.util.logging.Logger ;
import com.jme3.asset.AssetManager ;
import com.jme3.asset.AssetManager ;
import com.jme3.asset.BlenderKey ;
import com.jme3.asset.BlenderKey ;
import com.jme3.material.Material ;
import com.jme3.material.Material ;
@ -44,446 +54,538 @@ import com.jme3.scene.plugins.blender.file.Structure;
import com.jme3.scene.plugins.blender.materials.MaterialContext ;
import com.jme3.scene.plugins.blender.materials.MaterialContext ;
import com.jme3.scene.plugins.blender.meshes.MeshContext ;
import com.jme3.scene.plugins.blender.meshes.MeshContext ;
import com.jme3.scene.plugins.blender.modifiers.Modifier ;
import com.jme3.scene.plugins.blender.modifiers.Modifier ;
import java.io.IOException ;
import com.jme3.scene.plugins.ogre.AnimData ;
import java.util.* ;
import java.util.logging.Level ;
import java.util.logging.Logger ;
/ * *
/ * *
* The class that stores temporary data and manages it during loading the belnd file . This class is intended to be used
* The class that stores temporary data and manages it during loading the belnd
* in a single loading thread . It holds the state of loading operations .
* file . This class is intended to be used in a single loading thread . It holds
* the state of loading operations .
*
* @author Marcin Roguski ( Kaelthas )
* @author Marcin Roguski ( Kaelthas )
* /
* /
public class BlenderContext {
public class BlenderContext {
private static final Logger LOGGER = Logger . getLogger ( BlenderContext . class . getName ( ) ) ;
private static final Logger LOGGER = Logger . getLogger ( BlenderContext . class . getName ( ) ) ;
/** The blender key. */
/** The blender key. */
private BlenderKey blenderKey ;
private BlenderKey blenderKey ;
/** The header of the file block. */
/** The header of the file block. */
private DnaBlockData dnaBlockData ;
private DnaBlockData dnaBlockData ;
/** The input stream of the blend file. */
/** The input stream of the blend file. */
private BlenderInputStream inputStream ;
private BlenderInputStream inputStream ;
/** The asset manager. */
/** The asset manager. */
private AssetManager assetManager ;
private AssetManager assetManager ;
/** A map containing the file block headers. The key is the old pointer address. */
/ * *
private Map < Long , FileBlockHeader > fileBlockHeadersByOma = new HashMap < Long , FileBlockHeader > ( ) ;
* A map containing the file block headers . The key is the old pointer
/** A map containing the file block headers. The key is the block code. */
* address .
private Map < Integer , List < FileBlockHeader > > fileBlockHeadersByCode = new HashMap < Integer , List < FileBlockHeader > > ( ) ;
* /
/ * *
private Map < Long , FileBlockHeader > fileBlockHeadersByOma = new HashMap < Long , FileBlockHeader > ( ) ;
* This map stores the loaded features by their old memory address . The first object in the value table is the
/** A map containing the file block headers. The key is the block code. */
* loaded structure and the second - the structure already converted into proper data .
private Map < Integer , List < FileBlockHeader > > fileBlockHeadersByCode = new HashMap < Integer , List < FileBlockHeader > > ( ) ;
* /
/ * *
private Map < Long , Object [ ] > loadedFeatures = new HashMap < Long , Object [ ] > ( ) ;
* This map stores the loaded features by their old memory address . The
/ * *
* first object in the value table is the loaded structure and the second -
* This map stores the loaded features by their name . Only features with ID structure can be stored here .
* the structure already converted into proper data .
* The first object in the value table is the
* /
* loaded structure and the second - the structure already converted into proper data .
private Map < Long , Object [ ] > loadedFeatures = new HashMap < Long , Object [ ] > ( ) ;
* /
/ * *
private Map < String , Object [ ] > loadedFeaturesByName = new HashMap < String , Object [ ] > ( ) ;
* This map stores the loaded features by their name . Only features with ID
/** A stack that hold the parent structure of currently loaded feature. */
* structure can be stored here . The first object in the value table is the
private Stack < Structure > parentStack = new Stack < Structure > ( ) ;
* loaded structure and the second - the structure already converted into
/** A map storing loaded ipos. The key is the ipo's owner old memory address and the value is the ipo. */
* proper data .
private Map < Long , Ipo > loadedIpos = new HashMap < Long , Ipo > ( ) ;
* /
/** A list of modifiers for the specified object. */
private Map < String , Object [ ] > loadedFeaturesByName = new HashMap < String , Object [ ] > ( ) ;
protected Map < Long , List < Modifier > > modifiers = new HashMap < Long , List < Modifier > > ( ) ;
/** A stack that hold the parent structure of currently loaded feature. */
/** A list of constraints for the specified object. */
private Stack < Structure > parentStack = new Stack < Structure > ( ) ;
protected Map < Long , List < Constraint > > constraints = new HashMap < Long , List < Constraint > > ( ) ;
/ * *
/** A map of mesh contexts. */
* A map storing loaded ipos . The key is the ipo ' s owner old memory address
protected Map < Long , MeshContext > meshContexts = new HashMap < Long , MeshContext > ( ) ;
* and the value is the ipo .
/** A map of material contexts. */
* /
protected Map < Material , MaterialContext > materialContexts = new HashMap < Material , MaterialContext > ( ) ;
private Map < Long , Ipo > loadedIpos = new HashMap < Long , Ipo > ( ) ;
/** A map og helpers that perform loading. */
/** A list of modifiers for the specified object. */
private Map < String , AbstractBlenderHelper > helpers = new HashMap < String , AbstractBlenderHelper > ( ) ;
protected Map < Long , List < Modifier > > modifiers = new HashMap < Long , List < Modifier > > ( ) ;
/** A list of constraints for the specified object. */
/ * *
protected Map < Long , List < Constraint > > constraints = new HashMap < Long , List < Constraint > > ( ) ;
* This method sets the blender key .
/** Anim data loaded for features. */
* @param blenderKey
private Map < Long , AnimData > animData = new HashMap < Long , AnimData > ( ) ;
* the blender key
/** A map of mesh contexts. */
* /
protected Map < Long , MeshContext > meshContexts = new HashMap < Long , MeshContext > ( ) ;
public void setBlenderKey ( BlenderKey blenderKey ) {
/** A map of material contexts. */
this . blenderKey = blenderKey ;
protected Map < Material , MaterialContext > materialContexts = new HashMap < Material , MaterialContext > ( ) ;
}
/** A map og helpers that perform loading. */
private Map < String , AbstractBlenderHelper > helpers = new HashMap < String , AbstractBlenderHelper > ( ) ;
/ * *
* This method returns the blender key .
/ * *
* @return the blender key
* This method sets the blender key .
* /
*
public BlenderKey getBlenderKey ( ) {
* @param blenderKey
return blenderKey ;
* the blender key
}
* /
public void setBlenderKey ( BlenderKey blenderKey ) {
/ * *
this . blenderKey = blenderKey ;
* This method sets the dna block data .
}
* @param dnaBlockData
* the dna block data
/ * *
* /
* This method returns the blender key .
public void setBlockData ( DnaBlockData dnaBlockData ) {
*
this . dnaBlockData = dnaBlockData ;
* @return the blender key
}
* /
public BlenderKey getBlenderKey ( ) {
/ * *
return blenderKey ;
* This method returns the dna block data .
}
* @return the dna block data
* /
/ * *
public DnaBlockData getDnaBlockData ( ) {
* This method sets the dna block data .
return dnaBlockData ;
*
}
* @param dnaBlockData
* the dna block data
/ * *
* /
* This method returns the asset manager .
public void setBlockData ( DnaBlockData dnaBlockData ) {
* @return the asset manager
this . dnaBlockData = dnaBlockData ;
* /
}
public AssetManager getAssetManager ( ) {
return assetManager ;
/ * *
}
* This method returns the dna block data .
*
/ * *
* @return the dna block data
* This method sets the asset manager .
* /
* @param assetManager
public DnaBlockData getDnaBlockData ( ) {
* the asset manager
return dnaBlockData ;
* /
}
public void setAssetManager ( AssetManager assetManager ) {
this . assetManager = assetManager ;
/ * *
}
* This method returns the asset manager .
*
/ * *
* @return the asset manager
* This method returns the input stream of the blend file .
* /
* @return the input stream of the blend file
public AssetManager getAssetManager ( ) {
* /
return assetManager ;
public BlenderInputStream getInputStream ( ) {
}
return inputStream ;
}
/ * *
* This method sets the asset manager .
/ * *
*
* This method sets the input stream of the blend file .
* @param assetManager
* @param inputStream
* the asset manager
* the input stream of the blend file
* /
* /
public void setAssetManager ( AssetManager assetManager ) {
public void setInputStream ( BlenderInputStream inputStream ) {
this . assetManager = assetManager ;
this . inputStream = inputStream ;
}
}
/ * *
/ * *
* This method returns the input stream of the blend file .
* This method adds a file block header to the map . Its old memory address is the key .
*
* @param oldMemoryAddress
* @return the input stream of the blend file
* the address of the block header
* /
* @param fileBlockHeader
public BlenderInputStream getInputStream ( ) {
* the block header to store
return inputStream ;
* /
}
public void addFileBlockHeader ( Long oldMemoryAddress , FileBlockHeader fileBlockHeader ) {
fileBlockHeadersByOma . put ( oldMemoryAddress , fileBlockHeader ) ;
/ * *
List < FileBlockHeader > headers = fileBlockHeadersByCode . get ( Integer . valueOf ( fileBlockHeader . getCode ( ) ) ) ;
* This method sets the input stream of the blend file .
if ( headers = = null ) {
*
headers = new ArrayList < FileBlockHeader > ( ) ;
* @param inputStream
fileBlockHeadersByCode . put ( Integer . valueOf ( fileBlockHeader . getCode ( ) ) , headers ) ;
* the input stream of the blend file
}
* /
headers . add ( fileBlockHeader ) ;
public void setInputStream ( BlenderInputStream inputStream ) {
}
this . inputStream = inputStream ;
}
/ * *
* This method returns the block header of a given memory address . If the header is not present then null is
/ * *
* returned .
* This method adds a file block header to the map . Its old memory address
* @param oldMemoryAddress
* is the key .
* the address of the block header
*
* @return loaded header or null if it was not yet loaded
* @param oldMemoryAddress
* /
* the address of the block header
public FileBlockHeader getFileBlock ( Long oldMemoryAddress ) {
* @param fileBlockHeader
return fileBlockHeadersByOma . get ( oldMemoryAddress ) ;
* the block header to store
}
* /
public void addFileBlockHeader ( Long oldMemoryAddress , FileBlockHeader fileBlockHeader ) {
/ * *
fileBlockHeadersByOma . put ( oldMemoryAddress , fileBlockHeader ) ;
* This method returns a list of file blocks ' headers of a specified code .
List < FileBlockHeader > headers = fileBlockHeadersByCode . get ( Integer . valueOf ( fileBlockHeader . getCode ( ) ) ) ;
* @param code
if ( headers = = null ) {
* the code of file blocks
headers = new ArrayList < FileBlockHeader > ( ) ;
* @return a list of file blocks ' headers of a specified code
fileBlockHeadersByCode . put ( Integer . valueOf ( fileBlockHeader . getCode ( ) ) , headers ) ;
* /
}
public List < FileBlockHeader > getFileBlocks ( Integer code ) {
headers . add ( fileBlockHeader ) ;
return fileBlockHeadersByCode . get ( code ) ;
}
}
/ * *
/ * *
* This method returns the block header of a given memory address . If the
* This method clears the saved block headers stored in the features map .
* header is not present then null is returned .
* /
*
public void clearFileBlocks ( ) {
* @param oldMemoryAddress
fileBlockHeadersByOma . clear ( ) ;
* the address of the block header
fileBlockHeadersByCode . clear ( ) ;
* @return loaded header or null if it was not yet loaded
}
* /
public FileBlockHeader getFileBlock ( Long oldMemoryAddress ) {
/ * *
return fileBlockHeadersByOma . get ( oldMemoryAddress ) ;
* This method adds a helper instance to the helpers ' map .
}
* @param < T >
* the type of the helper
/ * *
* @param clazz
* This method returns a list of file blocks ' headers of a specified code .
* helper ' s class definition
*
* @param helper
* @param code
* the helper instance
* the code of file blocks
* /
* @return a list of file blocks ' headers of a specified code
public < T > void putHelper ( Class < T > clazz , AbstractBlenderHelper helper ) {
* /
helpers . put ( clazz . getSimpleName ( ) , helper ) ;
public List < FileBlockHeader > getFileBlocks ( Integer code ) {
}
return fileBlockHeadersByCode . get ( code ) ;
}
@SuppressWarnings ( "unchecked" )
public < T > T getHelper ( Class < ? > clazz ) {
/ * *
return ( T ) helpers . get ( clazz . getSimpleName ( ) ) ;
* This method clears the saved block headers stored in the features map .
}
* /
public void clearFileBlocks ( ) {
/ * *
fileBlockHeadersByOma . clear ( ) ;
* This method adds a loaded feature to the map . The key is its unique old memory address .
fileBlockHeadersByCode . clear ( ) ;
* @param oldMemoryAddress
}
* the address of the feature
* @param featureName the name of the feature
/ * *
* @param structure
* This method adds a helper instance to the helpers ' map .
* the filled structure of the feature
*
* @param feature
* @param < T >
* the feature we want to store
* the type of the helper
* /
* @param clazz
public void addLoadedFeatures ( Long oldMemoryAddress , String featureName , Structure structure , Object feature ) {
* helper ' s class definition
if ( oldMemoryAddress = = null | | structure = = null | | feature = = null ) {
* @param helper
throw new IllegalArgumentException ( "One of the given arguments is null!" ) ;
* the helper instance
}
* /
Object [ ] storedData = new Object [ ] { structure , feature } ;
public < T > void putHelper ( Class < T > clazz , AbstractBlenderHelper helper ) {
loadedFeatures . put ( oldMemoryAddress , storedData ) ;
helpers . put ( clazz . getSimpleName ( ) , helper ) ;
if ( featureName ! = null ) {
}
loadedFeaturesByName . put ( featureName , storedData ) ;
}
@SuppressWarnings ( "unchecked" )
}
public < T > T getHelper ( Class < ? > clazz ) {
return ( T ) helpers . get ( clazz . getSimpleName ( ) ) ;
/ * *
}
* This method returns the feature of a given memory address . If the feature is not yet loaded then null is
* returned .
/ * *
* @param oldMemoryAddress
* This method adds a loaded feature to the map . The key is its unique old
* the address of the feature
* memory address .
* @param loadedFeatureDataType
*
* the type of data we want to retreive it can be either filled structure or already converted feature
* @param oldMemoryAddress
* @return loaded feature or null if it was not yet loaded
* the address of the feature
* /
* @param featureName
public Object getLoadedFeature ( Long oldMemoryAddress , LoadedFeatureDataType loadedFeatureDataType ) {
* the name of the feature
Object [ ] result = loadedFeatures . get ( oldMemoryAddress ) ;
* @param structure
if ( result ! = null ) {
* the filled structure of the feature
return result [ loadedFeatureDataType . getIndex ( ) ] ;
* @param feature
}
* the feature we want to store
return null ;
* /
}
public void addLoadedFeatures ( Long oldMemoryAddress , String featureName , Structure structure , Object feature ) {
if ( oldMemoryAddress = = null | | structure = = null | | feature = = null ) {
/ * *
throw new IllegalArgumentException ( "One of the given arguments is null!" ) ;
* This method returns the feature of a given name . If the feature is not yet loaded then null is
}
* returned .
Object [ ] storedData = new Object [ ] { structure , feature } ;
* @param featureName
loadedFeatures . put ( oldMemoryAddress , storedData ) ;
* the name of the feature
if ( featureName ! = null ) {
* @param loadedFeatureDataType
loadedFeaturesByName . put ( featureName , storedData ) ;
* the type of data we want to retreive it can be either filled structure or already converted feature
}
* @return loaded feature or null if it was not yet loaded
}
* /
public Object getLoadedFeature ( String featureName , LoadedFeatureDataType loadedFeatureDataType ) {
/ * *
Object [ ] result = loadedFeaturesByName . get ( featureName ) ;
* This method returns the feature of a given memory address . If the feature
if ( result ! = null ) {
* is not yet loaded then null is returned .
return result [ loadedFeatureDataType . getIndex ( ) ] ;
*
}
* @param oldMemoryAddress
return null ;
* the address of the feature
}
* @param loadedFeatureDataType
* the type of data we want to retreive it can be either filled
/ * *
* structure or already converted feature
* This method clears the saved features stored in the features map .
* @return loaded feature or null if it was not yet loaded
* /
* /
public void clearLoadedFeatures ( ) {
public Object getLoadedFeature ( Long oldMemoryAddress , LoadedFeatureDataType loadedFeatureDataType ) {
loadedFeatures . clear ( ) ;
Object [ ] result = loadedFeatures . get ( oldMemoryAddress ) ;
}
if ( result ! = null ) {
return result [ loadedFeatureDataType . getIndex ( ) ] ;
/ * *
}
* This method adds the structure to the parent stack .
return null ;
* @param parent
}
* the structure to be added to the stack
* /
/ * *
public void pushParent ( Structure parent ) {
* This method returns the feature of a given name . If the feature is not
parentStack . push ( parent ) ;
* yet loaded then null is returned .
}
*
* @param featureName
/ * *
* the name of the feature
* This method removes the structure from the top of the parent ' s stack .
* @param loadedFeatureDataType
* @return the structure that was removed from the stack
* the type of data we want to retreive it can be either filled
* /
* structure or already converted feature
public Structure popParent ( ) {
* @return loaded feature or null if it was not yet loaded
try {
* /
return parentStack . pop ( ) ;
public Object getLoadedFeature ( String featureName , LoadedFeatureDataType loadedFeatureDataType ) {
} catch ( EmptyStackException e ) {
Object [ ] result = loadedFeaturesByName . get ( featureName ) ;
return null ;
if ( result ! = null ) {
}
return result [ loadedFeatureDataType . getIndex ( ) ] ;
}
}
return null ;
/ * *
}
* This method retreives the structure at the top of the parent ' s stack but does not remove it .
* @return the structure from the top of the stack
/ * *
* /
* This method clears the saved features stored in the features map .
public Structure peekParent ( ) {
* /
try {
public void clearLoadedFeatures ( ) {
return parentStack . peek ( ) ;
loadedFeatures . clear ( ) ;
} catch ( EmptyStackException e ) {
}
return null ;
}
/ * *
}
* This method adds the structure to the parent stack .
*
public void addIpo ( Long ownerOMA , Ipo ipo ) {
* @param parent
loadedIpos . put ( ownerOMA , ipo ) ;
* the structure to be added to the stack
}
* /
public void pushParent ( Structure parent ) {
public Ipo removeIpo ( Long ownerOma ) {
parentStack . push ( parent ) ;
return loadedIpos . remove ( ownerOma ) ;
}
}
/ * *
public Ipo getIpo ( Long ownerOMA ) {
* This method removes the structure from the top of the parent ' s stack .
return loadedIpos . get ( ownerOMA ) ;
*
}
* @return the structure that was removed from the stack
* /
/ * *
public Structure popParent ( ) {
* This method adds a new modifier to the list .
try {
* @param ownerOMA
return parentStack . pop ( ) ;
* the owner ' s old memory address
} catch ( EmptyStackException e ) {
* @param modifier
return null ;
* the object ' s modifier
}
* /
}
public void addModifier ( Long ownerOMA , Modifier modifier ) {
List < Modifier > objectModifiers = this . modifiers . get ( ownerOMA ) ;
/ * *
if ( objectModifiers = = null ) {
* This method retreives the structure at the top of the parent ' s stack but
objectModifiers = new ArrayList < Modifier > ( ) ;
* does not remove it .
this . modifiers . put ( ownerOMA , objectModifiers ) ;
*
}
* @return the structure from the top of the stack
objectModifiers . add ( modifier ) ;
* /
}
public Structure peekParent ( ) {
try {
/ * *
return parentStack . peek ( ) ;
* This method returns modifiers for the object specified by its old memory address and the modifier type . If no
} catch ( EmptyStackException e ) {
* modifiers are found - empty list is returned . If the type is null - all modifiers for the object are returned .
return null ;
* @param objectOMA
}
* object ' s old memory address
}
* @param type
* the type of the modifier
/ * *
* @return the list of object ' s modifiers
* This method adds new ipo curve for the feature .
* /
*
public List < Modifier > getModifiers ( Long objectOMA , String type ) {
* @param ownerOMA
List < Modifier > result = new ArrayList < Modifier > ( ) ;
* the OMA of blender feature that owns the ipo
List < Modifier > readModifiers = modifiers . get ( objectOMA ) ;
* @param ipo
if ( readModifiers ! = null & & readModifiers . size ( ) > 0 ) {
* the ipo to be added
for ( Modifier modifier : readModifiers ) {
* /
if ( type = = null | | type . isEmpty ( ) | | modifier . getType ( ) . equals ( type ) ) {
public void addIpo ( Long ownerOMA , Ipo ipo ) {
result . add ( modifier ) ;
loadedIpos . put ( ownerOMA , ipo ) ;
}
}
}
}
/ * *
return result ;
* This method removes the ipo curve from the feature .
}
*
* @param ownerOMA
/ * *
* the OMA of blender feature that owns the ipo
* This method adds a new modifier to the list .
* @param ipo
* @param ownerOMA
* the ipo that was just removed
* the owner ' s old memory address
* /
* @param constraints
public Ipo removeIpo ( Long ownerOma ) {
* the object ' s constraints
return loadedIpos . remove ( ownerOma ) ;
* /
}
public void addConstraints ( Long ownerOMA , List < Constraint > constraints ) {
List < Constraint > objectConstraints = this . constraints . get ( ownerOMA ) ;
/ * *
if ( objectConstraints = = null ) {
* This method returns the ipo curve of the feature .
objectConstraints = new ArrayList < Constraint > ( ) ;
*
this . constraints . put ( ownerOMA , objectConstraints ) ;
* @param ownerOMA
}
* the OMA of blender feature that owns the ipo
objectConstraints . addAll ( constraints ) ;
* @param ipo
}
* the ipo that belongs to the specified owner
* /
/ * *
public Ipo getIpo ( Long ownerOMA ) {
* This method returns constraints for the object specified by its old memory address . If no
return loadedIpos . get ( ownerOMA ) ;
* modifiers are found - < b > null < / b > is returned .
}
* @param objectOMA
* object ' s old memory address
/ * *
* @return the list of object ' s modifiers or null
* This method adds a new modifier to the list .
* /
*
public List < Constraint > getConstraints ( Long objectOMA ) {
* @param ownerOMA
return constraints . get ( objectOMA ) ;
* the owner ' s old memory address
}
* @param modifier
* the object ' s modifier
/ * *
* /
public void addModifier ( Long ownerOMA , Modifier modifier ) {
List < Modifier > objectModifiers = this . modifiers . get ( ownerOMA ) ;
if ( objectModifiers = = null ) {
objectModifiers = new ArrayList < Modifier > ( ) ;
this . modifiers . put ( ownerOMA , objectModifiers ) ;
}
objectModifiers . add ( modifier ) ;
}
/ * *
* This method returns modifiers for the object specified by its old memory
* address and the modifier type . If no modifiers are found - empty list is
* returned . If the type is null - all modifiers for the object are
* returned .
*
* @param objectOMA
* object ' s old memory address
* @param type
* the type of the modifier
* @return the list of object ' s modifiers
* /
public List < Modifier > getModifiers ( Long objectOMA , String type ) {
List < Modifier > result = new ArrayList < Modifier > ( ) ;
List < Modifier > readModifiers = modifiers . get ( objectOMA ) ;
if ( readModifiers ! = null & & readModifiers . size ( ) > 0 ) {
for ( Modifier modifier : readModifiers ) {
if ( type = = null | | type . isEmpty ( ) | | modifier . getType ( ) . equals ( type ) ) {
result . add ( modifier ) ;
}
}
}
return result ;
}
/ * *
* This method adds a new modifier to the list .
*
* @param ownerOMA
* the owner ' s old memory address
* @param constraints
* the object ' s constraints
* /
public void addConstraints ( Long ownerOMA , List < Constraint > constraints ) {
List < Constraint > objectConstraints = this . constraints . get ( ownerOMA ) ;
if ( objectConstraints = = null ) {
objectConstraints = new ArrayList < Constraint > ( ) ;
this . constraints . put ( ownerOMA , objectConstraints ) ;
}
objectConstraints . addAll ( constraints ) ;
}
/ * *
* This method returns constraints for the object specified by its old
* memory address . If no modifiers are found - < b > null < / b > is returned .
*
* @param objectOMA
* object ' s old memory address
* @return the list of object ' s modifiers or null
* /
public List < Constraint > getConstraints ( Long objectOMA ) {
return objectOMA = = null ? null : constraints . get ( objectOMA ) ;
}
/ * *
* This method sets the anim data for the specified OMA of its owner .
*
* @param ownerOMA
* the owner ' s old memory address
* @param animData
* the animation data for the feature specified by ownerOMA
* /
public void setAnimData ( Long ownerOMA , AnimData animData ) {
this . animData . put ( ownerOMA , animData ) ;
}
/ * *
* This method returns the animation data for the specified owner .
*
* @param ownerOMA
* the old memory address of the animation data owner
* @return the animation data or null if none exists
* /
public AnimData getAnimData ( Long ownerOMA ) {
return this . animData . get ( ownerOMA ) ;
}
/ * *
* This method sets the mesh context for the given mesh old memory address .
* This method sets the mesh context for the given mesh old memory address .
* If the context is already set it will be replaced .
* If the context is already set it will be replaced .
*
* @param meshOMA
* @param meshOMA
* the mesh ' s old memory address
* the mesh ' s old memory address
* @param meshContext
* @param meshContext
* the mesh ' s context
* the mesh ' s context
* /
* /
public void setMeshContext ( Long meshOMA , MeshContext meshContext ) {
public void setMeshContext ( Long meshOMA , MeshContext meshContext ) {
this . meshContexts . put ( meshOMA , meshContext ) ;
this . meshContexts . put ( meshOMA , meshContext ) ;
}
}
/ * *
/ * *
* This method returns the mesh context for the given mesh old memory address .
* This method returns the mesh context for the given mesh old memory
* If no context exists then < b > null < / b > is returned .
* address . If no context exists then < b > null < / b > is returned .
*
* @param meshOMA
* @param meshOMA
* the mesh ' s old memory address
* the mesh ' s old memory address
* @return mesh ' s context
* @return mesh ' s context
* /
* /
public MeshContext getMeshContext ( Long meshOMA ) {
public MeshContext getMeshContext ( Long meshOMA ) {
return this . meshContexts . get ( meshOMA ) ;
return this . meshContexts . get ( meshOMA ) ;
}
}
/ * *
/ * *
* This method sets the material context for the given material .
* This method sets the material context for the given material . If the
* If the context is already set it will be replaced .
* context is already set it will be replaced .
*
* @param material
* @param material
* the material
* the material
* @param materialContext
* @param materialContext
* the material ' s context
* the material ' s context
* /
* /
public void setMaterialContext ( Material material , MaterialContext materialContext ) {
public void setMaterialContext ( Material material , MaterialContext materialContext ) {
this . materialContexts . put ( material , materialContext ) ;
this . materialContexts . put ( material , materialContext ) ;
}
}
/ * *
/ * *
* This method returns the material context for the given material .
* This method returns the material context for the given material . If no
* If no context exists then < b > null < / b > is returned .
* context exists then < b > null < / b > is returned .
*
* @param material
* @param material
* the material
* the material
* @return material ' s context
* @return material ' s context
* /
* /
public MaterialContext getMaterialContext ( Material material ) {
public MaterialContext getMaterialContext ( Material material ) {
return materialContexts . get ( material ) ;
return materialContexts . get ( material ) ;
}
}
/ * *
/ * *
* This metod returns the default material .
* This metod returns the default material .
* @return the default material
*
* /
* @return the default material
public synchronized Material getDefaultMaterial ( ) {
* /
if ( blenderKey . getDefaultMaterial ( ) = = null ) {
public synchronized Material getDefaultMaterial ( ) {
Material defaultMaterial = new Material ( assetManager , "Common/MatDefs/Misc/Unshaded.j3md" ) ;
if ( blenderKey . getDefaultMaterial ( ) = = null ) {
defaultMaterial . setColor ( "Color" , ColorRGBA . DarkGray ) ;
Material defaultMaterial = new Material ( assetManager , "Common/MatDefs/Misc/Unshaded.j3md" ) ;
blenderKey . setDefaultMaterial ( defaultMaterial ) ;
defaultMaterial . setColor ( "Color" , ColorRGBA . DarkGray ) ;
}
blenderKey . setDefaultMaterial ( defaultMaterial ) ;
return blenderKey . getDefaultMaterial ( ) ;
}
}
return blenderKey . getDefaultMaterial ( ) ;
}
public void dispose ( ) {
try {
public void dispose ( ) {
try {
inputStream . close ( ) ;
inputStream . close ( ) ;
} catch ( IOException e ) {
} catch ( IOException e ) {
LOGGER . log ( Level . SEVERE , e . getLocalizedMessage ( ) , e ) ;
LOGGER . log ( Level . SEVERE , e . getLocalizedMessage ( ) , e ) ;
}
}
loadedFeatures . clear ( ) ;
loadedFeatures . clear ( ) ;
loadedFeaturesByName . clear ( ) ;
loadedFeaturesByName . clear ( ) ;
}
}
/ * *
/ * *
* This enum defines what loaded data type user wants to retreive . It can be either filled structure or already
* This enum defines what loaded data type user wants to retreive . It can be
* converted data .
* either filled structure or already converted data .
* @author Marcin Roguski
*
* /
* @author Marcin Roguski
public static enum LoadedFeatureDataType {
* /
public static enum LoadedFeatureDataType {
LOADED_STRUCTURE ( 0 ) , LOADED_FEATURE ( 1 ) ;
private int index ;
LOADED_STRUCTURE ( 0 ) , LOADED_FEATURE ( 1 ) ;
private int index ;
private LoadedFeatureDataType ( int index ) {
this . index = index ;
private LoadedFeatureDataType ( int index ) {
}
this . index = index ;
}
public int getIndex ( ) {
return index ;
public int getIndex ( ) {
}
return index ;
}
}
}
}
}