• Editor
  • Is there a way to reuse a Mesh Animation?

Alright. Let me try to explain what I mean. I have multiple flag objects, I map the flag to a texture map to make it wave realistically. All I want to do is be able to re-use the same mesh and animations across all the flag objects that are switched out on each sprite, but every time I place the new flag into the mesh, it renames it a new name and doesn't carry over the old animation.

For a live explanation about what I'm talking about skip to the 1 hour point into the below video exactly.

http://www.justin.tv/femjesseart/b/505034475

Please respond! I'm waiting on exporting these sprites to know if I have to manually re-animate all these flags. :drunk:

Related Discussions
...

I had to do something similar recently. It was really tedious.XD

But I imagine when skinning comes along, it'll be easier. Given the deformation will be based on bones, there won't be any re-animation necessary.
And even if you had several of the things in one animation, copying rotation and translation keys from one bone to another is now trivial.

Also, I think there's some restructuring to come that they're still trying to figure out on the mesh side.

For now though, I dunno. I don't know any way to reuse mesh animations. Let's wait for official word.

The weird thing is that meshes appear sub dependent on bones so unlike bones, you can't seem to "folder" images into them and switch them out on the fly. I hope they add this feature or a mod can at least explain a way to do this.

I have several sprites that reuse a body and switch out other minor bodyparts, so it is easier to just flick them off in their animations than use the skins feature. The skins feature also doesn't appear to work with meshes for the same reason that the mesh points are mapped in the animation individually and by the mesh name. =/

FFD keys are per attachment, the reason being that each attachment has its own mesh. The meshes may be different, either with a different number of vertices or just in a different order. Ie, when you move a mesh vertex, there is no way to know what vertex you want moved in a mesh for a different attachment. It only makes sense if you duplicate a mesh and then change the image, because then you have exactly the same mesh.

There are two use cases:

1) You have two attachments for the same slot and want to use FFD to deform them differently. Spine handles this, since FFD keys are specific to a mesh attachment.

2) You have two attachments for the same slot and want to use FFD to deform them the same (eg the flags in your video). Spine currently doesn't have a way to reuse the FFD keys for a different mesh. 🙁 I'm open to discussing how this might work.

The simplest is probably copy/pasting FFD keys, similar to how copy/pasting bone keys works (copy FFD keys, select different mesh, paste and it does the best it can to match the deformation). This may save you the work of animating the same mesh repeatedly, but is unfortunate in that the data is duplicated. Eg, if you change your flag deform, you'll have to change it for every flag mesh.

There may be some way of associating multiple meshes with the same FFD keys. This has some complexity with the UI and making sure the user understands what is going on.

Another possibility might be having only a single mesh attachment and the FFD keys are only for that mesh, as they are now, but somehow allowing the image used for the mesh to change. Conceptually this is different from keying a slot attachment change. It would have to show up as a separate row for the mesh in the dopesheet, similar to how FFD keys are for a specific mesh. The UVs are normalized, so nothing will break if an image is a different size, it will just be stretched.

There is the question of how to choose the image to show. It could be that in setup mode you can drag any number of images under a mesh, then you can show any one of those in animate mode. I'm not sure where to put the key button though, as it would make sense to put it next to the mesh, just like a slot attachment change, but this is already used for keying the mesh's FFD.

Skinning works by bones manipulating mesh vertices. The bones are outside the mesh, so unlike a mesh's vertices, the bones stay constant when a different mesh is shown. The deform of a mesh from skinning depends on the weights set for the mesh's vertices. If you have many meshes, you will need to set the weights for each mesh, which is how much each bone affects each mesh vertex. This is likely much easier than duplicating your flag deform, whether by hand or via copy/paste, but would still be quite tedious if you have many flags. Also, we want FFD to be usable on top of skinning to correct for situations where skinning performs poorly (eg extreme bends). Any FFD corrections would still have to be done for each mesh. It would seem a solution for reusing a mesh with different images is useful even when using skinning.

This could be worked around at runtime by simply changing the texture region a mesh attachment uses. This is not quite as nice as being able to key it in the editor, but it could work well for a situation like the flags and is something you can do until we concoct a more robust solution.

Thanks for getting back to me. I'll try some of these workarounds. I'm glad to know you may look into this feature in the future as well.

Unfortunately changing the object level data is not an option, we are exporting frames as PNGs for this project.

The only way to make it 100% reusable is if the deformation of the underlying image is done by a separate lattice mesh. Unfortunately this just brings up an entirely different problem. which is performance. I'm sure we can improve the current FFD tools, we already plan to do so, but first things first 🙂

2 months later

Any progress on this task? I need to copy-past mesh keys for the same copy of slot with mesh. Maybe is it possible to copy keys then we duplicate slot?

