-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- **started scene implementation** - **scene pipeline wip** - **temporary silences scene, toolchain update**
- Loading branch information
Showing
30 changed files
with
486 additions
and
219 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,7 @@ | ||
mod gyro_data; | ||
mod vector3; | ||
mod vertex; | ||
mod point3; | ||
mod vertex3d; | ||
|
||
pub use gyro_data::GyroData; | ||
pub use vector3::Vector3; | ||
pub use vertex::*; | ||
pub use point3::Point3; | ||
pub use vertex3d::Vertex3D; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
use bytemuck::{Pod, Zeroable}; | ||
|
||
use crate::{flat::Point, volume::Point3}; | ||
|
||
#[repr(C)] | ||
#[derive(Copy, Clone, Default, Debug, Zeroable, Pod)] | ||
pub struct Vertex3D { | ||
pub pos: Point3, | ||
pub uv: Point, | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
[package] | ||
authors = ["Vladas Zakrevskis <[email protected]>"] | ||
edition = "2021" | ||
name = "scene" | ||
version = "0.1.0" | ||
|
||
[lib] | ||
crate-type = ["rlib", "staticlib"] | ||
name = "scene" | ||
|
||
[dependencies] | ||
cgmath = { workspace = true } | ||
gm = { workspace = true } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
#[rustfmt::skip] | ||
pub const OPENGL_TO_WGPU_MATRIX: cgmath::Matrix4<f32> = cgmath::Matrix4::new( | ||
1.0, 0.0, 0.0, 0.0, | ||
0.0, 1.0, 0.0, 0.0, | ||
0.0, 0.0, 0.5, 0.5, | ||
0.0, 0.0, 0.0, 1.0, | ||
); | ||
|
||
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 build_view_projection_matrix(&self) -> cgmath::Matrix4<f32> { | ||
// 1. | ||
let view = cgmath::Matrix4::look_at_rh(self.eye, self.target, self.up); | ||
// 2. | ||
let proj = cgmath::perspective(cgmath::Deg(self.fovy), self.aspect, self.znear, self.zfar); | ||
|
||
// 3. | ||
OPENGL_TO_WGPU_MATRIX * proj * view | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
mod camera; | ||
mod object; | ||
mod scene; | ||
|
||
pub use camera::Camera; | ||
pub use scene::Scene; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
use gm::volume::Point3; | ||
|
||
pub struct Object { | ||
pub position: Point3, | ||
pub vertices: Vec<Point3>, | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
use gm::flat::Size; | ||
|
||
use crate::{camera::Camera, object::Object}; | ||
|
||
pub struct Scene { | ||
pub camera: Camera, | ||
pub objects: Vec<Object>, | ||
} | ||
|
||
impl Scene { | ||
pub fn set_aspect_ratio(&mut self, resolution: Size) { | ||
self.camera.aspect = resolution.width / resolution.height; | ||
} | ||
} | ||
|
||
impl Default for Scene { | ||
fn default() -> Self { | ||
Self { | ||
camera: Camera { | ||
// position the camera 1 unit up and 2 units back | ||
// +z is out of the screen | ||
eye: (0.0, 1.0, 2.0).into(), | ||
// have it look at the origin | ||
target: (0.0, 0.0, 0.0).into(), | ||
// which way is "up" | ||
up: cgmath::Vector3::unit_y(), | ||
aspect: 1.0, | ||
fovy: 45.0, | ||
znear: 0.1, | ||
zfar: 100.0, | ||
}, | ||
objects: Vec::new(), | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
mod scene_pipeline; |
Oops, something went wrong.