Smart bone action flipper - flipping control handles

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

Moderators: Víctor Paredes, Belgarath, slowtiger

Post Reply
User avatar
heyvern
Posts: 7035
Joined: Fri Sep 02, 2005 4:49 am

Smart bone action flipper - flipping control handles

Post by heyvern »

I have been able to copy and flip everything in an action except for the control handle positions. If anyone has some simple code snippets or guidance for getting control handle values for a point stored in a table that would be awesome. Everything else was so straightforward no it turns out that accessing the control handles is like string theory and particle physics. Poking around on the mohoscripting.com website I get very dizzy and start to pass out... uh... okay I exaggerate but it's proving tricky to figure out.

A bit of background on this project
This has been a dream of mine for a long time. I just kept putting it off.
I absolutely HATE duplicating smart bone actions on opposite sides. It is tedious and annoying. You get one side perfect... then you have to do the exact same thing on the other side. There really is no easy way to flip and smart bone action than keying the points from scratch on the other side. It's especially annoying when there are bunches of vectors on one layer with finicky little point tweaks to get it right only to have to repeat the process on the other side. And then you can never quite get it exactly the same. Then later you make a small change and have to repeat it. I wanted a one-click solution.

I'm off to a good start. I had to fix some older scripts I created years ago that broke with new versions. The old code was way over complicated so I started over and simplified the whole thing. It's working great so far. Flips all the points and the point curves. The trouble is point control handles. I never even considered that. For some odd reason, I kind of thought flipping the points and copying the curvature would "magically" flip and copy curve handles.
User avatar
hayasidist
Posts: 3525
Joined: Wed Feb 16, 2011 8:12 pm
Location: Kent, England

Re: Smart bone action flipper - flipping control handles

Post by hayasidist »

this might help... it's a tool to reshape curves by grabbing a segment of the curve to adjust the bezier handles on the segment's end points

http://www.lostmarble.com/forum/viewtop ... 77#p195377
but yeah ... string theory ... very appropriate!
User avatar
Rai López
Posts: 2243
Joined: Sun Aug 08, 2004 1:41 pm
Location: Spain
Contact:

Re: Smart bone action flipper - flipping control handles

Post by Rai López »

🤔 I may not be totally getting it, but couldn't M_Point:FlipControlHandles(frame) be of any help on that?
...
User avatar
hayasidist
Posts: 3525
Joined: Wed Feb 16, 2011 8:12 pm
Location: Kent, England

Re: Smart bone action flipper - flipping control handles

Post by hayasidist »

if you take a look at Alexandra's mods to Transform points (linked on the page you referenced), she's replaced pt:FlipControlHandles with her own .. so I'm guessing the "factory" Flip didn't achieve what she wanted especially where the points are also influenced by bones. Maybe her AE_TransformPoints:FlipControlHandles() plus her two utility routines GetOffsetChannel() and SumActionInfluences() will give you a better steer???
User avatar
Rai López
Posts: 2243
Joined: Sun Aug 08, 2004 1:41 pm
Location: Spain
Contact:

Re: Smart bone action flipper - flipping control handles

Post by Rai López »

Well, I couldn't go any deeper now, so I just wanted to be sure that the already existing function didn't pass unnoticed for whatever reason...

Anyway, for modifying actions itself, maybe taking into account bone transformations or whatever beyond points' handles actual state couldn't no be necessary? I mean, all that should apply at time the Action is being used, isn't it? But, again, just saying, cause I may not be taking into account a lot of factors...
...
Daxel
Posts: 996
Joined: Wed Mar 27, 2019 8:34 pm

Re: Smart bone action flipper - flipping control handles

Post by Daxel »

This tool would indeed be extremely useful. I wish I could help but for me it's more like string theory but on elvish, since I'm not a programmer.

I know there is a script that could be useful to look at because, if I understood your post correctly, I think he may had to solve the same handlers problem. I have actually used it to achieve exactly this action flip thing. It's Dkwroot's swap points script. You can find it here: http://www.lostmarble.com/forum/viewtop ... ot#p173070

I use this script to flip my turn actions. You need to have a symetric body part (like a head shape o a torso). The mirror points script is useful for that.

