diff --git a/jme3-plugins/src/fbx/java/com/jme3/scene/plugins/fbx/FbxLoader.java b/jme3-plugins/src/fbx/java/com/jme3/scene/plugins/fbx/FbxLoader.java index d0816dc184..02413e601f 100644 --- a/jme3-plugins/src/fbx/java/com/jme3/scene/plugins/fbx/FbxLoader.java +++ b/jme3-plugins/src/fbx/java/com/jme3/scene/plugins/fbx/FbxLoader.java @@ -343,6 +343,9 @@ private void constructAnimations() { // At this point we can construct the animation for all pairs ... for (FbxToJmeTrack pair : pairs.values()) { + if (pair.countKeyframes() == 0) { + continue; + } String animName = pair.animStack.getName(); float duration = pair.animStack.getDuration(); diff --git a/jme3-plugins/src/fbx/java/com/jme3/scene/plugins/fbx/anim/FbxCluster.java b/jme3-plugins/src/fbx/java/com/jme3/scene/plugins/fbx/anim/FbxCluster.java index 45801fc353..b010e66a92 100644 --- a/jme3-plugins/src/fbx/java/com/jme3/scene/plugins/fbx/anim/FbxCluster.java +++ b/jme3-plugins/src/fbx/java/com/jme3/scene/plugins/fbx/anim/FbxCluster.java @@ -93,6 +93,12 @@ public void fromElement(FbxElement element) { } } } + + if (indexes == null && weights == null) { + // The cluster doesn't contain any keyframes! + this.indexes = new int[0]; + this.weights = new double[0]; + } } public int[] getVertexIndices() { @@ -129,4 +135,4 @@ public void connectObject(FbxObject object) { public void connectObjectProperty(FbxObject object, String property) { unsupportedConnectObjectProperty(object, property); } -} \ No newline at end of file +} diff --git a/jme3-plugins/src/fbx/java/com/jme3/scene/plugins/fbx/anim/FbxToJmeTrack.java b/jme3-plugins/src/fbx/java/com/jme3/scene/plugins/fbx/anim/FbxToJmeTrack.java index 2e302fc4d3..4ae677700f 100644 --- a/jme3-plugins/src/fbx/java/com/jme3/scene/plugins/fbx/anim/FbxToJmeTrack.java +++ b/jme3-plugins/src/fbx/java/com/jme3/scene/plugins/fbx/anim/FbxToJmeTrack.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2009-2021 jMonkeyEngine + * Copyright (c) 2009-2023 jMonkeyEngine * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -91,7 +91,23 @@ public BoneTrack toJmeBoneTrack(int boneIndex, Transform inverseBindPose) { public SpatialTrack toJmeSpatialTrack() { return (SpatialTrack) toJmeTrackInternal(-1, null); } - + + /** + * Counts how many keyframes there are in the included curves. + * + * @return the total number of keyframes (≥0) + */ + public int countKeyframes() { + int count = 0; + for (FbxAnimCurveNode curveNode : animCurves.values()) { + for (FbxAnimCurve curve : curveNode.getCurves()) { + count += curve.getKeyTimes().length; + } + } + + return count; + } + public float getDuration() { long[] keyframes = getKeyTimes(); return (float) (keyframes[keyframes.length - 1] * FbxAnimUtil.SECONDS_PER_UNIT);