use camera offset
This commit is contained in:
parent
43b5406b93
commit
4fbe0d8a57
@ -23,6 +23,7 @@ struct Camera {
|
|||||||
vel: glam::Vec3,
|
vel: glam::Vec3,
|
||||||
gravity: glam::Vec3,
|
gravity: glam::Vec3,
|
||||||
screen_size: (u32, u32),
|
screen_size: (u32, u32),
|
||||||
|
offset: glam::Vec3,
|
||||||
yaw: f32,
|
yaw: f32,
|
||||||
pitch: f32,
|
pitch: f32,
|
||||||
controls: u32,
|
controls: u32,
|
||||||
@ -70,7 +71,7 @@ impl Camera {
|
|||||||
fn to_uniform_data(&self) -> [f32; 16 * 3 + 4] {
|
fn to_uniform_data(&self) -> [f32; 16 * 3 + 4] {
|
||||||
let aspect = self.screen_size.0 as f32 / self.screen_size.1 as f32;
|
let aspect = self.screen_size.0 as f32 / self.screen_size.1 as f32;
|
||||||
let proj = glam::Mat4::perspective_rh(consts::FRAC_PI_2, aspect, 1.0, 200.0);
|
let proj = glam::Mat4::perspective_rh(consts::FRAC_PI_2, aspect, 1.0, 200.0);
|
||||||
let view = (glam::Mat4::from_translation(self.pos) * glam::Mat4::from_euler(glam::EulerRot::YXZ, self.yaw, self.pitch, 0f32)).inverse();
|
let view = (glam::Mat4::from_translation(self.pos+self.offset) * glam::Mat4::from_euler(glam::EulerRot::YXZ, self.yaw, self.pitch, 0f32)).inverse();
|
||||||
let proj_inv = proj.inverse();
|
let proj_inv = proj.inverse();
|
||||||
|
|
||||||
let mut raw = [0f32; 16 * 3 + 4];
|
let mut raw = [0f32; 16 * 3 + 4];
|
||||||
@ -211,6 +212,7 @@ impl strafe_client::framework::Example for Skybox {
|
|||||||
vel: glam::Vec3 { x: 0.0, y: 0.0, z: 0.0 },
|
vel: glam::Vec3 { x: 0.0, y: 0.0, z: 0.0 },
|
||||||
gravity: glam::Vec3 { x: 0.0, y: -100.0, z: 0.0 },
|
gravity: glam::Vec3 { x: 0.0, y: -100.0, z: 0.0 },
|
||||||
screen_size: (config.width, config.height),
|
screen_size: (config.width, config.height),
|
||||||
|
offset: glam::Vec3::new(0.0,4.5,0.0),
|
||||||
pitch: 0.0,
|
pitch: 0.0,
|
||||||
yaw: 0.0,
|
yaw: 0.0,
|
||||||
mv: 2.7,
|
mv: 2.7,
|
||||||
|
Loading…
Reference in New Issue
Block a user