Added primitives
This commit is contained in:
64
Cargo.lock
generated
64
Cargo.lock
generated
@@ -93,6 +93,12 @@ dependencies = [
|
||||
"libc",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "anyhow"
|
||||
version = "1.0.75"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "a4668cab20f66d8d020e1fbc0ebe47217433c1b6c8f2040faf858554e394ace6"
|
||||
|
||||
[[package]]
|
||||
name = "approx"
|
||||
version = "0.5.1"
|
||||
@@ -222,6 +228,12 @@ dependencies = [
|
||||
"syn 2.0.39",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "byteorder"
|
||||
version = "1.5.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "1fd0f2584146f6f2ef48085050886acf353beff7305ebd1ae69500e27c67f64b"
|
||||
|
||||
[[package]]
|
||||
name = "calloop"
|
||||
version = "0.10.6"
|
||||
@@ -268,6 +280,12 @@ dependencies = [
|
||||
"unicode-width",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "color_quant"
|
||||
version = "1.1.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "3d7b894f5411737b7867f4827955924d7c254fc9f4d91a6aad6b097804b1018b"
|
||||
|
||||
[[package]]
|
||||
name = "com-rs"
|
||||
version = "0.2.1"
|
||||
@@ -616,6 +634,21 @@ version = "2.1.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "9a3a5bfb195931eeb336b2a7b4d761daec841b97f947d34394601737a7bba5e4"
|
||||
|
||||
[[package]]
|
||||
name = "image"
|
||||
version = "0.24.7"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "6f3dfdbdd72063086ff443e297b61695500514b1e41095b6fb9a5ab48a70a711"
|
||||
dependencies = [
|
||||
"bytemuck",
|
||||
"byteorder",
|
||||
"color_quant",
|
||||
"jpeg-decoder",
|
||||
"num-rational",
|
||||
"num-traits",
|
||||
"png",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "indexmap"
|
||||
version = "2.1.0"
|
||||
@@ -664,6 +697,12 @@ dependencies = [
|
||||
"libc",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "jpeg-decoder"
|
||||
version = "0.3.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "bc0000e42512c92e31c2252315bda326620a4e034105e900c98ec492fa077b3e"
|
||||
|
||||
[[package]]
|
||||
name = "js-sys"
|
||||
version = "0.3.65"
|
||||
@@ -869,6 +908,7 @@ checksum = "307ed9b18cc2423f29e83f84fd23a8e73628727990181f18641a8b5dc2ab1caa"
|
||||
dependencies = [
|
||||
"approx",
|
||||
"matrixmultiply",
|
||||
"nalgebra-macros",
|
||||
"num-complex",
|
||||
"num-rational",
|
||||
"num-traits",
|
||||
@@ -877,15 +917,14 @@ dependencies = [
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "nalgebra-glm"
|
||||
version = "0.18.0"
|
||||
name = "nalgebra-macros"
|
||||
version = "0.2.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "e68879ff227a94627e63bbd518b4f82b8f0cc56bb01a498251507de6d1c412d6"
|
||||
checksum = "91761aed67d03ad966ef783ae962ef9bbaca728d2dd7ceb7939ec110fffad998"
|
||||
dependencies = [
|
||||
"approx",
|
||||
"nalgebra",
|
||||
"num-traits",
|
||||
"simba",
|
||||
"proc-macro2",
|
||||
"quote",
|
||||
"syn 1.0.109",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
@@ -1291,16 +1330,25 @@ version = "1.0.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "216080ab382b992234dda86873c18d4c48358f5cfcb70fd693d7f6f2131b628b"
|
||||
|
||||
[[package]]
|
||||
name = "roots"
|
||||
version = "0.0.8"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "082f11ffa03bbef6c2c6ea6bea1acafaade2fd9050ae0234ab44a2153742b058"
|
||||
|
||||
[[package]]
|
||||
name = "rust-opengl"
|
||||
version = "0.1.0"
|
||||
dependencies = [
|
||||
"anyhow",
|
||||
"bytemuck",
|
||||
"cfg-if",
|
||||
"env_logger",
|
||||
"image",
|
||||
"log",
|
||||
"nalgebra-glm",
|
||||
"nalgebra",
|
||||
"pollster",
|
||||
"roots",
|
||||
"wgpu",
|
||||
"winit",
|
||||
]
|
||||
|
||||
@@ -4,6 +4,10 @@ version = "0.1.0"
|
||||
edition = "2021"
|
||||
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
|
||||
|
||||
[dependencies.image]
|
||||
version = "0.24"
|
||||
default-features = false
|
||||
features = ["png", "jpeg"]
|
||||
|
||||
[dependencies]
|
||||
cfg-if = "1"
|
||||
@@ -13,4 +17,6 @@ log = "0.4"
|
||||
wgpu = "0.18"
|
||||
pollster = "0.3"
|
||||
bytemuck = { version = "1.12", features = [ "derive" ] }
|
||||
nalgebra-glm = "0.18.0"
|
||||
anyhow = "1.0"
|
||||
nalgebra = "0.32.3"
|
||||
roots = "0.0.8"
|
||||
|
||||
12
src/main.rs
12
src/main.rs
@@ -2,10 +2,18 @@
|
||||
#![allow(unused_imports)]
|
||||
#![allow(unused_variables)]
|
||||
//Use linear algebra module
|
||||
|
||||
pub mod state;
|
||||
use state::run;
|
||||
|
||||
//Cameras
|
||||
mod camera;
|
||||
mod primitive;
|
||||
mod ray;
|
||||
mod state;
|
||||
mod texture;
|
||||
mod vertex;
|
||||
|
||||
const EPSILON: f32 = 1e-7;
|
||||
|
||||
fn main() {
|
||||
pollster::block_on(run());
|
||||
}
|
||||
|
||||
12
src/ray.rs
12
src/ray.rs
@@ -1,15 +1,17 @@
|
||||
use nalgebra::Vector4;
|
||||
use crate::EPSILON;
|
||||
|
||||
use nalgebra::{Matrix4, Point3, Vector3};
|
||||
|
||||
pub struct Ray {
|
||||
a: Vector4<f32>,
|
||||
b: Vector4<f32>,
|
||||
pub a: Point3<f32>,
|
||||
pub b: Vector3<f32>,
|
||||
}
|
||||
|
||||
impl Ray {
|
||||
fn new(_a: Vector4<f32>, _b: Vector4<f32>) -> Ray {
|
||||
pub fn new(_a: Point3<f32>, _b: Vector3<f32>) -> Ray {
|
||||
Ray { a: _a, b: _b }
|
||||
}
|
||||
fn at_t(self, t: f32) -> Vector4<f32> {
|
||||
pub fn at_t(self, t: f32) -> Point3<f32> {
|
||||
self.a + self.b * t
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user