com.jme3.scene.plugins.blender
Class BlenderContext

java.lang.Object
  extended by com.jme3.scene.plugins.blender.BlenderContext

public class BlenderContext
extends java.lang.Object

The class that stores temporary data and manages it during loading the belnd file. This class is intended to be used in a single loading thread. It holds the state of loading operations.


Nested Class Summary
static class BlenderContext.LoadedFeatureDataType
          This enum defines what loaded data type user wants to retreive.
 
Field Summary
protected  java.util.Map<java.lang.Long,BoneContext> boneContexts
          A map of bone contexts.
protected  java.util.Map<java.lang.Long,java.util.List<Constraint>> constraints
          A list of constraints for the specified object.
protected  java.util.Map<java.lang.Long,MeshContext> meshContexts
          A map of mesh contexts.
protected  java.util.Map<java.lang.Long,java.util.List<Modifier>> modifiers
          A list of modifiers for the specified object.
 
Constructor Summary
BlenderContext()
           
 
Method Summary
 void addConstraints(java.lang.Long ownerOMA, java.util.List<Constraint> constraints)
          This method adds a new modifier to the list.
 void addFileBlockHeader(java.lang.Long oldMemoryAddress, FileBlockHeader fileBlockHeader)
          This method adds a file block header to the map.
 void addIpo(java.lang.Long ownerOMA, Ipo ipo)
          This method adds new ipo curve for the feature.
 void addLoadedFeatures(java.lang.Long oldMemoryAddress, java.lang.String featureName, Structure structure, java.lang.Object feature)
          This method adds a loaded feature to the map.
 void addModifier(java.lang.Long ownerOMA, Modifier modifier)
          This method adds a new modifier to the list.
 void clearFileBlocks()
          This method clears the saved block headers stored in the features map.
 void clearLoadedFeatures()
          This method clears the saved features stored in the features map.
 void dispose()
           
 AnimData getAnimData(java.lang.Long ownerOMA)
          This method returns the animation data for the specified owner.
 AssetManager getAssetManager()
          This method returns the asset manager.
 BlenderKey getBlenderKey()
          This method returns the blender key.
 int getBlenderVersion()
           
 BoneContext getBoneContext(java.lang.Long boneOMA)
          This method returns the bone context for the given bone old memory address.
 java.util.List<Constraint> getConstraints(java.lang.Long objectOMA)
          This method returns constraints for the object specified by its old memory address.
 Material getDefaultMaterial()
          This metod returns the default material.
 DnaBlockData getDnaBlockData()
          This method returns the dna block data.
 FileBlockHeader getFileBlock(java.lang.Long oldMemoryAddress)
          This method returns the block header of a given memory address.
 java.util.List<FileBlockHeader> getFileBlocks(java.lang.Integer code)
          This method returns a list of file blocks' headers of a specified code.
<T> T
getHelper(java.lang.Class<?> clazz)
           
 BlenderInputStream getInputStream()
          This method returns the input stream of the blend file.
 Ipo getIpo(java.lang.Long ownerOMA)
          This method returns the ipo curve of the feature.
 java.lang.Object getLoadedFeature(java.lang.Long oldMemoryAddress, BlenderContext.LoadedFeatureDataType loadedFeatureDataType)
          This method returns the feature of a given memory address.
 java.lang.Object getLoadedFeature(java.lang.String featureName, BlenderContext.LoadedFeatureDataType loadedFeatureDataType)
          This method returns the feature of a given name.
 MeshContext getMeshContext(java.lang.Long meshOMA)
          This method returns the mesh context for the given mesh old memory address.
 java.util.List<Modifier> getModifiers(java.lang.Long objectOMA, java.lang.String type)
          This method returns modifiers for the object specified by its old memory address and the modifier type.
 Skeleton getSkeleton(java.lang.Long skeletonOMA)
          This method returns the skeleton for the specified OMA of its owner.
 Structure peekParent()
          This method retreives the structure at the top of the parent's stack but does not remove it.
 Structure popParent()
          This method removes the structure from the top of the parent's stack.
 void pushParent(Structure parent)
          This method adds the structure to the parent stack.
