changeset 780:f68e88237c95

fix: gltf import transform
author Sam <sam@basx.dev>
date Sun, 13 Aug 2023 00:19:37 +0700
parents a2c14402acd2
children e45c2927ecca
files src/semicongine/resources/mesh.nim
diffstat 1 files changed, 4 insertions(+), 3 deletions(-) [+]
line wrap: on
line diff
--- a/src/semicongine/resources/mesh.nim	Sat Aug 12 23:55:05 2023 +0700
+++ b/src/semicongine/resources/mesh.nim	Sun Aug 13 00:19:37 2023 +0700
@@ -153,13 +153,15 @@
         for entry in getValues[uint16](data)[]:
           tri.add uint32(entry) + baseIndex
           if tri.len == 3:
-            mesh.appendIndicesData(tri[0], tri[1], tri[2])
+            # FYI gltf uses counter-clockwise indexing
+            mesh.appendIndicesData(tri[0], tri[2], tri[1])
             tri.setLen(0)
       of UInt32:
         for entry in getValues[uint32](data)[]:
           tri.add uint32(entry)
           if tri.len == 3:
-            mesh.appendIndicesData(tri[0], tri[1], tri[2])
+            # FYI gltf uses counter-clockwise indexing
+            mesh.appendIndicesData(tri[0], tri[2], tri[1])
             tri.setLen(0)
       else:
         raise newException(Exception, &"Unsupported index data type: {data.thetype}")
@@ -247,7 +249,6 @@
   var rootEntity = newEntity("<root>")
   for nodeId in scenenode["nodes"]:
     var node = loadNode(root, root["nodes"][nodeId.getInt()], mainBuffer)
-    node.transform = node.transform * scale3d(1'f32, -1'f32, 1'f32)
     rootEntity.add node
 
   newScene(scenenode["name"].getStr(), rootEntity)