diff tests/test_mesh.nim @ 691:9182a5d2ea3a

add: test mesh
author Sam <sam@basx.dev>
date Tue, 16 May 2023 16:08:06 +0700
parents 2ca938595aea
children f05497ef8fd2
line wrap: on
line diff
--- a/tests/test_mesh.nim	Tue May 16 15:35:43 2023 +0700
+++ b/tests/test_mesh.nim	Tue May 16 16:08:06 2023 +0700
@@ -3,8 +3,7 @@
 import semicongine
 
 proc main() =
-  var scene = loadScene("test1.glb")
-  # var scene = loadScene("tutorialk-donat.glb")
+  var scene = loadScene("default_cube.glb")
 
   var engine = initEngine("Test meshes")
   const
@@ -15,7 +14,7 @@
       stage=VK_SHADER_STAGE_VERTEX_BIT,
       inputs=vertexInput,
       uniforms=uniforms,
-      main="""gl_Position = vec4(POSITION * 0.2, 1.0) * Uniforms.transform;"""
+      main="""gl_Position = vec4(POSITION, 1.0) * Uniforms.transform;"""
     )
     fragmentCode = compileGlslShader(
       stage=VK_SHADER_STAGE_FRAGMENT_BIT,
@@ -27,11 +26,14 @@
     )
   engine.setRenderer(engine.gpuDevice.simpleForwardRenderPass(vertexCode, fragmentCode))
   engine.addScene(scene, vertexInput)
-  let rotateAxis = newVec3f(1, 1, 1)
-  scene.addShaderGlobal("transform", rotate3d(0'f32, rotateAxis))
+  let rotateAxis = newVec3f(0, 1, 0)
+  scene.addShaderGlobal("transform", Unit4)
   var t = cpuTime()
   while engine.updateInputs() == Running and not engine.keyIsDown(Escape):
-    scene.setShaderGlobal("transform", rotate3d(float32(cpuTime() - t), rotateAxis))
+    scene.setShaderGlobal(
+      "transform",
+      scale3d(0.2'f32, 0.2'f32, 0.2'f32) * translate3d(0'f32, 0'f32, 1.8'f32) * rotate3d(float32(PI) / 4'f32, newVec3f(1, 0, 0)) * rotate3d(-float32(cpuTime() - t), rotateAxis)
+    )
     engine.renderScene(scene)
   engine.destroy()