Skip to content

Commit

Permalink
matrix rotation is broken for some reason
Browse files Browse the repository at this point in the history
  • Loading branch information
icewind1991 committed Dec 22, 2023
1 parent 2fb63ab commit f2f0acf
Showing 1 changed file with 10 additions and 11 deletions.
21 changes: 10 additions & 11 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,10 @@ mod prop;

use crate::bsp::{bsp_models, push_bsp_model};
use crate::prop::push_or_get_model;
use cgmath::Matrix4;
use clap::Parser;
pub use error::Error;
use gltf::Glb;
use gltf_json::scene::UnitQuaternion;
use gltf_json::validation::USize64;
use gltf_json::{Buffer, Index, Node, Root, Scene};
use miette::Context;
Expand Down Expand Up @@ -82,25 +82,24 @@ fn export(bsp: Bsp, loader: &Loader) -> Result<Glb<'static>, Error> {

for prop in bsp.static_props() {
let mesh = push_or_get_model(&mut buffer, &mut root, loader, prop.model(), prop.skin);

let matrix = Matrix4::from_translation(map_coords(prop.origin).into())
* Matrix4::from(prop.rotation());
let rotation = prop.rotation();

let node = Node {
camera: None,
children: None,
extensions: Default::default(),
extras: Default::default(),
matrix: Some([
matrix.x.x, matrix.x.y, matrix.x.z, matrix.x.w, matrix.y.x, matrix.y.y, matrix.y.z,
matrix.y.w, matrix.z.x, matrix.z.y, matrix.z.z, matrix.z.w, matrix.w.x, matrix.w.y,
matrix.w.z, matrix.w.w,
]),
matrix: None,
mesh: Some(mesh),
name: Some(prop.model().into()),
rotation: None,
rotation: Some(UnitQuaternion([
rotation.v.x,
rotation.v.y,
rotation.v.z,
rotation.s,
])),
scale: None,
translation: None,
translation: Some(map_coords(prop.origin)),
skin: None,
weights: None,
};
Expand Down

0 comments on commit f2f0acf

Please sign in to comment.