ndee85 / coa_tools

COA Tools is a 2D Animation Suite for blender. It offers a 2D cutout animation workflow similar to programs like spine or spriter.
GNU General Public License v3.0
885 stars 138 forks source link

DragonBones exporter does not export events and Z depth #171

Open davord45 opened 3 years ago

davord45 commented 3 years ago

Hi ndee85.

Dont know if you are working on this addon anymore,i see you post a commit from time to time.I gotta report that DragonBones exporter is not finished,if you could please finish it so that it exports Z depth animation and events.I use it in Godot game engine and its awesome,just lacking those features.

Hope you see this.

davord45 commented 3 years ago

173

I made a pull request for this isssue,for anyone having the same problem.

ndee85 commented 3 years ago

Hi @davord45, do you have a sample file that animates those properties? Do you use a custom build godot version to test?

ndee85 commented 3 years ago

Implemented zOrder animation with this commit: ceb5a4ce2942204338121e5e18e1c3ddf0613822 Next I am going to implement the event system.

davord45 commented 3 years ago

Sorry for getting back so late,i am using Godot Dragonbones module which you can download here:

https://www.godotdragonbones.com/

Its already compiled so no need to do that.

davord45 commented 3 years ago

I can make you a sample file tommorow.

davord45 commented 3 years ago

Thanks for taking the time to implement these features btw! @ndee85

davord45 commented 3 years ago

Also the events i managed to export only Sound and Play type not regular events cause they are a Array of events and the JSON formatter caused an error when i tried to add an array. Hopefully you can figure that out. Right now in my pull request In COA regular events are play events.

ndee85 commented 3 years ago

I have checked the regular events yesterday. I think it shouldn't be to hard to add. I will have a look at it when I have some spare time.

ndee85 commented 3 years ago

I didn't know that extra godotdragonbones version existed :-) Good to know.

davord45 commented 3 years ago

I tested out zOrder export and it works great! Way more elegant than what i had lol.

ndee85 commented 3 years ago

Great. Glad to hear! Goint to add the event system soon and than I think the exporter should be more or less complete. Or do I still miss something?

davord45 commented 3 years ago

Well i found that meshes that are Slots which have a ShapeKey driver deformation, those deformations dont get exported like regular Mesh ShapeKey deformations. And animation curves always get exported as a standard S curve. Also i found that when the bone scale for instance X goes to negative value it exports Y value as a negative as well,even when its positive. I have implemented some fixes for that. Do you think it is possible also to make 2 bone IKs to export as DragonBones IK? Cause i know that IKs get baked into chain bones.

davord45 commented 3 years ago

Slots deformation and scale are kind of a bug and Curve and IK are more of a new feature. Thats all i found missing in the exporter,rest is amazing.

ndee85 commented 3 years ago

the problem with ik is that they don't behave the exact same way as in dragonbones. Blender is more powerful in that regard. So I thought the best way would be to bake those. Based on the setup it can differ quite a lot in blender. So think the best way is to bake in that case. It is similar with the curves. Blenders graph editor is way more flexible, end exporting this is not as easy. :-)

davord45 commented 3 years ago

Understandable,i managed to export curves but in some cases when the curve is really extreme DragonBones runtime starts freaking out. But i found that when i divide the value i can get some variation in curves. It helps the animation,but i guess baking the animation solves that issue, but it leaves bunch of keyframes.

ndee85 commented 3 years ago

Ok. Timeline Events are now fully supported. Please have a test with your files and see if they work as expected! Commit: ba0e0ad3b3eb9aad395801d1205bb7939bc5f4be

ndee85 commented 3 years ago

Forgot to commit some changes. So now everything should be updated. ea3dc7e6a2bf616d0e726fdd07f3c8ed4192fbf3

davord45 commented 3 years ago

