Skip to content

Convert 3D characters/animations to 2D sprite sheets

License

Notifications You must be signed in to change notification settings

alexferl/3d-to-2d

Repository files navigation

3d-to-2d

A Python script to convert Mixamo (and others) 3D characters/animations to 2D sprite sheets using Blender (tested with 3.6.x) and Pillow. It contains a basic .blend file with a camera (name: Camera) and a light (name: Light).

NOTE: This is more an example that should be customized for one's needs versus a ready-to-use tool that just works for many different use cases. It works for my needs, but may not work for yours.

Using

git clone https://github.com/alexferl/3d-to-2d.git
cd 3d-to-2d
make dev
python convert.py --model-file-path=/path/to/model.fbx --animation-file-path=/path/to/anim.fbx

It's possible the default armature and action names won't work for you or if you want to use the script for non-Mixamo models/animations. You can modify them with:

python convert.py \
    --model-file-path=/path/to/model.fbx \
    --model-armature-name=SomeArmature \
    --animation-file-path=/path/to/anim.fbx \
    --animation-armature-name=AnotherArmature \
    --animation-action-name=SomeAction

You can see what objects are present in the scene with:

python convert.py \
    --model-file-path=/path/to/model.fbx \
    --animation-file-path=/path/to/anim.fbx \
    --print-objects

Or actions:

python convert.py \
    --model-file-path=/path/to/model.fbx \
    --animation-file-path=/path/to/anim.fbx \
    --print-actions

Using with animation(s) included with model

python convert.py \
    --model-file-path=/path/to/model.fbx \
    --model-armature-name=Rig \
    --model-action-name=Idle

Excluding meshes

python convert.py \
    --model-excluded-meshes=1H_Axe,2H_Axe

Including meshes

python convert.py \
    --model-included-meshes=1H_Axe,2H_Axe

See which other settings are available with:

python convert.py --help