فهرست منبع

Merge pull request #1873 from tonihele/bugfix/issue-1871

Fix #1871 (vertex colors not loaded in gltf models)
Toni Helenius 2 سال پیش
والد
کامیت
55574561cf

+ 1 - 2
jme3-plugins/src/gltf/java/com/jme3/scene/plugins/gltf/GltfLoader.java

@@ -1282,8 +1282,7 @@ public class GltfLoader implements AssetLoader {
         public VertexBuffer populate(Integer bufferViewIndex, int componentType, String type, int count,
                 int byteOffset, boolean normalized) throws IOException {
             if (bufferType == null) {
-                logger.log(Level.WARNING,
-                        "could not assign data to any VertexBuffer type for buffer view " + bufferViewIndex);
+                logger.log(Level.WARNING, "could not assign data to any VertexBuffer type for buffer view {0}", bufferViewIndex);
                 return null;
             }
 

+ 9 - 10
jme3-plugins/src/gltf/java/com/jme3/scene/plugins/gltf/GltfUtils.java

@@ -38,7 +38,6 @@ import com.jme3.math.*;
 import com.jme3.scene.*;
 import com.jme3.texture.Texture;
 import com.jme3.util.*;
-
 import java.io.*;
 import java.nio.*;
 import java.util.*;
@@ -383,20 +382,20 @@ public class GltfUtils {
         // 5121 (UNSIGNED_BYTE)      f = c / 255.0               c = round(f * 255.0)
         // 5122 (SHORT)              f = max(c / 32767.0, -1.0)  c = round(f * 32767.0)
         // 5123 (UNSIGNED_SHORT)     f = c / 65535.0             c = round(f * 65535.0)
-        byte b;
+        int c;
         switch (format) {
             case Byte:
-                b = stream.readByte();
-                return Math.max(b / 127f, -1f);
+                c = stream.readByte();
+                return Math.max(c / 127f, -1f);
             case UnsignedByte:
-                b = stream.readByte();
-                return b / 255f;
+                c = stream.readUnsignedByte();
+                return c / 255f;
             case Short:
-                b = stream.readByte();
-                return Math.max(b / 32767f, -1f);
+                c = stream.readShort();
+                return Math.max(c / 32767f, -1f);
             case UnsignedShort:
-                b = stream.readByte();
-                return b / 65535f;
+                c = stream.readUnsignedShort();
+                return c / 65535f;
             default:
                 //we have a regular float
                 return stream.readFloat();