CSG-Forge/editor/src/main.rs

41 lines
1.0 KiB
Rust

use csg::{
brush::{Brush, BrushPlane, MaterialId, TextureProjection},
glam::{self, Vec3},
plane::Plane,
};
fn generate_box_brush(position: Vec3, extent: Vec3) -> Brush {
let normals = vec![
glam::vec3(1.0, 0.0, 0.0),
glam::vec3(-1.0, 0.0, 0.0),
glam::vec3(0.0, 1.0, 0.0),
glam::vec3(0.0, -1.0, 0.0),
glam::vec3(0.0, 0.0, 1.0),
glam::vec3(0.0, 0.0, -1.0),
];
let mut brush_planes = vec![];
for normal in &normals {
let point = position + *normal * extent;
brush_planes.push(BrushPlane {
plane: Plane::from_point_normal(point, *normal),
material: MaterialId("Epic".to_string()),
tex_projection: TextureProjection::default(),
});
println!("Plane: {:?}", brush_planes.last().unwrap().plane);
}
Brush {
planes: brush_planes,
}
}
fn main() {
let brush = generate_box_brush(Vec3::new(1.0, 0.0, 0.0), Vec3::new(1.0, 2.0, 1.0));
let vs = brush.get_vertices();
println!("Vertices: {vs:?}");
}