Technohacker / godot_pixelorama_importer

Godot 4.x plugin to import Pixelorama (.pxo) projects in Godot
MIT License
40 stars 11 forks source link

[Feature proposal] Import as Sprite and AnimationPlayer #8

Open Kerberross opened 1 year ago

Kerberross commented 1 year ago

Note that the screenshots are from a POC in Godot 4, but doing it in Godot 3 should be possible. I will create a pull request for Godot 3 if this proposal seems good to you, then update the current one for Godot 4.

Why

How

New import type, Sprite (Godot 3)/ Sprite2D (Godot 4) & AnimationPlayer

import_parameter

Import properties

Parameters explanation:

Import process details

The import will create a packedScene with a tree like:

scene_tree

Generated tree

Changed done on the created Sprite[2D]:

Changed done on the created AnimationPlayer:

animation_variable

Example of variable fps animation (fps = 6, second frame have the duration set to 2 => with a fps of 12)

In case of the animations are stored separately, the import will only replace the tracks linked to the frame animation, leaving the others tracks added by the user. The animation length will also be updated.

Questions

I think I covered everything I had in mind, feel free to add new thing if it makes sense :smiley:

Technohacker commented 1 year ago

Thanks for the proposal!

Animation > External save path: The directory where the animation will be saved if External save is checked. Default value: current directory of the pxo file.

See if this field can be hidden when External Save is disabled, to make sure it's clearer to the end user :)

In case of the animations are stored separately, the import will only replace the tracks linked to the frame animation, leaving the others tracks added by the user. The animation length will also be updated.

So in case the pxo file defines a new animation with a name matching a custom animation that's already present, that may need overwriting, right? Unless we maybe have a special prefix for import-generated animation tracks

For the current SpriteFrames import, the fps is an import parameter and not the one define in the pxo, there is a reason for that?

I don't quite remember the justification off the cuff :sweat_smile: I believe I hadn't implemented it at the time, likely just focusing on having a basic importer to start with, or that the pxo file didn't specify project FPS. Feel free to remove it :)

For the external save, which file naming should we use?

One suggestion I have is {pxo-name}/{animation-name}.tres for Godot 3, mainly because in case someone happens to have multiple pxo files saving to the same folder, their animation files will be grouped together under a common folder rather than everything being listed out in the parent folder (Granted, this situation is unlikely, and it may just be my personal preference speaking here)

It may be a good idea to have some project parameters to define the default value of the import, as well as the default import (since it required an editor restart to change it), what do you think?

Are these for the game's Project Settings? There may be issues for when the Project defaults have changed, but existing imports have been done

Otherwise LGTM :D

OverloadedOrama commented 1 year ago

For the current SpriteFrames import, the fps is an import parameter and not the one define in the pxo, there is a reason for that?

I don't quite remember the justification off the cuff :sweat_smile: I believe I hadn't implemented it at the time, likely just focusing on having a basic importer to start with, or that the pxo file didn't specify project FPS. Feel free to remove it :)

If I remember correctly, it was because pxo's weren't storing the fps back then, so it had to be an import parameter. Now they do, so I don't think the parameter is needed any longer.

Kerberross commented 1 year ago

Animation > External save path: The directory where the animation will be saved if External save is checked. Default value: current directory of the pxo file.

See if this field can be hidden when External Save is disabled, to make sure it's clearer to the end user :)

There is a get_option_visibility available, so it should be possible

In case of the animations are stored separately, the import will only replace the tracks linked to the frame animation, leaving the others tracks added by the user. The animation length will also be updated.

So in case the pxo file defines a new animation with a name matching a custom animation that's already present, that may need overwriting, right? Unless we maybe have a special prefix for import-generated animation tracks

I am not quite sure that I understood the question:

A track is an attribute change. In the screenshot, it's the frame line. Somebody could add another track changing the position of the sprite, or another one calling a function in the same animation. What I was saying is that the track for the position of the sprite will be untouched, and the track for the frame will be updated. So for a track, a prefix is impossible, since it's a path to a Godot attribute (".:frame" is this case).

For the animation itself, in Godot 3 I am not quite sure that it's possible to add new one, since the list of animation is in the packed scene I guess, but I need to test that. Since the packed scene is in the .import directory, the user cannot modify it. In Godot 4, with the animation library save externally, it should be possible, but I don't really know what the best things to do.

I suggest that I do a first version in Godot 3, tests what's possible, to have a clearer view. Same thing later with Godot 4

For the current SpriteFrames import, the fps is an import parameter and not the one define in the pxo, there is a reason for that?

I don't quite remember the justification off the cuff 😅 I believe I hadn't implemented it at the time, likely just focusing on having a basic importer to start with, or that the pxo file didn't specify project FPS. Feel free to remove it :)

If I remember correctly, it was because pxo's weren't storing the fps back then, so it had to be an import parameter. Now they do, so I don't think the parameter is needed any longer.

Ok, I will do that

For the external save, which file naming should we use?

One suggestion I have is {pxo-name}/{animation-name}.tres for Godot 3, mainly because in case someone happens to have multiple pxo files saving to the same folder, their animation files will be grouped together under a common folder rather than everything being listed out in the parent folder (Granted, this situation is unlikely, and it may just be my personal preference speaking here)

You are right, putting everything in a folder seems a better idea!

It may be a good idea to have some project parameters to define the default value of the import, as well as the default import (since it required an editor restart to change it), what do you think?

Are these for the game's Project Settings? There may be issues for when the Project defaults have changed, but existing imports have been done

Yes. I didn't test it yet, but I think those settings will be used only for new imports, since Godot stored the one used for each import in a separate .import file. I will do a quick test and come back with the answer tomorrow

Kerberross commented 1 year ago

It may be a good idea to have some project parameters to define the default value of the import, as well as the default import (since it required an editor restart to change it), what do you think?

Are these for the game's Project Settings? There may be issues for when the Project defaults have changed, but existing imports have been done

Those projects settings are only used for new import. Older import keeps their values

In case of the animations are stored separately, the import will only replace the tracks linked to the frame animation, leaving the others tracks added by the user. The animation length will also be updated.

So in case the pxo file defines a new animation with a name matching a custom animation that's already present, that may need overwriting, right? Unless we maybe have a special prefix for import-generated animation tracks

In godot 3: Since the file is imported as a scene, the only 2 way to add an animation is by inherited it or making child editable. In both cases, the animation is stored outside of the imported file, so when reimporting the file, it's not possible to know if an animation was created. In case a new animation is imported and an inherited scene added one with the same name, the one in the inherited scene will overwrite it. Deleting the one in the inherited scene will bring back the imported one. It's the same behavior for 3d import.

I still need to have a look in godot 4.

Kerberross commented 1 year ago

In case of the animations are stored separately, the import will only replace the tracks linked to the frame animation, leaving the others tracks added by the user. The animation length will also be updated.

So in case the pxo file defines a new animation with a name matching a custom animation that's already present, that may need overwriting, right? Unless we maybe have a special prefix for import-generated animation tracks

In godot 4, if the animation is created in the same AnimationLibrary, the track related to the frame will be overwriten. But multiples AnimationLibrary can be added, so adding another for custom animations will avoid overwriting them.

nklbdev commented 1 year ago

I am very proud to have touched these projects in the course of my work. And I want to offer you an alternative - Importality, the bundle of importers, which can import Pixelorama files and other formats. Including in the form of a Sprite with AnimationPlayer.

I just now discovered this repository and would like to support its development, or invite the contributors of this plugin to join the development of Importality.