Genete's scripts

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

Moderators: Víctor Paredes, Belgarath, slowtiger

Genete
Posts: 3483
Joined: Tue Oct 17, 2006 3:27 pm
Location: España / Spain

Re: Animated Sort Shapes Based on Bones Position Script

Post by Genete »

Rudiger wrote:So, I tried out the sort_shapes_by_bonesv2.lua script and "Yeaaaaah!" is right! It works great and you don't even need to name your shapes. It would be nice if the strength of the generated bones were automatically set to 0 though.

Thanks for delivering on your promise, and so quickly. I can't wait to try this script out on some of my stalled projects.
Thanks! you're welcome!
I did the update yesterday very late in the night and I was so tired to fix it due I realized that missing once the file was uploaded. Obviously the strength of the added bones must be set to 0 to avoid influence on the model.
I have updated the file (ge_bones_for_shapes.lua) and now it set the strength of the added bones to 0. Please download it and update your version. I've tested and works OK.

Did you find useful the bone_of_shape button tool?

I think this script can be used in any place you need shape sort during animation and don't have influence on what ever other script or technique you use to perform your animation.
I like so much this script! :D
-G
Rudiger
Posts: 786
Joined: Sun Dec 18, 2005 2:25 am

Post by Rudiger »

genete wrote:I have updated the file (ge_bones_for_shapes.lua) and now it set the strength of the added bones to 0. Please download it and update your version. I've tested and works OK.
Cool thanks. That should save some time if you've got loads of shapes.
genete wrote:Did you find useful the bone_of_shape button tool?
I wasn't able to get this tool to do anything useful yet, so I thought it was maybe unfinished. If I have a shape selected, I'm able to click on it and doing that highlights the icon and gives me a cross-hair cursor, but no bone is selected. I can click on the screen, but nothing happens. Am I doing something wrong?

This script is useful not just for animating shape ordering, but provides a superior way of organizing shapes than is currently available. I sometimes use many semi-transparent variable width strokes to get an airbrushed or watercolor effect with vectors. I could add hierarchy to the shape ordering control bones so that I could move, say, all of the shapes that make up the left arm behind all of the shapes that make up the right arm with one click! This will save me buckets of time.
Genete
Posts: 3483
Joined: Tue Oct 17, 2006 3:27 pm
Location: España / Spain

Post by Genete »

Rudiger wrote:
genete wrote:I have updated the file (ge_bones_for_shapes.lua) and now it set the strength of the added bones to 0. Please download it and update your version. I've tested and works OK.
Cool thanks. That should save some time if you've got loads of shapes.
Hehe. Did you know that you can select several bones at the same time (using Select bone tool) and set its strength to zero at the same time using the numerical input of the Bone Strength tool?. AS is a box of surprises man!. :wink:

Rudiger wrote:
genete wrote:Did you find useful the bone_of_shape button tool?
I wasn't able to get this tool to do anything useful yet, so I thought it was maybe unfinished. If I have a shape selected, I'm able to click on it and doing that highlights the icon and gives me a cross-hair cursor, but no bone is selected. I can click on the screen, but nothing happens. Am I doing something wrong?
That was my fault. You have to include this code instead inside the _tool_list.txt file:

Code: Select all

button ge_bone_of_shape   ...
If you write tool instead of button then it doesn't work. Instructions updated.
Rudiger wrote:This script is useful not just for animating shape ordering, but provides a superior way of organizing shapes than is currently available. I sometimes use many semi-transparent variable width strokes to get an airbrushed or watercolor effect with vectors. I could add hierarchy to the shape ordering control bones so that I could move, say, all of the shapes that make up the left arm behind all of the shapes that make up the right arm with one click! This will save me buckets of time.
I'm glad on that!
Cheers!
-G
Rudiger
Posts: 786
Joined: Sun Dec 18, 2005 2:25 am

Post by Rudiger »

Thanks for the tips. Everything now works perfectly.

I have one more suggestion for improvement, but feel free to ignore it, as it already works great how the way it is. It would be great if ge_bones_for_shapes.lua checked for existing bones with the magic naming first and added bones only for new shapes. At the moment you either have to add the bones for new shapes manually or start from scratch. Like I said, it's only a a very minor wish, and not worth spending any great amount of time on.

Anyway, thanks again for this awesome script.
Genete
Posts: 3483
Joined: Tue Oct 17, 2006 3:27 pm
Location: España / Spain

Post by Genete »

Rudiger wrote:Thanks for the tips. Everything now works perfectly.

