mirror of
https://codeberg.org/icewind/vbsp-to-gltf.git
synced 2026-06-03 10:14:08 +02:00
matrix rotation is broken for some reason
This commit is contained in:
parent
2fb63ab17f
commit
f2f0acf543
1 changed files with 10 additions and 11 deletions
21
src/main.rs
21
src/main.rs
|
|
@ -7,10 +7,10 @@ mod prop;
|
||||||
|
|
||||||
use crate::bsp::{bsp_models, push_bsp_model};
|
use crate::bsp::{bsp_models, push_bsp_model};
|
||||||
use crate::prop::push_or_get_model;
|
use crate::prop::push_or_get_model;
|
||||||
use cgmath::Matrix4;
|
|
||||||
use clap::Parser;
|
use clap::Parser;
|
||||||
pub use error::Error;
|
pub use error::Error;
|
||||||
use gltf::Glb;
|
use gltf::Glb;
|
||||||
|
use gltf_json::scene::UnitQuaternion;
|
||||||
use gltf_json::validation::USize64;
|
use gltf_json::validation::USize64;
|
||||||
use gltf_json::{Buffer, Index, Node, Root, Scene};
|
use gltf_json::{Buffer, Index, Node, Root, Scene};
|
||||||
use miette::Context;
|
use miette::Context;
|
||||||
|
|
@ -82,25 +82,24 @@ fn export(bsp: Bsp, loader: &Loader) -> Result<Glb<'static>, Error> {
|
||||||
|
|
||||||
for prop in bsp.static_props() {
|
for prop in bsp.static_props() {
|
||||||
let mesh = push_or_get_model(&mut buffer, &mut root, loader, prop.model(), prop.skin);
|
let mesh = push_or_get_model(&mut buffer, &mut root, loader, prop.model(), prop.skin);
|
||||||
|
let rotation = prop.rotation();
|
||||||
let matrix = Matrix4::from_translation(map_coords(prop.origin).into())
|
|
||||||
* Matrix4::from(prop.rotation());
|
|
||||||
|
|
||||||
let node = Node {
|
let node = Node {
|
||||||
camera: None,
|
camera: None,
|
||||||
children: None,
|
children: None,
|
||||||
extensions: Default::default(),
|
extensions: Default::default(),
|
||||||
extras: Default::default(),
|
extras: Default::default(),
|
||||||
matrix: Some([
|
matrix: None,
|
||||||
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,
|
|
||||||
]),
|
|
||||||
mesh: Some(mesh),
|
mesh: Some(mesh),
|
||||||
name: Some(prop.model().into()),
|
name: Some(prop.model().into()),
|
||||||
rotation: None,
|
rotation: Some(UnitQuaternion([
|
||||||
|
rotation.v.x,
|
||||||
|
rotation.v.y,
|
||||||
|
rotation.v.z,
|
||||||
|
rotation.s,
|
||||||
|
])),
|
||||||
scale: None,
|
scale: None,
|
||||||
translation: None,
|
translation: Some(map_coords(prop.origin)),
|
||||||
skin: None,
|
skin: None,
|
||||||
weights: None,
|
weights: None,
|
||||||
};
|
};
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue