Smart bone flipping and mirror point tool

Moho allows users to write new tools and plugins. Discuss scripting ideas and problems here.

Moderators: Fahim, Distinct Sun, Víctor Paredes, erey, Belgarath, slowtiger

User avatar
heyvern
Posts: 6964
Joined: Fri Sep 02, 2005 4:49 am

Smart bone flipping and mirror point tool

Post by heyvern » Sat Oct 26, 2013 10:04 am

Download the scripts:

Mirror translate points tool:
http://hubumedia.com/anime-studio-servi ... oints-tool

Mirror points menu scripts
http://hubumedia.com/anime-studio-servi ... nu-scripts



Finally!

I was going nuts "flipping" mirrored smart bones for multiple vector layers. I had to do a TON of duplicate smart bones for a full body and head turn on multiple layers for the opposite side. It was so frustrating because the layers are all symmetrical, the point positions are right there but no easy way to flip them for the opposite turn of the smart bone. You can't use the "flip horizontal" point tool because that reverses everything.

I finally have a solution. It's a working prototype but should be ready very shortly. Instead of hours of recreating the same point movement for a ton of layers for the opposite turn of a smart bone, it only took a few minutes.

Basically it works based only on perfectly symmetrical vector layers for doing "full turns" like head or body turns. It is limited a bit because the vector layers have to be symmetrical but there really is no way to work around this and it's pretty much how you would do something like this anyway. If the vector layer isn't symmetrical to begin with, creating mirrored smart bone actions would have to be done by hand anyway.

To make things easier I also created a script to make vectors symmetrical. For example if the layer is "close" but not "perfect", you run the script and it mirrors the left and right sides by selecting the closest point on the opposite side. Not perfect but it gets it pretty close and still saves a ton of time. This could also be useful just for regular character designs.

While I was at it I also created a "mirror" point translation tool that works pretty well. Still tweaking a "radius" setting for it.

Smart Bone Flipper
So the smart bone flipper works by using the point positions on frame 0 where they aren't moved to create a table of matching points. That was the tricky part. How to find the "opposite" point if they are moved around on a frame. It's virtually impossible. Point IDs aren't "matching" unless they are drawn that way to start. If you draw a shape then insert points between other points later the IDs on the opposite sides won't match. The only way to get the exact opposite side point is to use their translations so this would be done on frame 0 only. This is why they have to be exactly symmetrical which required creating another script to do this first on frame 0. Many times you might have points that are really close to each other and if they aren't exactly the opposite value on either side it won't work as well.

Once that left/right point table is created it's a piece of cake to simply "reverse" the point positions on any other frame to flip the point movement.

The steps are simple. For my current usage, I had already created a full front to side turn of the body to the right. With a full front to side right turn, I now needed to do the exact same thing for the left turn. The body is a switch to go from front to back on the cross of the turn so I had to create smart bone turn point keys for a whole pile of layers.

I created my new left turn smart bone action (body turn 2) and inserted a copy of the original left body turn action. I now had all the keys for the points but in the wrong direction. I went to each key frame and ran the script which "flips" the point movement. The bone movements wasn't a big deal because that is simple to copy and didn't take long to do by hand, although I am thinking of adding in that feature to make it a one step process.

Just to be clear, this is NOT like the point flipping tool. That completely flips the points in the opposite direction. That won't work with smart bone turns. This changes the position of opposite points to create the same motion but "mirrored".
Last edited by heyvern on Sun Oct 27, 2013 2:37 am, edited 2 times in total.
ulrik
Posts: 1073
Joined: Thu Aug 11, 2005 10:32 pm
Location: Stockholm Sweden
Contact:

Re: Smart bone flipping script and mirror point tool

Post by ulrik » Sat Oct 26, 2013 3:02 pm

This sounds like great timesaver, I'm really curious about your script. :D
User avatar
heyvern
Posts: 6964
Joined: Fri Sep 02, 2005 4:49 am

Re: Smart bone flipping and mirror point tool

Post by heyvern » Sun Oct 27, 2013 2:11 am

I added the download links for the files in the first post.

I also did a short video demonstrating the scripts.
otonal
Posts: 39
Joined: Tue Jun 05, 2012 4:44 pm

Re: Smart bone flipping and mirror point tool

Post by otonal » Sun Oct 27, 2013 10:45 am

the mirror translate points tool is something i was wishing to have in anime for a Long time-- thank you very much !

but as you mention in the video it should operate with multiple point selections as well and my wish and proposal would be to also inculde an add-points(mirrored) function to it, would come very handy while doing bodys and faces with it.
then you could do all basic shape-modelling with it.