I have one more suggestion for improvement, but feel free to ignore it, as it already works great how the way it is. It would be great if ge_bones_for_shapes.lua checked for existing bones with the magic naming first and added bones only for new shapes. At the moment you either have to add the bones for new shapes manually or start from scratch. Like I said, it's only a a very minor wish, and not worth spending any great amount of time on.

Anyway, thanks again for this awesome script.
I though on that from the beggining but during script develpment I only focus on if it works. Now that I know it works I can do that with the automatic creator of bones. It wouldn't be so difficult.
The problem is that if you have altered the shape order using bones position, then the bones names have changed also. Running the script again would move the bones altering their Y position what can confuse a lot to the user. Even I don't know what would happen if I run the script meanwhile the embedded scritp still being embedded... I have to check if it works.

One more thing: If you add a new orphan shape and still using the embedded script then you would mess up all the shapes - bones relationship. Finally the script don't know what is doing... So, if you're editiong the model then you should un embed the script, run the bone adder script (the improved one) and embed again the script. If not it would be a problem.

Imagine that you have two shapes (internal ID are 0 and 1, that is its order also). Then you add an new shape and place it at the bottom of the stack (becomes shape ID=0). How can the script know what bones have to respect the names? Probably the added bone would be for the last number (i nthis case numbre ID=3)... Difficult to predice.

As I said it is better not touch the Raise up or Lower down buttons or their relative menu entries if you use the embedded script.

It would be a great inprovement that you fix the bones at any time as if they were part of any kind of property of the shapes... I have to think about it. This would change the shapes sort concept, though.
Added to the TODO list.
Thanks Rudiger!
Cheers!

PD: I think it could be better that the script erases any specially named bone in the skeleton and add new ones for all the shapes. It would save some time to the user and wouldn't allow the user make strange things with more shapes than allowed. Maybe I change the embedded script to don't allow shape order if there is not exact same number of bones than shapes. It would prevent for weird things.
User avatar
heyvern
Posts: 7035
Joined: Fri Sep 02, 2005 4:49 am

Post by heyvern »

Genete, have you considered using shape names?

I haven't tried this or looked at the script reference for it but could you name the shapes and link bones to the shape names somehow and store the Z value. Then you could run through the list of shape names and match it to the bone names. You wouldn't have to rename the bones and bone and shape names that aren't named properly would be ignored.

Just a shot in the dark.

-vern
Genete
Posts: 3483
Joined: Tue Oct 17, 2006 3:27 pm
Location: España / Spain

Post by Genete »

heyvern wrote:Genete, have you considered using shape names?

I haven't tried this or looked at the script reference for it but could you name the shapes and link bones to the shape names somehow and store the Z value. Then you could run through the list of shape names and match it to the bone names. You wouldn't have to rename the bones and bone and shape names that aren't named properly would be ignored.

Just a shot in the dark.

-vern
Remember that shape names are not available for user interface. It is a LM_String and AFAIK there is no member function to retrieve the shape's name like the Name() function for the bones.
The only working way that I have found to keep track on shapes order is its ID (what at the same time is the shape order). I could have had an array of shapes ID and bones ID that could do same job. But when I started the embedded script I made the bones by hand so the only way to tell the embedded script what bone represent what shape was using bone's name that is something that user can store over AS interface. As well as bones ID are something that can change "randomly" if you delete or add a bone I decided not to use bone ID for that task and use bone name.
Remember that the embedded script look for .sh bones every time the script runs. How can associate the bones to the shapes if I don't keep track of the corresponding shape on its name? Points vs bones is different. Points ID don't change during animation. Shapes IDs YES and it is the thing that the script does...

Maybe you can find a better way to perform that shape sort based on bones positions... Please don't hesitate on modify the code, reuse it or adopt to new uses or approaches to the same solution. it'll be welcome.
Best
-G
User avatar
heyvern
Posts: 7035
Joined: Fri Sep 02, 2005 4:49 am

Post by heyvern »

Hmm...

Remember how we discovered you could store any information with a bone? Just stick in a variable and that value stays with the bone.

So I may try this when I get a chance...

The bone is linked to a shape in a specific order or ID. The name of the bone won't change, the shape order VARIABLE or Z value changes.

If a bone named "Bobs_big_bone.sh" has a Z or shape ID value of "6" it controls that shapes order. Change "Bobs_big_bone.sh" Z value to "4" after changing the shape ID or order to "4" and the bone has the same name just the value has changed.

You could even "hard code" a shape order "range". This would allow other shapes to be not effected possibly. If the shape "range" is from 1 to 10, or something like that, those would be the only shapes reordered.

Maybe the shape "range" could be linked to the bones name as well. You create "sets" of bones using a different extension that could "reorder" shapes that are only in that range.

I did this with my "flipper" script. I use a name with "bonename.mstTS" or "bonename.slvRT". I check for the slave or master and then check the last two characters to determine what property gets changed. TS is "Translate-scale" RT is "rotate-translate".

So for example, a set of bones named "bonename.sh-1-4-7" would be the first bone in that range and only reorder shapes that are in the range of "4 to 7" in the shape order.

This sounds promising. I will give it a shot. I love having more flexibility. It could get very tricky to manage though.

-vern
Genete
Posts: 3483
Joined: Tue Oct 17, 2006 3:27 pm
Location: España / Spain

Post by Genete »

Remember how we discovered you could store any information with a bone? Just stick in a variable and that value stays with the bone.
Yes I remember it, but I have seen several "Attempt to use z a nil value" messages or "Z = nil" coming from my sort shapes for the 3D model. I'm afraid with that.

Regarding to the idea of having controlled some shapes yes and some shapes not it could complicate a lot the script due to if you have two sets separated (shapes 0 to 5 controlled 6 to 8 not controlled and 9 to 13 controlled for example) then there will be problems when you cross the X position of a bone of the set 0-5 with a bone of the set 9 -13. How do you know how many times you need to raise (lower) the shape to put it in that place?. How many sets are allowed? how do you care of the sets boundaries?.... Mmmm better to have all the shapes under control and move only what you need. Remember that you can move groups of bones using move points / bones from fazek. In that way you can move an ordered set of bones to any place an the script would do the job.

Please comment us any other research you do in this field.

Meanwhile enjoy the new version I have made for the bones creator. It would recycle the already existing bones with a proper name for the shapes and place it at the proper position. With this new creator script you can work freely creating shapes and deleting it and just run again the script and the bones would be put in a row like a good soldiers battalion. It is funny! If you create a new shape and the bone already exists then the shape's stack position is determined by the bone's X position!! That's cool!.
http://www.darthfurby.com/genete/Script ... apesv2.lua
Initial post updated.
-G
Genete
Posts: 3483
Joined: Tue Oct 17, 2006 3:27 pm
Location: España / Spain

Post by Genete »

PLEASE RELOAD sort_shapes_by_bonesv2.lua!!! I have discovered a bug that did not allow to sort shapes if other bones exists in the mesh. Now it is corrected. and the link updated.
-G
Genete
Posts: 3483
Joined: Tue Oct 17, 2006 3:27 pm
Location: España / Spain

Post by Genete »

Hi folks!
I've added a new script set to freeze points to prevent movements under drawing tools and even under bone influence. Please visit the link in my signature.

Enjoy!

-G
Rudiger
Posts: 786
Joined: Sun Dec 18, 2005 2:25 am

Post by Rudiger »

Hi folks!
I've added a new script set to freeze points to prevent movements under drawing tools and even under bone influence. Please visit the link in my signature.

Enjoy!

-G
Wow, always wanted that feature for drawing tools. Very nice! I'm even more intrigued about the masking of bone influence, though. If you could make the masking selective based on the bones, then you would have a means of rigging a character without having to break it apart. That would truly be a gift for every Anime Studio user!!

The way I always thought it could work is you select a group of points, then hit "mask from bone" and select the bone you want masked. From then on that bone would no longer be able to influence that group of points. For example, you could unbind the points that make up a character's torso from the arm bones. To me, this is a much cleaner approach than doing it by location, as you do with the whole break-apart scheme.
Genete
Posts: 3483
Joined: Tue Oct 17, 2006 3:27 pm
Location: España / Spain

Post by Genete »

Thanks. I'm glad you find it useful.
Beware that bones could not move the points that are frozen but can make a keyframe for them (that obviously place the points always at the same place). You can remove the keyframe just selecting the points again using the Select frozen points tool and deleting manually the keyframe for them.
AFAIK avoid inserting a keyframe for points, from any of the existing tools should imply redo all those tools...
I have to think about it because I could try to delete any added keyframe for those frozen points during the execution of the embedded script...
-G
Genete
Posts: 3483
Joined: Tue Oct 17, 2006 3:27 pm
Location: España / Spain

Post by Genete »

Hey!

As requested by DK, I've modified the "freezer" scripts to allow limit the movements of the points beyond a certain X or Y values.

Please review the initial post and tell me if it works. :D
If you need help using them let me know.

-G
User avatar
heyvern
Posts: 7035
Joined: Fri Sep 02, 2005 4:49 am

Post by heyvern »

This is cool!

I've always wanted a bone translation limit... this might be a possible alternative!

p.s. Genete, where have all the scripters gone? Are we the only ones left? ;)

-vern
Post Reply