Compare commits

...

3 Commits

5 changed files with 58 additions and 16 deletions

View File

@ -2,6 +2,6 @@
Lithium is a small Real-Time 3D renderer written in rust. Lithium is a small Real-Time 3D renderer written in rust.
It is not meant for real world usage, but for learning about 3D rendering. It is not meant for real world usage, but for learning about 3D rendering.
# License ## License
Lithium is licensed under the MIT open source license. Lithium is licensed under the MIT open source license.
Check the `LICENSE` file for more info. Check the `LICENSE` file for more info.

View File

@ -2,10 +2,17 @@
# It is not intended for manual editing. # It is not intended for manual editing.
version = 3 version = 3
[[package]]
name = "anyhow"
version = "1.0.75"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "a4668cab20f66d8d020e1fbc0ebe47217433c1b6c8f2040faf858554e394ace6"
[[package]] [[package]]
name = "lithium-loader" name = "lithium-loader"
version = "0.1.0" version = "0.1.0"
dependencies = [ dependencies = [
"anyhow",
"lithium-utils", "lithium-utils",
] ]

View File

@ -9,3 +9,5 @@ authors = ["antifallobst"]
[dependencies] [dependencies]
lithium-utils = { path = "../lithium-utils" } lithium-utils = { path = "../lithium-utils" }
anyhow = "1.0.75"

View File

@ -1,3 +1,4 @@
use anyhow::Result;
use lithium_utils::{Vector2, Vector3}; use lithium_utils::{Vector2, Vector3};
pub struct Vertex { pub struct Vertex {
@ -53,4 +54,12 @@ impl Model {
faces, faces,
} }
} }
pub fn faces(&self) -> &Vec<(u32, u32, u32)> {
&self.faces
}
pub fn vertex(&self, id: u32) -> Option<&Vertex> {
self.vertices.get(id as usize)
}
} }

View File

@ -1,6 +1,26 @@
use std::ops::{Add, Sub};
pub struct Vector2 { pub struct Vector2 {
x: f32, pub x: f32,
y: f32, pub y: f32,
}
impl Default for Vector2 {
fn default() -> Self {
Self { x: 0_f32, y: 0_f32 }
}
}
impl Vector2 {
pub fn new(x: f32, y: f32) -> Self {
Self { x, y }
}
}
pub struct Vector3 {
pub x: f32,
pub y: f32,
pub z: f32,
} }
impl Default for Vector3 { impl Default for Vector3 {
@ -13,21 +33,25 @@ impl Default for Vector3 {
} }
} }
impl Vector2 { impl Add for Vector3 {
pub fn new(x: f32, y: f32) -> Self { type Output = Self;
Self { x, y } fn add(self, rhs: Self) -> Self::Output {
Self::Output {
x: self.x + rhs.x,
y: self.y + rhs.y,
z: self.z + rhs.z,
}
} }
} }
pub struct Vector3 { impl Sub for Vector3 {
x: f32, type Output = Vector3;
y: f32, fn sub(self, rhs: Self) -> Self::Output {
z: f32, Self::Output {
} x: self.x - rhs.x,
y: self.y - rhs.y,
impl Default for Vector2 { z: self.z - rhs.z,
fn default() -> Self { }
Self { x: 0_f32, y: 0_f32 }
} }
} }