.or, maybe even better add a mirror functionality directly to the add point tool as a mod as well
Last edited by otonal on Sun Oct 27, 2013 1:18 pm, edited 1 time in total.
videodv
Posts: 69
Joined: Tue Feb 08, 2011 10:17 am

Re: Smart bone flipping and mirror point tool

Post by videodv » Sun Oct 27, 2013 12:54 pm

Good script heyvern will be very useful.

Regards
Chris.
User avatar
heyvern
Posts: 6964
Joined: Fri Sep 02, 2005 4:49 am

Re: Smart bone flipping and mirror point tool

Post by heyvern » Sun Oct 27, 2013 4:19 pm

otonal wrote: .or, maybe even better add a mirror functionality directly to the add point tool as a mod as well
That can easily be done, I was just concerned modifying the "core" tools. It makes me nervous when I do that. What I can do then is to include two downloads, a "new" version and a modded core version.

When I started this, I was trying to figure out the best way to implement it. There is the "magnet tool" which is a completely separate tool in Anime Studio but does the same thing as the translate tool, it moves points. My thought was that mirroring point translation could also be a separate tool but then I was either going to "reinvent the wheel" or eliminate all of the translate point tools features.

I started experimenting to test it out by pasting the "mirror" code into different spots of the LM translate tool. When I got it working without huge modifications I decided to simply go with that. The code that does the mirroring isn't much at all, just a few lines (not including the tool option checkbox). With some effort I should be able to make it a separate function that can be applied to all of the point motion options of the standard tool. Currently I simply dropped it in the "moving only one point" section.

I agree with all of the other suggestions as well. Definitely need this to work on point selections or groups and adding in "Mirror add points' is a FANTASTIC IDEA!!!! I never even thought of that! That would be COOL AS HECK! Definitely want to add that somehow. The one problem is that It's really difficult to find the opposite points accurately. Because points move around and the positions are constantly changing you can't keep an accurate listing of "opposite" points. As you saw from the video when you drag past another point it gets all wonky. This is due to how the translate point tool keys the points. It evaluates each point individually, so when you are dragging a point and it gets close to another point it will switch which opposite point is selected. I have to find a way to "lock" the opposite point as it's dragging.

The translate points tool is "kind of complex". There's a lot of things going on when you mousedown or drag points... it's checking for modifier keys, auto welding, shape selection, edge selection, etc etc. So the reason it won't work with multiple points is because moving more than one point is a different block of code than moving one point at a time.

The closest application I've seen this feature is Animation Master which is 3D but has points almost EXACTLY like Anime Studio. The mirroring option in Animation Master has the the same issues and has a radius of influence to move opposite points. So the model doesn't have to be perfectly symmetrical. If you have a large radius you can move points like the magnet tool on both sides. Something like that would be cool for Anime Studio, but would involve a blending the magnet tool and translate tool features (easier said than done).

This feature of mirroring point translation has been a long time coming and is really really REALLY needed. I am desperately hoping Smith Micro will add it in as a core feature someday and have the "real" programmers handle all of these complexities. :)
otonal
Posts: 39
Joined: Tue Jun 05, 2012 4:44 pm

Re: Smart bone flipping and mirror point tool

Post by otonal » Mon Oct 28, 2013 10:28 am

another thing came to my mind while i was using your new mirror points horizontally script:

often i would like to force symmetry and mirror over from left to right or vice versa by completely overwriting/replacing everything that was there.
by this you could symmetrize any shape not regarding the pointcount or positions on the other side at all.
this would come in handy in earlier stages, when you blocked out and refined just one side of a face or character.

the mirror points horizontally script as it is by now, looking for corresponding points, is perfect for its purposes but something like the more radical variant i described above might be a great timesaver as well for different situations.

so maybe there is a chance for a script like this to join your symmetry team ;)
User avatar
heyvern
Posts: 6964
Joined: Fri Sep 02, 2005 4:49 am

Re: Smart bone flipping and mirror point tool

Post by heyvern » Mon Oct 28, 2013 4:18 pm

otonal wrote: ... often i would like to force symmetry and mirror over from left to right or vice versa by completely overwriting/replacing everything that was there... so maybe there is a chance for a script like this to join your symmetry team ;)
Yes this could be possible. There would be two ways this could be done:

