diff tests/test_gltf.nim @ 1248:317bb5a73606

did: continue on gltf importer
author sam <sam@basx.dev>
date Thu, 25 Jul 2024 20:23:54 +0700
parents c15770761865
children d83726af7abb
line wrap: on
line diff
--- a/tests/test_gltf.nim	Wed Jul 24 23:26:34 2024 +0700
+++ b/tests/test_gltf.nim	Thu Jul 25 20:23:54 2024 +0700
@@ -12,15 +12,15 @@
 
   type
     Material = object
-      color: Vec4f
+      color: Vec4f = NewVec4f(1, 1, 1, 1)
       colorTexture: int32 = -1
-      metallic: float32 = -1
-      roughness: float32 = -1
+      metallic: float32 = 0
+      roughness: float32 = 0
       metallicRoughnessTexture: int32 = -1
 
       normalTexture: int32 = -1
       occlusionTexture: int32 = -1
-      emissive: Vec4f = NewVec4f(-1, -1, -1, -1)
+      emissive: Vec4f = NewVec4f(0, 0, 0, 0)
       emissiveTexture: int32 = -1
     MainDescriptors = object
       material: GPUValue[Material, UniformBuffer]
@@ -47,17 +47,24 @@
 
   let gltfMesh = LoadMeshes[Mesh, Material](
     "town.glb",
-    baseColorFactor = "color",
-    baseColorTexture = "colorTexture",
-    metallicFactor = "metallic",
-    roughnessFactor = "roughness",
-    metallicRoughnessTexture = "metallicRoughnessTexture",
-    normalTexture = "normalTexture",
-    occlusionTexture = "occlusionTexture",
-    emissiveTexture = "emissiveTexture",
-    emissiveFactor = "emissive",
+    MeshAttributeNames(
+      POSITION: "position",
+      COLOR: @["color"],
+      TEXCOORD: @["uv"],
+    ),
+    MaterialAttributeNames(
+      baseColorFactor: "color",
+      baseColorTexture: "colorTexture",
+      metallicFactor: "metallic",
+      roughnessFactor: "roughness",
+      metallicRoughnessTexture: "metallicRoughnessTexture",
+      normalTexture: "normalTexture",
+      occlusionTexture: "occlusionTexture",
+      emissiveTexture: "emissiveTexture",
+      emissiveFactor: "emissive",
+    )
   )
-  var mesh = gltfMesh.meshes[0]
+  var mesh = gltfMesh.meshes[0][0]
   renderdata.AssignBuffers(mesh)
   renderdata.FlushAllMemory()