Skip to content

Commit

Permalink
Merge pull request #1873 from tonihele/bugfix/issue-1871
Browse files Browse the repository at this point in the history
Fix #1871 (vertex colors not loaded in gltf models)
  • Loading branch information
tonihele authored Nov 29, 2022
2 parents a2d639c + 8fc4079 commit 5557456
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -1282,8 +1282,7 @@ public VertexBufferPopulator(VertexBuffer.Type bufferType) {
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;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,6 @@
import com.jme3.scene.*;
import com.jme3.texture.Texture;
import com.jme3.util.*;

import java.io.*;
import java.nio.*;
import java.util.*;
Expand Down Expand Up @@ -383,20 +382,20 @@ public static float readAsFloat(LittleEndien stream, VertexBuffer.Format format)
// 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();
Expand Down

0 comments on commit 5557456

Please sign in to comment.