Compare commits
3 Commits
d74879d339
...
4e536d420d
Author | SHA1 | Date |
---|---|---|
antifallobst | 4e536d420d | |
antifallobst | 83ea75fea9 | |
antifallobst | a583049532 |
|
@ -2,6 +2,6 @@
|
|||
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.
|
||||
|
||||
# License
|
||||
## License
|
||||
Lithium is licensed under the MIT open source license.
|
||||
Check the `LICENSE` file for more info.
|
|
@ -2,10 +2,17 @@
|
|||
# It is not intended for manual editing.
|
||||
version = 3
|
||||
|
||||
[[package]]
|
||||
name = "anyhow"
|
||||
version = "1.0.75"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "a4668cab20f66d8d020e1fbc0ebe47217433c1b6c8f2040faf858554e394ace6"
|
||||
|
||||
[[package]]
|
||||
name = "lithium-loader"
|
||||
version = "0.1.0"
|
||||
dependencies = [
|
||||
"anyhow",
|
||||
"lithium-utils",
|
||||
]
|
||||
|
||||
|
|
|
@ -9,3 +9,5 @@ authors = ["antifallobst"]
|
|||
|
||||
[dependencies]
|
||||
lithium-utils = { path = "../lithium-utils" }
|
||||
|
||||
anyhow = "1.0.75"
|
|
@ -1,3 +1,4 @@
|
|||
use anyhow::Result;
|
||||
use lithium_utils::{Vector2, Vector3};
|
||||
|
||||
pub struct Vertex {
|
||||
|
@ -53,4 +54,12 @@ impl Model {
|
|||
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)
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,6 +1,26 @@
|
|||
use std::ops::{Add, Sub};
|
||||
|
||||
pub struct Vector2 {
|
||||
x: f32,
|
||||
y: f32,
|
||||
pub x: 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 {
|
||||
|
@ -13,21 +33,25 @@ impl Default for Vector3 {
|
|||
}
|
||||
}
|
||||
|
||||
impl Vector2 {
|
||||
pub fn new(x: f32, y: f32) -> Self {
|
||||
Self { x, y }
|
||||
impl Add for Vector3 {
|
||||
type Output = Self;
|
||||
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 {
|
||||
x: f32,
|
||||
y: f32,
|
||||
z: f32,
|
||||
impl Sub for Vector3 {
|
||||
type Output = Vector3;
|
||||
fn sub(self, rhs: Self) -> Self::Output {
|
||||
Self::Output {
|
||||
x: self.x - rhs.x,
|
||||
y: self.y - rhs.y,
|
||||
z: self.z - rhs.z,
|
||||
}
|
||||
|
||||
impl Default for Vector2 {
|
||||
fn default() -> Self {
|
||||
Self { x: 0_f32, y: 0_f32 }
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue