Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -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();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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() {
Expand Down Expand Up @@ -129,4 +135,4 @@ public void connectObject(FbxObject object) {
public void connectObjectProperty(FbxObject object, String property) {
unsupportedConnectObjectProperty(object, property);
}
}
}
Original file line number Diff line number Diff line change
@@ -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
Expand Down Expand Up @@ -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);
Expand Down