GithubHelp home page GithubHelp logo

Comments (5)

sdfgeoff avatar sdfgeoff commented on June 3, 2024

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:
structure

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.

Joe23232 avatar Joe23232 commented on June 3, 2024

@sdfgeoff

image

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.

sdfgeoff avatar sdfgeoff commented on June 3, 2024

@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.

Joe23232 avatar Joe23232 commented on June 3, 2024

@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.

image

not too sure why this is happening?

from blender_bevy_toolkit.

Joe23232 avatar Joe23232 commented on June 3, 2024

Starting a new thread at #11 @sdfgeoff

from blender_bevy_toolkit.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.