|
1 | 1 | /* |
2 | | - * Copyright (c) 2009-2021 jMonkeyEngine |
| 2 | + * Copyright (c) 2009-2023 jMonkeyEngine |
3 | 3 | * All rights reserved. |
4 | 4 | * |
5 | 5 | * Redistribution and use in source and binary forms, with or without |
@@ -62,18 +62,43 @@ public void fromElement(FbxElement element) { |
62 | 62 | if (e.id.equals("Node")) { |
63 | 63 | node = FbxId.create(e.properties.get(0)); |
64 | 64 | } else if (e.id.equals("Matrix")) { |
65 | | - double[] matDataDoubles = (double[]) e.properties.get(0); |
66 | | - |
67 | | - if (matDataDoubles.length != 16) { |
68 | | - // corrupt |
69 | | - throw new UnsupportedOperationException("Bind pose matrix " |
70 | | - + "must have 16 doubles, but it has " |
71 | | - + matDataDoubles.length + ". Data is corrupt"); |
72 | | - } |
73 | | - |
74 | 65 | matData = new float[16]; |
75 | | - for (int i = 0; i < matDataDoubles.length; i++) { |
76 | | - matData[i] = (float) matDataDoubles[i]; |
| 66 | + int numProperties = e.propertiesTypes.length; |
| 67 | + if (numProperties == 1) { |
| 68 | + char propertyType = e.propertiesTypes[0]; |
| 69 | + if (propertyType != 'd') { |
| 70 | + throw new UnsupportedOperationException( |
| 71 | + "Bind-pose matrix should have property type 'd'," |
| 72 | + + "but found '" + propertyType + "'"); |
| 73 | + } |
| 74 | + double[] array = (double[]) e.properties.get(0); |
| 75 | + int length = array.length; |
| 76 | + if (length != 16) { |
| 77 | + throw new UnsupportedOperationException( |
| 78 | + "Bind-pose matrix should have 16 elements," |
| 79 | + + "but found " + length); |
| 80 | + } |
| 81 | + for (int i = 0; i < length; ++i) { |
| 82 | + matData[i] = (float) array[i]; |
| 83 | + } |
| 84 | + |
| 85 | + } else if (numProperties == 16) { |
| 86 | + for (int i = 0; i < numProperties; ++i) { |
| 87 | + char propertyType = e.propertiesTypes[i]; |
| 88 | + if (propertyType != 'D') { |
| 89 | + throw new UnsupportedOperationException( |
| 90 | + "Bind-pose matrix should have properties of type 'D'," |
| 91 | + + "but found '" + propertyType + "'"); |
| 92 | + } |
| 93 | + double d = (Double) e.properties.get(i); |
| 94 | + matData[i] = (float) d; |
| 95 | + } |
| 96 | + |
| 97 | + } else { |
| 98 | + throw new UnsupportedOperationException( |
| 99 | + "Bind pose matrix should have either " |
| 100 | + + "1 or 16 properties, but found " |
| 101 | + + numProperties); |
77 | 102 | } |
78 | 103 | } |
79 | 104 | } |
|
0 commit comments