In my last tutorial, I gave a quick explanation for Blender >> Panda3D conversion using the X plugin. Having said that, this didn’t make me fully confident that I’d be able to use Blender animations with Panda3D.
The Chicken plugin is what’s commonly used to export from Blender to Panda3D, so I decided to create a very simple animation and see if I could export it to Panda3D using Chicken.
First, overview of how it works:
- You create several animations and export them by selecting frame ranges – so for example 0 to 50 could be your first animation, 60 to 90 another animation, and so forth.
- In Panda3D, it’s recommended to use separate files for models and animations. Chicken let’s you do that.
- You instantiate the Actor class, loading your models and animations.
- You invoke your actor to play animations.
Chicken also allows exporting static models (ie, no animation)
This tutorial doesn’t cover using Blender. If you’re not familiar with it, it may save you quite a bit of time to get somebody showing you around. Otherwise, stay posted as I’ve been fumbling around and will publish a few links very soon.
Also, this tutorial assumes that you’re using the ‘walking panda‘ tutorial as a starting point.
Try to follow the steps in this tutorial very carefully. All these steps are a little sensitive and it feels nicer to get something to work first – rather than fiddling for hours, which is practically what happened to me (see caveats below).
Setup
1. Download Chicken
2. Copy archive content to .blender/scripts/ or similar (check the Chicken installation info)
3. Ensure you have Python installed. Your version of Python needs to match whatever Blender says on startup. If versions don’t match you can only use built-in plugins with Blender.
4. Ensure you have Panda3D installed. Chicken requires Panda3D
Create and export your animation using Blender/Chicken
1. Create an object
2. Create an armature
3. Parent your object under your armature. create vertex groups using the envelope when prompted.
4. Remove the object from it’s parent (I just do the parenting first to create vertex groups in the only way I figured so far).
5. Add the armature as a modifier to your object.
6. Keyframe your armature. A couple of frames is enough for a test.
7. Select your object (as far as I know, you don’t need to select the armature).
8. Select export using Chicken. The first time there’s a configuration screen but no need to touch anything as I remember.
9. Add an animation (if not done automatically) using the Chicken GUI
10. Export (deselect ‘single file’). You could enable [pview] to preview your animation (in pview, use the L key to get your materials and textures to show)
There’s more you can do with Chicken, but the hardest part is getting your first animation exporting correctly.
Add your animation to your program
After exporting, you should have two files, one for your model and one for your animation.
The easiest way to test whether everything’s OK is to replace the default animation (just change the paths – you may also need to rescale the model) from the ‘walking panda’.
I tried to get that working by including Actor code into a world definition (e.g, hacking into Solar-System step 2) and it didn’t work (model is displayed, not the animation) – at least not until I moved my actor.loop(ANIM) statement out of the def statement. Why this doesn’t work the other way I have no idea so far.
Caveats
- Why are my objects all white? For materials and textures to show, you need to add some lighting to your scene. Seems obvious? Maybe, but when exporting to Panda3D via the X plugin for blender, materials show, whether lighting has been added or not.
- I had to uninstall an old version of Blender to get this to work. When I was asked whether to keep my .scripts folder, I said yes. But then, starting blender, I had no plugins working. I started over again, clearing the .scripts folder (for the record, I also asked the installer to keep my scripts under the blender folder in program files. Not sure if there’s a connection or not).
- Chicken doesn’t support using an armature’s envelope, only vertex groups. By default, envelope is typically enabled.
- Chicken doesn’t take into account modifiers other than envelope. Apply your modifiers before exporting.
- As explained in the last section, I run into a problem when including the loop() call into a def statement. I’ll try to clarify this later.
Here comes your .egg
I’m not really fond of this way of doing things. Never mind the lack of organisation (frame ranges! But at least it appears that we can save export configurations), it’s not very clear how 3D model updates could get into a build process automatically – Chicken exports from Blender, so we’d have to start Blender first, then somehow get Chicken to configure and run as well. However, it doesn’t seem that there is an alternative, and for trying out things on a small scale, it’s ‘kind of OK’.
That’s it for now. If you can’t get this to work, don’t hesitate to ask so I can improve this tutorial – I’ll probably link a couple of sample files and add some screenshots later on, along with references to useful Blender resources.
1 Response to “Chicken Comes First: Exporting Animations from Blender to Panda3D”