🚧 wip: matrices are giving me grief again
parent
3803a48c13
commit
c8baadc24c
|
@ -2,6 +2,11 @@ use std::{
|
|||
collections::HashMap,
|
||||
};
|
||||
|
||||
use glam::{
|
||||
Quat,
|
||||
Vec4,
|
||||
};
|
||||
|
||||
use opengl_rust::{
|
||||
prelude::*,
|
||||
gl_state::{
|
||||
|
@ -184,7 +189,15 @@ impl Graphics {
|
|||
|
||||
let proj_mat = Mat4::perspective_rh_gl (fov.to_radians (), screen_size.0 / screen_size.1, 0.125, 200.0);
|
||||
|
||||
let view_mat = proj_mat * camera.mat;
|
||||
let (
|
||||
cam_trans,
|
||||
cam_rot,
|
||||
_
|
||||
) = camera.transform.clone ().decomposed ();
|
||||
|
||||
let view_mat = proj_mat *
|
||||
Mat4::from_quat (Quat::from_array (cam_rot).inverse ());
|
||||
//Mat4::from_translation (cam_trans.into ()) *
|
||||
let world_model_mat = Mat4::IDENTITY;
|
||||
|
||||
self.passes [0].with (gl_state, || {
|
||||
|
@ -319,7 +332,7 @@ impl Graphics {
|
|||
}
|
||||
}
|
||||
|
||||
if false {
|
||||
if true {
|
||||
let sky_mvp_mat = view_mat * Mat4::from_scale ((64.0, 64.0, 64.0).into ());
|
||||
|
||||
self.texture_sky.bind ();
|
||||
|
|
|
@ -75,7 +75,7 @@ async fn main () -> Result <()> {
|
|||
for node in scene.nodes () {
|
||||
if let Some (c) = node.camera () {
|
||||
camera = Some (Camera {
|
||||
mat: gltf_node_get_mat4 (&node).inverse (),
|
||||
transform: node.transform ().clone (),
|
||||
});
|
||||
}
|
||||
|
||||
|
@ -412,7 +412,7 @@ struct TriangleStream {
|
|||
}
|
||||
|
||||
struct Camera {
|
||||
mat: Mat4,
|
||||
transform: gltf::scene::Transform,
|
||||
}
|
||||
|
||||
fn gltf_node_get_mat4 (node: &gltf::Node) -> Mat4 {
|
||||
|
|
Loading…
Reference in New Issue