|
@@ -114,8 +114,18 @@ public final class Bone implements Savable {
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
/**
|
|
|
- * Copy constructor. local bind and world inverse bind transforms shallow copied.
|
|
|
|
|
- * @param source
|
|
|
|
|
|
|
+ * Special-purpose copy constructor.
|
|
|
|
|
+ * <p>
|
|
|
|
|
+ * Only copies the name and bind pose from the original.
|
|
|
|
|
+ * <p>
|
|
|
|
|
+ * WARNING: Local bind pose and world inverse bind pose transforms shallow
|
|
|
|
|
+ * copied. Modifying that data on the original bone will cause it to
|
|
|
|
|
+ * be recomputed on any cloned bones.
|
|
|
|
|
+ * <p>
|
|
|
|
|
+ * The rest of the data is <em>NOT</em> copied, as it will be
|
|
|
|
|
+ * generated automatically when the bone is animated.
|
|
|
|
|
+ *
|
|
|
|
|
+ * @param source The bone from which to copy the data.
|
|
|
*/
|
|
*/
|
|
|
Bone(Bone source) {
|
|
Bone(Bone source) {
|
|
|
this.name = source.name;
|
|
this.name = source.name;
|
|
@@ -134,9 +144,7 @@ public final class Bone implements Savable {
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
/**
|
|
|
- * Used for binary loading as a Savable; the object must be constructed,
|
|
|
|
|
- * then the parameters usually present in the constructor for this class are
|
|
|
|
|
- * restored from the file the object was saved to.
|
|
|
|
|
|
|
+ * Serialization only. Do not use.
|
|
|
*/
|
|
*/
|
|
|
public Bone() {
|
|
public Bone() {
|
|
|
}
|
|
}
|
|
@@ -223,6 +231,9 @@ public final class Bone implements Savable {
|
|
|
|
|
|
|
|
/**
|
|
/**
|
|
|
* Returns the inverse world bind pose position.
|
|
* Returns the inverse world bind pose position.
|
|
|
|
|
+ * <p>
|
|
|
|
|
+ * The bind pose transform of the bone is its "default"
|
|
|
|
|
+ * transform with no animation applied.
|
|
|
*
|
|
*
|
|
|
* @return the inverse world bind pose position.
|
|
* @return the inverse world bind pose position.
|
|
|
*/
|
|
*/
|
|
@@ -232,6 +243,9 @@ public final class Bone implements Savable {
|
|
|
|
|
|
|
|
/**
|
|
/**
|
|
|
* Returns the inverse world bind pose rotation.
|
|
* Returns the inverse world bind pose rotation.
|
|
|
|
|
+ * <p>
|
|
|
|
|
+ * The bind pose transform of the bone is its "default"
|
|
|
|
|
+ * transform with no animation applied.
|
|
|
*
|
|
*
|
|
|
* @return the inverse world bind pose rotation.
|
|
* @return the inverse world bind pose rotation.
|
|
|
*/
|
|
*/
|
|
@@ -241,12 +255,51 @@ public final class Bone implements Savable {
|
|
|
|
|
|
|
|
/**
|
|
/**
|
|
|
* Returns the inverse world bind pose scale.
|
|
* Returns the inverse world bind pose scale.
|
|
|
|
|
+ * <p>
|
|
|
|
|
+ * The bind pose transform of the bone is its "default"
|
|
|
|
|
+ * transform with no animation applied.
|
|
|
*
|
|
*
|
|
|
* @return the inverse world bind pose scale.
|
|
* @return the inverse world bind pose scale.
|
|
|
*/
|
|
*/
|
|
|
public Vector3f getWorldBindInverseScale() {
|
|
public Vector3f getWorldBindInverseScale() {
|
|
|
return worldBindInverseScale;
|
|
return worldBindInverseScale;
|
|
|
}
|
|
}
|
|
|
|
|
+
|
|
|
|
|
+ /**
|
|
|
|
|
+ * Returns the world bind pose position.
|
|
|
|
|
+ * <p>
|
|
|
|
|
+ * The bind pose transform of the bone is its "default"
|
|
|
|
|
+ * transform with no animation applied.
|
|
|
|
|
+ *
|
|
|
|
|
+ * @return the world bind pose position.
|
|
|
|
|
+ */
|
|
|
|
|
+ public Vector3f getWorldBindPosition() {
|
|
|
|
|
+ return initialPos;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ /**
|
|
|
|
|
+ * Returns the world bind pose rotation.
|
|
|
|
|
+ * <p>
|
|
|
|
|
+ * The bind pose transform of the bone is its "default"
|
|
|
|
|
+ * transform with no animation applied.
|
|
|
|
|
+ *
|
|
|
|
|
+ * @return the world bind pose rotation.
|
|
|
|
|
+ */
|
|
|
|
|
+ public Quaternion getWorldBindRotation() {
|
|
|
|
|
+ return initialRot;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ /**
|
|
|
|
|
+ * Returns the world bind pose scale.
|
|
|
|
|
+ * <p>
|
|
|
|
|
+ * The bind pose transform of the bone is its "default"
|
|
|
|
|
+ * transform with no animation applied.
|
|
|
|
|
+ *
|
|
|
|
|
+ * @return the world bind pose scale.
|
|
|
|
|
+ */
|
|
|
|
|
+ public Vector3f getWorldBindScale() {
|
|
|
|
|
+ return initialScale;
|
|
|
|
|
+ }
|
|
|
|
|
|
|
|
/**
|
|
/**
|
|
|
* If enabled, user can control bone transform with setUserTransforms.
|
|
* If enabled, user can control bone transform with setUserTransforms.
|
|
@@ -259,7 +312,8 @@ public final class Bone implements Savable {
|
|
|
/**
|
|
/**
|
|
|
* 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
|
|
|
|
|
|
|
+ *
|
|
|
|
|
+ * @param bone The bone to add
|
|
|
*/
|
|
*/
|
|
|
public void addChild(Bone bone) {
|
|
public void addChild(Bone bone) {
|
|
|
children.add(bone);
|
|
children.add(bone);
|
|
@@ -267,7 +321,11 @@ public final class Bone implements Savable {
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
/**
|
|
|
- * Updates the world transforms for this bone, and, possibly the attach node if not null.
|
|
|
|
|
|
|
+ * Updates the world transforms for this bone, and, possibly the attach node
|
|
|
|
|
+ * if not null.
|
|
|
|
|
+ * <p>
|
|
|
|
|
+ * The world transform of this bone is computed by combining the parent's
|
|
|
|
|
+ * world transform with this bones' local transform.
|
|
|
*/
|
|
*/
|
|
|
public final void updateWorldVectors() {
|
|
public final void updateWorldVectors() {
|
|
|
if (parent != null) {
|
|
if (parent != null) {
|
|
@@ -376,8 +434,7 @@ public final class Bone implements Savable {
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
/**
|
|
|
- * Set user transform.
|
|
|
|
|
- * Combine the given transforms to bone's current transforms
|
|
|
|
|
|
|
+ * Sets user transform.
|
|
|
*/
|
|
*/
|
|
|
public void setUserTransforms(Vector3f translation, Quaternion rotation, Vector3f scale) {
|
|
public void setUserTransforms(Vector3f translation, Quaternion rotation, Vector3f scale) {
|
|
|
if (!userControl) {
|
|
if (!userControl) {
|
|
@@ -397,12 +454,13 @@ public final class Bone implements Savable {
|
|
|
* Must update all bones in skeleton for this to work.
|
|
* Must update all bones in skeleton for this to work.
|
|
|
* @param translation
|
|
* @param translation
|
|
|
* @param rotation
|
|
* @param rotation
|
|
|
- *///TODO: add scale here ???
|
|
|
|
|
|
|
+ */
|
|
|
public void setUserTransformsWorld(Vector3f translation, Quaternion rotation) {
|
|
public void setUserTransformsWorld(Vector3f translation, Quaternion rotation) {
|
|
|
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");
|
|
|
}
|
|
}
|
|
|
-
|
|
|
|
|
|
|
+
|
|
|
|
|
+ // TODO: add scale here ???
|
|
|
worldPos.set(translation);
|
|
worldPos.set(translation);
|
|
|
worldRot.set(rotation);
|
|
worldRot.set(rotation);
|
|
|
}
|
|
}
|
|
@@ -497,15 +555,11 @@ public final class Bone implements Savable {
|
|
|
public void setBindTransforms(Vector3f translation, Quaternion rotation, Vector3f scale) {
|
|
public void setBindTransforms(Vector3f translation, Quaternion rotation, Vector3f scale) {
|
|
|
initialPos.set(translation);
|
|
initialPos.set(translation);
|
|
|
initialRot.set(rotation);
|
|
initialRot.set(rotation);
|
|
|
- if (scale != null) {
|
|
|
|
|
- initialScale.set(scale);
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
|
|
+ initialScale.set(scale);
|
|
|
|
|
+
|
|
|
localPos.set(translation);
|
|
localPos.set(translation);
|
|
|
localRot.set(rotation);
|
|
localRot.set(rotation);
|
|
|
- if (scale != null) {
|
|
|
|
|
- localScale.set(scale);
|
|
|
|
|
- }
|
|
|
|
|
|
|
+ localScale.set(scale);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
private String toString(int depth) {
|
|
private String toString(int depth) {
|
|
@@ -562,12 +616,4 @@ public final class Bone implements Savable {
|
|
|
output.write(initialScale, "initialScale", new Vector3f(1.0f, 1.0f, 1.0f));
|
|
output.write(initialScale, "initialScale", new Vector3f(1.0f, 1.0f, 1.0f));
|
|
|
output.writeSavableArrayList(children, "children", null);
|
|
output.writeSavableArrayList(children, "children", null);
|
|
|
}
|
|
}
|
|
|
-
|
|
|
|
|
- public Vector3f getInitialPos() {
|
|
|
|
|
- return initialPos;
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
- public Quaternion getInitialRot() {
|
|
|
|
|
- return initialRot;
|
|
|
|
|
- }
|
|
|
|
|
}
|
|
}
|