added cylinder invisible with character from blender

This commit is contained in:
Franklin Blanco 2023-11-16 13:24:54 -08:00
parent ca0987bbe3
commit d34b52e33f
9 changed files with 88 additions and 9 deletions

Binary file not shown.

View File

@ -0,0 +1 @@
pub mod visbility;

View File

@ -0,0 +1,78 @@
/*use bevy::{prelude::*, render::view::Visibility as BevyVisibility};
use bevy_rapier3d::prelude::*;
#[derive(Component, Reflect, Default, Debug)]
#[reflect(Component)]
pub enum Visibility {
Visible,
Hidden,
#[default]
Inherited
}
// replaces all physics stand-ins with the actual rapier types
pub fn bevy_replace_proxies(
mut proxy_colliders: Query<
(Entity, &BevyVisibility, &Name, &mut Visibility),
(Without<RapierCollider>, Added<Collider>),
>,
mut commands: Commands,
) {
for proxy_colider in proxy_colliders.iter_mut() {
let (entity, collider_proxy, name, mut visibility) = proxy_colider;
// we hide the collider meshes: perhaps they should be removed altogether once processed ?
if name.ends_with("_collider") || name.ends_with("_sensor") {
*visibility = Visibility::Hidden;
}
let mut rapier_collider: RapierCollider;
match collider_proxy {
Collider::Ball(radius) => {
println!("proxy: ball");
rapier_collider = RapierCollider::ball(*radius);
commands.entity(entity)
.insert(rapier_collider)
.insert(ActiveEvents::COLLISION_EVENTS) // FIXME: this is just for demo purposes !!!
;
}
Collider::Cuboid(size) => {
println!("proxy: cuboid");
rapier_collider = RapierCollider::cuboid(size.x, size.y, size.z);
commands.entity(entity)
.insert(rapier_collider)
.insert(ActiveEvents::COLLISION_EVENTS) // FIXME: this is just for demo purposes !!!
;
}
Collider::Capsule(a, b, radius) => {
println!("proxy: capsule");
rapier_collider = RapierCollider::capsule(*a, *b, *radius);
commands.entity(entity)
.insert(rapier_collider)
.insert(ActiveEvents::COLLISION_EVENTS) // FIXME: this is just for demo purposes !!!
;
}
Collider::Mesh => {
println!("proxy: mesh");
for (_, collider_mesh) in
Mesh::search_in_children(entity, &children, &meshes, &mesh_handles)
{
rapier_collider = RapierCollider::from_bevy_mesh(
collider_mesh,
&ComputedColliderShape::TriMesh,
)
.unwrap();
commands
.entity(entity)
.insert(rapier_collider);
// FIXME: this is just for demo purposes !!!;
//.insert(ActiveEvents::COLLISION_EVENTS);
// .insert(ActiveEvents::COLLISION_EVENTS)
// break;
}
}
}
}
}*/

View File

@ -1,3 +1,4 @@
pub mod character; pub mod character;
pub mod plugin; pub mod plugin;
pub mod physics; pub mod physics;
pub mod bevy;

View File

@ -1,7 +1,7 @@
use bevy::prelude::*; use bevy::prelude::*;
// use bevy::render::primitives::Aabb; // use bevy::render::primitives::Aabb;
use bevy_rapier3d::geometry::{Collider as RapierCollider, Sensor}; use bevy_rapier3d::geometry::Collider as RapierCollider;
use bevy_rapier3d::prelude::{ActiveCollisionTypes, ActiveEvents, ComputedColliderShape}; use bevy_rapier3d::prelude::{ActiveEvents, ComputedColliderShape};
use super::utils::*; use super::utils::*;

View File

@ -10,6 +10,9 @@ pub struct ProxyComponentsPlugin;
impl Plugin for ProxyComponentsPlugin { impl Plugin for ProxyComponentsPlugin {
fn build(&self, app: &mut bevy::prelude::App) { fn build(&self, app: &mut bevy::prelude::App) {
// Bevy
// Character // Character
app.register_type::<PlayerHitBox>(); app.register_type::<PlayerHitBox>();
app.register_type::<PlayerCharacter>(); app.register_type::<PlayerCharacter>();

View File

@ -16,7 +16,7 @@ use crate::{
player_values_state::PlayerValuesState, player_values_state::PlayerValuesState,
}, },
}, },
setup::{equipment::EquipmentChangeEvent, load_state::GameLoadState, assets::{GltfAsset, GltfAssets}}, setup::{equipment::EquipmentChangeEvent, load_state::GameLoadState, assets::GltfAssets},
}; };
use super::spawn_point::SpawnPoint; use super::spawn_point::SpawnPoint;
@ -49,7 +49,7 @@ pub fn player_spawner(
} }
for (player_spawn_point_entity, player_spawn_point) in player_sp_query.iter() { for (player_spawn_point_entity, player_spawn_point) in player_sp_query.iter() {
let mut plyer_transform = Transform::from_xyz(25.0, 0.0, 25.0).with_scale(Vec3 { x: 3.0, y: 3.0, z: 3.0 }); let plyer_transform = Transform::from_xyz(25.0, 0.0, 25.0).with_scale(Vec3 { x: 3.0, y: 3.0, z: 3.0 });
commands.spawn( commands.spawn(
( (
SceneBundle { SceneBundle {

View File

@ -1,7 +1,5 @@
use bevy::prelude::*; use bevy::prelude::*;
use crate::comps::core::markers::proxy::physics::rapier::physics_replace_proxies;
use super::{ use super::{
item::{item_spawner, ItemSpawnPointPlugin}, item::{item_spawner, ItemSpawnPointPlugin},
player::player_spawner, player::player_spawner,

View File

@ -5,8 +5,6 @@ use crate::{
scenes::scene1::skybox::{Cubemap, CUBEMAPS}, scenes::scene1::skybox::{Cubemap, CUBEMAPS},
}; };
use super::load_state::GameLoadState;
#[derive(PartialEq, Eq, PartialOrd, Ord, Reflect)] #[derive(PartialEq, Eq, PartialOrd, Ord, Reflect)]
pub enum GltfAssetType { pub enum GltfAssetType {
Firearm(Firearm), Firearm(Firearm),