jpaver / opengametools

A set of open c++ game development tools that are lightweight, easy-to-integrate and free to use. Currently hosting a magicavoxel .vox full scene loader.
MIT License
373 stars 35 forks source link

ogt_vox : implement animation looping and sampling #34

Closed jpaver closed 2 years ago

jpaver commented 2 years ago

This seems to work on a number of import tests I've done locally. @mgerhardy @dougbinks please take a look and let me know if this works okay within your codebases too. Thanks!

There is a small API incompatibility if you already grabbed the initial animation support -- I've wrapped animations into their own structs instead of having keyframes+count embedded within instances/groups, but it should be a fairly straightforward thing to fix up.

Please let me know if you have any additional thoughts before I merge. Will try do so early next week, thanks!

mgerhardy commented 2 years ago

All of my test cases are working fine - thanks a lot.

(There are a few new trailing whitespaces ;) )

dougbinks commented 2 years ago

This branch doesn't appear to cause issues with loading .vox files, however it doesn't fix an issue I have observed with a walk cycle Dima has provided us (I note that you should have the same file). In this file the head appears dislocated and rotated from the body when loaded by ogt_vox.

Avoyd doesn't yet support vox animations, so was just loading the models and transforms without referencing the animations. I tried using the explicit ogt_vox_sample_instance_transform and ogt_vox_sample_instance_model with a given frame but this gives the same result.

I'm not sure if this is a similar problem to the one experienced by a user on our discord, but it looks similar.

One quick note - in CHUNK_ID_nSHP loop dict reading you test loop_string for non-null however you provide the default of "0". Perhaps don't provide the default in _vox_dict_get_value_as_string?

I'll keep investigating but I'm not yet fully familiar with the transform / animation handling so it's slow going.

dougbinks commented 2 years ago

Update: the transform issue is possibly not related to animations, as I can reproduce this in a file I have from an earlier version of MV which loads correctly in with ogt_vox prior to the animation handling. I don't currently have permission to share this file but will try to reproduce in my own vox file.

jpaver commented 2 years ago

(There are a few new trailing whitespaces ;) )

Thanks, fixed.

Perhaps don't provide the default in _vox_dict_get_value_as_string?

Good idea. I've actually opted to use new _vox_dict_get_value_as_bool/_vox_dict_get_value_as_uint32 to simplify and improve overall readability in a few key places.