<T> void
putHelper(java.lang.Class<T> clazz, AbstractBlenderHelper helper)
          This method adds a helper instance to the helpers' map.
 Ipo removeIpo(java.lang.Long ownerOma)
          This method removes the ipo curve from the feature.
 void setAnimData(java.lang.Long ownerOMA, AnimData animData)
          This method sets the anim data for the specified OMA of its owner.
 void setAssetManager(AssetManager assetManager)
          This method sets the asset manager.
 void setBlenderKey(BlenderKey blenderKey)
          This method sets the blender key.
 void setBlenderVersion(java.lang.String blenderVersion)
          This method sets the blender file version.
 void setBlockData(DnaBlockData dnaBlockData)
          This method sets the dna block data.
 void setBoneContext(java.lang.Long boneOMA, BoneContext boneContext)
          This method sets the bone context for the given bone old memory address.
 void setInputStream(BlenderInputStream inputStream)
          This method sets the input stream of the blend file.
 void setMeshContext(java.lang.Long meshOMA, MeshContext meshContext)
          This method sets the mesh context for the given mesh old memory address.
 void setSkeleton(java.lang.Long skeletonOMA, Skeleton skeleton)
          This method sets the skeleton for the specified OMA of its owner.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

modifiers

protected java.util.Map<java.lang.Long,java.util.List<Modifier>> modifiers
A list of modifiers for the specified object.


constraints

protected java.util.Map<java.lang.Long,java.util.List<Constraint>> constraints
A list of constraints for the specified object.


meshContexts

protected java.util.Map<java.lang.Long,MeshContext> meshContexts
A map of mesh contexts.


boneContexts

protected java.util.Map<java.lang.Long,BoneContext> boneContexts
A map of bone contexts.

Constructor Detail

BlenderContext

public BlenderContext()
Method Detail

setBlenderVersion

public void setBlenderVersion(java.lang.String blenderVersion)
This method sets the blender file version.

Parameters:
blenderVersion - the blender file version

getBlenderVersion

public int getBlenderVersion()
Returns:
the blender file version

setBlenderKey

public void setBlenderKey(BlenderKey blenderKey)
This method sets the blender key.

Parameters:
blenderKey - the blender key

getBlenderKey

public BlenderKey getBlenderKey()
This method returns the blender key.

Returns:
the blender key

setBlockData

public void setBlockData(DnaBlockData dnaBlockData)
This method sets the dna block data.

Parameters:
dnaBlockData - the dna block data

getDnaBlockData

public DnaBlockData getDnaBlockData()
This method returns the dna block data.

Returns:
the dna block data

getAssetManager

public AssetManager getAssetManager()
This method returns the asset manager.

Returns:
the asset manager

setAssetManager

public void setAssetManager(AssetManager assetManager)
This method sets the asset manager.

Parameters:
assetManager - the asset manager

getInputStream

public BlenderInputStream getInputStream()
This method returns the input stream of the blend file.

Returns:
the input stream of the blend file

setInputStream

public void setInputStream(BlenderInputStream inputStream)
This method sets the input stream of the blend file.

Parameters:
inputStream - the input stream of the blend file

addFileBlockHeader

public void addFileBlockHeader(java.lang.Long oldMemoryAddress,
                               FileBlockHeader fileBlockHeader)
This method adds a file block header to the map. Its old memory address is the key.

Parameters:
oldMemoryAddress - the address of the block header
fileBlockHeader - the block header to store

getFileBlock

public FileBlockHeader getFileBlock(java.lang.Long oldMemoryAddress)
This method returns the block header of a given memory address. If the header is not present then null is returned.

Parameters:
oldMemoryAddress - the address of the block header
Returns:
loaded header or null if it was not yet loaded

getFileBlocks

public java.util.List<FileBlockHeader> getFileBlocks(java.lang.Integer code)
This method returns a list of file blocks' headers of a specified code.

Parameters:
code - the code of file blocks
Returns:
a list of file blocks' headers of a specified code

clearFileBlocks

public void clearFileBlocks()
This method clears the saved block headers stored in the features map.


putHelper

public <T> void putHelper(java.lang.Class<T> clazz,
                          AbstractBlenderHelper helper)
This method adds a helper instance to the helpers' map.

Type Parameters:
T - the type of the helper
Parameters:
clazz - helper's class definition
helper - the helper instance

getHelper

public <T> T getHelper(java.lang.Class<?> clazz)

addLoadedFeatures

public void addLoadedFeatures(java.lang.Long oldMemoryAddress,
                              java.lang.String featureName,
                              Structure structure,
                              java.lang.Object feature)
This method adds a loaded feature to the map. The key is its unique old memory address.

Parameters:
oldMemoryAddress - the address of the feature
featureName - the name of the feature
structure - the filled structure of the feature
feature - the feature we want to store

getLoadedFeature

public java.lang.Object getLoadedFeature(java.lang.Long oldMemoryAddress,
                                         BlenderContext.LoadedFeatureDataType loadedFeatureDataType)
This method returns the feature of a given memory address. If the feature is not yet loaded then null is returned.

Parameters:
oldMemoryAddress - the address of the feature
loadedFeatureDataType - the type of data we want to retreive it can be either filled structure or already converted feature
Returns:
loaded feature or null if it was not yet loaded

getLoadedFeature

