-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
221c7ff
commit 0b957cc
Showing
21 changed files
with
307 additions
and
116 deletions.
There are no files selected for viewing
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 @@ | ||
name: CI | ||
|
||
on: | ||
push: | ||
branches: | ||
- main | ||
- develop | ||
pull_request: {} | ||
|
||
|
||
jobs: | ||
|
||
build: | ||
name: cargo build | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v4 | ||
- uses: dtolnay/rust-toolchain@stable | ||
- name: Build | ||
run: cargo build | ||
|
||
test: | ||
name: cargo test | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v4 | ||
- uses: dtolnay/rust-toolchain@stable | ||
with: | ||
components: rustfmt clippy | ||
- name: rustfmt | ||
run: cargo fmt --all -- --check | ||
- name: clippy | ||
run: cargo clippy | ||
- name: test | ||
run: cargo test --verbose |
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 |
---|---|---|
|
@@ -3,17 +3,19 @@ members = [ | |
"crates/*" | ||
] | ||
|
||
resolver = "2" | ||
|
||
[workspace.package] | ||
version = "0.0.1-alpha.1" | ||
authors = ["Benedikt Schwab"] | ||
version = "0.0.1-alpha.3" | ||
authors = ["Benedikt Schwab <[email protected]>"] | ||
edition = "2021" | ||
license = "MIT OR Apache-2.0" | ||
repository = "https://github.com/tum-gis/egraphics" | ||
repository = "https://github.com/envis-space/egraphics" | ||
|
||
[workspace.dependencies] | ||
thiserror = "1.0" | ||
tracing = "0.1.30" | ||
tracing-subscriber = "0.3.8" | ||
gltf = "1.0.0" | ||
gltf-json = "1.0.0" | ||
nalgebra = "0.31.1" | ||
thiserror = "1.0.61" | ||
tracing = "0.1.40" | ||
tracing-subscriber = "0.3.18" | ||
gltf = "1.4.1" | ||
gltf-json = "1.4.1" | ||
nalgebra = "0.33.0" |
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 +1,10 @@ | ||
# egraphics | ||
|
||
A Rust library for processing graphics formats in 3D space. | ||
|
||
> [!WARNING] | ||
> The library is at an early stage of development. | ||
## Contributing | ||
|
||
The library is developed at the [TUM Chair of Geoinformatics](https://github.com/tum-gis) and contributions are highly welcome. |
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 @@ | ||
# egraphics-cli | ||
|
||
CLI tool for processing graphics formats in 3D space. | ||
|
||
> [!WARNING] | ||
> The library is at an early stage of development. | ||
## Contributing | ||
|
||
The library is developed at the [TUM Chair of Geoinformatics](https://github.com/tum-gis) and contributions are highly welcome. |
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 @@ | ||
# egraphics-core | ||
|
||
Core primitives and operations for processing graphics formats in 3D space. | ||
|
||
> [!WARNING] | ||
> The library is at an early stage of development. | ||
## Contributing | ||
|
||
The library is developed at the [TUM Chair of Geoinformatics](https://github.com/tum-gis) and contributions are highly welcome. |
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 thiserror::Error; | ||
|
||
#[derive(Error, Debug)] | ||
pub enum Error { | ||
#[error(transparent)] | ||
Io(#[from] std::io::Error), | ||
|
||
#[error("No triangle")] | ||
NoElements, | ||
} |
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,46 +1,46 @@ | ||
use crate::geometry::geometry; | ||
use crate::geometry::triangle; | ||
use nalgebra; | ||
|
||
pub fn generate_sample_triangle_mesh() -> geometry::TriangleMesh { | ||
pub fn generate_sample_triangle_mesh() -> triangle::TriangleMesh { | ||
let triangle_a_vertices = vec![ | ||
geometry::Vertex { | ||
triangle::Vertex { | ||
position: nalgebra::Point3::new(0.0, 0.5, 0.0), | ||
color: nalgebra::Point3::new(1.0, 0.0, 0.0), | ||
}, | ||
geometry::Vertex { | ||
triangle::Vertex { | ||
position: nalgebra::Point3::new(-0.5, -0.5, 0.0), | ||
color: nalgebra::Point3::new(0.0, 1.0, 0.0), | ||
}, | ||
geometry::Vertex { | ||
triangle::Vertex { | ||
position: nalgebra::Point3::new(0.5, -0.5, 0.0), | ||
color: nalgebra::Point3::new(1.0, 1.0, 1.0), | ||
}, | ||
]; | ||
let triangle_a = geometry::Triangle { | ||
let triangle_a = triangle::Triangle { | ||
vertices: triangle_a_vertices, | ||
}; | ||
|
||
let triangle_b_vertices = vec![ | ||
geometry::Vertex { | ||
triangle::Vertex { | ||
position: nalgebra::Point3::new(3.0, 3.5, 3.0), | ||
color: nalgebra::Point3::new(1.0, 0.0, 0.0), | ||
}, | ||
geometry::Vertex { | ||
triangle::Vertex { | ||
position: nalgebra::Point3::new(2.5, 2.5, 3.0), | ||
color: nalgebra::Point3::new(0.0, 1.0, 0.0), | ||
}, | ||
geometry::Vertex { | ||
triangle::Vertex { | ||
position: nalgebra::Point3::new(3.5, 2.5, 3.0), | ||
color: nalgebra::Point3::new(1.0, 1.0, 1.0), | ||
}, | ||
]; | ||
let triangle_b = geometry::Triangle { | ||
let triangle_b = triangle::Triangle { | ||
vertices: triangle_b_vertices, | ||
}; | ||
|
||
let triangle_list: Vec<geometry::Triangle> = vec![triangle_a, triangle_b]; | ||
let triangle_list: Vec<triangle::Triangle> = vec![triangle_a, triangle_b]; | ||
|
||
geometry::TriangleMesh { | ||
triangle::TriangleMesh { | ||
triangles: triangle_list, | ||
} | ||
} |
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,4 +1,15 @@ | ||
mod geometry; | ||
mod error; | ||
mod triangle; | ||
mod triangle_mesh; | ||
|
||
#[doc(inline)] | ||
pub use geometry::geometry::*; | ||
pub use error::Error; | ||
|
||
#[doc(inline)] | ||
pub use triangle::Triangle; | ||
|
||
#[doc(inline)] | ||
pub use triangle::Vertex; | ||
|
||
#[doc(inline)] | ||
pub use triangle_mesh::TriangleMesh; |
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,77 @@ | ||
use crate::Error; | ||
use crate::Error::NoElements; | ||
use std::mem; | ||
|
||
#[derive(Copy, Clone, Debug, PartialEq)] | ||
pub struct Vector3D { | ||
x: f32, | ||
y: f32, | ||
z: f32, | ||
} | ||
|
||
impl Vector3D { | ||
pub fn new(x: f32, y: f32, z: f32) -> Self { | ||
Self { x, y, z } | ||
} | ||
} | ||
|
||
#[derive(Copy, Clone, Debug, PartialEq)] | ||
#[repr(C)] | ||
pub struct Vertex { | ||
pub(crate) position: nalgebra::Point3<f32>, | ||
pub(crate) color: nalgebra::Point3<f32>, | ||
} | ||
|
||
impl Vertex { | ||
pub fn new(position: nalgebra::Point3<f32>, color: nalgebra::Point3<f32>) -> Self { | ||
Self { position, color } | ||
} | ||
|
||
pub fn position(&self) -> &nalgebra::Point3<f32> { | ||
&self.position | ||
} | ||
|
||
pub fn color(&self) -> &nalgebra::Point3<f32> { | ||
&self.color | ||
} | ||
} | ||
|
||
#[derive(Clone, Debug, PartialEq)] | ||
pub struct Triangle { | ||
vertices: Vec<Vertex>, | ||
} | ||
|
||
impl Triangle { | ||
pub fn new(vertices: Vec<Vertex>) -> Result<Self, Error> { | ||
if vertices.is_empty() { | ||
return Err(NoElements); | ||
} | ||
|
||
Ok(Self { vertices }) | ||
} | ||
|
||
pub(crate) fn buffer_length(&self) -> u32 { | ||
(self.vertices.len() * mem::size_of::<Vertex>()) as u32 | ||
} | ||
|
||
pub(crate) fn len(&self) -> usize { | ||
self.vertices.len() | ||
} | ||
|
||
pub(crate) fn get_vertices(&self) -> &Vec<Vertex> { | ||
&self.vertices | ||
} | ||
} | ||
|
||
impl From<Vec<nalgebra::Point3<f32>>> for Triangle { | ||
fn from(item: Vec<nalgebra::Point3<f32>>) -> Self { | ||
let vertices = item | ||
.iter() | ||
.map(|p| Vertex { | ||
position: *p, | ||
color: nalgebra::Point3::new(0.5, 0.5, 0.5), | ||
}) | ||
.collect(); | ||
Triangle { vertices } | ||
} | ||
} |
Oops, something went wrong.