diff --git a/engine/src/blender/com/jme3/scene/plugins/blender/constraints/Constraint.java b/engine/src/blender/com/jme3/scene/plugins/blender/constraints/Constraint.java
index 80ade1971..729394433 100644
--- a/engine/src/blender/com/jme3/scene/plugins/blender/constraints/Constraint.java
+++ b/engine/src/blender/com/jme3/scene/plugins/blender/constraints/Constraint.java
@@ -8,7 +8,6 @@ import com.jme3.animation.SpatialTrack;
import com.jme3.animation.Track;
import com.jme3.scene.Spatial;
import com.jme3.scene.plugins.blender.BlenderContext;
-import com.jme3.scene.plugins.blender.BlenderContext.LoadedFeatureDataType;
import com.jme3.scene.plugins.blender.animations.Ipo;
import com.jme3.scene.plugins.blender.exceptions.BlenderFileException;
import com.jme3.scene.plugins.blender.file.Pointer;
@@ -21,6 +20,8 @@ import com.jme3.scene.plugins.blender.objects.ObjectHelper;
* @author Marcin Roguski (Kaelthas)
*/
public abstract class Constraint {
+ public static final int BAKE_DYNAMIC = 0x01;
+ public static final int BAKE_STATIC = 0x02;
/** The name of this constraint. */
protected final String name;
@@ -72,24 +73,38 @@ public abstract class Constraint {
throw new BlenderFileException("The constraint has no data specified!");
}
Space ownerSpace = Space.valueOf(((Number) constraintStructure.getFieldValue("ownspace")).byteValue());
- Object owner = blenderContext.getLoadedFeature(ownerOMA, LoadedFeatureDataType.LOADED_FEATURE);
- if(owner instanceof Spatial) {
- this.owner = new Feature((Spatial)owner, ownerSpace, ownerOMA, blenderContext);
- } else {
- this.owner = new Feature((Bone)owner, ownerSpace, ownerOMA, blenderContext);
- }
+ this.owner = new Feature(ownerSpace, ownerOMA, blenderContext);
this.ipo = influenceIpo;
}
+ /**
+ * This method bakes the required sontraints into its owner.
+ * @param bakeFlag the bake type flag support the following values:
+ *
BAKE_DYNAMIC - bake animation's constraints
+ * BAKE_STATIC - bake static constraints
+ */
+ public void bake(int bakeFlag) {
+ this.owner.update();
+ if(this.target != null) {
+ this.target.update();
+ }
+ if((bakeFlag & BAKE_DYNAMIC) != 0) {
+ this.bakeDynamic();
+ }
+ if((bakeFlag & BAKE_STATIC) != 0) {
+ this.bakeStatic();
+ }
+ }
+
/**
* Bake the animation's constraints into its owner.
*/
- public abstract void bakeDynamic();
+ protected abstract void bakeDynamic();
/**
* Bake the static constraints into its owner.
*/
- public abstract void bakeStatic();
+ protected abstract void bakeStatic();
/**
* This method returns the bone traces for the bone that is affected by the given constraint.
diff --git a/engine/src/blender/com/jme3/scene/plugins/blender/constraints/ConstraintAction.java b/engine/src/blender/com/jme3/scene/plugins/blender/constraints/ConstraintAction.java
index a198e441a..fe81792da 100644
--- a/engine/src/blender/com/jme3/scene/plugins/blender/constraints/ConstraintAction.java
+++ b/engine/src/blender/com/jme3/scene/plugins/blender/constraints/ConstraintAction.java
@@ -35,13 +35,13 @@ import java.util.logging.Logger;
}
@Override
- public void bakeDynamic() {
+ protected void bakeDynamic() {
// TODO: implement 'Action' constraint
LOGGER.log(Level.WARNING, "'Action' constraint NOT implemented!");
}
@Override
- public void bakeStatic() {
+ protected void bakeStatic() {
// TODO: implement 'Action' constraint
LOGGER.log(Level.WARNING, "'Action' constraint NOT implemented!");
}
diff --git a/engine/src/blender/com/jme3/scene/plugins/blender/constraints/ConstraintChildOf.java b/engine/src/blender/com/jme3/scene/plugins/blender/constraints/ConstraintChildOf.java
index 99fe8c5cc..aa6d7f785 100644
--- a/engine/src/blender/com/jme3/scene/plugins/blender/constraints/ConstraintChildOf.java
+++ b/engine/src/blender/com/jme3/scene/plugins/blender/constraints/ConstraintChildOf.java
@@ -35,13 +35,13 @@ import java.util.logging.Logger;
}
@Override
- public void bakeDynamic() {
+ protected void bakeDynamic() {
// TODO: implement ChildOf constraint
LOGGER.log(Level.WARNING, "ChildOf constraint NOT implemented!");
}
@Override
- public void bakeStatic() {
+ protected void bakeStatic() {
// TODO: implement ChildOf constraint
LOGGER.log(Level.WARNING, "ChildOf constraint NOT implemented!");
}
diff --git a/engine/src/blender/com/jme3/scene/plugins/blender/constraints/ConstraintClampTo.java b/engine/src/blender/com/jme3/scene/plugins/blender/constraints/ConstraintClampTo.java
index 48905e33e..c37f7ba0b 100644
--- a/engine/src/blender/com/jme3/scene/plugins/blender/constraints/ConstraintClampTo.java
+++ b/engine/src/blender/com/jme3/scene/plugins/blender/constraints/ConstraintClampTo.java
@@ -36,13 +36,13 @@ import java.util.logging.Logger;
}
@Override
- public void bakeDynamic() {
+ protected void bakeDynamic() {
//TODO: implement when curves are implemented
LOGGER.log(Level.INFO, "'Clamp to' not yet implemented! Curves not yet implemented!", name);
}
@Override
- public void bakeStatic() {
+ protected void bakeStatic() {
//TODO: implement when curves are implemented
LOGGER.log(Level.INFO, "'Clamp to' not yet implemented! Curves not yet implemented!", name);
}
diff --git a/engine/src/blender/com/jme3/scene/plugins/blender/constraints/ConstraintDampTrack.java b/engine/src/blender/com/jme3/scene/plugins/blender/constraints/ConstraintDampTrack.java
index 4c2dc999c..c7b0e89c2 100644
--- a/engine/src/blender/com/jme3/scene/plugins/blender/constraints/ConstraintDampTrack.java
+++ b/engine/src/blender/com/jme3/scene/plugins/blender/constraints/ConstraintDampTrack.java
@@ -36,13 +36,13 @@ import com.jme3.scene.plugins.blender.file.Structure;
}
@Override
- public void bakeDynamic() {
+ protected void bakeDynamic() {
// TODO Auto-generated method stub
LOGGER.log(Level.WARNING, "'Damp Track' constraint NOT implemented!");
}
@Override
- public void bakeStatic() {
+ protected void bakeStatic() {
// TODO Auto-generated method stub
LOGGER.log(Level.WARNING, "'Damp Track' constraint NOT implemented!");
}
diff --git a/engine/src/blender/com/jme3/scene/plugins/blender/constraints/ConstraintDistLimit.java b/engine/src/blender/com/jme3/scene/plugins/blender/constraints/ConstraintDistLimit.java
index 3d3778d52..0fae66e9f 100644
--- a/engine/src/blender/com/jme3/scene/plugins/blender/constraints/ConstraintDistLimit.java
+++ b/engine/src/blender/com/jme3/scene/plugins/blender/constraints/ConstraintDistLimit.java
@@ -47,7 +47,7 @@ import com.jme3.scene.plugins.ogre.AnimData;
}
@Override
- public void bakeDynamic() {
+ protected void bakeDynamic() {
AnimData animData = blenderContext.getAnimData(this.owner.getOma());
if(animData != null) {
Object owner = this.owner.getObject();
@@ -69,7 +69,7 @@ import com.jme3.scene.plugins.ogre.AnimData;
}
@Override
- public void bakeStatic() {
+ protected void bakeStatic() {
Matrix4f targetWorldMatrix = target.getWorldTransformMatrix();
Vector3f targetLocation = targetWorldMatrix.toTranslationVector();
Matrix4f m = owner.getParentWorldTransformMatrix();
diff --git a/engine/src/blender/com/jme3/scene/plugins/blender/constraints/ConstraintFollowPath.java b/engine/src/blender/com/jme3/scene/plugins/blender/constraints/ConstraintFollowPath.java
index 644ef320a..056353741 100644
--- a/engine/src/blender/com/jme3/scene/plugins/blender/constraints/ConstraintFollowPath.java
+++ b/engine/src/blender/com/jme3/scene/plugins/blender/constraints/ConstraintFollowPath.java
@@ -35,13 +35,13 @@ import java.util.logging.Logger;
}
@Override
- public void bakeDynamic() {
+ protected void bakeDynamic() {
//TODO: implement when curves are implemented
LOGGER.log(Level.INFO, "'Follow path' not implemented! Curves not yet implemented!");
}
@Override
- public void bakeStatic() {
+ protected void bakeStatic() {
//TODO: implement when curves are implemented
LOGGER.log(Level.INFO, "'Follow path' not implemented! Curves not yet implemented!");
}
diff --git a/engine/src/blender/com/jme3/scene/plugins/blender/constraints/ConstraintInverseKinematics.java b/engine/src/blender/com/jme3/scene/plugins/blender/constraints/ConstraintInverseKinematics.java
index 2b586a10e..76b59a959 100644
--- a/engine/src/blender/com/jme3/scene/plugins/blender/constraints/ConstraintInverseKinematics.java
+++ b/engine/src/blender/com/jme3/scene/plugins/blender/constraints/ConstraintInverseKinematics.java
@@ -38,7 +38,7 @@ import java.util.logging.Logger;
}
@Override
- public void bakeDynamic() {
+ protected void bakeDynamic() {
// try {
// IK solver is only attached to bones
// Bone ownerBone = (Bone) blenderContext.getLoadedFeature(ownerOMA, LoadedFeatureDataType.LOADED_FEATURE);
@@ -128,7 +128,7 @@ import java.util.logging.Logger;
}
@Override
- public void bakeStatic() {
+ protected void bakeStatic() {
// TODO Auto-generated method stub
}
diff --git a/engine/src/blender/com/jme3/scene/plugins/blender/constraints/ConstraintLocLike.java b/engine/src/blender/com/jme3/scene/plugins/blender/constraints/ConstraintLocLike.java
index 495c67a03..83d876893 100644
--- a/engine/src/blender/com/jme3/scene/plugins/blender/constraints/ConstraintLocLike.java
+++ b/engine/src/blender/com/jme3/scene/plugins/blender/constraints/ConstraintLocLike.java
@@ -61,7 +61,7 @@ import com.jme3.scene.plugins.ogre.AnimData;
}
@Override
- public void bakeDynamic() {
+ protected void bakeDynamic() {
AnimData animData = blenderContext.getAnimData(owner.getOma());
if(animData != null) {
Object owner = this.owner.getObject();
@@ -79,7 +79,7 @@ import com.jme3.scene.plugins.ogre.AnimData;
}
@Override
- public void bakeStatic() {
+ protected void bakeStatic() {
Transform targetTransform = this.target.getTransform();
Transform ownerTransform = this.owner.getTransform();
Vector3f ownerLocation = ownerTransform.getTranslation();
diff --git a/engine/src/blender/com/jme3/scene/plugins/blender/constraints/ConstraintLocLimit.java b/engine/src/blender/com/jme3/scene/plugins/blender/constraints/ConstraintLocLimit.java
index 65f9b813a..fcc167383 100644
--- a/engine/src/blender/com/jme3/scene/plugins/blender/constraints/ConstraintLocLimit.java
+++ b/engine/src/blender/com/jme3/scene/plugins/blender/constraints/ConstraintLocLimit.java
@@ -73,7 +73,7 @@ import com.jme3.scene.plugins.ogre.AnimData;
}
@Override
- public void bakeDynamic() {
+ protected void bakeDynamic() {
Object owner = this.owner.getObject();
AnimData animData = blenderContext.getAnimData(this.owner.getOma());
if(animData != null) {
@@ -90,7 +90,7 @@ import com.jme3.scene.plugins.ogre.AnimData;
}
@Override
- public void bakeStatic() {
+ protected void bakeStatic() {
Transform ownerTransform = this.owner.getTransform();
Vector3f ownerLocation = ownerTransform.getTranslation();
this.locLimit(ownerLocation, ipo.calculateValue(0));
diff --git a/engine/src/blender/com/jme3/scene/plugins/blender/constraints/ConstraintLockTrack.java b/engine/src/blender/com/jme3/scene/plugins/blender/constraints/ConstraintLockTrack.java
index cd435ec46..6f4a763dd 100644
--- a/engine/src/blender/com/jme3/scene/plugins/blender/constraints/ConstraintLockTrack.java
+++ b/engine/src/blender/com/jme3/scene/plugins/blender/constraints/ConstraintLockTrack.java
@@ -36,13 +36,13 @@ import java.util.logging.Logger;
}
@Override
- public void bakeDynamic() {
+ protected void bakeDynamic() {
// TODO: implement 'Lock track' constraint
LOGGER.log(Level.WARNING, "'Lock track' constraint NOT implemented!");
}
@Override
- public void bakeStatic() {
+ protected void bakeStatic() {
// TODO: implement 'Lock track' constraint
LOGGER.log(Level.WARNING, "'Lock track' constraint NOT implemented!");
}
diff --git a/engine/src/blender/com/jme3/scene/plugins/blender/constraints/ConstraintMinMax.java b/engine/src/blender/com/jme3/scene/plugins/blender/constraints/ConstraintMinMax.java
index 5749ccbd7..fcef6f5fd 100644
--- a/engine/src/blender/com/jme3/scene/plugins/blender/constraints/ConstraintMinMax.java
+++ b/engine/src/blender/com/jme3/scene/plugins/blender/constraints/ConstraintMinMax.java
@@ -35,13 +35,13 @@ import java.util.logging.Logger;
}
@Override
- public void bakeDynamic() {
+ protected void bakeDynamic() {
// TODO: implement 'Min max' constraint
LOGGER.log(Level.WARNING, "'Min max' constraint NOT implemented!");
}
@Override
- public void bakeStatic() {
+ protected void bakeStatic() {
// TODO: implement 'Min max' constraint
LOGGER.log(Level.WARNING, "'Min max' constraint NOT implemented!");
}
diff --git a/engine/src/blender/com/jme3/scene/plugins/blender/constraints/ConstraintNull.java b/engine/src/blender/com/jme3/scene/plugins/blender/constraints/ConstraintNull.java
index 3ff3b8694..d011d7f64 100644
--- a/engine/src/blender/com/jme3/scene/plugins/blender/constraints/ConstraintNull.java
+++ b/engine/src/blender/com/jme3/scene/plugins/blender/constraints/ConstraintNull.java
@@ -33,8 +33,8 @@ import com.jme3.scene.plugins.blender.file.Structure;
}
@Override
- public void bakeDynamic() {}
+ protected void bakeDynamic() {}
@Override
- public void bakeStatic() {}
+ protected void bakeStatic() {}
}
diff --git a/engine/src/blender/com/jme3/scene/plugins/blender/constraints/ConstraintPivot.java b/engine/src/blender/com/jme3/scene/plugins/blender/constraints/ConstraintPivot.java
index d24a3642d..172a352e1 100644
--- a/engine/src/blender/com/jme3/scene/plugins/blender/constraints/ConstraintPivot.java
+++ b/engine/src/blender/com/jme3/scene/plugins/blender/constraints/ConstraintPivot.java
@@ -37,13 +37,13 @@ import com.jme3.scene.plugins.blender.file.Structure;
}
@Override
- public void bakeDynamic() {
+ protected void bakeDynamic() {
// TODO Auto-generated method stub
LOGGER.log(Level.WARNING, "'Pivot' constraint NOT implemented!");
}
@Override
- public void bakeStatic() {
+ protected void bakeStatic() {
// TODO Auto-generated method stub
LOGGER.log(Level.WARNING, "'Pivot' constraint NOT implemented!");
}
diff --git a/engine/src/blender/com/jme3/scene/plugins/blender/constraints/ConstraintPython.java b/engine/src/blender/com/jme3/scene/plugins/blender/constraints/ConstraintPython.java
index 8d2bdd106..aef782021 100644
--- a/engine/src/blender/com/jme3/scene/plugins/blender/constraints/ConstraintPython.java
+++ b/engine/src/blender/com/jme3/scene/plugins/blender/constraints/ConstraintPython.java
@@ -35,13 +35,13 @@ import java.util.logging.Logger;
}
@Override
- public void bakeDynamic() {
+ protected void bakeDynamic() {
// TODO: implement 'Python' constraint
LOGGER.log(Level.WARNING, "'Python' constraint NOT implemented!");
}
@Override
- public void bakeStatic() {
+ protected void bakeStatic() {
// TODO: implement 'Python' constraint
LOGGER.log(Level.WARNING, "'Python' constraint NOT implemented!");
}
diff --git a/engine/src/blender/com/jme3/scene/plugins/blender/constraints/ConstraintRigidBodyJoint.java b/engine/src/blender/com/jme3/scene/plugins/blender/constraints/ConstraintRigidBodyJoint.java
index 62f3999cc..345990225 100644
--- a/engine/src/blender/com/jme3/scene/plugins/blender/constraints/ConstraintRigidBodyJoint.java
+++ b/engine/src/blender/com/jme3/scene/plugins/blender/constraints/ConstraintRigidBodyJoint.java
@@ -35,13 +35,13 @@ import java.util.logging.Logger;
}
@Override
- public void bakeDynamic() {
+ protected void bakeDynamic() {
// TODO: implement 'Rigid body joint' constraint
LOGGER.log(Level.WARNING, "'Rigid body joint' constraint NOT implemented!");
}
@Override
- public void bakeStatic() {
+ protected void bakeStatic() {
// TODO: implement 'Rigid body joint' constraint
LOGGER.log(Level.WARNING, "'Rigid body joint' constraint NOT implemented!");
}
diff --git a/engine/src/blender/com/jme3/scene/plugins/blender/constraints/ConstraintRotLike.java b/engine/src/blender/com/jme3/scene/plugins/blender/constraints/ConstraintRotLike.java
index 7be3d7f54..ef5a4883c 100644
--- a/engine/src/blender/com/jme3/scene/plugins/blender/constraints/ConstraintRotLike.java
+++ b/engine/src/blender/com/jme3/scene/plugins/blender/constraints/ConstraintRotLike.java
@@ -47,7 +47,7 @@ import com.jme3.scene.plugins.ogre.AnimData;
}
@Override
- public void bakeDynamic() {
+ protected void bakeDynamic() {
AnimData animData = blenderContext.getAnimData(this.owner.getOma());
if(animData != null) {
Object owner = this.owner.getObject();
@@ -69,7 +69,7 @@ import com.jme3.scene.plugins.ogre.AnimData;
}
@Override
- public void bakeStatic() {
+ protected void bakeStatic() {
Transform targetTransform = this.target.getTransform();
Transform ownerTransform = this.owner.getTransform();
Quaternion ownerRotation = ownerTransform.getRotation();
diff --git a/engine/src/blender/com/jme3/scene/plugins/blender/constraints/ConstraintRotLimit.java b/engine/src/blender/com/jme3/scene/plugins/blender/constraints/ConstraintRotLimit.java
index 7a53926c0..3e0907885 100644
--- a/engine/src/blender/com/jme3/scene/plugins/blender/constraints/ConstraintRotLimit.java
+++ b/engine/src/blender/com/jme3/scene/plugins/blender/constraints/ConstraintRotLimit.java
@@ -68,7 +68,7 @@ import com.jme3.scene.plugins.ogre.AnimData;
}
@Override
- public void bakeDynamic() {
+ protected void bakeDynamic() {
AnimData animData = blenderContext.getAnimData(owner.getOma());
if(animData != null) {
Object owner = this.owner.getObject();
@@ -88,7 +88,7 @@ import com.jme3.scene.plugins.ogre.AnimData;
}
@Override
- public void bakeStatic() {
+ protected void bakeStatic() {
Transform ownerTransform = this.owner.getTransform();
float[] angles = ownerTransform.getRotation().toAngles(null);
this.rotLimit(angles, ipo.calculateValue(0));
diff --git a/engine/src/blender/com/jme3/scene/plugins/blender/constraints/ConstraintShrinkWrap.java b/engine/src/blender/com/jme3/scene/plugins/blender/constraints/ConstraintShrinkWrap.java
index e37759387..9b6f7bdd5 100644
--- a/engine/src/blender/com/jme3/scene/plugins/blender/constraints/ConstraintShrinkWrap.java
+++ b/engine/src/blender/com/jme3/scene/plugins/blender/constraints/ConstraintShrinkWrap.java
@@ -45,7 +45,7 @@ import com.jme3.scene.plugins.ogre.AnimData;
}
@Override
- public void bakeDynamic() {
+ protected void bakeDynamic() {
//loading mesh points (blender ensures that the target is a mesh-object)
List pts = new ArrayList();
Node target = (Node) this.target.getObject();
@@ -89,7 +89,7 @@ import com.jme3.scene.plugins.ogre.AnimData;
}
@Override
- public void bakeStatic() {
+ protected void bakeStatic() {
// TODO Auto-generated method stub
}
diff --git a/engine/src/blender/com/jme3/scene/plugins/blender/constraints/ConstraintSizeLike.java b/engine/src/blender/com/jme3/scene/plugins/blender/constraints/ConstraintSizeLike.java
index 42d1b9caa..bd4068bee 100644
--- a/engine/src/blender/com/jme3/scene/plugins/blender/constraints/ConstraintSizeLike.java
+++ b/engine/src/blender/com/jme3/scene/plugins/blender/constraints/ConstraintSizeLike.java
@@ -52,7 +52,7 @@ import com.jme3.scene.plugins.ogre.AnimData;
}
@Override
- public void bakeDynamic() {
+ protected void bakeDynamic() {
AnimData animData = blenderContext.getAnimData(this.owner.getOma());
if(animData != null) {
Object owner = this.owner.getObject();
@@ -71,7 +71,7 @@ import com.jme3.scene.plugins.ogre.AnimData;
}
@Override
- public void bakeStatic() {
+ protected void bakeStatic() {
Transform targetTransform = this.target.getTransform();
Transform ownerTransform = this.owner.getTransform();
this.sizeLike(ownerTransform.getScale(), targetTransform.getScale(), ipo.calculateValue(0));
diff --git a/engine/src/blender/com/jme3/scene/plugins/blender/constraints/ConstraintSizeLimit.java b/engine/src/blender/com/jme3/scene/plugins/blender/constraints/ConstraintSizeLimit.java
index 80ec46122..5c3dea041 100644
--- a/engine/src/blender/com/jme3/scene/plugins/blender/constraints/ConstraintSizeLimit.java
+++ b/engine/src/blender/com/jme3/scene/plugins/blender/constraints/ConstraintSizeLimit.java
@@ -73,7 +73,7 @@ import com.jme3.scene.plugins.ogre.AnimData;
}
@Override
- public void bakeDynamic() {
+ protected void bakeDynamic() {
AnimData animData = blenderContext.getAnimData(this.owner.getOma());
if(animData != null) {
Object owner = this.owner.getObject();
@@ -90,7 +90,7 @@ import com.jme3.scene.plugins.ogre.AnimData;
}
@Override
- public void bakeStatic() {
+ protected void bakeStatic() {
Transform ownerTransform = this.owner.getTransform();
this.sizeLimit(ownerTransform.getScale(), ipo.calculateValue(0));
this.owner.applyTransform(ownerTransform);
diff --git a/engine/src/blender/com/jme3/scene/plugins/blender/constraints/ConstraintSplineInverseKinematic.java b/engine/src/blender/com/jme3/scene/plugins/blender/constraints/ConstraintSplineInverseKinematic.java
index 753ebf87b..f03db1dca 100644
--- a/engine/src/blender/com/jme3/scene/plugins/blender/constraints/ConstraintSplineInverseKinematic.java
+++ b/engine/src/blender/com/jme3/scene/plugins/blender/constraints/ConstraintSplineInverseKinematic.java
@@ -37,13 +37,13 @@ import com.jme3.scene.plugins.blender.file.Structure;
}
@Override
- public void bakeDynamic() {
+ protected void bakeDynamic() {
// TODO Auto-generated method stub
LOGGER.log(Level.WARNING, "'Splie IK' constraint NOT implemented!");
}
@Override
- public void bakeStatic() {
+ protected void bakeStatic() {
// TODO Auto-generated method stub
LOGGER.log(Level.WARNING, "'Spline IK' constraint NOT implemented!");
}
diff --git a/engine/src/blender/com/jme3/scene/plugins/blender/constraints/ConstraintStretchTo.java b/engine/src/blender/com/jme3/scene/plugins/blender/constraints/ConstraintStretchTo.java
index 7c56d346b..c25097fd6 100644
--- a/engine/src/blender/com/jme3/scene/plugins/blender/constraints/ConstraintStretchTo.java
+++ b/engine/src/blender/com/jme3/scene/plugins/blender/constraints/ConstraintStretchTo.java
@@ -35,13 +35,13 @@ import java.util.logging.Logger;
}
@Override
- public void bakeDynamic() {
+ protected void bakeDynamic() {
// TODO: implement 'Stretch to' constraint
LOGGER.log(Level.WARNING, "'Stretch to' constraint NOT implemented!");
}
@Override
- public void bakeStatic() {
+ protected void bakeStatic() {
// TODO: implement 'Stretch to' constraint
LOGGER.log(Level.WARNING, "'Stretch to' constraint NOT implemented!");
}
diff --git a/engine/src/blender/com/jme3/scene/plugins/blender/constraints/ConstraintTransform.java b/engine/src/blender/com/jme3/scene/plugins/blender/constraints/ConstraintTransform.java
index b5ac5fa30..6928fb821 100644
--- a/engine/src/blender/com/jme3/scene/plugins/blender/constraints/ConstraintTransform.java
+++ b/engine/src/blender/com/jme3/scene/plugins/blender/constraints/ConstraintTransform.java
@@ -35,13 +35,13 @@ import java.util.logging.Logger;
}
@Override
- public void bakeDynamic() {
+ protected void bakeDynamic() {
// TODO: implement 'Transform' constraint
LOGGER.log(Level.WARNING, "'Transform' constraint NOT implemented!");
}
@Override
- public void bakeStatic() {
+ protected void bakeStatic() {
// TODO: implement 'Transform' constraint
LOGGER.log(Level.WARNING, "'Transform' constraint NOT implemented!");
}
diff --git a/engine/src/blender/com/jme3/scene/plugins/blender/constraints/Feature.java b/engine/src/blender/com/jme3/scene/plugins/blender/constraints/Feature.java
index 9d2158c2b..9f20ff7a2 100644
--- a/engine/src/blender/com/jme3/scene/plugins/blender/constraints/Feature.java
+++ b/engine/src/blender/com/jme3/scene/plugins/blender/constraints/Feature.java
@@ -30,6 +30,24 @@ import com.jme3.scene.plugins.blender.file.Structure;
/** The blender context. */
protected BlenderContext blenderContext;
+ /**
+ * Constructs the feature. This object should be loaded later
+ * when it is read from the blender file.
+ * The update method should be called before the feature is used.
+ *
+ * @param space
+ * the spatial's evaluation space
+ * @param oma
+ * the spatial's old memory address
+ * @param blenderContext
+ * the blender context
+ */
+ public Feature(Space space, Long oma, BlenderContext blenderContext) {
+ this.space = space;
+ this.oma = oma;
+ this.blenderContext = blenderContext;
+ }
+
/**
* Constructs the feature based on spatial.
*
@@ -43,9 +61,7 @@ import com.jme3.scene.plugins.blender.file.Structure;
* the blender context
*/
public Feature(Spatial spatial, Space space, Long oma, BlenderContext blenderContext) {
- this.space = space;
- this.oma = oma;
- this.spatial = spatial;
+ this(space, oma, blenderContext);
this.blenderContext = blenderContext;
}
@@ -62,12 +78,26 @@ import com.jme3.scene.plugins.blender.file.Structure;
* the blender context
*/
public Feature(Bone bone, Space space, Long oma, BlenderContext blenderContext) {
- this.space = space;
- this.oma = oma;
- this.blenderContext = blenderContext;
+ this(space, oma, blenderContext);
this.bone = bone;
}
-
+
+ /**
+ * This method should be called before the feature is used.
+ * It may happen that the object this feature refers to was not yet loaded from blend file
+ * when the instance of this class was created.
+ */
+ public void update() {
+ Object owner = blenderContext.getLoadedFeature(oma, LoadedFeatureDataType.LOADED_FEATURE);
+ if(owner instanceof Spatial) {
+ this.spatial = (Spatial) owner;
+ } else if(owner instanceof Bone) {
+ this.bone = (Bone) owner;
+ } else {
+ throw new IllegalStateException("Unknown type of owner: " + owner.getClass());
+ }
+ }
+
/**
* @return the feature's old memory address
*/
diff --git a/engine/src/blender/com/jme3/scene/plugins/blender/modifiers/ArmatureModifier.java b/engine/src/blender/com/jme3/scene/plugins/blender/modifiers/ArmatureModifier.java
index 30944ed9c..40dee6ac2 100644
--- a/engine/src/blender/com/jme3/scene/plugins/blender/modifiers/ArmatureModifier.java
+++ b/engine/src/blender/com/jme3/scene/plugins/blender/modifiers/ArmatureModifier.java
@@ -11,9 +11,11 @@ import java.util.logging.Logger;
import com.jme3.animation.AnimControl;
import com.jme3.animation.Animation;
+import com.jme3.animation.Bone;
import com.jme3.animation.BoneTrack;
import com.jme3.animation.Skeleton;
import com.jme3.animation.SkeletonControl;
+import com.jme3.math.Matrix4f;
import com.jme3.scene.Geometry;
import com.jme3.scene.Mesh;
import com.jme3.scene.Node;
@@ -88,16 +90,33 @@ import com.jme3.util.BufferUtils;
Pointer pArmatureObject = (Pointer) modifierStructure.getFieldValue("object");
if (pArmatureObject.isNotNull()) {
ArmatureHelper armatureHelper = blenderContext.getHelper(ArmatureHelper.class);
- ObjectHelper objectHelper = blenderContext.getHelper(ObjectHelper.class);
-
+
Structure armatureObject = pArmatureObject.fetchData(blenderContext.getInputStream()).get(0);
// load skeleton
Structure armatureStructure = ((Pointer) armatureObject.getFieldValue("data")).fetchData(blenderContext.getInputStream()).get(0);
+
+ Structure pose = ((Pointer) armatureObject.getFieldValue("pose")).fetchData(blenderContext.getInputStream()).get(0);
+ List chanbase = ((Structure) pose.getFieldValue("chanbase")).evaluateListBase(blenderContext);
+
+ Map bonesPoseChannels = new HashMap(chanbase.size());
+ for (Structure poseChannel : chanbase) {
+ Pointer pBone = (Pointer) poseChannel.getFieldValue("bone");
+ bonesPoseChannels.put(pBone.getOldMemoryAddress(), poseChannel);
+ }
+
+ ObjectHelper objectHelper = blenderContext.getHelper(ObjectHelper.class);
+ Matrix4f armatureObjectMatrix = objectHelper.getMatrix(armatureObject, "obmat", true);
+ Matrix4f inverseMeshObjectMatrix = objectHelper.getMatrix(objectStructure, "obmat", true).invertLocal();
+ Matrix4f objectToArmatureTransformation = armatureObjectMatrix.multLocal(inverseMeshObjectMatrix);
+
List bonebase = ((Structure) armatureStructure.getFieldValue("bonebase")).evaluateListBase(blenderContext);
- //load the skeleton and its bones first
- objectHelper.toObject(armatureObject, blenderContext);
- Skeleton skeleton = blenderContext.getSkeleton(armatureObject.getOldMemoryAddress());
+ List bonesList = new ArrayList();
+ for (int i = 0; i < bonebase.size(); ++i) {
+ armatureHelper.buildBones(bonebase.get(i), null, bonesList, objectToArmatureTransformation, bonesPoseChannels, blenderContext);
+ }
+ bonesList.add(0, new Bone(""));
+ Skeleton skeleton = new Skeleton(bonesList.toArray(new Bone[bonesList.size()]));
// read mesh indexes
this.meshOMA = meshStructure.getOldMemoryAddress();
@@ -179,8 +198,7 @@ import com.jme3.util.BufferUtils;
List constraints = blenderContext.getConstraints(boneOMA);
if (constraints != null && constraints.size() > 0) {
for (Constraint constraint : constraints) {
- constraint.bakeDynamic();
- constraint.bakeStatic();
+ constraint.bake(Constraint.BAKE_DYNAMIC | Constraint.BAKE_STATIC);
}
}
}
diff --git a/engine/src/blender/com/jme3/scene/plugins/blender/objects/ObjectHelper.java b/engine/src/blender/com/jme3/scene/plugins/blender/objects/ObjectHelper.java
index 1dee924b4..8d98a3c4a 100644
--- a/engine/src/blender/com/jme3/scene/plugins/blender/objects/ObjectHelper.java
+++ b/engine/src/blender/com/jme3/scene/plugins/blender/objects/ObjectHelper.java
@@ -31,16 +31,11 @@
*/
package com.jme3.scene.plugins.blender.objects;
-import java.util.ArrayList;
import java.util.Collection;
-import java.util.HashMap;
import java.util.List;
-import java.util.Map;
import java.util.logging.Level;
import java.util.logging.Logger;
-import com.jme3.animation.Bone;
-import com.jme3.animation.Skeleton;
import com.jme3.asset.BlenderKey.FeaturesToLoad;
import com.jme3.light.DirectionalLight;
import com.jme3.light.Light;
@@ -58,7 +53,6 @@ import com.jme3.scene.Spatial.CullHint;
import com.jme3.scene.plugins.blender.AbstractBlenderHelper;
import com.jme3.scene.plugins.blender.BlenderContext;
import com.jme3.scene.plugins.blender.BlenderContext.LoadedFeatureDataType;
-import com.jme3.scene.plugins.blender.animations.ArmatureHelper;
import com.jme3.scene.plugins.blender.cameras.CameraHelper;
import com.jme3.scene.plugins.blender.constraints.Constraint;
import com.jme3.scene.plugins.blender.constraints.ConstraintHelper;
@@ -239,31 +233,6 @@ public class ObjectHelper extends AbstractBlenderHelper {
}
break;
case OBJECT_TYPE_ARMATURE:
- //load the skeleton first and store it in the blender context
- Structure armatureStructure = ((Pointer) objectStructure.getFieldValue("data")).fetchData(blenderContext.getInputStream()).get(0);
- Structure pose = ((Pointer) objectStructure.getFieldValue("pose")).fetchData(blenderContext.getInputStream()).get(0);
- List chanbase = ((Structure) pose.getFieldValue("chanbase")).evaluateListBase(blenderContext);
-
- Map bonesPoseChannels = new HashMap(chanbase.size());
- for (Structure poseChannel : chanbase) {
- Pointer pBone = (Pointer) poseChannel.getFieldValue("bone");
- bonesPoseChannels.put(pBone.getOldMemoryAddress(), poseChannel);
- }
-
- Matrix4f armatureObjectMatrix = this.getMatrix(objectStructure, "obmat", true);
- Matrix4f inverseMeshObjectMatrix = this.getMatrix(objectStructure, "obmat", true).invertLocal();
- Matrix4f objectToArmatureTransformation = armatureObjectMatrix.multLocal(inverseMeshObjectMatrix);
-
- List bonebase = ((Structure) armatureStructure.getFieldValue("bonebase")).evaluateListBase(blenderContext);
- ArmatureHelper armatureHelper = blenderContext.getHelper(ArmatureHelper.class);
- List bonesList = new ArrayList();
- for (int i = 0; i < bonebase.size(); ++i) {
- armatureHelper.buildBones(bonebase.get(i), null, bonesList, objectToArmatureTransformation, bonesPoseChannels, blenderContext);
- }
- bonesList.add(0, new Bone(""));
- Skeleton skeleton = new Skeleton(bonesList.toArray(new Bone[bonesList.size()]));
- blenderContext.setSkeleton(objectStructure.getOldMemoryAddress(), skeleton);
-
//need to create an empty node to properly create parent-children relationships between nodes
Node armature = new Node(name);
armature.setLocalTransform(t);
@@ -292,7 +261,7 @@ public class ObjectHelper extends AbstractBlenderHelper {
List objectConstraints = blenderContext.getConstraints(objectStructure.getOldMemoryAddress());
if(objectConstraints!=null) {
for(Constraint objectConstraint : objectConstraints) {
- objectConstraint.bakeStatic();
+ objectConstraint.bake(Constraint.BAKE_STATIC);
}
}