mauville-technologies / godot_dragonbones

Plugin module for Godot 2.1 & Godot 3 Game Engine to use DragonBones
MIT License
87 stars 13 forks source link

Here comes slot swapping! #11

Closed Ozzadar closed 4 years ago

Ozzadar commented 4 years ago

gradual picker skins face_thing

New slot manipulation functions:

    bool has_slot(const String &_slot_name) const;
    Color get_slot_display_color_multiplier(const String &_slot_name);
    void set_slot_display_color_multiplier(const String &_slot_name, const Color &_color);
    void set_slot_display_index(const String &_slot_name, int _index = 0);
    int get_slot_display_index(const String &_slot_name);
    int get_total_items_in_slot(const String &_slot_name);
    void cycle_next_item_in_slot(const String &_slot_name);
    void cycle_previous_item_in_slot(const String &_slot_name);
    void set_slot_by_item_name(const String &_slot_name, const String &_item_name);
    void set_all_slots_by_item_name(const String &_item_name);

New Convenience playback functions:

These functions streamline the process of forcing a new animation to play. No effect if the animation is not changed.

        // for animation blending
       String get_current_animation_on_layer(int _layer) const;

    void play_new_animation(const String &_str_anim, int _num_times);
    void play_new_animation_from_progress(const String &_str_anim, int _num_times, float _f_progress);
    void play_new_animation_from_time(const String &_str_anim, int _num_times, float _f_time);

Demo code:

extends Node2D

onready var dragonbones_sprite = $Character
onready var color_picker = $CanvasLayer/ColorPickerButton

# Called when the node enters the scene tree for the first time.
func _ready():
    dragonbones_sprite.set_slot_display_index("slot_head", -1)
    dragonbones_sprite.set_slot_display_index("slot_face", -1)
    dragonbones_sprite.set_slot_display_index("slot_chest", -1)
    dragonbones_sprite.set_slot_display_index("slot_hip", -1)
    pass # Replace with function body.

func next_in_slot(slot_name : String):
    dragonbones_sprite.cycle_next_item_in_slot(slot_name)
    pass

This will be released with 3.2.51

blurymind commented 4 years ago

this is awesome! Would be great if we can also affect things like opacity/colour of individual body parts

Ozzadar commented 4 years ago

Might be do-able.

Ozzadar commented 4 years ago

@blurymind here you go ezgif-4-f4420a59de6e

blurymind commented 4 years ago

No I mean outside of slots. What if you want gradual transition šŸ¤”

blurymind commented 4 years ago

oh wait sorry I didn't read properly. You implemented a method to apply it. This is awesome stuff šŸ‘Œ

Ozzadar commented 4 years ago

Yeah, i couldnt really capture it but every time i swap slots I decrease the alpha and randomize the color multiplier in the GIF. It's the same base file as the original 2 slot gif :)

blurymind commented 4 years ago

Main poin being, you don't have to change a slot in order to apply an alpha or a tinto to it :) you can stay on a slot and change these

Ozzadar commented 4 years ago

Yeah, here is a better gif:

gradual

blurymind commented 4 years ago

Thats perfect šŸ‘Œ fantastic work on this!

Ozzadar commented 4 years ago

Last update on slots probably. I think I've got everything needed in here now; here's a demo of it all together with a "full" dragonbones export:

picker

blurymind commented 4 years ago

Can you add a godot project demo somewhere. I think this is an excellent addition that will allow easy character equipment systems and enemy variety. Fantastic job šŸ‘

Ozzadar commented 4 years ago

When I produce the build, there will be a corresponding tutorial up (probably demonstrating creating what I have above). Source code for all the tutorials will be found here:

https://github.com/mauville-technologies/godot_dragonbones_tutorial

Ozzadar commented 4 years ago

So I lied, I thought of more things I can do with slots; namely -- an informal skinning system.

So now if you name the items in your slot the same, you can make a one line call to your sprite to switch all slots to that item:

If the requested slot only has one item, it will not be switched; as you can specify none to remove all skinned slots.

dragonbones_sprite.set_slot_by_item_name(slot_name, skin_name) dragonbones_sprite.set_all_slots_by_item_name(skin_name)

image

skins

blurymind commented 4 years ago

I love what you're doing here. Animation blending is the other huge feature that is missing in godot and now you are laying the grounds for that too :)

Ozzadar commented 4 years ago
I'm glad! If I can garner enough support, there's alot of things that can be done. There are some things that are supported in DragonBones API but not in the DragonBones Pro editor. (Skinning, multi-armature/multi-texture atlas rigs) It'd be cool if I (or someone could help me) add to the Godot editor itself. Alot of the functionality can probably be integrated into the existing Godot animation tools and then we can extend out to the additional functionality to get a full-featured animation suite straight in Godot. Another route is investigating COATools to see if it has support (or we can extend support) for these things already and suggesting that route. (through tutorials and content)

With that being said, I declare this PR: MERGED!

Next PR will be focusing on updating documentation (README and adding classdocs).

blurymind commented 4 years ago

I know gdscript and have some basic understanding of the plug in api, so if you create an addon I can try to help out with it.

It would be great if one day we have a true open source alternative to the dragon bones editor that runs on all operating systems natively

On Tue, 4 Aug 2020, 01:20 Paul Mauviel, notifications@github.com wrote:

Merged #11 https://github.com/mauville-technologies/godot_dragonbones/pull/11 into master.

ā€” You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/mauville-technologies/godot_dragonbones/pull/11#event-3618022079, or unsubscribe https://github.com/notifications/unsubscribe-auth/ABRRWVPGZA7CAKXO5FKV7FLR65H43ANCNFSM4PRLRUIA .

blurymind commented 4 years ago

I guess potentially for editing the dragonbones animation inside godot, we would need to pass it the dragonbones json animation data in the correct format and be able to convert between the two on the fly.

It will most probably be easier to add the new features to blender's coa tools, but not quite as satisfying as having it straight in godot. Remember if we can edit dragonbones in godot - we can edit it everywhere godot compiles to - all desktop os, the web browser, native android/ios. It's gonna make the official editor look like its stuck in the past in the platform support aspect

Heck, if we had an open source and free alternative to dragonbones editor that might get you the Unreal open source grant. Projects like Leighter are getting it, so why not a game animation tool

blurymind commented 4 years ago

btw A few months ago I suggested adding dragonbones json export to anime effects https://github.com/hidefuku/AnimeEffects/issues/38 It has most of the editor functions you would need, but might need adding some dragonbones specific ones. If you want an open source dragonbones editor, that might be something worth exploring too

Ozzadar commented 4 years ago

Never heard of AnimeEffects before; but it might be a good idea to post your suggestion here:

https://github.com/herace/AnimeEffects

looks to be the most up to date fork. It seems like it could have potential. However without some serious funding I personally can't commit to adding DragonBones support to anything past what I'm doing here with the Godot module.

It's definitely something I'm open to exploring more in the future though as the module becomes feature complete with the existing Dragonbones Pro editor. This will hopefully give us a little time to drive adoption, hopefully save up some money, and look at also providing an open source animation editor that has day1 support in the Godot engine.