Add all model

This commit is contained in:
Hanno Braun 2023-06-19 13:10:59 +02:00
parent 395e4ca139
commit 90976d37d8
5 changed files with 66 additions and 0 deletions

10
Cargo.lock generated
View File

@ -65,6 +65,16 @@ dependencies = [
"memchr",
]
[[package]]
name = "all"
version = "0.1.0"
dependencies = [
"cuboid",
"fj",
"spacer",
"star",
]
[[package]]
name = "android-activity"
version = "0.4.1"

View File

@ -9,6 +9,7 @@ members = [
"crates/fj-viewer",
"crates/fj-window",
"models/all",
"models/cuboid",
"models/spacer",
"models/star",

16
models/all/Cargo.toml Normal file
View File

@ -0,0 +1,16 @@
[package]
name = "all"
version = "0.1.0"
edition = "2021"
[dependencies.fj]
path = "../../crates/fj"
[dependencies.cuboid]
path = "../cuboid"
[dependencies.spacer]
path = "../spacer"
[dependencies.star]
path = "../star"

32
models/all/src/lib.rs Normal file
View File

@ -0,0 +1,32 @@
use fj::{
core::{
algorithms::transform::TransformObject,
objects::Solid,
operations::{Insert, Merge},
services::Services,
storage::Handle,
},
math::{Scalar, Vector},
};
pub fn model(services: &mut Services) -> Handle<Solid> {
// Just combine all the other models using offsets/rotations that won't
// result in neat vertex positions or axis-aligned edges/faces. This is
// useful for testing.
let offset = Vector::from([5., 5., 5.]);
let axis = Vector::from([1., 1., 1.]).normalize();
let angle_rad = Scalar::PI / 6.;
let cuboid = cuboid::model(1., 2., 3., services)
.translate(offset * 1., services)
.rotate(axis * angle_rad * 1., services);
let spacer = spacer::model(2., 1., 1., services)
.translate(offset * 2., services)
.rotate(axis * angle_rad * 2., services);
let star = star::model(5, 2., 1., 1., services)
.translate(offset * 3., services)
.rotate(axis * angle_rad * 3., services);
cuboid.merge(&spacer).merge(&star).insert(services)
}

7
models/all/src/main.rs Normal file
View File

@ -0,0 +1,7 @@
use fj::{core::services::Services, handle_model};
fn main() -> fj::Result {
let model = all::model(&mut Services::new());
handle_model(model)?;
Ok(())
}