Skip to content
This repository has been archived by the owner on Nov 21, 2022. It is now read-only.

cyberbotics/blender-webots-exporter

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

77 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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.