Skip to content

Blender exporter with animation #47

Closed

Description

@michaeleggers

Hi and happy new year!
I have written a blender exporter that writes out .gpmesh, .gpskel and .gpanim(s) These are the custom file formats in the book from chapter 12 on.
When loading the files in the engine (I used chapter 12) the gpmesh comes in fine, the tpose is correct but the other
animations are messed up. You can still see the animation matches somewhat the one created in blender but something is wrong there. I was not able to figure out where the mistake happens. To my best knowledge the skeleton and animation files contain the
local transforms of the bones using matrix_local in Blender's python API.

I included the script and the example Blend file (Blender 3.0.0) for testing in my fork: https://github.com/michaeleggers/code/tree/blender-exporter-update/Exporter/Blender

Maybe someone is interested in looking into it.

As I am relatively new to Blender, I used this tutorial to model, rig and animate and also used the texture provided by Imphenzia:
https://youtu.be/yjjLD3h3yRc

Activity

  1. michaeleggers commented on Jan 15, 2022

    @michaeleggers
    ContributorAuthor

    The exporter works now. The reason it did not work is that you manually have to calculate the bone's local transformation by hand. When doing the calculation the matrix-multiplication is done by operator @ and not *, which does a component-wise multiplication!!! Wasted some time on that as I was not familiar enough with mathutils which is the math lib used by Blender Python API. Also, the quaternions have to be inverted. I am not sure why, though. It was intuition after a lot of trial and error.
    To export:

    • make sure the armatures pivot is the same as the model's pivot it is attached to.
    • at the moment there have to be at least two keyframes for an animation if you decide to export it.
    • select the model in object mode and then go to file -> export -> gpmesh.

    Exported UV's are incorrect at the moment. About to fix that.

  2. chalonverse commented on Jan 16, 2022

    @chalonverse
    Contributor

    This is really cool! Well done.

  3. michaeleggers commented on Jan 16, 2022

    @michaeleggers
    ContributorAuthor

    Thank you! I am going to fix the UVs and then going to open a PR if that's okay.

  4. michaeleggers commented on Jan 23, 2022

    @michaeleggers
    ContributorAuthor

    Opened a PR: #48

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions