Support for object animation constraints loading.

git-svn-id: https://jmonkeyengine.googlecode.com/svn/trunk@7684 75d07b2b-3a1a-0410-a2c5-0572b91ccdca
3.0
Kae..pl 14 years ago
parent 542559738d
commit 697a02e7c5
  1. 20
      engine/src/blender/com/jme3/scene/plugins/blender/helpers/v249/ConstraintHelper.java
  2. 10
      engine/src/blender/com/jme3/scene/plugins/blender/helpers/v249/ModifierHelper.java
  3. 2
      engine/src/blender/com/jme3/scene/plugins/blender/helpers/v249/ObjectHelper.java
  4. 2
      engine/src/blender/com/jme3/scene/plugins/blender/structures/AbstractInfluenceFunction.java
  5. BIN
      engine/src/test-data/Blender/2.4x/constraints.blend

@ -625,7 +625,7 @@ public class ConstraintHelper extends AbstractBlenderHelper {
}
}
}
/* TODO: reading constraints for objects (implement when object's animation will be available)
// TODO: reading constraints for objects (implement when object's animation will be available)
List<Structure> constraintChannels = ((Structure)objectStructure.getFieldValue("constraintChannels")).evaluateListBase(dataRepository);
for(Structure constraintChannel : constraintChannels) {
System.out.println(constraintChannel);
@ -636,14 +636,26 @@ public class ConstraintHelper extends AbstractBlenderHelper {
List<Structure> constraints = ((Structure)objectStructure.getFieldValue("constraints")).evaluateListBase(dataRepository);
Constraint[] result = new Constraint[constraints.size()];
int i = 0;
for(Structure constraint : constraints) {
int type = ((Number)constraint.getFieldValue("type")).intValue();
String name = constraint.getFieldValue("name").toString();
result[i++] = new Constraint(constraint, influenceFunctions[type], null, dataRepository);//TODO: influence ipos for object animation
String constraintName = constraint.getFieldValue("name").toString();
String objectName = objectStructure.getName();
Map<String, Ipo> objectConstraintsIpos = constraintsIpos.get(objectName);
Ipo ipo = objectConstraintsIpos!=null ? objectConstraintsIpos.get(constraintName) : null;
if (ipo == null) {
float enforce = ((Number) constraint.getFieldValue("enforce")).floatValue();
ipo = ipoHelper.createIpo(enforce);
}
Space ownerSpace = Space.valueOf(((Number) constraint.getFieldValue("ownspace")).byteValue());
Space targetSpace = Space.valueOf(((Number) constraint.getFieldValue("tarspace")).byteValue());
result[i++] = new Constraint(constraint, influenceFunctions[type], null,
ownerSpace, targetSpace, ipo, dataRepository);//TODO: influence ipos for object animation
}
this.constraints.put(objectStructure.getOldMemoryAddress(), result);
}
*/
if (constraintsList.size() > 0) {
this.constraints.put(objectStructure.getOldMemoryAddress(), constraintsList.toArray(new Constraint[constraintsList.size()]));
}

@ -663,16 +663,14 @@ public class ModifierHelper extends AbstractBlenderHelper {
Vector3f[] translations = new Vector3f[tablesLength];
Quaternion[] rotations = new Quaternion[tablesLength];
Vector3f[] scales = sourceScales == null ? null : new Vector3f[tablesLength];
Vector3f[] scales = new Vector3f[tablesLength];
for (int j = 0; j < tablesLength; ++j) {
translations[j] = sourceTranslations[j].clone();
rotations[j] = sourceRotations[j].clone();
if (sourceScales != null) {// only scales may not be applied
scales[j] = sourceScales[j].clone();
scales[j] = sourceScales != null ? sourceScales[j].clone() : new Vector3f(1.0f, 1.0f, 1.0f);
}
}
boneTracks[i] = new BoneTrack(sourceTracks[i].getTargetBoneIndex(), sourceTracks[i].getTimes(),// times do not change, no need
// to clone them,
// times do not change, no need to clone them
boneTracks[i] = new BoneTrack(sourceTracks[i].getTargetBoneIndex(), sourceTracks[i].getTimes(),
translations, rotations, scales);
}
result.setTracks(boneTracks);

@ -403,7 +403,7 @@ public class ObjectHelper extends AbstractBlenderHelper {
Bone bone = new Bone(null);
bone.setBindTransforms(t.getTranslation(), t.getRotation(), t.getScale());
return new Modifier(Modifier.ARMATURE_MODIFIER_DATA, new AnimData(new Skeleton(new Bone[] {bone}), animations), null);
return new Modifier(Modifier.ARMATURE_MODIFIER_DATA, new AnimData(new Skeleton(new Bone[] {bone}), animations), objectStructure.getOldMemoryAddress());
}
return null;
}

@ -117,7 +117,7 @@ public abstract class AbstractInfluenceFunction {
protected BoneTrack getBoneTrack(Skeleton skeleton, BoneAnimation boneAnimation, Constraint constraint) {
Long boneOMA = constraint.getBoneOMA();
Bone bone = (Bone) dataRepository.getLoadedFeature(boneOMA, LoadedFeatureDataType.LOADED_FEATURE);
int boneIndex = skeleton.getBoneIndex(bone);
int boneIndex = bone==null ? 0 : skeleton.getBoneIndex(bone);//bone==null may mean the object animation
if (boneIndex != -1) {
//searching for track for this bone
for (BoneTrack boneTrack : boneAnimation.getTracks()) {

Loading…
Cancel
Save