I added the events but they dont export or they export in the JSON but are not imported in the DragonBones Editor. And now i got a bug with the zOrder export as well,i made a simple one arm go behind the body and other go in front.In DragonBones Editor it made the keyframes but the only plays second arm going in front of the body but on a keyframe where first arm goes behind the body.

davord45 commented 3 years ago

Do you want me to send you the .blend to test with it? Also there is no limit to sound events,if you add too many sound events it crashes the DragonBones Editor and probably the runtime.

davord45 commented 3 years ago

@ndee85 Here is the link to the .blend file: https://www.mediafire.com/file/e02akkpnvz2ov5m/nDeechaser.blend/file

Attack animation is the only one that has events and zOrder animation. Also i didnt bake the animation when i was exporting.

ndee85 commented 3 years ago

Thanks. I'll have a check with your file an see what is causing the problem.

ndee85 commented 3 years ago

Are you sure you updated the sources correctly? I just tested your file and all events did export properly. Also adding multiple sound events should not be possible on the same frame. Do you have an "Animation" event? If not, you did not update correctly.

Just checked that drawing order is still not working correctly in some cases. Will have a recheck on that.

davord45 commented 3 years ago

I didnt have "Animation" type,I downloaded the commit from blender28 and installed it to Blender. Do i need to update in Blender as well?

ndee85 commented 3 years ago

make sure to zip the coa_tools directory from Blender directory. Install that zip file then.

davord45 commented 3 years ago

You are right i was downloading the wrong branch. Sorry about that.

Now exporting works very nicely, I like how you give on Animation events dropdown of all animations!

May i ask how do Target,Int,Float,String fields on regular events effect JSON and what is their use in DragonBones?

Thank you for this nice feature! @ndee85

ndee85 commented 3 years ago

I have to admit I am not sure how to use the custom event. I asume it will trigger a callback in the runtime with the given parameters that can be set. The rest will be up to the dev what callback will be doing. But those are just assumptions.

I just reverse engineered the json file that dragonbones exports and made sure it outputs the same structure.

ndee85 commented 3 years ago

Just checked the godotdragonbones. It seems there are two signals in godot. One is for triggering sounds and the other is used to trigger customEvents.

dragon_anim_snd_event dragon_anim_event

The dragon_anim_event will have a dictionary parameter which delivers the int, float and string props.

davord45 commented 3 years ago

Nice, that does seem useful actually.

Was wondering could you add a field on the export panel for naming the armature? Cause right now everything that gets exported is called "Armature". Godot Dragonbones module has a way to control child armatures that are parented to a bone of another armature. Demonstrated in the video below.

https://youtu.be/qUPBceXtIDM

Naming the armature in COA would save some time.

176

This pull request has a field for naming the armature.

ndee85 commented 3 years ago

ok. Just added the armature name in the export settings. You can also update COATools via the addon preferences. There for open the addon settings. Refresh and then install the blender28 branch. Just force the install. This will get the latest source from the github repo.

davord45 commented 3 years ago

I get this error when i try to export. But i dont have slots in this armature. image

davord45 commented 3 years ago

Updated to a new commit,its different error

image

ndee85 commented 3 years ago

Is this the exact same file you posted above? Strange exports fine for me. Did you restart after updating blender?

ndee85 commented 3 years ago

Also just added a check which makes sure that slot_data does exists before accessing it. Not sure if this will fix your issue. Or something else is the root. But please make sure to restart blender after updating to latest branch.

davord45 commented 3 years ago

It was the same project. I updated it but i dont see a check for slots. But it worked now correctly.

Armature name in DB Editor is as i set it in COA.

ndee85 commented 3 years ago

Ok. Still working on exporting the zOrder correctly. I noticed some problems which I need to think of how to best fix.

davord45 commented 3 years ago

If it helps i noticed that the zOrder in DragonBones is looking at the default order and then comparing to the changed order on the keyframe. It looks what is the fastest way of rearranging the order of meshes from top to bottom in order. It does not compare changed order to the previous order in animation,just the default one.

Hopefully that helps you out.