Animated shapes sort script

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

Moderators: Víctor Paredes, Belgarath, slowtiger

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

Animated shapes sort script

Post by Genete »

Hi!
I've told my self to not continue creating more scripts and REALLY starting to make some animation once and for all!...
But I said "what the hell! I get fun creating scripts!, so go fot it!" and here I am with an new adventure.

Someone said that my sort_shapes script need the other 3D scripts to perform a Z sort of shapes. That's completely true and one cannot work with the other.
But it is true also that the sort-shapes scritp don't need to retrieve the information from the 3D script exclusively. It can obtain the "Z value" from any other source.

I have figured out how to do it.

First I have to create an script that (at frame 0) create a bone for the selected shape. That bone would have special characteristics:
1.- Its name is based on Shape's ID + a extension (it maybe ".sh"). For example Shape 23 would have a associated bone called "23.sh"
2.- The bone's relative X position would represent the shape "Z position". It is 3D meanless and its only porpouse is that the embedded script can perform the "Z" sort.

In this way it is so easy to retrieve the "Z" of a shape. Just composite its corresponding bone's name based on shape's ID, locate the bone and get its "Z value" (represented by the X value of the bone).
The problem comes when the embedded script raise or lower a shape based on its "Z" value. Then the link with the bone is broken due to the fact that the every shape's ID is also its staking order (so the script change its internal shape's ID everytime it rasie or lower it)
To solve that I have realizaed that I can make the same change into the bones's names. Just warp the bone corresponding to the shape to be raised (lower) and its upper (lower) bone and change its name accordingly.
In this way I don't need to store any information on the shape and probably the script would work better that the other for 3D (besides that it would do less calculations). Bone's names are changing by frames as well as shapes changes its ID.
The user only would take care about bone's X positions.

Let's do it! It would be SO FUN! :D (I hope it work)
-G
Genete
Posts: 3483
Joined: Tue Oct 17, 2006 3:27 pm
Location: España / Spain

Post by Genete »

Here is the file:
http://www.darthfurby.com/genete/Script ... pesort.zip

Samples and usage in this thread:

viewtopic.php?p=46012#46012

Have fun!

-G
Post Reply