Mercurial > games > semicongine
comparison semiconginev2/gltf.nim @ 1253:c4f98eb4bb05
fix: a few things
author | sam <sam@basx.dev> |
---|---|
date | Fri, 26 Jul 2024 23:39:24 +0700 |
parents | 01e9f41d35b1 |
children | b0f4c8ccd49a |
comparison
equal
deleted
inserted
replaced
1252:01e9f41d35b1 | 1253:c4f98eb4bb05 |
---|---|
231 for child in items(node["children"]): | 231 for child in items(node["children"]): |
232 result.children.add child.getInt() | 232 result.children.add child.getInt() |
233 if "matrix" in node: | 233 if "matrix" in node: |
234 for i in 0 ..< node["matrix"].len: | 234 for i in 0 ..< node["matrix"].len: |
235 result.transform[i] = node["matrix"][i].getFloat() | 235 result.transform[i] = node["matrix"][i].getFloat() |
236 | 236 result.transform = result.transform.Transposed() |
237 var (t, r, s) = (Unit4, Unit4, Unit4) | 237 else: |
238 if "translation" in node: | 238 var (t, r, s) = (Unit4, Unit4, Unit4) |
239 t = Translate( | 239 if "translation" in node: |
240 float32(node["translation"][0].getFloat()), | 240 t = Translate( |
241 float32(node["translation"][1].getFloat()), | 241 float32(node["translation"][0].getFloat()), |
242 float32(node["translation"][2].getFloat()) | 242 float32(node["translation"][1].getFloat()), |
243 ) | 243 float32(node["translation"][2].getFloat()) |
244 if "rotation" in node: | |
245 t = Rotate( | |
246 float32(node["rotation"][3].getFloat()), | |
247 NewVec3f( | |
248 float32(node["rotation"][0].getFloat()), | |
249 float32(node["rotation"][1].getFloat()), | |
250 float32(node["rotation"][2].getFloat()) | |
251 ) | 244 ) |
252 ) | 245 if "rotation" in node: |
253 if "scale" in node: | 246 t = Rotate( |
254 t = Scale( | 247 float32(node["rotation"][3].getFloat()), |
255 float32(node["scale"][0].getFloat()), | 248 NewVec3f( |
256 float32(node["scale"][1].getFloat()), | 249 float32(node["rotation"][0].getFloat()), |
257 float32(node["scale"][2].getFloat()) | 250 float32(node["rotation"][1].getFloat()), |
258 ) | 251 float32(node["rotation"][2].getFloat()) |
259 | 252 ) |
260 result.transform = t * r * s * result.transform | 253 ) |
254 if "scale" in node: | |
255 t = Scale( | |
256 float32(node["scale"][0].getFloat()), | |
257 float32(node["scale"][1].getFloat()), | |
258 float32(node["scale"][2].getFloat()) | |
259 ) | |
260 | |
261 result.transform = t * r * s | |
261 | 262 |
262 proc ReadglTF*[TMesh, TMaterial]( | 263 proc ReadglTF*[TMesh, TMaterial]( |
263 stream: Stream, | 264 stream: Stream, |
264 meshAttributesMapping: static MeshAttributeNames, | 265 meshAttributesMapping: static MeshAttributeNames, |
265 materialAttributesMapping: static MaterialAttributeNames, | 266 materialAttributesMapping: static MaterialAttributeNames, |