For the rest of the parts that are not symetric but specular, like limbs or eyes, you obviously have to animate both directions manually since they are not the same animation, but if you created your character centered in the X axis like people usually do (its X position value should be 0, its Y position value doesn't matter) then you can use a copy of one side (like the left arm) to be the other side (the right arm) so you can not only easily reuse the drawing and the bones but copy the keyframes of the actions and reuse them too. You have to revert the order of the keyframes, using the reverse keyframes feature selecting all the keyframes, holding alt and draging to the left. You then have to go to each keyframe of the action to select all the points of the drawing, flip them, and then change the sign of its X position value (for example if it was -23 then you change it to 23).

If all these things could be automated to a click it would be super useful.
Daxel
Posts: 996
Joined: Wed Mar 27, 2019 8:34 pm

Re: Smart bone action flipper - flipping control handles

Post by Daxel »

I also remembered that months ago I saw that our forum mate Mult Rush posted a video about an incredibly cool tool he is developing that looks like it can reuse limbs with ease and create flipped versions of them with their smart actions working correctly, between other things.

https://www.youtube.com/watch?v=dIdPWnXeFpo
User avatar
heyvern
Posts: 7035
Joined: Fri Sep 02, 2005 4:49 am

Re: Smart bone action flipper - flipping control handles

Post by heyvern »

The point:FlipControlHandles() does a bit of what I need so, thanks for that.

The issue I have been struggling with is how to get the whole pile of data for control handles from one point to another. There is a bit of explanation and some sample code I got working from the mohoscripting snippets section https://mohoscripting.com/snippets/5 about converting handle positions to useable values which makes absolute sense but WOW! 5 different properties for every point is proving troublesome to get my head around.
YIKES! No wonder Mike was reluctant to add bezier to Moho for so many years. :) It never occurred to me how much data is associated with every single point when you have that seemingly simple feature.
Daxel wrote: Fri Apr 22, 2022 2:42 pm I also remembered that months ago I saw that our forum mate Mult Rush posted a video about an incredibly cool tool he is developing that looks like it can reuse limbs with ease and create flipped versions of them with their smart actions working correctly, between other things.

https://www.youtube.com/watch?v=dIdPWnXeFpo
Holy cow! Yes along with a bazillion other features that tool appears to do exactly what I want.
I simply don't have the brainpower to produce something that sophisticated or complex, I have much simpler expectations and still plan on continuing with my version. It will simply be a "one-trick pony". Nothing fancy, just one-click flipping of smart bones and actions. At the moment if I can simply duplicate and flip the ACTION alone I will be happy. I may try to duplicate the bones as well. Scripting the bones is so much easier to work with than points I've found.

I have made headway on my script with the posts here - THANK YOU, so I think I will continue working on it.

p.s. Yes yes, I haven't even considered the additive bone transforms yet. A lot of the control handle values are ALL THE TRANSFORMS including other smart bone actions.
User avatar
heyvern
Posts: 7035
Joined: Fri Sep 02, 2005 4:49 am

Re: Smart bone action flipper - flipping control handles

Post by heyvern »

Yeeehaaaw! I pounded it with a sledgehammer and finally, I got it working. Good grief it was an uphill battle. I have soooo missed out on a bunch of new features. It's tough trying to catch up.
I am happy. Thanks for the guidance. A little bit here, a little bit there and finally put it together. Most of my confusion and problems had to do with M_Curve:PointID(point) versus M_Mesh:PointID(point). I forgot they aren't the same. I was getting really wonky inconsistent results because I transferred the completely wrong control handle values.

p.s. I use to wish that complex artistic or technical tasks like designing a website, drawing a character or coding a new tool could be converted to brute force labor. If you need to dig a hole you just grab a shovel and dig. Eventually, it's just done. It would be so cool if we could just hit a rock with a sledgehammer and eventually end up with a cool new tool script. :)
swingsoneto
Posts: 26
Joined: Mon Feb 20, 2017 9:23 pm
Contact:

Re: Smart bone action flipper - flipping control handles

Post by swingsoneto »

heyvern wrote: Sun Apr 24, 2022 6:28 am Yeeehaaaw! I pounded it with a sledgehammer and finally, I got it working. Good grief it was an uphill battle. I have soooo missed out on a bunch of new features. It's tough trying to catch up.
I am happy. Thanks for the guidance. A little bit here, a little bit there and finally put it together. Most of my confusion and problems had to do with M_Curve:PointID(point) versus M_Mesh:PointID(point). I forgot they aren't the same. I was getting really wonky inconsistent results because I transferred the completely wrong control handle values.

p.s. I use to wish that complex artistic or technical tasks like designing a website, drawing a character or coding a new tool could be converted to brute force labor. If you need to dig a hole you just grab a shovel and dig. Eventually, it's just done. It would be so cool if we could just hit a rock with a sledgehammer and eventually end up with a cool new tool script. :)
My apologies for the thread necromancy, but I'm super interested in this discussion. Have you been able to get this working? I noticed your thread here https://lostmarble.com/forum/viewtopic.php?t=24954 and saw that you had accomplished this back in 2013. Are there updates to Moho's backend that have broken the functionality?
Post Reply