|
@@ -48,21 +48,21 @@ import java.util.ArrayList;
|
|
* <code>Bone</code> describes a bone in the bone-weight skeletal animation
|
|
* <code>Bone</code> describes a bone in the bone-weight skeletal animation
|
|
* system. A bone contains a name and an index, as well as relevant
|
|
* system. A bone contains a name and an index, as well as relevant
|
|
* transformation data.
|
|
* transformation data.
|
|
- *
|
|
|
|
|
|
+ *
|
|
* A bone has 3 sets of transforms :
|
|
* A bone has 3 sets of transforms :
|
|
* 1. The bind transforms, that are the transforms of the bone when the skeleton
|
|
* 1. The bind transforms, that are the transforms of the bone when the skeleton
|
|
- * is in its rest pose (also called bind pose or T pose in the literature).
|
|
|
|
- * The bind transforms are expressed in Local space meaning relatively to the
|
|
|
|
|
|
+ * is in its rest pose (also called bind pose or T pose in the literature).
|
|
|
|
+ * The bind transforms are expressed in Local space meaning relatively to the
|
|
* parent bone.
|
|
* parent bone.
|
|
- *
|
|
|
|
|
|
+ *
|
|
* 2. The Local transforms, that are the transforms of the bone once animation
|
|
* 2. The Local transforms, that are the transforms of the bone once animation
|
|
* or user transforms has been applied to the bind pose. The local transforms are
|
|
* or user transforms has been applied to the bind pose. The local transforms are
|
|
* expressed in Local space meaning relatively to the parent bone.
|
|
* expressed in Local space meaning relatively to the parent bone.
|
|
- *
|
|
|
|
- * 3. The Model transforms, that are the transforms of the bone relatives to the
|
|
|
|
- * rootBone of the skeleton. Those transforms are what is needed to apply skinning
|
|
|
|
|
|
+ *
|
|
|
|
+ * 3. The Model transforms, that are the transforms of the bone relatives to the
|
|
|
|
+ * rootBone of the skeleton. Those transforms are what is needed to apply skinning
|
|
* to the mesh the skeleton controls.
|
|
* to the mesh the skeleton controls.
|
|
- * Note that there can be several rootBones in a skeleton. The one considered for
|
|
|
|
|
|
+ * Note that there can be several rootBones in a skeleton. The one considered for
|
|
* these transforms is the one that is an ancestor of this bone.
|
|
* these transforms is the one that is an ancestor of this bone.
|
|
*
|
|
*
|
|
* @author Kirill Vainer
|
|
* @author Kirill Vainer
|
|
@@ -96,14 +96,14 @@ public final class Bone implements Savable, JmeCloneable {
|
|
private Vector3f bindPos;
|
|
private Vector3f bindPos;
|
|
private Quaternion bindRot;
|
|
private Quaternion bindRot;
|
|
private Vector3f bindScale;
|
|
private Vector3f bindScale;
|
|
-
|
|
|
|
|
|
+
|
|
/**
|
|
/**
|
|
- * The inverse bind transforms of this bone expressed in model space
|
|
|
|
|
|
+ * The inverse bind transforms of this bone expressed in model space
|
|
*/
|
|
*/
|
|
private Vector3f modelBindInversePos;
|
|
private Vector3f modelBindInversePos;
|
|
private Quaternion modelBindInverseRot;
|
|
private Quaternion modelBindInverseRot;
|
|
private Vector3f modelBindInverseScale;
|
|
private Vector3f modelBindInverseScale;
|
|
-
|
|
|
|
|
|
+
|
|
/**
|
|
/**
|
|
* The local animated or user transform combined with the local bind transform
|
|
* The local animated or user transform combined with the local bind transform
|
|
*/
|
|
*/
|
|
@@ -111,15 +111,15 @@ public final class Bone implements Savable, JmeCloneable {
|
|
private Quaternion localRot = new Quaternion();
|
|
private Quaternion localRot = new Quaternion();
|
|
private Vector3f localScale = new Vector3f(1.0f, 1.0f, 1.0f);
|
|
private Vector3f localScale = new Vector3f(1.0f, 1.0f, 1.0f);
|
|
/**
|
|
/**
|
|
- * The model transforms of this bone
|
|
|
|
|
|
+ * The model transforms of this bone
|
|
*/
|
|
*/
|
|
private Vector3f modelPos = new Vector3f();
|
|
private Vector3f modelPos = new Vector3f();
|
|
private Quaternion modelRot = new Quaternion();
|
|
private Quaternion modelRot = new Quaternion();
|
|
private Vector3f modelScale = new Vector3f();
|
|
private Vector3f modelScale = new Vector3f();
|
|
-
|
|
|
|
|
|
+
|
|
// Used for getCombinedTransform
|
|
// Used for getCombinedTransform
|
|
private Transform tmpTransform;
|
|
private Transform tmpTransform;
|
|
-
|
|
|
|
|
|
+
|
|
/**
|
|
/**
|
|
* Used to handle blending from one animation to another.
|
|
* Used to handle blending from one animation to another.
|
|
* See {@link #blendAnimTransforms(com.jme3.math.Vector3f, com.jme3.math.Quaternion, com.jme3.math.Vector3f, float)}
|
|
* See {@link #blendAnimTransforms(com.jme3.math.Vector3f, com.jme3.math.Quaternion, com.jme3.math.Vector3f, float)}
|
|
@@ -129,13 +129,13 @@ public final class Bone implements Savable, JmeCloneable {
|
|
|
|
|
|
/**
|
|
/**
|
|
* Creates a new bone with the given name.
|
|
* Creates a new bone with the given name.
|
|
- *
|
|
|
|
|
|
+ *
|
|
* @param name Name to give to this bone
|
|
* @param name Name to give to this bone
|
|
*/
|
|
*/
|
|
public Bone(String name) {
|
|
public Bone(String name) {
|
|
if (name == null)
|
|
if (name == null)
|
|
throw new IllegalArgumentException("Name cannot be null");
|
|
throw new IllegalArgumentException("Name cannot be null");
|
|
-
|
|
|
|
|
|
+
|
|
this.name = name;
|
|
this.name = name;
|
|
|
|
|
|
bindPos = new Vector3f();
|
|
bindPos = new Vector3f();
|
|
@@ -148,13 +148,13 @@ public final class Bone implements Savable, JmeCloneable {
|
|
}
|
|
}
|
|
|
|
|
|
/**
|
|
/**
|
|
- * Special-purpose copy constructor.
|
|
|
|
|
|
+ * Special-purpose copy constructor.
|
|
* <p>
|
|
* <p>
|
|
* Only copies the name, user control state and bind pose transforms from the original.
|
|
* Only copies the name, user control state and bind pose transforms from the original.
|
|
* <p>
|
|
* <p>
|
|
* The rest of the data is <em>NOT</em> copied, as it will be
|
|
* The rest of the data is <em>NOT</em> copied, as it will be
|
|
* generated automatically when the bone is animated.
|
|
* generated automatically when the bone is animated.
|
|
- *
|
|
|
|
|
|
+ *
|
|
* @param source The bone from which to copy the data.
|
|
* @param source The bone from which to copy the data.
|
|
*/
|
|
*/
|
|
Bone(Bone source) {
|
|
Bone(Bone source) {
|
|
@@ -178,48 +178,48 @@ public final class Bone implements Savable, JmeCloneable {
|
|
*/
|
|
*/
|
|
protected Bone() {
|
|
protected Bone() {
|
|
}
|
|
}
|
|
-
|
|
|
|
- @Override
|
|
|
|
|
|
+
|
|
|
|
+ @Override
|
|
public Object jmeClone() {
|
|
public Object jmeClone() {
|
|
try {
|
|
try {
|
|
- Bone clone = (Bone)super.clone();
|
|
|
|
|
|
+ Bone clone = (Bone) super.clone();
|
|
return clone;
|
|
return clone;
|
|
} catch (CloneNotSupportedException ex) {
|
|
} catch (CloneNotSupportedException ex) {
|
|
throw new AssertionError();
|
|
throw new AssertionError();
|
|
}
|
|
}
|
|
- }
|
|
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ @Override
|
|
|
|
+ public void cloneFields(Cloner cloner, Object original) {
|
|
|
|
|
|
- @Override
|
|
|
|
- public void cloneFields( Cloner cloner, Object original ) {
|
|
|
|
-
|
|
|
|
this.parent = cloner.clone(parent);
|
|
this.parent = cloner.clone(parent);
|
|
- this.children = cloner.clone(children);
|
|
|
|
-
|
|
|
|
|
|
+ this.children = cloner.clone(children);
|
|
|
|
+
|
|
this.attachNode = cloner.clone(attachNode);
|
|
this.attachNode = cloner.clone(attachNode);
|
|
this.targetGeometry = cloner.clone(targetGeometry);
|
|
this.targetGeometry = cloner.clone(targetGeometry);
|
|
|
|
|
|
this.bindPos = cloner.clone(bindPos);
|
|
this.bindPos = cloner.clone(bindPos);
|
|
this.bindRot = cloner.clone(bindRot);
|
|
this.bindRot = cloner.clone(bindRot);
|
|
this.bindScale = cloner.clone(bindScale);
|
|
this.bindScale = cloner.clone(bindScale);
|
|
-
|
|
|
|
|
|
+
|
|
this.modelBindInversePos = cloner.clone(modelBindInversePos);
|
|
this.modelBindInversePos = cloner.clone(modelBindInversePos);
|
|
this.modelBindInverseRot = cloner.clone(modelBindInverseRot);
|
|
this.modelBindInverseRot = cloner.clone(modelBindInverseRot);
|
|
this.modelBindInverseScale = cloner.clone(modelBindInverseScale);
|
|
this.modelBindInverseScale = cloner.clone(modelBindInverseScale);
|
|
-
|
|
|
|
|
|
+
|
|
this.localPos = cloner.clone(localPos);
|
|
this.localPos = cloner.clone(localPos);
|
|
this.localRot = cloner.clone(localRot);
|
|
this.localRot = cloner.clone(localRot);
|
|
this.localScale = cloner.clone(localScale);
|
|
this.localScale = cloner.clone(localScale);
|
|
-
|
|
|
|
|
|
+
|
|
this.modelPos = cloner.clone(modelPos);
|
|
this.modelPos = cloner.clone(modelPos);
|
|
this.modelRot = cloner.clone(modelRot);
|
|
this.modelRot = cloner.clone(modelRot);
|
|
this.modelScale = cloner.clone(modelScale);
|
|
this.modelScale = cloner.clone(modelScale);
|
|
-
|
|
|
|
|
|
+
|
|
this.tmpTransform = cloner.clone(tmpTransform);
|
|
this.tmpTransform = cloner.clone(tmpTransform);
|
|
}
|
|
}
|
|
|
|
|
|
/**
|
|
/**
|
|
* Returns the name of the bone, set in the constructor.
|
|
* Returns the name of the bone, set in the constructor.
|
|
- *
|
|
|
|
|
|
+ *
|
|
* @return The name of the bone, set in the constructor.
|
|
* @return The name of the bone, set in the constructor.
|
|
*/
|
|
*/
|
|
public String getName() {
|
|
public String getName() {
|
|
@@ -236,7 +236,7 @@ public final class Bone implements Savable, JmeCloneable {
|
|
|
|
|
|
/**
|
|
/**
|
|
* Returns all the children bones of this bone.
|
|
* Returns all the children bones of this bone.
|
|
- *
|
|
|
|
|
|
+ *
|
|
* @return All the children bones of this bone.
|
|
* @return All the children bones of this bone.
|
|
*/
|
|
*/
|
|
public ArrayList<Bone> getChildren() {
|
|
public ArrayList<Bone> getChildren() {
|
|
@@ -245,7 +245,7 @@ public final class Bone implements Savable, JmeCloneable {
|
|
|
|
|
|
/**
|
|
/**
|
|
* Returns the local position of the bone, relative to the parent bone.
|
|
* Returns the local position of the bone, relative to the parent bone.
|
|
- *
|
|
|
|
|
|
+ *
|
|
* @return The local position of the bone, relative to the parent bone.
|
|
* @return The local position of the bone, relative to the parent bone.
|
|
*/
|
|
*/
|
|
public Vector3f getLocalPosition() {
|
|
public Vector3f getLocalPosition() {
|
|
@@ -254,7 +254,7 @@ public final class Bone implements Savable, JmeCloneable {
|
|
|
|
|
|
/**
|
|
/**
|
|
* Returns the local rotation of the bone, relative to the parent bone.
|
|
* Returns the local rotation of the bone, relative to the parent bone.
|
|
- *
|
|
|
|
|
|
+ *
|
|
* @return The local rotation of the bone, relative to the parent bone.
|
|
* @return The local rotation of the bone, relative to the parent bone.
|
|
*/
|
|
*/
|
|
public Quaternion getLocalRotation() {
|
|
public Quaternion getLocalRotation() {
|
|
@@ -263,7 +263,7 @@ public final class Bone implements Savable, JmeCloneable {
|
|
|
|
|
|
/**
|
|
/**
|
|
* Returns the local scale of the bone, relative to the parent bone.
|
|
* Returns the local scale of the bone, relative to the parent bone.
|
|
- *
|
|
|
|
|
|
+ *
|
|
* @return The local scale of the bone, relative to the parent bone.
|
|
* @return The local scale of the bone, relative to the parent bone.
|
|
*/
|
|
*/
|
|
public Vector3f getLocalScale() {
|
|
public Vector3f getLocalScale() {
|
|
@@ -272,7 +272,7 @@ public final class Bone implements Savable, JmeCloneable {
|
|
|
|
|
|
/**
|
|
/**
|
|
* Returns the position of the bone in model space.
|
|
* Returns the position of the bone in model space.
|
|
- *
|
|
|
|
|
|
+ *
|
|
* @return The position of the bone in model space.
|
|
* @return The position of the bone in model space.
|
|
*/
|
|
*/
|
|
public Vector3f getModelSpacePosition() {
|
|
public Vector3f getModelSpacePosition() {
|
|
@@ -281,7 +281,7 @@ public final class Bone implements Savable, JmeCloneable {
|
|
|
|
|
|
/**
|
|
/**
|
|
* Returns the rotation of the bone in model space.
|
|
* Returns the rotation of the bone in model space.
|
|
- *
|
|
|
|
|
|
+ *
|
|
* @return The rotation of the bone in model space.
|
|
* @return The rotation of the bone in model space.
|
|
*/
|
|
*/
|
|
public Quaternion getModelSpaceRotation() {
|
|
public Quaternion getModelSpaceRotation() {
|
|
@@ -290,7 +290,7 @@ public final class Bone implements Savable, JmeCloneable {
|
|
|
|
|
|
/**
|
|
/**
|
|
* Returns the scale of the bone in model space.
|
|
* Returns the scale of the bone in model space.
|
|
- *
|
|
|
|
|
|
+ *
|
|
* @return The scale of the bone in model space.
|
|
* @return The scale of the bone in model space.
|
|
*/
|
|
*/
|
|
public Vector3f getModelSpaceScale() {
|
|
public Vector3f getModelSpaceScale() {
|
|
@@ -301,19 +301,19 @@ public final class Bone implements Savable, JmeCloneable {
|
|
* @return the pre-existing vector
|
|
* @return the pre-existing vector
|
|
* @deprecated use {@link #getModelBindInversePosition()}
|
|
* @deprecated use {@link #getModelBindInversePosition()}
|
|
*/
|
|
*/
|
|
- @Deprecated
|
|
|
|
|
|
+ @Deprecated
|
|
public Vector3f getWorldBindInversePosition() {
|
|
public Vector3f getWorldBindInversePosition() {
|
|
return modelBindInversePos;
|
|
return modelBindInversePos;
|
|
}
|
|
}
|
|
-
|
|
|
|
- /**
|
|
|
|
|
|
+
|
|
|
|
+ /**
|
|
* Returns the inverse Bind position of this bone expressed in model space.
|
|
* Returns the inverse Bind position of this bone expressed in model space.
|
|
* <p>
|
|
* <p>
|
|
* The inverse bind pose transform of the bone in model space is its "default"
|
|
* The inverse bind pose transform of the bone in model space is its "default"
|
|
* transform with no animation applied.
|
|
* transform with no animation applied.
|
|
- *
|
|
|
|
|
|
+ *
|
|
* @return the inverse bind position of this bone expressed in model space.
|
|
* @return the inverse bind position of this bone expressed in model space.
|
|
- */
|
|
|
|
|
|
+ */
|
|
public Vector3f getModelBindInversePosition() {
|
|
public Vector3f getModelBindInversePosition() {
|
|
return modelBindInversePos;
|
|
return modelBindInversePos;
|
|
}
|
|
}
|
|
@@ -326,20 +326,19 @@ public final class Bone implements Savable, JmeCloneable {
|
|
public Quaternion getWorldBindInverseRotation() {
|
|
public Quaternion getWorldBindInverseRotation() {
|
|
return modelBindInverseRot;
|
|
return modelBindInverseRot;
|
|
}
|
|
}
|
|
-
|
|
|
|
- /**
|
|
|
|
|
|
+
|
|
|
|
+ /**
|
|
* Returns the inverse bind rotation of this bone expressed in model space.
|
|
* Returns the inverse bind rotation of this bone expressed in model space.
|
|
* <p>
|
|
* <p>
|
|
* The inverse bind pose transform of the bone in model space is its "default"
|
|
* The inverse bind pose transform of the bone in model space is its "default"
|
|
* transform with no animation applied.
|
|
* transform with no animation applied.
|
|
- *
|
|
|
|
|
|
+ *
|
|
* @return the inverse bind rotation of this bone expressed in model space.
|
|
* @return the inverse bind rotation of this bone expressed in model space.
|
|
*/
|
|
*/
|
|
public Quaternion getModelBindInverseRotation() {
|
|
public Quaternion getModelBindInverseRotation() {
|
|
return modelBindInverseRot;
|
|
return modelBindInverseRot;
|
|
}
|
|
}
|
|
|
|
|
|
-
|
|
|
|
/**
|
|
/**
|
|
* @return the pre-existing vector
|
|
* @return the pre-existing vector
|
|
* @deprecated use {@link #getModelBindInverseScale()}
|
|
* @deprecated use {@link #getModelBindInverseScale()}
|
|
@@ -348,13 +347,13 @@ public final class Bone implements Savable, JmeCloneable {
|
|
public Vector3f getWorldBindInverseScale() {
|
|
public Vector3f getWorldBindInverseScale() {
|
|
return modelBindInverseScale;
|
|
return modelBindInverseScale;
|
|
}
|
|
}
|
|
-
|
|
|
|
|
|
+
|
|
/**
|
|
/**
|
|
* Returns the inverse world bind pose scale.
|
|
* Returns the inverse world bind pose scale.
|
|
* <p>
|
|
* <p>
|
|
* The inverse bind pose transform of the bone in model space is its "default"
|
|
* The inverse bind pose transform of the bone in model space is its "default"
|
|
* transform with no animation applied.
|
|
* transform with no animation applied.
|
|
- *
|
|
|
|
|
|
+ *
|
|
* @return the inverse world bind pose scale.
|
|
* @return the inverse world bind pose scale.
|
|
*/
|
|
*/
|
|
public Vector3f getModelBindInverseScale() {
|
|
public Vector3f getModelBindInverseScale() {
|
|
@@ -370,7 +369,7 @@ public final class Bone implements Savable, JmeCloneable {
|
|
}
|
|
}
|
|
return t;
|
|
return t;
|
|
}
|
|
}
|
|
-
|
|
|
|
|
|
+
|
|
public Transform getBindInverseTransform() {
|
|
public Transform getBindInverseTransform() {
|
|
Transform t = new Transform();
|
|
Transform t = new Transform();
|
|
t.setTranslation(bindPos);
|
|
t.setTranslation(bindPos);
|
|
@@ -380,7 +379,7 @@ public final class Bone implements Savable, JmeCloneable {
|
|
}
|
|
}
|
|
return t.invert();
|
|
return t.invert();
|
|
}
|
|
}
|
|
-
|
|
|
|
|
|
+
|
|
/**
|
|
/**
|
|
* @return the pre-existing vector
|
|
* @return the pre-existing vector
|
|
* @deprecated use {@link #getBindPosition()}
|
|
* @deprecated use {@link #getBindPosition()}
|
|
@@ -389,13 +388,13 @@ public final class Bone implements Savable, JmeCloneable {
|
|
public Vector3f getWorldBindPosition() {
|
|
public Vector3f getWorldBindPosition() {
|
|
return bindPos;
|
|
return bindPos;
|
|
}
|
|
}
|
|
-
|
|
|
|
- /**
|
|
|
|
|
|
+
|
|
|
|
+ /**
|
|
* Returns the bind position expressed in local space (relative to the parent bone).
|
|
* Returns the bind position expressed in local space (relative to the parent bone).
|
|
* <p>
|
|
* <p>
|
|
* The bind pose transform of the bone in local space is its "default"
|
|
* The bind pose transform of the bone in local space is its "default"
|
|
* transform with no animation applied.
|
|
* transform with no animation applied.
|
|
- *
|
|
|
|
|
|
+ *
|
|
* @return the bind position in local space.
|
|
* @return the bind position in local space.
|
|
*/
|
|
*/
|
|
public Vector3f getBindPosition() {
|
|
public Vector3f getBindPosition() {
|
|
@@ -405,7 +404,7 @@ public final class Bone implements Savable, JmeCloneable {
|
|
/**
|
|
/**
|
|
* @return the pre-existing Quaternion
|
|
* @return the pre-existing Quaternion
|
|
* @deprecated use {@link #getBindRotation() }
|
|
* @deprecated use {@link #getBindRotation() }
|
|
- */
|
|
|
|
|
|
+ */
|
|
@Deprecated
|
|
@Deprecated
|
|
public Quaternion getWorldBindRotation() {
|
|
public Quaternion getWorldBindRotation() {
|
|
return bindRot;
|
|
return bindRot;
|
|
@@ -416,13 +415,13 @@ public final class Bone implements Savable, JmeCloneable {
|
|
* <p>
|
|
* <p>
|
|
* The bind pose transform of the bone in local space is its "default"
|
|
* The bind pose transform of the bone in local space is its "default"
|
|
* transform with no animation applied.
|
|
* transform with no animation applied.
|
|
- *
|
|
|
|
|
|
+ *
|
|
* @return the bind rotation in local space.
|
|
* @return the bind rotation in local space.
|
|
- */
|
|
|
|
|
|
+ */
|
|
public Quaternion getBindRotation() {
|
|
public Quaternion getBindRotation() {
|
|
return bindRot;
|
|
return bindRot;
|
|
- }
|
|
|
|
-
|
|
|
|
|
|
+ }
|
|
|
|
+
|
|
/**
|
|
/**
|
|
* @return the pre-existing vector
|
|
* @return the pre-existing vector
|
|
* @deprecated use {@link #getBindScale() }
|
|
* @deprecated use {@link #getBindScale() }
|
|
@@ -431,13 +430,13 @@ public final class Bone implements Savable, JmeCloneable {
|
|
public Vector3f getWorldBindScale() {
|
|
public Vector3f getWorldBindScale() {
|
|
return bindScale;
|
|
return bindScale;
|
|
}
|
|
}
|
|
-
|
|
|
|
|
|
+
|
|
/**
|
|
/**
|
|
* Returns the bind scale expressed in local space (relative to the parent bone).
|
|
* Returns the bind scale expressed in local space (relative to the parent bone).
|
|
* <p>
|
|
* <p>
|
|
* The bind pose transform of the bone in local space is its "default"
|
|
* The bind pose transform of the bone in local space is its "default"
|
|
* transform with no animation applied.
|
|
* transform with no animation applied.
|
|
- *
|
|
|
|
|
|
+ *
|
|
* @return the bind scale in local space.
|
|
* @return the bind scale in local space.
|
|
*/
|
|
*/
|
|
public Vector3f getBindScale() {
|
|
public Vector3f getBindScale() {
|
|
@@ -457,7 +456,7 @@ public final class Bone implements Savable, JmeCloneable {
|
|
/**
|
|
/**
|
|
* Add a new child to this bone. Shouldn't be used by user code.
|
|
* Add a new child to this bone. Shouldn't be used by user code.
|
|
* Can corrupt skeleton.
|
|
* Can corrupt skeleton.
|
|
- *
|
|
|
|
|
|
+ *
|
|
* @param bone The bone to add
|
|
* @param bone The bone to add
|
|
*/
|
|
*/
|
|
public void addChild(Bone bone) {
|
|
public void addChild(Bone bone) {
|
|
@@ -466,15 +465,14 @@ public final class Bone implements Savable, JmeCloneable {
|
|
}
|
|
}
|
|
|
|
|
|
/**
|
|
/**
|
|
- *
|
|
|
|
|
|
+ *
|
|
* @deprecated use {@link #updateModelTransforms() }
|
|
* @deprecated use {@link #updateModelTransforms() }
|
|
*/
|
|
*/
|
|
@Deprecated
|
|
@Deprecated
|
|
- public final void updateWorldVectors(){
|
|
|
|
|
|
+ public final void updateWorldVectors() {
|
|
updateModelTransforms();
|
|
updateModelTransforms();
|
|
}
|
|
}
|
|
-
|
|
|
|
-
|
|
|
|
|
|
+
|
|
/**
|
|
/**
|
|
* Updates the model transforms for this bone and, possibly, the attachments node
|
|
* Updates the model transforms for this bone and, possibly, the attachments node
|
|
* if not null.
|
|
* if not null.
|
|
@@ -497,11 +495,11 @@ public final class Bone implements Savable, JmeCloneable {
|
|
localPos.interpolateLocal(bindPos, invWeightSum);
|
|
localPos.interpolateLocal(bindPos, invWeightSum);
|
|
localScale.interpolateLocal(bindScale, invWeightSum);
|
|
localScale.interpolateLocal(bindScale, invWeightSum);
|
|
}
|
|
}
|
|
-
|
|
|
|
|
|
+
|
|
// Future invocations of transform blend will start over.
|
|
// Future invocations of transform blend will start over.
|
|
currentWeightSum = -1;
|
|
currentWeightSum = -1;
|
|
}
|
|
}
|
|
-
|
|
|
|
|
|
+
|
|
if (parent != null) {
|
|
if (parent != null) {
|
|
//rotation
|
|
//rotation
|
|
parent.modelRot.mult(localRot, modelRot);
|
|
parent.modelRot.mult(localRot, modelRot);
|
|
@@ -512,7 +510,7 @@ public final class Bone implements Savable, JmeCloneable {
|
|
parent.modelScale.mult(localScale, modelScale);
|
|
parent.modelScale.mult(localScale, modelScale);
|
|
|
|
|
|
//translation
|
|
//translation
|
|
- //scale and rotation of parent affect bone position
|
|
|
|
|
|
+ //scale and rotation of parent affect bone position
|
|
parent.modelRot.mult(localPos, modelPos);
|
|
parent.modelRot.mult(localPos, modelPos);
|
|
modelPos.multLocal(parent.modelScale);
|
|
modelPos.multLocal(parent.modelScale);
|
|
modelPos.addLocal(parent.modelPos);
|
|
modelPos.addLocal(parent.modelPos);
|
|
@@ -624,14 +622,14 @@ public final class Bone implements Savable, JmeCloneable {
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
- /**
|
|
|
|
|
|
+ /**
|
|
* Stores the skinning transform in the specified Matrix4f.
|
|
* Stores the skinning transform in the specified Matrix4f.
|
|
* The skinning transform applies the animation of the bone to a vertex.
|
|
* The skinning transform applies the animation of the bone to a vertex.
|
|
- *
|
|
|
|
|
|
+ *
|
|
* This assumes that the world transforms for the entire bone hierarchy
|
|
* This assumes that the world transforms for the entire bone hierarchy
|
|
* have already been computed, otherwise this method will return undefined
|
|
* have already been computed, otherwise this method will return undefined
|
|
* results.
|
|
* results.
|
|
- *
|
|
|
|
|
|
+ *
|
|
* @param outTransform
|
|
* @param outTransform
|
|
*/
|
|
*/
|
|
void getOffsetTransform(Matrix4f outTransform, Quaternion tmp1, Vector3f tmp2, Vector3f tmp3, Matrix3f tmp4) {
|
|
void getOffsetTransform(Matrix4f outTransform, Quaternion tmp1, Vector3f tmp2, Vector3f tmp3, Matrix3f tmp4) {
|
|
@@ -650,7 +648,7 @@ public final class Bone implements Savable, JmeCloneable {
|
|
}
|
|
}
|
|
|
|
|
|
/**
|
|
/**
|
|
- *
|
|
|
|
|
|
+ *
|
|
* Sets the transforms of this bone in local space (relative to the parent bone)
|
|
* Sets the transforms of this bone in local space (relative to the parent bone)
|
|
*
|
|
*
|
|
* @param translation the translation in local space
|
|
* @param translation the translation in local space
|
|
@@ -673,7 +671,7 @@ public final class Bone implements Savable, JmeCloneable {
|
|
|
|
|
|
/**
|
|
/**
|
|
* Sets the transforms of this bone in model space (relative to the root bone)
|
|
* Sets the transforms of this bone in model space (relative to the root bone)
|
|
- *
|
|
|
|
|
|
+ *
|
|
* Must update all bones in skeleton for this to work.
|
|
* Must update all bones in skeleton for this to work.
|
|
* @param translation translation in model space
|
|
* @param translation translation in model space
|
|
* @param rotation rotation in model space
|
|
* @param rotation rotation in model space
|
|
@@ -686,9 +684,9 @@ public final class Bone implements Savable, JmeCloneable {
|
|
// TODO: add scale here ???
|
|
// TODO: add scale here ???
|
|
modelPos.set(translation);
|
|
modelPos.set(translation);
|
|
modelRot.set(rotation);
|
|
modelRot.set(rotation);
|
|
-
|
|
|
|
- //if there is an attached Node we need to set its local transforms too.
|
|
|
|
- if(attachNode != null){
|
|
|
|
|
|
+
|
|
|
|
+ // if there is an attached Node we need to set its local transforms too.
|
|
|
|
+ if (attachNode != null) {
|
|
attachNode.setLocalTranslation(translation);
|
|
attachNode.setLocalTranslation(translation);
|
|
attachNode.setLocalRotation(rotation);
|
|
attachNode.setLocalRotation(rotation);
|
|
}
|
|
}
|
|
@@ -701,7 +699,7 @@ public final class Bone implements Savable, JmeCloneable {
|
|
* @return the resulting Transform (in reusable temporary storage!)
|
|
* @return the resulting Transform (in reusable temporary storage!)
|
|
*/
|
|
*/
|
|
public Transform getCombinedTransform(Vector3f position, Quaternion rotation) {
|
|
public Transform getCombinedTransform(Vector3f position, Quaternion rotation) {
|
|
- if(tmpTransform == null){
|
|
|
|
|
|
+ if (tmpTransform == null) {
|
|
tmpTransform = new Transform();
|
|
tmpTransform = new Transform();
|
|
}
|
|
}
|
|
rotation.mult(localPos, tmpTransform.getTranslation()).addLocal(position);
|
|
rotation.mult(localPos, tmpTransform.getTranslation()).addLocal(position);
|
|
@@ -781,7 +779,7 @@ public final class Bone implements Savable, JmeCloneable {
|
|
* updateModelTransforms() call will result in final transform = transform * 0.5.
|
|
* updateModelTransforms() call will result in final transform = transform * 0.5.
|
|
* Two transform blends with weight = 0.5 each will result in the two
|
|
* Two transform blends with weight = 0.5 each will result in the two
|
|
* transforms blended together (nlerp) with blend = 0.5.
|
|
* transforms blended together (nlerp) with blend = 0.5.
|
|
- *
|
|
|
|
|
|
+ *
|
|
* @param translation The translation to blend in
|
|
* @param translation The translation to blend in
|
|
* @param rotation The rotation to blend in
|
|
* @param rotation The rotation to blend in
|
|
* @param scale The scale to blend in
|
|
* @param scale The scale to blend in
|
|
@@ -792,13 +790,13 @@ public final class Bone implements Savable, JmeCloneable {
|
|
if (userControl) {
|
|
if (userControl) {
|
|
return;
|
|
return;
|
|
}
|
|
}
|
|
-
|
|
|
|
|
|
+
|
|
if (weight == 0) {
|
|
if (weight == 0) {
|
|
// Do not apply this transform at all.
|
|
// Do not apply this transform at all.
|
|
return;
|
|
return;
|
|
}
|
|
}
|
|
|
|
|
|
- if (currentWeightSum == 1){
|
|
|
|
|
|
+ if (currentWeightSum == 1) {
|
|
return; // More than 2 transforms are being blended
|
|
return; // More than 2 transforms are being blended
|
|
} else if (currentWeightSum == -1 || currentWeightSum == 0) {
|
|
} else if (currentWeightSum == -1 || currentWeightSum == 0) {
|
|
// Set the transform fully
|
|
// Set the transform fully
|
|
@@ -810,14 +808,14 @@ public final class Bone implements Savable, JmeCloneable {
|
|
// Set the weight. It will be applied in updateModelTransforms().
|
|
// Set the weight. It will be applied in updateModelTransforms().
|
|
currentWeightSum = weight;
|
|
currentWeightSum = weight;
|
|
} else {
|
|
} else {
|
|
- // The weight is already set.
|
|
|
|
|
|
+ // The weight is already set.
|
|
// Blend in the new transform.
|
|
// Blend in the new transform.
|
|
TempVars vars = TempVars.get();
|
|
TempVars vars = TempVars.get();
|
|
|
|
|
|
Vector3f tmpV = vars.vect1;
|
|
Vector3f tmpV = vars.vect1;
|
|
Vector3f tmpV2 = vars.vect2;
|
|
Vector3f tmpV2 = vars.vect2;
|
|
Quaternion tmpQ = vars.quat1;
|
|
Quaternion tmpQ = vars.quat1;
|
|
-
|
|
|
|
|
|
+
|
|
tmpV.set(bindPos).addLocal(translation);
|
|
tmpV.set(bindPos).addLocal(translation);
|
|
localPos.interpolateLocal(tmpV, weight);
|
|
localPos.interpolateLocal(tmpV, weight);
|
|
|
|
|
|
@@ -828,10 +826,10 @@ public final class Bone implements Savable, JmeCloneable {
|
|
tmpV2.set(bindScale).multLocal(scale);
|
|
tmpV2.set(bindScale).multLocal(scale);
|
|
localScale.interpolateLocal(tmpV2, weight);
|
|
localScale.interpolateLocal(tmpV2, weight);
|
|
}
|
|
}
|
|
-
|
|
|
|
|
|
+
|
|
// Ensures no new weights will be blended in the future.
|
|
// Ensures no new weights will be blended in the future.
|
|
currentWeightSum = 1;
|
|
currentWeightSum = 1;
|
|
-
|
|
|
|
|
|
+
|
|
vars.release();
|
|
vars.release();
|
|
}
|
|
}
|
|
}
|
|
}
|
|
@@ -884,16 +882,16 @@ public final class Bone implements Savable, JmeCloneable {
|
|
|
|
|
|
name = input.readString("name", null);
|
|
name = input.readString("name", null);
|
|
int ver = input.getSavableVersion(Bone.class);
|
|
int ver = input.getSavableVersion(Bone.class);
|
|
- if(ver < 2){
|
|
|
|
|
|
+ if (ver < 2) {
|
|
bindPos = (Vector3f) input.readSavable("initialPos", null);
|
|
bindPos = (Vector3f) input.readSavable("initialPos", null);
|
|
bindRot = (Quaternion) input.readSavable("initialRot", null);
|
|
bindRot = (Quaternion) input.readSavable("initialRot", null);
|
|
bindScale = (Vector3f) input.readSavable("initialScale", new Vector3f(1.0f, 1.0f, 1.0f));
|
|
bindScale = (Vector3f) input.readSavable("initialScale", new Vector3f(1.0f, 1.0f, 1.0f));
|
|
- }else{
|
|
|
|
|
|
+ } else {
|
|
bindPos = (Vector3f) input.readSavable("bindPos", null);
|
|
bindPos = (Vector3f) input.readSavable("bindPos", null);
|
|
bindRot = (Quaternion) input.readSavable("bindRot", null);
|
|
bindRot = (Quaternion) input.readSavable("bindRot", null);
|
|
bindScale = (Vector3f) input.readSavable("bindScale", new Vector3f(1.0f, 1.0f, 1.0f));
|
|
bindScale = (Vector3f) input.readSavable("bindScale", new Vector3f(1.0f, 1.0f, 1.0f));
|
|
}
|
|
}
|
|
-
|
|
|
|
|
|
+
|
|
attachNode = (Node) input.readSavable("attachNode", null);
|
|
attachNode = (Node) input.readSavable("attachNode", null);
|
|
targetGeometry = (Geometry) input.readSavable("targetGeometry", null);
|
|
targetGeometry = (Geometry) input.readSavable("targetGeometry", null);
|
|
|
|
|
|
@@ -931,7 +929,7 @@ public final class Bone implements Savable, JmeCloneable {
|
|
*
|
|
*
|
|
* @param rot the desired rotation (not null, unaffected)
|
|
* @param rot the desired rotation (not null, unaffected)
|
|
*/
|
|
*/
|
|
- public void setLocalRotation(Quaternion rot){
|
|
|
|
|
|
+ public void setLocalRotation(Quaternion rot) {
|
|
if (!userControl) {
|
|
if (!userControl) {
|
|
throw new IllegalStateException("User control must be on bone to allow user transforms");
|
|
throw new IllegalStateException("User control must be on bone to allow user transforms");
|
|
}
|
|
}
|
|
@@ -944,7 +942,7 @@ public final class Bone implements Savable, JmeCloneable {
|
|
*
|
|
*
|
|
* @param pos the desired translation (not null, unaffected)
|
|
* @param pos the desired translation (not null, unaffected)
|
|
*/
|
|
*/
|
|
- public void setLocalTranslation(Vector3f pos){
|
|
|
|
|
|
+ public void setLocalTranslation(Vector3f pos) {
|
|
if (!userControl) {
|
|
if (!userControl) {
|
|
throw new IllegalStateException("User control must be on bone to allow user transforms");
|
|
throw new IllegalStateException("User control must be on bone to allow user transforms");
|
|
}
|
|
}
|
|
@@ -956,7 +954,7 @@ public final class Bone implements Savable, JmeCloneable {
|
|
* Warning: you need to call {@link #setUserControl(boolean)} with true to be able to do that operation
|
|
* Warning: you need to call {@link #setUserControl(boolean)} with true to be able to do that operation
|
|
* @param scale the scale to apply
|
|
* @param scale the scale to apply
|
|
*/
|
|
*/
|
|
- public void setLocalScale(Vector3f scale){
|
|
|
|
|
|
+ public void setLocalScale(Vector3f scale) {
|
|
if (!userControl) {
|
|
if (!userControl) {
|
|
throw new IllegalStateException("User control must be on bone to allow user transforms");
|
|
throw new IllegalStateException("User control must be on bone to allow user transforms");
|
|
}
|
|
}
|
|
@@ -968,7 +966,7 @@ public final class Bone implements Savable, JmeCloneable {
|
|
* @see #setUserControl(boolean)
|
|
* @see #setUserControl(boolean)
|
|
* @return true if it can be manipulated
|
|
* @return true if it can be manipulated
|
|
*/
|
|
*/
|
|
- public boolean hasUserControl(){
|
|
|
|
|
|
+ public boolean hasUserControl() {
|
|
return userControl;
|
|
return userControl;
|
|
}
|
|
}
|
|
}
|
|
}
|