Compare commits

..

No commits in common. "50eabecfe95efeced6645da8d24ebe32fd9c1af0" and "c4a794c4f25ada8c51db41aae1d7999525d3b637" have entirely different histories.

3 changed files with 5 additions and 90 deletions

View File

@ -1,2 +1,2 @@
pub mod geometry;
mod geometry;
pub mod math;

View File

@ -1,83 +1,8 @@
use hello::geometry::{self, Geometry, Sphere};
use hello::math::{Mat4x4, Point3};
use std::rc::Rc;
#[derive(Clone)]
struct RGB {
red: f64,
green: f64,
blue: f64,
}
#[derive(Clone)]
struct Texture {
width: usize,
height: usize,
pixel: Vec<RGB>,
}
impl Texture {
fn load_texture() -> Texture {
let width = 640;
let height = 480;
let mut pixel = Vec::new();
for x in 0..width {
for y in 0..height {
pixel.push(RGB {
red: 1.0,
green: 1.0,
blue: 1.0,
});
}
}
Texture {
width,
height,
pixel,
}
}
}
struct RenderableGeometry {
transform: Mat4x4,
geometry: Geometry,
texture: Rc<Texture>,
}
impl RenderableGeometry {
fn new(transform: Mat4x4, geometry: Geometry, texture: Rc<Texture>) -> RenderableGeometry {
RenderableGeometry {
transform,
geometry,
texture,
}
}
}
use hello::math::Point3;
fn main() {
let tex = Rc::new(Texture::load_texture());
let p1 = Point3::new(0.0, 0.0, 0.0);
let p2 = Point3::new(0.0, 0.0, 0.0);
let geo1 = RenderableGeometry::new(
Mat4x4::ident(),
Geometry::Sphere(Sphere::new(Point3::new(0.0, 0.0, 0.0), 1.0)),
tex.clone(),
);
let geo2 = RenderableGeometry::new(
Mat4x4::ident(),
Geometry::Sphere(Sphere::new(Point3::new(-2.0, 0.0, 0.0), 1.0)),
tex.clone(),
);
let geo3 = RenderableGeometry::new(
Mat4x4::ident(),
Geometry::Sphere(Sphere::new(Point3::new(2.0, 0.0, 0.0), 1.0)),
tex.clone(),
);
println!("Reference counter = {}", Rc::strong_count(&tex));
let v = p1 - p2;
}

View File

@ -90,16 +90,6 @@ impl Sub for Point3 {
}
}
pub struct Mat4x4 {
v: f64,
}
impl Mat4x4 {
pub fn ident() -> Mat4x4 {
Mat4x4 { v: 0.0 }
}
}
#[cfg(test)]
mod tests {
use super::*;