Comments (3)
Currently all components must be structs - which I think is generically true in bevy.
While the interface can display an enum, the backing storage is still an integer. For example for bevy-rapier (whatever old version is in this repo), I had the struct:
The struct that the blender plugin creates
pub struct RigidBodyDescription {
/// Because we can't export enums yet, this is encoded as a u8
/// 0 => dynamic
/// 1 => static
/// 2 => kinematic
pub body_status: u8,
<< snip >>
With definition:
{
"name": "RigidBody",
"description": "Makes this object obey physics",
"id": "rapier_rigid_body",
"struct": "blender_bevy_toolkit::rapier_physics::RigidBodyDescription",
"fields": [
{
"field": "body_status",
"type": "u8enum",
"default": ["dynamic", "static", "kinematic"],
"description": "Dynamic bodies respond to forces. Static bodies do not move. Kinematic bodies must be moved manually but internally track velocity so they push other dynamic bodies properly"
},
<< snip >>
And then at runtime:
/// Converts a RigidBodyDescription into a rapier::dynamics::RigidBodyBuilder. This allows
/// RigidBodyBuilders to be created from a file using bevies Reflection system and scene format
pub fn body_description_to_builder(
mut commands: Commands,
body_desc_query: Query<(&RigidBodyDescription, Entity, &Transform)>,
) {
for (body_desc, entity, transform) in body_desc_query.iter() {
commands.entity(entity).remove::<RigidBodyDescription>();
<< snip >>
let body_status = match body_desc.body_status {
0 => BodyStatus::Dynamic,
1 => BodyStatus::Static,
2 => BodyStatus::Kinematic,
_ => panic!("Unknown body status"),
};
<< snip >>
let rigid_body_builder = RigidBodyBuilder::new(body_status)
.position(position)
.linear_damping(body_desc.damping_linear)
.angular_damping(body_desc.damping_angular)
.ccd_enabled(body_desc.ccd_enable)
.can_sleep(body_desc.sleep_allow)
.additional_mass(body_desc.mass_extra)
.additional_principal_angular_inertia(inertia_vec);
commands.entity(entity).insert(rigid_body_builder);
It was done this way because at the time, Bevy didn't support Reflect
on enums. That's probably changed now.
When you do an integration with the new bevy-rapier, I'm super interested in including it into this repo, so please ping back when you've got something working.
from blender_bevy_toolkit.
thank you for the detailed response, it's much appreciated! Closing as the original issue is solved but if I happen to run into any more info about Reflect
on enums I'll ping back - and likewise if I have any success with new rapier.
from blender_bevy_toolkit.
Got some progress done which I published to my fork, unsure if it is of any use. I think the components work but I got the positions wrong as it glitches for non-zero transforms. Looking into that tomorrow (seems to work OK now) but in the meantime it appears to properly add colliders at least
from blender_bevy_toolkit.
Related Issues (20)
- Exports appear sideways HOT 2
- bevy 0.6 HOT 1
- Python components should inherit from a base class
- Export test run on windows
- Rapier as optional dependency
- Directional Lights
- Simple PBR materials (no textures)
- Materials with image textures
- Auto run pytest and cargo test
- Add support for configuring shadow casting
- Allow disabling export of blender-internal components (eg disable mesh or material export)
- BLENDER setting in Makefile for MacOS HOT 1
- selecting a scene (2nd time the same or different one) after 'make run' doesn't work properly HOT 2
- Not everything is displayed from the start HOT 1
- feature request: example of using cargo-watch to only convert newly saved .blend files HOT 1
- Bevy new version is out HOT 5
- blender_bevy_toolkit dead? HOT 3
- Consider Using GLTF as the interchange format rather than bevy's scene format. HOT 4
- Saved entities, but with no components HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from blender_bevy_toolkit.