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
@@ -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 @@ -62,18 +62,43 @@ public void fromElement(FbxElement element) {
if (e.id.equals("Node")) {
node = FbxId.create(e.properties.get(0));
} else if (e.id.equals("Matrix")) {
double[] matDataDoubles = (double[]) e.properties.get(0);

if (matDataDoubles.length != 16) {
// corrupt
throw new UnsupportedOperationException("Bind pose matrix "
+ "must have 16 doubles, but it has "
+ matDataDoubles.length + ". Data is corrupt");
}

matData = new float[16];
for (int i = 0; i < matDataDoubles.length; i++) {
matData[i] = (float) matDataDoubles[i];
int numProperties = e.propertiesTypes.length;
if (numProperties == 1) {
char propertyType = e.propertiesTypes[0];
if (propertyType != 'd') {
throw new UnsupportedOperationException(
"Bind-pose matrix should have property type 'd',"
+ "but found '" + propertyType + "'");
}
double[] array = (double[]) e.properties.get(0);
int length = array.length;
if (length != 16) {
throw new UnsupportedOperationException(
"Bind-pose matrix should have 16 elements,"
+ "but found " + length);
}
for (int i = 0; i < length; ++i) {
matData[i] = (float) array[i];
}

} else if (numProperties == 16) {
for (int i = 0; i < numProperties; ++i) {
char propertyType = e.propertiesTypes[i];
if (propertyType != 'D') {
throw new UnsupportedOperationException(
"Bind-pose matrix should have properties of type 'D',"
+ "but found '" + propertyType + "'");
}
double d = (Double) e.properties.get(i);
matData[i] = (float) d;
}

} else {
throw new UnsupportedOperationException(
"Bind pose matrix should have either "
+ "1 or 16 properties, but found "
+ numProperties);
}
}
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2009-2015 jMonkeyEngine
* Copyright (c) 2009-2023 jMonkeyEngine
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
Expand Down Expand Up @@ -54,9 +54,43 @@ public void fromElement(FbxElement element) {
super.fromElement(element);
for (FbxElement e : element.children) {
if (e.id.equals("Indexes")) {
indexes = (int[]) e.properties.get(0);
int numProperties = e.propertiesTypes.length;
if (numProperties == 1 && e.propertiesTypes[0] == 'i') {
this.indexes = (int[]) e.properties.get(0);

} else {
this.indexes = new int[numProperties];
for (int i = 0; i < numProperties; ++i) {
char propertyType = e.propertiesTypes[i];
if (propertyType != 'I') {
throw new UnsupportedOperationException(
"Indexes should have properties of type 'I',"
+ "but found '" + propertyType + "'");
}
int index = (Integer) e.properties.get(i);
this.indexes[i] = index;
}
}

} else if (e.id.equals("Weights")) {
weights = (double[]) e.properties.get(0);
int numTypes = e.propertiesTypes.length;
if (numTypes == 1 && e.propertiesTypes[0] == 'd') {
this.weights = (double[]) e.properties.get(0);

} else {
int numElements = numTypes;
this.weights = new double[numElements];
for (int i = 0; i < numElements; ++i) {
int propertyType = e.propertiesTypes[i];
if (propertyType != 'D') {
throw new UnsupportedOperationException(
"Weights should have properties of type 'D',"
+ "but found '" + propertyType + "'");
}
double weight = (Double) e.properties.get(i);
this.weights[i] = weight;
}
}
}
}
}
Expand Down