Mercurial > games > semicongine
comparison tests/test_gltf.nim @ 1257:e9b8d87b9883
fix: super stupid bug in perspective matrix X(
author | sam <sam@basx.dev> |
---|---|
date | Sun, 28 Jul 2024 18:55:46 +0700 |
parents | bfb75c934f4e |
children | 5442d0e9d8ff |
comparison
equal
deleted
inserted
replaced
1256:bfb75c934f4e | 1257:e9b8d87b9883 |
---|---|
136 let camDir = (Rotate(camYaw, Y) * Rotate(camPitch, X)) * Z | 136 let camDir = (Rotate(camYaw, Y) * Rotate(camPitch, X)) * Z |
137 let camDirSide = camDir.Cross(-Y).Normalized | 137 let camDirSide = camDir.Cross(-Y).Normalized |
138 camPos += camDir * forward * dt | 138 camPos += camDir * forward * dt |
139 camPos += camDirSide * sideward * dt | 139 camPos += camDirSide * sideward * dt |
140 | 140 |
141 let fovH = PI / 2 | |
142 let fovV = 2 * arctan(tan(fovH / 2) * 1 / GetAspectRatio()) | |
141 descriptors.data.camera.data.viewPerspective = ( | 143 descriptors.data.camera.data.viewPerspective = ( |
142 Perspective(PI/3, aspect = GetAspectRatio(), zNear = 0.1, zFar = 1) * | 144 Perspective(fovV, aspect = GetAspectRatio(), zNear = 0.01, zFar = 20) * |
143 Rotate(-camPitch, X) * Rotate(-camYaw, Y) * Translate(-camPos) | 145 Rotate(-camPitch, X) * Rotate(-camYaw, Y) * Translate(-camPos) |
144 ) | 146 ) |
145 | 147 |
146 UpdateGPUBuffer(descriptors.data.camera) | 148 UpdateGPUBuffer(descriptors.data.camera) |
147 | 149 |