Setting up the Blender export plugin

Most of the digital content creation tools for making 3D meshes are very advanced pieces of software. Not only do they come packed with thousands of features, they cost thousands of dollars. This raises the entry barrier for everyone, but impacts less-funded developers more than well-funded ones. Luckily, there's an alternative to paying for an expensive modelling and animation tool, which does not involve robbing a bank.

Initially started as a proprietary product, Blender was bought and open-sourced by a community of enthusiasts when its original developer went out of business. Blender features advanced modeling and animation capabilities and has been used for various professional-grade film and game projects.

Besides abilities that enable artists to build stunning 3D meshes, Blender has a Python API for developing custom plugins. Many of these plugins add data import and export features, which made Blender a premium tool for converting 3D mesh data from one format into another.

In this recipe we set up a plugin called Chicken Exporter that was written for exporting models from Blender.

Getting ready

If Blender is not already installed on your system, you will first need to download and install it. Blender can be downloaded and used for free, just go to www.blender.org/download/get-blender/ to get a copy of the program. Be sure to download a version prior to 2.5 because from this version on, Blender comes with a completely new version of its Python API that is not compatible with one found in previous versions. The download page should look similar to the following screenshot.

Getting ready

Download and run the installer. This recipe assumes you installed Blender in its default location. You will need to modify the file paths according to your settings if you made a different choice about the install location.

How to do it...

Configure Blender and Chicken Exporter with the following steps:

  1. Go to sourceforge.net/projects/chicken-export/files/. Click the Download Now! button to retrieve the latest version of Chicken Exporter.
    How to do it...
  2. Unpack the downloaded archive. Copy the bpydata and bpymodules directories, as well as the file chicken_exportR91.py to C:Users[YOUR USERNAME]AppDataRoamingBlender FoundationBlender.blenderscripts. Replace [YOUR USERNAME] with your login name.
  3. Create a new environment variable called PYTHONPATH and set its value to C:Panda3D-1.7.0pythonpython.exe;C:Panda3D-1.7.0pythonDLLs; C:Panda3D-1.7.0pythonLib; C:Panda3D-1.7.0pythonLiblib-tk
  4. Start Blender. Click File | Export | Chicken R91 (.egg).
    How to do it...
  5. In the following screen, choose either Auto or Manual. When choosing Manual, you need to enter the installation path of the Panda3D SDK.
    How to do it...
  6. Click Check Config and then Launch Chicken.

How it works...

While installing, the plugin involves copying the right files to the right place, we need to take a closer look at the PYTHONPATH environment variable and how Blender works. Blender internally uses a minimal version of Python, which loads a set of scripts that define the user interface and its behavior. This embedded version of Python is also used for running any user-provided plugin scripts.

The only problem about Blender's embedded Python version is that it is a stripped-down version of the Python runtime. While this allows Blender to keep its initial download size small, this is a problem for us because some plugins like Chicken require functionality found in the standard libraries of the full Python distribution. To overcome this limitation, Blender automatically looks to see if the PYTHONPATH environment variable contains paths to a complete distribution of Python, which is then used instead of the built-in, slimmed-down version.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset