Bugfix: locations of bones not connected to their parents are now properly applied if their constraints force them to
git-svn-id: https://jmonkeyengine.googlecode.com/svn/trunk@10853 75d07b2b-3a1a-0410-a2c5-0572b91ccdca
This commit is contained in:
parent
e148d0e01a
commit
821d6b6aa3
@ -23,7 +23,7 @@ import com.jme3.scene.plugins.blender.objects.ObjectHelper;
|
|||||||
*/
|
*/
|
||||||
public class BoneContext {
|
public class BoneContext {
|
||||||
// the flags of the bone
|
// the flags of the bone
|
||||||
private static final int CONNECTED_TO_PARENT = 0x10;
|
public static final int CONNECTED_TO_PARENT = 0x10;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The bones' matrices have, unlike objects', the coordinate system identical to JME's (Y axis is UP, X to the right and Z toward us).
|
* The bones' matrices have, unlike objects', the coordinate system identical to JME's (Y axis is UP, X to the right and Z toward us).
|
||||||
@ -35,7 +35,7 @@ public class BoneContext {
|
|||||||
/** The OMA of the bone's armature object. */
|
/** The OMA of the bone's armature object. */
|
||||||
private Long armatureObjectOMA;
|
private Long armatureObjectOMA;
|
||||||
/** The OMA of the model that owns the bone's skeleton. */
|
/** The OMA of the model that owns the bone's skeleton. */
|
||||||
private Long skeletonOwnerOma;
|
private Long skeletonOwnerOma;
|
||||||
/** The structure of the bone. */
|
/** The structure of the bone. */
|
||||||
private Structure boneStructure;
|
private Structure boneStructure;
|
||||||
/** Bone's name. */
|
/** Bone's name. */
|
||||||
@ -207,7 +207,7 @@ public class BoneContext {
|
|||||||
* the mask of the flag (constants defined in this class)
|
* the mask of the flag (constants defined in this class)
|
||||||
* @return <b>true</b> if the bone IS of specified proeprty and <b>false</b> otherwise
|
* @return <b>true</b> if the bone IS of specified proeprty and <b>false</b> otherwise
|
||||||
*/
|
*/
|
||||||
private boolean is(int flagMask) {
|
public boolean is(int flagMask) {
|
||||||
return (flag & flagMask) != 0;
|
return (flag & flagMask) != 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -4,6 +4,7 @@ import com.jme3.animation.Bone;
|
|||||||
import com.jme3.math.Transform;
|
import com.jme3.math.Transform;
|
||||||
import com.jme3.math.Vector3f;
|
import com.jme3.math.Vector3f;
|
||||||
import com.jme3.scene.plugins.blender.BlenderContext;
|
import com.jme3.scene.plugins.blender.BlenderContext;
|
||||||
|
import com.jme3.scene.plugins.blender.animations.BoneContext;
|
||||||
import com.jme3.scene.plugins.blender.constraints.ConstraintHelper.Space;
|
import com.jme3.scene.plugins.blender.constraints.ConstraintHelper.Space;
|
||||||
import com.jme3.scene.plugins.blender.file.Structure;
|
import com.jme3.scene.plugins.blender.file.Structure;
|
||||||
|
|
||||||
@ -28,8 +29,9 @@ import com.jme3.scene.plugins.blender.file.Structure;
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void bake(Space ownerSpace, Space targetSpace, Transform targetTransform, float influence) {
|
public void bake(Space ownerSpace, Space targetSpace, Transform targetTransform, float influence) {
|
||||||
if (this.getOwner() instanceof Bone && ((Bone) this.getOwner()).getParent() != null) {
|
if (this.getOwner() instanceof Bone && ((Bone) this.getOwner()).getParent() != null &&
|
||||||
// distance limit does not work on bones who have parent
|
blenderContext.getBoneContext(ownerOMA).is(BoneContext.CONNECTED_TO_PARENT)) {
|
||||||
|
// distance limit does not work on bones who are connected to their parent
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -4,6 +4,7 @@ import com.jme3.animation.Bone;
|
|||||||
import com.jme3.math.Transform;
|
import com.jme3.math.Transform;
|
||||||
import com.jme3.math.Vector3f;
|
import com.jme3.math.Vector3f;
|
||||||
import com.jme3.scene.plugins.blender.BlenderContext;
|
import com.jme3.scene.plugins.blender.BlenderContext;
|
||||||
|
import com.jme3.scene.plugins.blender.animations.BoneContext;
|
||||||
import com.jme3.scene.plugins.blender.constraints.ConstraintHelper.Space;
|
import com.jme3.scene.plugins.blender.constraints.ConstraintHelper.Space;
|
||||||
import com.jme3.scene.plugins.blender.file.Structure;
|
import com.jme3.scene.plugins.blender.file.Structure;
|
||||||
|
|
||||||
@ -31,10 +32,9 @@ import com.jme3.scene.plugins.blender.file.Structure;
|
|||||||
int invY = flag & LOCLIKE_Y_INVERT;
|
int invY = flag & LOCLIKE_Y_INVERT;
|
||||||
int z = flag & LOCLIKE_Z;
|
int z = flag & LOCLIKE_Z;
|
||||||
int invZ = flag & LOCLIKE_Z_INVERT;
|
int invZ = flag & LOCLIKE_Z_INVERT;
|
||||||
flag &= LOCLIKE_X | LOCLIKE_X_INVERT | LOCLIKE_OFFSET;// clear the
|
// clear the other flags to swap them
|
||||||
// other flags
|
flag &= LOCLIKE_X | LOCLIKE_X_INVERT | LOCLIKE_OFFSET;
|
||||||
// to swap
|
|
||||||
// them
|
|
||||||
flag |= y << 1;
|
flag |= y << 1;
|
||||||
flag |= invY << 1;
|
flag |= invY << 1;
|
||||||
flag |= z >> 1;
|
flag |= z >> 1;
|
||||||
@ -44,9 +44,9 @@ import com.jme3.scene.plugins.blender.file.Structure;
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void bake(Space ownerSpace, Space targetSpace, Transform targetTransform, float influence) {
|
public void bake(Space ownerSpace, Space targetSpace, Transform targetTransform, float influence) {
|
||||||
if (this.getOwner() instanceof Bone && ((Bone) this.getOwner()).getParent() != null) {
|
if (this.getOwner() instanceof Bone && ((Bone) this.getOwner()).getParent() != null &&
|
||||||
// cannot copy the location of a bone attached to its parent,
|
blenderContext.getBoneContext(ownerOMA).is(BoneContext.CONNECTED_TO_PARENT)) {
|
||||||
// Blender forbids that
|
// location copy does not work on bones who are connected to their parent
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -57,8 +57,7 @@ import com.jme3.scene.plugins.blender.file.Structure;
|
|||||||
|
|
||||||
Vector3f startLocation = ownerTransform.getTranslation().clone();
|
Vector3f startLocation = ownerTransform.getTranslation().clone();
|
||||||
Vector3f offset = Vector3f.ZERO;
|
Vector3f offset = Vector3f.ZERO;
|
||||||
if ((flag & LOCLIKE_OFFSET) != 0) {// we add the original location to
|
if ((flag & LOCLIKE_OFFSET) != 0) {// we add the original location to the copied location
|
||||||
// the copied location
|
|
||||||
offset = startLocation;
|
offset = startLocation;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -4,6 +4,7 @@ import com.jme3.animation.Bone;
|
|||||||
import com.jme3.math.Transform;
|
import com.jme3.math.Transform;
|
||||||
import com.jme3.math.Vector3f;
|
import com.jme3.math.Vector3f;
|
||||||
import com.jme3.scene.plugins.blender.BlenderContext;
|
import com.jme3.scene.plugins.blender.BlenderContext;
|
||||||
|
import com.jme3.scene.plugins.blender.animations.BoneContext;
|
||||||
import com.jme3.scene.plugins.blender.constraints.ConstraintHelper.Space;
|
import com.jme3.scene.plugins.blender.constraints.ConstraintHelper.Space;
|
||||||
import com.jme3.scene.plugins.blender.file.Structure;
|
import com.jme3.scene.plugins.blender.file.Structure;
|
||||||
|
|
||||||
@ -55,8 +56,9 @@ import com.jme3.scene.plugins.blender.file.Structure;
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void bake(Space ownerSpace, Space targetSpace, Transform targetTransform, float influence) {
|
public void bake(Space ownerSpace, Space targetSpace, Transform targetTransform, float influence) {
|
||||||
if (this.getOwner() instanceof Bone && ((Bone) this.getOwner()).getParent() != null) {
|
if (this.getOwner() instanceof Bone && ((Bone) this.getOwner()).getParent() != null &&
|
||||||
// location limit does not work on bones who have parent
|
blenderContext.getBoneContext(ownerOMA).is(BoneContext.CONNECTED_TO_PARENT)) {
|
||||||
|
// location limit does not work on bones who are connected to their parent
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user