com.jme3.scene.plugins.blender
Class AbstractBlenderHelper

java.lang.Object
  extended by com.jme3.scene.plugins.blender.AbstractBlenderHelper
Direct Known Subclasses:
ArmatureHelper, CameraHelper, ConstraintHelper, CurvesHelper, IpoHelper, LightHelper, MaterialHelper, MeshHelper, ModifierHelper, ObjectHelper, ParticlesHelper, TextureHelper

public abstract class AbstractBlenderHelper
extends java.lang.Object

A purpose of the helper class is to split calculation code into several classes. Each helper after use should be cleared because it can hold the state of the calculations.


Field Summary
protected  int blenderVersion
          The version of the blend file.
protected  boolean fixUpAxis
          This variable indicates if the Y asxis is the UP axis or not.
protected  Quaternion upAxisRotationQuaternion
          Quaternion used to rotate data when Y is up axis.
 
Constructor Summary
AbstractBlenderHelper(java.lang.String blenderVersion, boolean fixUpAxis)
          This constructor parses the given blender version and stores the result.
 
Method Summary
protected  void applyProperties(Spatial spatial, Properties properties)
          The method applies properties to the given spatial.
 void clearState()
          This method clears the state of the helper so that it can be used for different calculations of another feature.
protected  boolean isBlank(java.lang.String text)
          This method should be used to check if the text is blank.
protected  Properties loadProperties(Structure structure, BlenderContext blenderContext)
          This method loads the properties if they are available and defined for the structure.
abstract  boolean shouldBeLoaded(Structure structure, BlenderContext blenderContext)
          This method analyzes the given structure and the data contained within blender context and decides if the feature should be loaded.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

blenderVersion

protected final int blenderVersion
The version of the blend file.


fixUpAxis

protected boolean fixUpAxis
This variable indicates if the Y asxis is the UP axis or not.


upAxisRotationQuaternion

protected Quaternion upAxisRotationQuaternion
Quaternion used to rotate data when Y is up axis.

Constructor Detail

AbstractBlenderHelper

public AbstractBlenderHelper(java.lang.String blenderVersion,
                             boolean fixUpAxis)
This constructor parses the given blender version and stores the result. Some functionalities may differ in different blender versions.

Parameters:
blenderVersion - the version read from the blend file
fixUpAxis - a variable that indicates if the Y asxis is the UP axis or not
Method Detail

clearState

public void clearState()
This method clears the state of the helper so that it can be used for different calculations of another feature.


isBlank

protected boolean isBlank(java.lang.String text)
This method should be used to check if the text is blank. Avoid using text.trim().length()==0. This causes that more strings are being created and stored in the memory. It can be unwise especially inside loops.

Parameters:
text - the text to be checked
Returns:
true if the text is blank and false otherwise

loadProperties

protected Properties loadProperties(Structure structure,
                                    BlenderContext blenderContext)
                             throws BlenderFileException
This method loads the properties if they are available and defined for the structure.

Parameters:
structure - the structure we read the properties from
blenderContext - the blender context
Returns:
loaded properties or null if they are not available
Throws:
BlenderFileException - an exception is thrown when the blend file is somehow corrupted

applyProperties

protected void applyProperties(Spatial spatial,
                               Properties properties)
The method applies properties to the given spatial. The Properties instance cannot be directly applied because the end-user might not have the blender plugin jar file and thus receive ClassNotFoundException. The values are set by name instead.

Parameters:
spatial - the spatial that is to have properties applied
properties - the properties to be applied

shouldBeLoaded

public abstract boolean shouldBeLoaded(Structure structure,
                                       BlenderContext blenderContext)
This method analyzes the given structure and the data contained within blender context and decides if the feature should be loaded.

Parameters:
structure - structure to be analyzed
blenderContext - the blender context
Returns:
true if the feature should be loaded and false otherwise