Coder Social home page Coder Social logo

blender-webots-exporter's Introduction

Blender to Webots exporter add-on

Blender add-on to export your Blender project to Webots.

Demo

Features

  • Export your Blender project to Webots
  • Define conversion rules in a JSON file
  • Support collision export (either generated from the AABB boxes or manually defined)
  • Support joint export (linear or rotational with custom parameters including axis, limits, etc.)
  • Support the export of any Webots Solid (or derived) node with custom fields (Camera.width, name, etc.).
  • Basic support of materials (colors and the base color map) to Webots PBR appearance.

Requirements

Installation and Update

Let say $BLENDER_ADD_ON_PATH is the Blender add-on user directory:

  • on macOS: export BLENDER_ADD_ON_PATH=$HOME/Library/Application\ Support/Blender/2.79/scripts/addons
  • on Linux: export BLENDER_ADD_ON_PATH=$HOME/.config/blender/2.79/scripts/addons
  • on Windows:
    • go to Blender / Preferences / File / Scripts and paste C:\Users\username\AppData\Roaming\Blender Foundation\Blender\2.79\scripts. (replace username)
    • for the following steps, use the pasted address as $BLENDER_ADD_ON_PATH.

Install the add-on by applying the following commands:

mkdir -p $BLENDER_ADD_ON_PATH/export_webots
cp __init__.py "$BLENDER_ADD_ON_PATH/export_webots"
cp export_webots.py "$BLENDER_ADD_ON_PATH/export_webots"

Enable the "Webots exporter" add-on in Blender / Preferences / Add-ons / Community.

JSON Conversion File Specifications

The JSON conversion file specifies how to convert the Blender nodes to Webots ones.

If not specified in the parameters, the JSON conversion file is searched in the same path as the .blend file.

It is basically a JSON Object (i.e. key-value associative array) containing a conversion rule for each node. During the exportation, when a key of this JSON Object matches with the slugified Blender node name, then its value (a JSON Object) is used for the conversion.

The conversion JSON Object could contain the following conversion rules:

Key Flags Value
target node required JSON String defining to which Webots node the Blender node should be converted. For example, it could be Solid, Robot, Camera, HingeJoint, SliderJoint or a custom Webots appearance node (like BrushedAluminium).
fields optional JSON Object which can contain any Webots node fields. The conversion tool will add these fields as-is. It is convenient to add device specific fields, like Camera.width, Emitter.name, etc.

The following conversion rules are only available in the case of a Solid node (or derived):

Key Flags Value
physics optional JSON Object which can contain the Webots Physics node fields (like mass, density and centerOfMass). If this key is not defined, then no Physics node is generated (the Solid can be pinned to the static environment, or controlled using kinematics rules.)
boundingObject optional JSON Object which can contain either a JSON String called custom to define the content of the Webots Solid.boundingObject field fields. If custom is not defined, then the AABB box of the Blender object is used to create the boundingObject. If this key is not defined, then no collision object is generated.

The following conversion rules are only available in the case of a Joint node:

Key Flags Value
jointParameters optional JSON Object which can contain the Webots (Hinge)JointParameters node fields (like axis, spring/dampingConstant and suspension*).
motor optional JSON Object which can contain the Webots LinearMotor or RotationalMotor node fields (like name, maxTorque, maxPosition or maxVelocity)
positionSensor optional JSON Object which can contain the Webots PositionSensor node fields (like name)

Examples:

https://github.com/cyberbotics/blender-webots-exporter/tree/master/examples

References

This script has been inspired by the Blender X3D exporter of Campbell Barton, Bart, Bastien Montagne, Seva Alekseyev.

blender-webots-exporter's People

Contributors

davidmansolino avatar edusanketdk avatar fabienrohrer avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

blender-webots-exporter's Issues

Support for Blender >= 2.80

Blender unfortunately modified their plugin API in Blender >= 2.80.
This project should be updated accordingly.

cannot enable the "Webots exporter" add-on

When I enable the "Webots exporter" add-on in Blender / Preferences / Add-ons / Community, there is an ERROR!
ImportError: cannot import name 'orientation_helper_factory' from 'bpy_extras.io_utils' (C:\Program Files\Blender Foundation\Blender 2.82\2.82\scripts\modules\bpy_extras\io_utils.py);
It seems that blender has changed quite a few things since v2.80.

Empty appearance DEF names

I was trying to export the blender file below and it did not give me any problems then but when I tried opening it in Webots it gave me:
ERROR: 'C:/Users/***/Documents/Inventor/FRC Field 2019/FRC Field 2019.wbt':17:37: error: Expected node or PROTO name, found '{'.
ERROR: 'C:/Users/***/Documents/Inventor/FRC Field 2019/FRC Field 2019.wbt': Failed to load due to syntax error(s).

I am in Webots R2019b and in Windows 10

https://drive.google.com/open?id=1kuIG4Jh2BoMZ4Qza5nOWXdTzLzb_mli0

Wrong texture url in case of more than one texture

If more than one texture is defined, the export is wrong:

texture DEF IM_COLOR_MAP ImageTexture {
  url [ ""toilet/map/stargalaxy granite color.jpg" "stargalaxy granite color.jpg" "/home/david/Téléchargements/toilet/map/stargalaxy granite color.jpg"" ]
}

Is this still the suggested approach for Webots2022?

We're trying to import a complex model into Webots and we're looking for the best way to do this (model, UV's, etc.). Is this plugin still the suggested approach or is there a new way to do it? It looks like this is out of date.

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.