Not yet. The runtimes need to be updated before more editor features can be worked on.

The problem you are having may also be solved when we are able to add an entire different skeleton as an attatchment. you can re-use mesh there by using skins.

What I did to reuse meshes in an old project I had was to create a new skin for the same object and rename the image attatchment of the mesh to a new image attatchment that had exactly the same size. It worked well but It doesn't allow to copy the very same object keeping the animations several times within the same skeleton, which would be solved it they were actual different skeletons as attatchments.

5 months later

I'd love to see this as well. Mesh Attachments not having an efficient workflow with skins is the only thing keeping me from using mesh animations right now, and I really want to start using them :p

I see there's a task for it in the backlog, though. Looking forward to it!

6 months later

Hi Nate, thanks for all the great work on this app, it has really helped to bring my projects to life.

I too am wondering about swapping attachments for meshes. Basically I need to accomplish the same thing as the person with the flags in this thread. I have 50 or so skins which are basically the same shape just with different colours and/or details. Unfortunately I can't accomplish the animations I want without FFD but I don't want to have to re-key each animation for each of the 50 skins! Ideally I could have multiple attachments and/or skins with the same mesh and keys and changing the attachment would be as simple as enabling whichever one I want to see at that time.

It seems that this is in the works, from the searching I've done. My first question is, do you have an approximation of when we can expect to see an update to the Mesh capabilities of Spine? I have a deadline to meet and would love to be able to continue using Spine for the project.

Secondly, I noticed this in your post:

This could be worked around at runtime by simply changing the texture region a mesh attachment uses. This is not quite as nice as being able to key it in the editor, but it could work well for a situation like the flags and is something you can do until we concoct a more robust solution.

Would you be willing to elaborate on how this would be accomplished programatically? I'm not asking you to write my code for me, haha, just some direction on where to look and what to do generally would be greatly appreciated.

Thanks again for a fantastic app and continued improvements!

I've been focusing on skewing scale, though there is quite a bit of work left. It's hard to say when mesh switching can be done. I have a summer vacation planned to visit family which won't help. I don't normally give estimates and this isn't really one of those, but I wouldn't expect it done before 3 months from now. Sorry!

17 days later

This might help if you're desperate to re-use FFD animation across multiple characters before there's a neat way to do it in the software.

It may not be efficient for animation re-work or game engines, but I was able to re-use animation on another skin for a similar character (girls with dresses) by hacking the JSON file. I exported the character as a JSON with FFD animation already done, then opened the JSON with a text editor. I copied & pasted the first skin and animation info and renamed all references to the images eg. Green > Blue. The girls are very similar with mostly costume changes.

Then I imported the JSON and there I had one skeleton, two skins and identically animated dresses on both. Might just get someone out of a pinch.

I've since decided to use bones & meshes anyway so animating the verts of the dress isn't necessary for me anymore.

For the customization of our character, we use a similar way to do it like you BradPrice.
So I confirm that it's possible to do it 🙂

3 months later

I managed to duplicate a mesh attachment, and then modify it's path property to point to another Image. Works for me!

nimbling wrote

I managed to duplicate a mesh attachment, and then modify it's path property to point to another Image. Works for me!

But the animation goes with the duplication? Becouse when i do that the animation get lost in the duplicated mesh.

We need to be able to swap out images at runtime and maintain FFD, so this won't help us out I don't think. We aren't using skins, instead in Unity when a player equips "Cloth_Robe_A" for example it is defined as 6 different images like Cloth_Robe_A_Chest, Cloth_Robe_A_Left_Forearm, Cloth_Robe_A_Left_Upper_Arm and I swap out the images for all of those slots. We aren't using skins due to swapping out 3 other attachments also at runtime which are all bound to the default skin.

Making a skin for all 20+ of our robe only customizations seems like an improper way to do this since we have another 60 or so customizations without FFD for other equipment options.

Majicpanda wrote

We need to be able to swap out images at runtime and maintain FFD, so this won't help us out I don't think. We aren't using skins, instead in Unity when a player equips "Cloth_Robe_A" for example it is defined as 6 different images like Cloth_Robe_A_Chest, Cloth_Robe_A_Left_Forearm, Cloth_Robe_A_Left_Upper_Arm and I swap out the images for all of those slots. We aren't using skins due to swapping out 3 other attachments also at runtime which are all bound to the default skin.

Making a skin for all 20+ of our robe only customizations seems like an improper way to do this since we have another 60 or so customizations without FFD for other equipment options.

I believe you should use skin for the character, but for the robes use attachments that go NULL when it is not "Cloth_Robe_A" .

I was using the same system you are, for different views. But i changed that. I am trying something i never did before here:
3D Effect technique - example and discussion

A hand is really simple, i do not know how that would work on clothes. Also to animate it all would be a lot of work.