• R/O
  • HTTP
  • SSH
  • HTTPS

Commit

Tags
No Tags

Frequently used words (click to add to your profile)

javac++androidlinuxc#windowsobjective-ccocoa誰得qtpythonphprubygameguibathyscaphec計画中(planning stage)翻訳omegatframeworktwitterdomtestvb.netdirectxゲームエンジンbtronarduinopreviewer

Main repository of MikuMikuStudio


Commit MetaInfo

Revisión5e9256a3c607a8a942ba6893ff6d514022e65671 (tree)
Tiempo2013-04-05 04:00:21
AutorKaelthas_Spellsinger@o2.pl <Kaelthas_Spellsinger@o2.p...>
CommiterKaelthas_Spellsinger@o2.pl

Log Message

Bugfix: fixed an issue with skeleton loading when the armature was not a parent of an object it should animate.

git-svn-id: http://jmonkeyengine.googlecode.com/svn/trunk@10511 75d07b2b-3a1a-0410-a2c5-0572b91ccdca

Cambiar Resumen

Diferencia incremental

--- a/engine/src/blender/com/jme3/scene/plugins/blender/animations/BoneContext.java
+++ b/engine/src/blender/com/jme3/scene/plugins/blender/animations/BoneContext.java
@@ -25,8 +25,6 @@ public class BoneContext {
2525 private Structure boneStructure;
2626 /** Bone's name. */
2727 private String boneName;
28- /** This variable indicates if the Y axis should be the UP axis. */
29- private boolean fixUpAxis;
3028 /** The bone's armature matrix. */
3129 private Matrix4f armatureMatrix;
3230 /** The parent context. */
@@ -93,7 +91,6 @@ public class BoneContext {
9391 ObjectHelper objectHelper = blenderContext.getHelper(ObjectHelper.class);
9492 armatureMatrix = objectHelper.getMatrix(boneStructure, "arm_mat", true);
9593
96- fixUpAxis = blenderContext.getBlenderKey().isFixUpAxis();
9794 this.computeRestMatrix(objectToArmatureMatrix);
9895 List<Structure> childbase = ((Structure) boneStructure.getFieldValue("childbase")).evaluateListBase(blenderContext);
9996 for (Structure child : childbase) {
@@ -112,10 +109,8 @@ public class BoneContext {
112109 private void computeRestMatrix(Matrix4f objectToArmatureMatrix) {
113110 if (parent != null) {
114111 inverseParentMatrix = parent.inverseTotalTransformation.clone();
115- } else if (fixUpAxis) {
116- inverseParentMatrix = objectToArmatureMatrix.clone();
117112 } else {
118- inverseParentMatrix = Matrix4f.IDENTITY.clone();
113+ inverseParentMatrix = objectToArmatureMatrix.clone();
119114 }
120115
121116 restMatrix = armatureMatrix.clone();
--- a/engine/src/blender/com/jme3/scene/plugins/blender/modifiers/ArmatureModifier.java
+++ b/engine/src/blender/com/jme3/scene/plugins/blender/modifiers/ArmatureModifier.java
@@ -94,10 +94,14 @@ import com.jme3.util.BufferUtils;
9494 bonesPoseChannels.put(pBone.getOldMemoryAddress(), poseChannel);
9595 }
9696
97+ Matrix4f objectToArmatureTransformation = Matrix4f.IDENTITY;
9798 ObjectHelper objectHelper = blenderContext.getHelper(ObjectHelper.class);
98- Matrix4f armatureObjectMatrix = objectHelper.getMatrix(armatureObject, "obmat", true);
99- Matrix4f inverseMeshObjectMatrix = objectHelper.getMatrix(objectStructure, "obmat", true).invertLocal();
100- Matrix4f objectToArmatureTransformation = armatureObjectMatrix.multLocal(inverseMeshObjectMatrix);
99+
100+ if(objectHelper.isLineage(armatureObject, objectStructure, blenderContext)) {
101+ Matrix4f armatureObjectMatrix = objectHelper.getMatrix(armatureObject, "obmat", blenderContext.getBlenderKey().isFixUpAxis());
102+ Matrix4f inverseMeshObjectMatrix = objectHelper.getMatrix(objectStructure, "obmat", true).invertLocal();
103+ objectToArmatureTransformation = armatureObjectMatrix.multLocal(inverseMeshObjectMatrix);
104+ }
101105
102106 List<Structure> bonebase = ((Structure) armatureStructure.getFieldValue("bonebase")).evaluateListBase(blenderContext);
103107 List<Bone> bonesList = new ArrayList<Bone>();
@@ -202,11 +206,11 @@ import com.jme3.util.BufferUtils;
202206 mesh.setBuffer(buffers[0]);
203207 mesh.setBuffer(buffers[1]);
204208
205- VertexBuffer bindNormalBuffer = (meshContext.getBindNormalBuffer(materialIndex));
209+ VertexBuffer bindNormalBuffer = meshContext.getBindNormalBuffer(materialIndex);
206210 if (bindNormalBuffer != null) {
207211 mesh.setBuffer(bindNormalBuffer);
208212 }
209- VertexBuffer bindPoseBuffer = (meshContext.getBindPoseBuffer(materialIndex));
213+ VertexBuffer bindPoseBuffer = meshContext.getBindPoseBuffer(materialIndex);
210214 if (bindPoseBuffer != null) {
211215 mesh.setBuffer(bindPoseBuffer);
212216 }
--- a/engine/src/blender/com/jme3/scene/plugins/blender/objects/ObjectHelper.java
+++ b/engine/src/blender/com/jme3/scene/plugins/blender/objects/ObjectHelper.java
@@ -174,9 +174,9 @@ public class ObjectHelper extends AbstractBlenderHelper {
174174 List<Geometry> curves = curvesHelper.toCurve(curveData, blenderContext);
175175 result = new Node(name);
176176 for (Geometry curve : curves) {
177- ((Node) result).attachChild(curve);
177+ result.attachChild(curve);
178178 }
179- ((Node) result).setLocalTransform(t);
179+ result.setLocalTransform(t);
180180 }
181181 break;
182182 case OBJECT_TYPE_LAMP:
@@ -244,7 +244,7 @@ public class ObjectHelper extends AbstractBlenderHelper {
244244 Properties properties = this.loadProperties(objectStructure, blenderContext);
245245 // the loaded property is a group property, so we need to get each value and set it to Spatial
246246 if (result instanceof Spatial && properties != null && properties.getValue() != null) {
247- this.applyProperties((Spatial) result, properties);
247+ this.applyProperties(result, properties);
248248 }
249249 }
250250 }
@@ -252,6 +252,31 @@ public class ObjectHelper extends AbstractBlenderHelper {
252252 }
253253
254254 /**
255+ * Method tells if the structure1 is a lineage of structure2.
256+ *
257+ * @param structure1
258+ * the first structure
259+ * @param structure2
260+ * the second structure
261+ * @return <b>true</b> if the first structure is a lineage of the second
262+ * structure and <b>false</b> otherwise
263+ * @throws BlenderFileException
264+ * thrown when problems with reading the blend file occur
265+ */
266+ public boolean isLineage(Structure structure1, Structure structure2, BlenderContext blenderContext) throws BlenderFileException {
267+ Pointer pParent = (Pointer) structure2.getFieldValue("parent");
268+ while (pParent.isNotNull()) {
269+ long oma = pParent.getOldMemoryAddress();
270+ if (structure1.getOldMemoryAddress().longValue() == oma) {
271+ return true;
272+ }
273+ structure2 = blenderContext.getFileBlock(oma).getStructure(blenderContext);
274+ pParent = (Pointer) structure2.getFieldValue("parent");
275+ }
276+ return false;
277+ }
278+
279+ /**
255280 * This method calculates local transformation for the object. Parentage is taken under consideration.
256281 * @param objectStructure
257282 * the object's structure