-
-
Notifications
You must be signed in to change notification settings - Fork 141
add an example for intersection plane #249
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 4 commits
8b34ccb
ec13983
358e6b1
d06491b
4a7f833
8ac9df1
b7128e5
d88dd24
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
| @@ -0,0 +1,156 @@ | ||||||
| use macroquad::models::Vertex; | ||||||
| use macroquad::prelude::*; | ||||||
| use nalgebra::{Point3, UnitVector3, Vector3}; | ||||||
| use parry3d::math::Real; | ||||||
| use parry3d::query::IntersectResult; | ||||||
| use parry3d::shape::{Cuboid, TriMesh}; | ||||||
|
|
||||||
| #[macroquad::main("parry3d::query::PlaneIntersection")] | ||||||
| async fn main() { | ||||||
| let trimesh = Cuboid::new(Vector3::new(1.0, 1.0, 1.0)).to_trimesh(); | ||||||
|
|
||||||
| let camera_pos = Vec3::new(-1.5f32, 2.5f32, -3f32); | ||||||
|
|
||||||
| let mesh = mquad_mesh_from_points(&trimesh, camera_pos); | ||||||
| let trimesh = TriMesh::new(trimesh.0, trimesh.1); | ||||||
|
|
||||||
| for _ in 1.. { | ||||||
| clear_background(BLACK); | ||||||
|
|
||||||
| let elapsed_time = get_time(); | ||||||
|
|
||||||
| // Animated rotation for the intersection plane. | ||||||
| let bias = -1.2 * (elapsed_time as f32 / 3f32).sin(); | ||||||
| let rotation = Quat::from_axis_angle(Vec3::Z, (elapsed_time as f32 * 40f32).to_radians()); | ||||||
| let up_plane_vector = rotation * Vec3::Y; | ||||||
|
|
||||||
| // Get the intersection polyline. | ||||||
| let intersection_result = trimesh.intersection_with_local_plane( | ||||||
| &UnitVector3::new_normalize(Vector3::<Real>::new( | ||||||
|
||||||
| &UnitVector3::new_normalize(Vector3::<Real>::new( | |
| &UnitVector3::new_normalize(Vector3::new( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
all this is lengthy, but unfortunately there's not much way around it (see not-fl3/macroquad#321); it would be good to settle on a "common" library for all examples, but as it's the first 3d example this might be ok to keep it here, and we'll move it out with the next example, probably #250
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.