2019-01-13 20:53:55 +00:00
|
|
|
pub mod figure;
|
2019-01-11 20:14:37 +00:00
|
|
|
pub mod skybox;
|
|
|
|
|
|
|
|
// Library
|
|
|
|
use gfx::{
|
|
|
|
self,
|
|
|
|
// Macros
|
|
|
|
gfx_defines,
|
|
|
|
gfx_constant_struct_meta,
|
|
|
|
gfx_impl_struct_meta,
|
|
|
|
};
|
2019-01-11 23:18:34 +00:00
|
|
|
use vek::*;
|
2019-01-11 20:14:37 +00:00
|
|
|
|
2019-01-12 01:14:58 +00:00
|
|
|
// Local
|
|
|
|
use super::util::arr_to_mat;
|
|
|
|
|
2019-01-11 20:14:37 +00:00
|
|
|
gfx_defines! {
|
|
|
|
constant Globals {
|
|
|
|
view_mat: [[f32; 4]; 4] = "view_mat",
|
|
|
|
proj_mat: [[f32; 4]; 4] = "proj_mat",
|
|
|
|
cam_pos: [f32; 4] = "cam_pos",
|
|
|
|
focus_pos: [f32; 4] = "focus_pos",
|
2019-01-12 15:57:19 +00:00
|
|
|
// TODO: Fix whatever alignment issue requires these uniforms to be aligned
|
2019-01-11 20:14:37 +00:00
|
|
|
view_distance: [f32; 4] = "view_distance",
|
2019-01-12 15:57:19 +00:00
|
|
|
time_of_day: [f32; 4] = "time_of_day", // TODO: Make this f64
|
2019-01-11 20:14:37 +00:00
|
|
|
time: [f32; 4] = "time",
|
|
|
|
}
|
|
|
|
}
|
2019-01-11 23:18:34 +00:00
|
|
|
|
|
|
|
impl Globals {
|
2019-01-12 01:14:58 +00:00
|
|
|
/// Create global consts with default values.
|
|
|
|
pub fn default() -> Self {
|
2019-01-11 23:18:34 +00:00
|
|
|
Self {
|
2019-01-12 01:14:58 +00:00
|
|
|
view_mat: arr_to_mat(Mat4::identity().into_col_array()),
|
|
|
|
proj_mat: arr_to_mat(Mat4::identity().into_col_array()),
|
2019-01-11 23:18:34 +00:00
|
|
|
cam_pos: [0.0; 4],
|
|
|
|
focus_pos: [0.0; 4],
|
|
|
|
view_distance: [0.0; 4],
|
2019-01-12 01:14:58 +00:00
|
|
|
time_of_day: [0.0; 4],
|
2019-01-11 23:18:34 +00:00
|
|
|
time: [0.0; 4],
|
|
|
|
}
|
|
|
|
}
|
2019-01-12 01:14:58 +00:00
|
|
|
|
|
|
|
/// Create global consts from the provided parameters.
|
|
|
|
pub fn new(
|
|
|
|
view_mat: Mat4<f32>,
|
|
|
|
proj_mat: Mat4<f32>,
|
|
|
|
cam_pos: Vec3<f32>,
|
|
|
|
focus_pos: Vec3<f32>,
|
|
|
|
view_distance: f32,
|
2019-01-12 15:57:19 +00:00
|
|
|
time_of_day: f64,
|
2019-01-12 01:14:58 +00:00
|
|
|
time: f32,
|
|
|
|
) -> Self {
|
|
|
|
Self {
|
|
|
|
view_mat: arr_to_mat(view_mat.into_col_array()),
|
|
|
|
proj_mat: arr_to_mat(proj_mat.into_col_array()),
|
|
|
|
cam_pos: Vec4::from(cam_pos).into_array(),
|
|
|
|
focus_pos: Vec4::from(focus_pos).into_array(),
|
|
|
|
view_distance: [view_distance; 4],
|
2019-01-12 15:57:19 +00:00
|
|
|
time_of_day: [time_of_day as f32; 4],
|
2019-01-12 01:14:58 +00:00
|
|
|
time: [time; 4],
|
|
|
|
}
|
|
|
|
}
|
2019-01-11 23:18:34 +00:00
|
|
|
}
|