Skip to content

Commit 5557456

Browse files
authored
Merge pull request #1873 from tonihele/bugfix/issue-1871
Fix #1871 (vertex colors not loaded in gltf models)
2 parents a2d639c + 8fc4079 commit 5557456

File tree

2 files changed

+10
-12
lines changed

2 files changed

+10
-12
lines changed

jme3-plugins/src/gltf/java/com/jme3/scene/plugins/gltf/GltfLoader.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1282,8 +1282,7 @@ public VertexBufferPopulator(VertexBuffer.Type bufferType) {
12821282
public VertexBuffer populate(Integer bufferViewIndex, int componentType, String type, int count,
12831283
int byteOffset, boolean normalized) throws IOException {
12841284
if (bufferType == null) {
1285-
logger.log(Level.WARNING,
1286-
"could not assign data to any VertexBuffer type for buffer view " + bufferViewIndex);
1285+
logger.log(Level.WARNING, "could not assign data to any VertexBuffer type for buffer view {0}", bufferViewIndex);
12871286
return null;
12881287
}
12891288

jme3-plugins/src/gltf/java/com/jme3/scene/plugins/gltf/GltfUtils.java

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,6 @@
3838
import com.jme3.scene.*;
3939
import com.jme3.texture.Texture;
4040
import com.jme3.util.*;
41-
4241
import java.io.*;
4342
import java.nio.*;
4443
import java.util.*;
@@ -383,20 +382,20 @@ public static float readAsFloat(LittleEndien stream, VertexBuffer.Format format)
383382
// 5121 (UNSIGNED_BYTE) f = c / 255.0 c = round(f * 255.0)
384383
// 5122 (SHORT) f = max(c / 32767.0, -1.0) c = round(f * 32767.0)
385384
// 5123 (UNSIGNED_SHORT) f = c / 65535.0 c = round(f * 65535.0)
386-
byte b;
385+
int c;
387386
switch (format) {
388387
case Byte:
389-
b = stream.readByte();
390-
return Math.max(b / 127f, -1f);
388+
c = stream.readByte();
389+
return Math.max(c / 127f, -1f);
391390
case UnsignedByte:
392-
b = stream.readByte();
393-
return b / 255f;
391+
c = stream.readUnsignedByte();
392+
return c / 255f;
394393
case Short:
395-
b = stream.readByte();
396-
return Math.max(b / 32767f, -1f);
394+
c = stream.readShort();
395+
return Math.max(c / 32767f, -1f);
397396
case UnsignedShort:
398-
b = stream.readByte();
399-
return b / 65535f;
397+
c = stream.readUnsignedShort();
398+
return c / 65535f;
400399
default:
401400
//we have a regular float
402401
return stream.readFloat();

0 commit comments

Comments
 (0)