-
-
Notifications
You must be signed in to change notification settings - Fork 119
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1892 from hannobraun/examples
Add `all` model
- Loading branch information
Showing
11 changed files
with
104 additions
and
33 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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(()) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,7 @@ | ||
use fj::handle_model; | ||
use fj::{core::services::Services, handle_model}; | ||
|
||
fn main() -> fj::Result { | ||
let model = cuboid::model(3., 2., 1.); | ||
let model = cuboid::model(3., 2., 1., &mut Services::new()); | ||
handle_model(model)?; | ||
Ok(()) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,7 @@ | ||
use fj::handle_model; | ||
use fj::{core::services::Services, handle_model}; | ||
|
||
fn main() -> fj::Result { | ||
let model = spacer::model(1., 0.5, 1.); | ||
let model = spacer::model(1., 0.5, 1., &mut Services::new()); | ||
handle_model(model)?; | ||
Ok(()) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,7 @@ | ||
use fj::handle_model; | ||
use fj::{core::services::Services, handle_model}; | ||
|
||
fn main() -> fj::Result { | ||
let model = star::model(5, 1., 2., 1.); | ||
let model = star::model(5, 1., 2., 1., &mut Services::new()); | ||
handle_model(model)?; | ||
Ok(()) | ||
} |