public java.lang.Object getLoadedFeature(java.lang.String featureName,
                                         BlenderContext.LoadedFeatureDataType loadedFeatureDataType)
This method returns the feature of a given name. If the feature is not yet loaded then null is returned.

Parameters:
featureName - the name of the feature
loadedFeatureDataType - the type of data we want to retreive it can be either filled structure or already converted feature
Returns:
loaded feature or null if it was not yet loaded

clearLoadedFeatures

public void clearLoadedFeatures()
This method clears the saved features stored in the features map.


pushParent

public void pushParent(Structure parent)
This method adds the structure to the parent stack.

Parameters:
parent - the structure to be added to the stack

popParent

public Structure popParent()
This method removes the structure from the top of the parent's stack.

Returns:
the structure that was removed from the stack

peekParent

public Structure peekParent()
This method retreives the structure at the top of the parent's stack but does not remove it.

Returns:
the structure from the top of the stack

addIpo

public void addIpo(java.lang.Long ownerOMA,
                   Ipo ipo)
This method adds new ipo curve for the feature.

Parameters:
ownerOMA - the OMA of blender feature that owns the ipo
ipo - the ipo to be added

removeIpo

public Ipo removeIpo(java.lang.Long ownerOma)
This method removes the ipo curve from the feature.

Parameters:
ownerOma - the OMA of blender feature that owns the ipo

getIpo

public Ipo getIpo(java.lang.Long ownerOMA)
This method returns the ipo curve of the feature.

Parameters:
ownerOMA - the OMA of blender feature that owns the ipo

addModifier

public void addModifier(java.lang.Long ownerOMA,
                        Modifier modifier)
This method adds a new modifier to the list.

Parameters:
ownerOMA - the owner's old memory address
modifier - the object's modifier

getModifiers

public java.util.List<Modifier> getModifiers(java.lang.Long objectOMA,
                                             java.lang.String type)
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.

Parameters:
objectOMA - object's old memory address
type - the type of the modifier
Returns:
the list of object's modifiers

addConstraints

public void addConstraints(java.lang.Long ownerOMA,
                           java.util.List<Constraint> constraints)
This method adds a new modifier to the list.

Parameters:
ownerOMA - the owner's old memory address
constraints - the object's constraints

getConstraints

public java.util.List<Constraint> getConstraints(java.lang.Long objectOMA)
This method returns constraints for the object specified by its old memory address. If no modifiers are found - null is returned.

Parameters:
objectOMA - object's old memory address
Returns:
the list of object's modifiers or null

setAnimData

public void setAnimData(java.lang.Long ownerOMA,
                        AnimData animData)
This method sets the anim data for the specified OMA of its owner.

Parameters:
ownerOMA - the owner's old memory address
animData - the animation data for the feature specified by ownerOMA

getAnimData

public AnimData getAnimData(java.lang.Long ownerOMA)
This method returns the animation data for the specified owner.

Parameters:
ownerOMA - the old memory address of the animation data owner
Returns:
the animation data or null if none exists

setSkeleton

public void setSkeleton(java.lang.Long skeletonOMA,
                        Skeleton skeleton)
This method sets the skeleton for the specified OMA of its owner.

Parameters:
skeletonOMA - the skeleton's old memory address
skeleton - the skeleton specified by the given OMA

getSkeleton

public Skeleton getSkeleton(java.lang.Long skeletonOMA)
This method returns the skeleton for the specified OMA of its owner.

Parameters:
skeletonOMA - the skeleton's old memory address
Returns:
the skeleton specified by the given OMA

setMeshContext

public void setMeshContext(java.lang.Long meshOMA,
                           MeshContext meshContext)
This method sets the mesh context for the given mesh old memory address. If the context is already set it will be replaced.

Parameters:
meshOMA - the mesh's old memory address
meshContext - the mesh's context

getMeshContext

public MeshContext getMeshContext(java.lang.Long meshOMA)
This method returns the mesh context for the given mesh old memory address. If no context exists then null is returned.

Parameters:
meshOMA - the mesh's old memory address
Returns:
mesh's context

setBoneContext

public void setBoneContext(java.lang.Long boneOMA,
                           BoneContext boneContext)
This method sets the bone context for the given bone old memory address. If the context is already set it will be replaced.

Parameters:
boneOMA - the bone's old memory address
boneContext - the bones's context

getBoneContext

public BoneContext getBoneContext(java.lang.Long boneOMA)
This method returns the bone context for the given bone old memory address. If no context exists then null is returned.

Parameters:
boneOMA - the bone's old memory address
Returns:
bone's context

getDefaultMaterial

public Material getDefaultMaterial()
This metod returns the default material.

Returns:
the default material

dispose

public void dispose()