diff --git a/vtm-playground/src/org/oscim/test/gdx/poi3d/SharedModel.java b/vtm-playground/src/org/oscim/test/gdx/poi3d/SharedModel.java index 13009283..4f1babb2 100644 --- a/vtm-playground/src/org/oscim/test/gdx/poi3d/SharedModel.java +++ b/vtm-playground/src/org/oscim/test/gdx/poi3d/SharedModel.java @@ -12,6 +12,7 @@ import com.badlogic.gdx.graphics.g3d.model.NodeAnimation; import com.badlogic.gdx.graphics.g3d.model.NodeKeyframe; import com.badlogic.gdx.graphics.g3d.model.NodePart; import com.badlogic.gdx.math.Matrix4; +import com.badlogic.gdx.math.Quaternion; import com.badlogic.gdx.math.Vector3; import com.badlogic.gdx.math.collision.BoundingBox; import com.badlogic.gdx.utils.Array; @@ -100,13 +101,13 @@ public class SharedModel implements RenderableProvider { this.transform = transform == null ? new Matrix4() : transform; nodePartBones.clear(); Node copy, node = model.getNode(nodeId, recursive); - this.nodes.add(copy = copyNode(null, node)); + this.nodes.add(copy = copyNode(node)); if (mergeTransform) { this.transform.mul(parentTransform ? node.globalTransform : node.localTransform); copy.translation.set(0,0,0); copy.rotation.idt(); copy.scale.set(1,1,1); - } else if (parentTransform && copy.getParent() != null) + } else if (parentTransform && copy.hasParent()) this.transform.mul(node.getParent().globalTransform); setBones(); copyAnimations(model.animations); @@ -185,7 +186,7 @@ public class SharedModel implements RenderableProvider { nodePartBones.clear(); for(int i = 0, n = nodes.size; i>(); + nodeAnim.rotation.ensureCapacity(nanim.rotation.size); + for (final NodeKeyframe kf : nanim.rotation) { + if (kf.keytime > animation.duration) + animation.duration = kf.keytime; + nodeAnim.rotation.add(new NodeKeyframe(kf.keytime, new Quaternion(kf.value == null ? node.rotation : kf.value))); + } } - if (nodeAnim.translation.size > 0) + if (nanim.scaling != null) { + nodeAnim.scaling = new Array>(); + nodeAnim.scaling.ensureCapacity(nanim.scaling.size); + for (final NodeKeyframe kf : nanim.scaling) { + if (kf.keytime > animation.duration) + animation.duration = kf.keytime; + nodeAnim.scaling.add(new NodeKeyframe(kf.keytime, new Vector3(kf.value == null ? node.scale : kf.value))); + } + } + if (nanim.translation != null) { + nodeAnim.translation = new Array>(); + nodeAnim.translation.ensureCapacity(nanim.translation.size); + for (final NodeKeyframe kf : nanim.translation) { + if (kf.keytime > animation.duration) + animation.duration = kf.keytime; + nodeAnim.translation.add(new NodeKeyframe(kf.keytime, new Vector3(kf.value == null ? node.translation : kf.value))); + } + } + if ((nodeAnim.rotation != null && nodeAnim.rotation.size > 0) + || (nodeAnim.scaling != null && nodeAnim.scaling.size > 0) + || (nodeAnim.translation != null && nodeAnim.translation.size > 0)) animation.nodeAnimations.add(nodeAnim); } if (animation.nodeAnimations.size > 0)