nstokes2 / ozz-animation

Automatically exported from code.google.com/p/ozz-animation
zlib License
0 stars 0 forks source link

How to write a custom importer? #7

Closed GoogleCodeExporter closed 8 years ago

GoogleCodeExporter commented 8 years ago
I have a SQLite DB representing a skeletal animation, and each table 
(representing a keyframe) has the following schema:

Key_Frame_Time

Joint_Name    4x4 Matrix    Parent (first is NULL)

How would someone turn this into a raw skeleton, and each subsequent key-frame 
into a raw animation? I have looked a lot at the source code, but C++ is not my 
best language and I cannot find the proper functions to call.

I would be glad to share the format with the community once fully developed.

Thanks!
Colin

Original issue reported on code.google.com by colingil...@gmail.com on 16 Jan 2015 at 6:02

GoogleCodeExporter commented 8 years ago
Oops, I have failed to notice the howto link on the front page (unless it was 
added recently)!

Original comment by colingil...@gmail.com on 18 Jan 2015 at 9:05

GoogleCodeExporter commented 8 years ago
Hi,

This sounds really do-able and you're on the right track talking about 
RawSkeleton and RawAnimation objects.

To help with the understanding of how to build RawSkeleton and RawAnimation, I 
started writing HowTos that you'll find here 
http://code.google.com/p/ozz-animation/wiki/HowTos on the wiki. You'll find 
corresponding sources attached to this thread, while waiting for their official 
commit. Don't hesitate to give feeback about it so I can improve it. 

To be more specific to your case, you'll have to convert 4x4 matrices to 
seperate affine translation, rotation (quaternion) and scale values. These 
transformation will be used to fill RawSkeleton bind-pose and RawAnimation 
keyframes. If you don't have the required function to do the conversion, you 
can use ozz::math::Float4x4::ToAffine function. They are unfortunately not that 
easy to use because of their simd interface, I'll work on helper functions.

For the skeleton, once you'll have fetch all the data from the DB, you'll have 
to iterate your joint's hierarchy and fill RawSkeleton joints accordingly (as 
explained in the how-to). You can use the first keyframe of your animation as 
the skeleton bind-pose (in local-space!).

For the animation, you'll have to push keyframes to each track (in local-space 
also). The main difficulty is to order tracks in the same order as your 
ozz::animation::Skeleton joints. I recommend to name skeleton joints so that 
you can lookup their index (by name) once the ozz::animation::Skeleton is built.

To simplify your implementation you can also use ozz_animation_offline_tools 
library and inherit from SkeletonConverter and Animation Converter. It will 
handle keyframes optimization, and corner cases with file io. It can help if 
your implementation is also a command line tool. 

Hope it will help, thanks for posting,
Guillaume

Original comment by guillaum...@gmail.com on 18 Jan 2015 at 10:39

Attachments:

GoogleCodeExporter commented 8 years ago
How-tos were added very recently indeed, to answer to your question and start 
answering to other people asking for more "how-tos".

I'll close the thread if your question is answered. Don't hesitate if something 
is not clear...

Regards,
Guillaume

Original comment by guillaum...@gmail.com on 22 Jan 2015 at 9:31

GoogleCodeExporter commented 8 years ago

Original comment by guillaum...@gmail.com on 23 Jan 2015 at 9:19

GoogleCodeExporter commented 8 years ago

Original comment by guillaum...@gmail.com on 25 Jan 2015 at 9:54