diff options
Diffstat (limited to 'world/src/mesh.rs')
-rw-r--r-- | world/src/mesh.rs | 27 |
1 files changed, 4 insertions, 23 deletions
diff --git a/world/src/mesh.rs b/world/src/mesh.rs index 2bcf4c0..79e0edc 100644 --- a/world/src/mesh.rs +++ b/world/src/mesh.rs @@ -18,9 +18,9 @@ use crate::{Args, TextureCache, load_texture}; use anyhow::Result; use gltf::{Mesh, Node, buffer::Data}; use log::{debug, info}; -use std::{f32::consts::PI, path::Path}; +use std::path::Path; use weareshared::{ - Affine3A, Mat3A, Vec3A, + Affine3A, Vec3A, resources::{MeshPart, Prefab}, store::ResourceStore, vec2, vec3a, @@ -28,6 +28,7 @@ use weareshared::{ pub fn import_mesh( mesh: Mesh, + trans: Affine3A, buffers: &[Data], store: &ResourceStore, path_base: &Path, @@ -350,26 +351,6 @@ pub fn import_mesh( va_roughness: None, })?; - prefab - .mesh - .push((node_transform_to_affine(node, args), mesh)) + prefab.mesh.push((trans, mesh)) }) } - -pub fn node_transform_to_affine(node: &Node, args: &Args) -> Affine3A { - let mat = node.transform().matrix(); - let mut aff = Affine3A::from_cols_array_2d(&[ - [mat[0][0], mat[0][1], mat[0][2]], - [mat[1][0], mat[1][1], mat[1][2]], - [mat[2][0], mat[2][1], mat[2][2]], - [mat[3][0], mat[3][1], mat[3][2]], - ]); - aff.matrix3 *= args.scale.unwrap_or(1.); - aff.translation *= args.scale.unwrap_or(1.); - if args.z_up { - let r = Mat3A::from_rotation_x(PI / 2.); - aff.matrix3 *= r; - aff.translation = r * aff.translation; - } - aff -} |