Comments (5)
In order to add a component you need to tell the exporter what components are available in your game.
The editor looks for files in a 'component_defintions' folder in the same directory as your blend file. Eg:
You can see some examples for these files in the core_definitions
and rapier_definitions
folders, or look at the ones below:
Simple "tag" struct
{
"name": "GncComputer",
"description": "Coordinates RCS thrusters and main engines to produce a desired motion",
"id": "space_ship_gnc_computer",
"struct": "game::ship_parts::gnc_computer::GncComputer",
"fields": []
}
Simple parameter:
{
"name": "Engine",
"description": "Used to apply thrust to an object",
"id": "space_ship_engine",
"struct": "game::ship_parts::engine::Engine",
"fields": [
{
"field": "max_thrust_newtons",
"type": "f64",
"default": 10.0,
"description": "The max amount of force the engine can apply, measured in Newtons"
}
]
}
Actually, I remember this didn't work on windows a couple months back. One of my friends fixed it, let me push the changes.
from blender_bevy_toolkit.
So in regards to this image, so if I had all of these files, then suddenly if I go to "add component" in Blender, then I will see all the components such as clock.json
, com_node.json
etc?
So how does the json
files work, what would I put inside the json
files? Or does it get auto generated?
Actually, I remember this didn't work on windows a couple months back. One of my friends fixed it, let me push the changes.
So when you push the changes, do I have to reinstall the Blender extension?
from blender_bevy_toolkit.
@Joe23232 I've just pushed the changes. Yes you will have to re-install the addon.
What you put inside the JSON files depends on what components you have in your game.
Eg from the example above:
{
"name": "Engine",
"description": "Used to apply thrust to an object",
"id": "space_ship_engine",
"struct": "game::ship_parts::engine::Engine",
"fields": [
{
"field": "max_thrust_newtons",
"type": "f64",
"default": 10.0,
"description": "The max amount of force the engine can apply, measured in Newtons"
}
]
}
- "name" => What appears in blender
- "description" => Text that appears when you over over it in blender
- "id" => Should be unique for this component. (Used to store data internally to the blend file between saves)
- "struct" => This is a path to the struct that represents your object in bevy. Finding this can be a bit hard as it doesn't follow through
pub use
statements, it has to be the path to the module where the struct is actually defined. - "fields" => These are what properties the component has. For example, in rust, the engine looks like:
/// An engine applies thrust to the spacecraft
use bevy::prelude::*;
#[derive(Reflect, Default)]
#[reflect(Component)]
pub struct Engine {
/// The amount of force the engine can apply, measured in Newtons
pub max_thrust_newtons: f64,
#[reflect(ignore)]
pub current_thrust_newtons: f64,
}
See also: https://crates.io/crates/bevy_reflect
Each field has the following parameters:
- "field" => the name. Needs to match with the rust struct field
- "type" => what type it is. Currently supported are "string", "bool", "f64", "f32", "int", "vec3", "vec2" and "u8enum"
- "default" => what value to use when the user hasn't set one yet. Note that for type "u8enum" this is instead an array of options for the user to pick from.
- "description" => help text for the user.
Be aware that the bevy rapier API has changed since I wrote this addon, so physics components probably won't work. Heck, it may not even compile into bevy. I haven't tried.
from blender_bevy_toolkit.
@sdfgeoff Hey man.
So I uninstalled the all addon and I installed the new addon.
What you put inside the JSON files depends on what components you have in your game.
Eg from the example above:
So I added this exact same script:
{
"name": "Engine",
"description": "Used to apply thrust to an object",
"id": "space_ship_engine",
"struct": "game::ship_parts::engine::Engine",
"fields": [
{
"field": "max_thrust_newtons",
"type": "f64",
"default": 10.0,
"description": "The max amount of force the engine can apply, measured in Newtons"
}
]
}
into a file called windmill.json
inside the folder component_definitions
. In the outside directory of component_definitions
I have a file called Demo.blend
. And I still can't see any components to add.
not too sure why this is happening?
from blender_bevy_toolkit.
Starting a new thread at #11 @sdfgeoff
from blender_bevy_toolkit.
Related Issues (20)
- Exports appear sideways HOT 2
- Adding enum component types HOT 3
- 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.