mirror of
https://github.com/guilhermewerner/wgpu-renderer
synced 2025-06-15 21:34:21 +00:00
Update project
This commit is contained in:
20
Source/Camera/Camera.rs
Normal file
20
Source/Camera/Camera.rs
Normal file
@ -0,0 +1,20 @@
|
||||
use super::OPENGL_TO_WGPU_MATRIX;
|
||||
|
||||
pub struct Camera {
|
||||
pub eye: cgmath::Point3<f32>,
|
||||
pub target: cgmath::Point3<f32>,
|
||||
pub up: cgmath::Vector3<f32>,
|
||||
pub aspect: f32,
|
||||
pub fovy: f32,
|
||||
pub znear: f32,
|
||||
pub zfar: f32,
|
||||
}
|
||||
|
||||
impl Camera {
|
||||
pub fn BuildViewProjectionMatrix(&self) -> cgmath::Matrix4<f32> {
|
||||
let view = cgmath::Matrix4::look_at_rh(self.eye, self.target, self.up);
|
||||
let proj = cgmath::perspective(cgmath::Deg(self.fovy), self.aspect, self.znear, self.zfar);
|
||||
|
||||
OPENGL_TO_WGPU_MATRIX * proj * view
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user