Fix the debug arrow lighting too
parent
5b1b59db5e
commit
4faa272877
|
@ -216,6 +216,11 @@ struct Arrow {
|
|||
direction: Vec3,
|
||||
}
|
||||
|
||||
struct RenderableArrow {
|
||||
model_mat: Mat4,
|
||||
inv_model_mat: Mat4,
|
||||
}
|
||||
|
||||
fn main () {
|
||||
let sdl_context = sdl2::init ().unwrap ();
|
||||
let video_subsystem = sdl_context.video ().unwrap ();
|
||||
|
@ -408,7 +413,7 @@ fn main () {
|
|||
},
|
||||
];
|
||||
|
||||
let arrow_mats: Vec <_> = arrows.iter ().map (|arrow| {
|
||||
let renderable_arrows: Vec <_> = arrows.iter ().map (|arrow| {
|
||||
let d = arrow.direction;
|
||||
|
||||
let up: Vec3 = if d.z () > 0.5 {
|
||||
|
@ -432,9 +437,17 @@ fn main () {
|
|||
dir_mat.set_y_axis ((up.x (), up.y (), up.z (), 0.0).into ());
|
||||
dir_mat.set_z_axis ((d.x (), d.y (), d.z (), 0.0).into ());
|
||||
|
||||
let model_mat =
|
||||
Mat4::from_translation (arrow.origin) *
|
||||
Mat4::from_scale ((0.125, 0.125, 0.125).into ()) *
|
||||
dir_mat
|
||||
dir_mat;
|
||||
|
||||
let inv_model_mat = model_mat.inverse ();
|
||||
|
||||
RenderableArrow {
|
||||
model_mat,
|
||||
inv_model_mat,
|
||||
}
|
||||
}).collect ();
|
||||
|
||||
use uniforms::*;
|
||||
|
@ -474,10 +487,15 @@ fn main () {
|
|||
});
|
||||
|
||||
glezz::uniform_3fv (unis [&ALBEDO], &magenta);
|
||||
for arrow_mat in &arrow_mats {
|
||||
let mvp = view_mat * *arrow_mat;
|
||||
for arrow in &renderable_arrows {
|
||||
let mvp = view_mat * arrow.model_mat;
|
||||
|
||||
glezz::uniform_matrix_4fv (unis [&MVP], &mvp);
|
||||
let object_space_light = make_object_space_vec (&arrow.inv_model_mat, &light);
|
||||
let object_space_sky = make_object_space_vec (&arrow.inv_model_mat, &Vec3::from ((0.0, 0.0, 1.0)));
|
||||
glezz::uniform_3fv (unis [&OBJECT_SPACE_LIGHT], &object_space_light);
|
||||
glezz::uniform_3fv (unis [&OBJECT_SPACE_SKY], &object_space_sky);
|
||||
|
||||
mesh_arrow.draw_all (attrs, |_| true);
|
||||
}
|
||||
|
||||
|
@ -520,8 +538,8 @@ fn main () {
|
|||
|
||||
mesh_pitch.draw_all (attrs, |i| i != grass_index);
|
||||
|
||||
for arrow_mat in &arrow_mats {
|
||||
let mvp = view_mat * *arrow_mat;
|
||||
for renderable_arrow in &renderable_arrows {
|
||||
let mvp = view_mat * renderable_arrow.model_mat;
|
||||
|
||||
glezz::uniform_matrix_4fv (unis [&MVP], &mvp);
|
||||
mesh_arrow.draw_all (attrs, |_| true);
|
||||
|
|
Loading…
Reference in New Issue