use bevy::prelude::*; use bevy_mod_bounding::{aabb, debug, obb, *}; fn main() { App::build() .insert_resource(Msaa { samples: 2 }) .add_plugins(DefaultPlugins) .add_plugin(BoundingVolumePlugin::::default()) .add_plugin(BoundingVolumePlugin::::default()) .add_plugin(BoundingVolumePlugin::::default()) .add_startup_system(setup.system()) .add_system(rotation_system.system()) .run(); } struct Rotator; fn setup( mut commands: Commands, mut meshes: ResMut>, mut materials: ResMut>, ) { let mut ortho_cam = OrthographicCameraBundle::new_3d(); ortho_cam.transform = Transform::from_matrix(Mat4::face_toward( Vec3::new(0.1, 0.1, 1.0), Vec3::ZERO, Vec3::Y, )); commands.spawn_bundle(ortho_cam); // AABB commands .spawn_bundle(PbrBundle { mesh: meshes.add(Mesh::from(shape::Cube::default())), material: materials.add(Color::rgb(1.0, 1.0, 1.0).into()), transform: Transform::from_translation(Vec3::new(-1.0, 0.0, 0.0)), ..Default::default() }) .insert(Bounded::::default()) .insert(debug::DebugBounds) .insert(Rotator); // OBB commands .spawn_bundle(PbrBundle { mesh: meshes.add(Mesh::from(shape::Cube::default())), material: materials.add(Color::rgb(1.0, 1.0, 1.0).into()), transform: Transform::from_translation(Vec3::new(0.0, 0.0, 0.0)), ..Default::default() }) .insert(Bounded::::default()) .insert(debug::DebugBounds) .insert(Rotator); // Sphere commands .spawn_bundle(PbrBundle { mesh: meshes.add(Mesh::from(shape::Cube::default())), material: materials.add(Color::rgb(1.0, 1.0, 1.0).into()), transform: Transform::from_translation(Vec3::new(1.0, 0.0, 0.0)), ..Default::default() }) .insert(Bounded::::default()) .insert(debug::DebugBounds) .insert(Rotator); // Light commands.spawn_bundle(LightBundle { transform: Transform::from_translation(Vec3::new(4.0, 8.0, 4.0)), ..Default::default() }); } /// Rotate the meshes to demonstrate how the bounding volumes update fn rotation_system(time: Res