Skip to content

Commit

Permalink
feat: Finalized vector.rs
Browse files Browse the repository at this point in the history
All of the *most used* functions are implemented for both Vector3 & Vector2. Examples have been updated, tho it makes the import of blue_engine in `Cargo.toml` be a path instead of a version. Cube has been fixed, there might need more test to ensure everything is working correctly
  • Loading branch information
Gipson62 committed Jan 11, 2025
1 parent 4dbf03c commit da69d1e
Show file tree
Hide file tree
Showing 12 changed files with 401 additions and 133 deletions.
23 changes: 20 additions & 3 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ u16 = ["blue_engine_core?/u16", "blue_engine_dynamic?/u16"]
u32 = ["blue_engine_core?/u32", "blue_engine_dynamic?/u32"]

[dependencies]
blue_engine_core = { version = "0.6.0", optional = true }
blue_engine_core = { path = "./crates/blue_engine_core", optional = true }

# Wasm does not support dynamic linking.
[target.'cfg(not(target_family = "wasm"))'.dependencies]
Expand Down
4 changes: 2 additions & 2 deletions crates/blue_engine_core/src/header.rs
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ impl Vertex {
},
wgpu::VertexAttribute {
// This should be replaced with `std::mem::size_of::<Vector3>() as wgpu::BufferAddress`
offset: std::mem::size_of::<[f32; 3]>() as wgpu::BufferAddress,
offset: std::mem::size_of::<[f32; 3]>() as wgpu::BufferAddress,
shader_location: 1,
format: wgpu::VertexFormat::Float32x2,
},
Expand Down Expand Up @@ -441,7 +441,7 @@ pub struct Camera {
/// The up vector of the camera. This defines the elevation of the camera
pub up: Vector3,
/// The resolution of the camera view
pub resolution: (f32, f32),
pub resolution: (f32, f32), //maybe this should be a Vector2i
/// The projection of the camera
pub projection: Projection,
/// The closest view of camera
Expand Down
44 changes: 22 additions & 22 deletions crates/blue_engine_core/src/primitive_shapes/three_dimensions.rs
Original file line number Diff line number Diff line change
Expand Up @@ -69,18 +69,13 @@ pub fn cube(name: impl StringBuffer, renderer: &mut Renderer, objects: &mut Obje
},
Vertex {
position: Vector3::new(1.0, -1.0, 1.0),
uv: Vector2::new(1.0, 1.0),
normal: Vector3::new(0.0, 0.0, 0.0),
},
// Left face
Vertex {
position: Vector3::new(-1.0, -1.0, -1.0),
uv: Vector2::new(0.0, 1.0),
normal: Vector3::new(0.0, 0.0, 0.0),
},
// Left face
Vertex {
position: Vector3::new(-1.0, 1.0, -1.0),
uv: Vector2::new(0.0, 0.0),
position: Vector3::new(-1.0, -1.0, 1.0),
uv: Vector2::new(1.0, 1.0),
normal: Vector3::new(0.0, 0.0, 0.0),
},
Vertex {
Expand All @@ -89,42 +84,37 @@ pub fn cube(name: impl StringBuffer, renderer: &mut Renderer, objects: &mut Obje
normal: Vector3::new(0.0, 0.0, 0.0),
},
Vertex {
position: Vector3::new(-1.0, -1.0, 1.0),
uv: Vector2::new(1.0, 1.0),
position: Vector3::new(-1.0, 1.0, -1.0),
uv: Vector2::new(0.0, 0.0),
normal: Vector3::new(0.0, 0.0, 0.0),
},
// Top face
Vertex {
position: Vector3::new(-1.0, 1.0, -1.0),
position: Vector3::new(-1.0, -1.0, -1.0),
uv: Vector2::new(0.0, 1.0),
normal: Vector3::new(0.0, 0.0, 0.0),
},
// Top face
Vertex {
position: Vector3::new(1.0, 1.0, -1.0),
uv: Vector2::new(1.0, 1.0),
normal: Vector3::new(0.0, 0.0, 0.0),
},
Vertex {
position: Vector3::new(1.0, 1.0, 1.0),
uv: Vector2::new(1.0, 0.0),
normal: Vector3::new(0.0, 0.0, 0.0),
},
Vertex {
position: Vector3::new(-1.0, 1.0, 1.0),
position: Vector3::new(-1.0, 1.0, -1.0),
uv: Vector2::new(0.0, 0.0),
normal: Vector3::new(0.0, 0.0, 0.0),
},
// Bottom face
Vertex {
position: Vector3::new(-1.0, -1.0, -1.0),
uv: Vector2::new(0.0, 1.0),
position: Vector3::new(-1.0, 1.0, 1.0),
uv: Vector2::new(0.0, -1.0),
normal: Vector3::new(0.0, 0.0, 0.0),
},
Vertex {
position: Vector3::new(1.0, -1.0, -1.0),
position: Vector3::new(1.0, 1.0, 1.0),
uv: Vector2::new(1.0, 1.0),
normal: Vector3::new(0.0, 0.0, 0.0),
},
// Bottom face
Vertex {
position: Vector3::new(1.0, -1.0, 1.0),
uv: Vector2::new(1.0, 0.0),
Expand All @@ -135,6 +125,16 @@ pub fn cube(name: impl StringBuffer, renderer: &mut Renderer, objects: &mut Obje
uv: Vector2::new(0.0, 0.0),
normal: Vector3::new(0.0, 0.0, 0.0),
},
Vertex {
position: Vector3::new(-1.0, -1.0, -1.0),
uv: Vector2::new(0.0, 1.0),
normal: Vector3::new(0.0, 0.0, 0.0),
},
Vertex {
position: Vector3::new(1.0, -1.0, 1.0),
uv: Vector2::new(1.0, 1.0),
normal: Vector3::new(0.0, 0.0, 0.0),
},
],
vec![
0, 1, 2, 2, 3, 0, // top
Expand Down
Loading

0 comments on commit da69d1e

Please sign in to comment.