1. if the points originally are relatively "symmetrical" (basically how it works now sort of but with a "radius" of some kind".
2. Points on frame 0 or another frame are PERFECTLY symmetrical, run the script and use that symmetry frame as a reference.

Forgive me, but I am going to get a tiny bit technical explaining how points are stored in Anime Studio.

The script you mentioned that mirrors the points is based on something in the Anime Studio scripting reference called "nearest point". This is how the translate point tool works when selecting a single point. It uses the click location of the mouse, and calculates the nearest point to the mouse click's X and Y position. I simply use one side to get an XY location, reverse the X value and use nearest point on the opposite side to find the opposite matching point.

Anime Studio uses an internal "ID" for each point. As I said earlier, each point is not always created in a sequential order so the ID's aren't "mirrored" as you might expect.

Imagine you create a perfectly symmetrical 8 point box with 4 points on each side, by clicking the add point tool.

The point ID's are 0 - 7 in logical order (IDs start at 0, so point 8 has an ID of 7) in the direction you created the points of the vector. 4 on the left, 4 on the right. You would expect that following in a counter clockwise direction or order based on the visual location of points that the ID order would be:

left side:
0-3
right side:
4-7

0 is top left, it counts down the left then back up the right to 7 at the top right.

If this ID ordering were maintained no matter how much editing is done then finding symmetrical points would be simple and based on points not point location. If this ordering were maintained you could always "split" the point count, and divide it to find left and right matching IDs.

Unfortunately this is not the case. Deleting or adding points "randomly" as you would when drawing in Anime Studio, maintains unique ID numbers but it changes the IDs of points non-sequentially. Left side point IDs might be 0, 1, 6, 5, instead of 0, 1, 2, 3.

This means there is no way to use the point count and ID numbers to find opposite points. The only way to do that is using position. It's the only way. The only way to get left and right locations based on location is to have points somewhere on some frame that are "close" to symmetrical and use the script to "clean it up".

There might be some other way to find point ordering based on location on the connected vector shape, for example find the "first" point of a vector, then create a sequential "visual" list of points based on getting the next point along the vector and not using point IDs at all. Once again non sequential point IDs still makes this very problematic. If there is a closed shape on the left and a matching closed shape on right how do you find the opposite shape to count the points along the vector? You still have to use the location along the X axis.

Another option would be to change the order of the points, making all of the points IDs in the proper order. This of course would be a total disaster for any point motion in actions or animation because the point locations are based on the ID number. Change a points ID and it's location will be wrong for existing key frames. Although, there might be a way to change the IDs and keep the proper motion but this change would "break" smooth interpolated switch layers unless all the layers were also "reordered".

I am rambling, but that is basically why mirroring points is so difficult. :)
Breinmeester
Posts: 294
Joined: Thu May 13, 2010 2:01 pm

Re: Smart bone flipping and mirror point tool

Post by Breinmeester » Sat Nov 02, 2013 4:37 pm

This looks handy and coulod be very valuable. Thanks a lot for sharing!! 8)
ulrik
Posts: 1073
Joined: Thu Aug 11, 2005 10:32 pm
Location: Stockholm Sweden
Contact:

Re: Smart bone flipping and mirror point tool

Post by ulrik » Wed Nov 06, 2013 8:46 pm

Thanks a lot for this, great script!
Lychee
Posts: 110
Joined: Mon Dec 24, 2012 12:59 pm

Re: Smart bone flipping and mirror point tool

Post by Lychee » Mon Dec 07, 2015 5:01 pm

Hello Heyvern !

What is the problem with the French poeples ? It is impossible for me to download your flip points script from your site because i've got this message: "Your location (FR) has been blacklisted". :shock: :shock: :shock:

Dont worry, French people are kind (sometimes :D ).

I'm very sad because i'm on a "big" project and that will be very helpfull and help me saving time to have this script.

PLEASE HELP ME !!!!

Best regards.
hayasidist
Posts: 2139
Joined: Wed Feb 16, 2011 8:12 pm
Location: Kent, England

Re: Smart bone flipping and mirror point tool

Post by hayasidist » Mon Dec 07, 2015 6:22 pm

ha! same for me in the UK....
Oddity
Posts: 64
Joined: Tue Jul 17, 2012 7:49 am
Contact:

Re: Smart bone flipping and mirror point tool

Post by Oddity » Tue Dec 08, 2015 8:54 am

Hi
I tried with a VPN in several countries and i finally found a the website but the link seems dead.
heyvern could you allow us to download those scripts please or give us other links :)

regards
-------------------------------------------------------------------------------------
"All those moments will be lost in time, like tears in rain. Time to die. "
jsiino2
Posts: 7
Joined: Sat Jan 16, 2016 12:07 pm

Re: Smart bone flipping and mirror point tool

Post by jsiino2 » Tue Jan 19, 2016 10:06 pm

Hello Heyvern. The links to these very useful tools is no longer available. May you please send new links? Also, these do work with AS pro 10 right?
Post Reply