pub struct Model { pub name: Option, pub objects: Vec, } pub struct Object { pub name: Option, pub transform: Transform, pub meshes: Vec, pub children: Vec, } pub struct Mesh { pub vertices: Vec, pub indices: Vec, } pub struct BasicVertex { pub position: glam::Vec3, } #[derive(Copy, Clone, Debug)] pub struct Transform { pub position: glam::Vec3, pub rotation: glam::Vec3, // TODO support glam::Quat too pub scale: f32, } impl Transform { pub fn to_mat4(&self) -> glam::Mat4 { let translation = self.position; let rotation = glam::Quat::from_euler( glam::EulerRot::XYZ, self.rotation[0], self.rotation[1], self.rotation[2], ); let scale = glam::Vec3::splat(self.scale); glam::Mat4::from_scale_rotation_translation(scale, rotation, translation) } } impl Default for Transform { fn default() -> Self { Self { position: glam::Vec3::ZERO, rotation: glam::Vec3::ZERO, scale: 1.0, } } }