Z sort layers automatically

Have you come up with a good Moho trick? Need help solving an animation problem? Come on in.

Moderators: Víctor Paredes, Belgarath, slowtiger

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

Z sort layers automatically

Post by Genete »

Hi!
As I announced in other post, I was working on a way to use the 3D rig skeleton to automatically Z sort the layers of your model.

Here it is!!!!

http://www.darthfurby.com/genete/Script ... layers.zip
http://www.darthfurby.com/genete/Script ... layers.swf

PLEASE BACKUP YOUR FILES FIRST!. THIS IS A UNDER DEVELOPMENT SCRIPT AND I CANNOT GUARANTEE THAT SOME ERROR CAN CAUSE DATA LOOSE.

CONTENT of Zsortlayers.zip:
  1. 3Dgrid10.lua: A new version of the embedded script that allow move in 3D points as shown in this and this threads. It have now a new subroutine that make the following: Search all the chils layers of the bone layers, check if the layers is binded to a bone, if yes, then check if the bone is a .pt (have included a Z value from the script) then assign the Z value to the layer.
  2. sortlayers.anme: A sample file.
USAGE:
  1. Create a 3D skeleton that can rotate with the masterX and masterY bones. Follow this tutorial to create it from this thread.
  2. Embed the 3Dgrid10.lua file to the bone layer
  3. Be sure that "Sort layers by depth" is enabled in the bone layer.
  4. Add some layers (they could be any kind of layers) and bind them to the .pt bones (the horizontal ones in the font view)
  5. Automatically binded layers would move with the .pt bones and also modify its Z value and its order.
This tool combined with the DarthFurby's head turn by actions technique would allow make a complete 3D head turn easily!!! Just morph the shapes to their front, 3/4 left, 3/4 right, side left, side right and the back corresponding positions and it would work perfectly!!!.
DarthFurby's technique has a drawback that is the fact that you have linear translation of the points and that you have to control the overall position of the shape to move it from side to side. Also need to change to another composition to make the shapes change its order.
This simplification of the 3D rig would allow (I hope!) use Darth's technique but with the advantage of forget about shape sort and forget about shape main position(what is done by the 3D skeleton). You have only to morph the shape to match the head turn.

I have created a new post because I believe people would enthuse with this technique a little more than with the full 3D. :shock:

In the example the skeleton is a flat square that you can see in layers
skel FRONT and skel SIDE
Also I have taken apart (to the right) the bones of the side view because they don't contribute to the sample.

Finally I have left the real Z value of the bone unaltered to copy it to the layer. This produce some 3D distortion (small shapes for negative Z and bigger for positive Z). Do you think I would add a feature that allow the user select the Z increment to allow or restrict the Z distortion? Remember that usually people don't like that because they are looking only sort layers and don't magnify or reduce its size. It could be done using a bone scale.

Last. This technique can be use also in combination of other 3Dgrid embedded in the child layers. It allow multiple limbs easily done!. The bad new is that they are "point unconnected" so that should be done by hand. It is time for experimenting. :wink:

Please all comments are welcome.
Cheers!
-G
Last edited by Genete on Mon Aug 06, 2007 8:04 pm, edited 1 time in total.
User avatar
jahnocli
Posts: 3471
Joined: Fri Oct 29, 2004 2:13 pm
Location: UK

Post by jahnocli »

Hi Genete,

If I was brainy enough, I would no doubt appreciate the importance of what you are doing rather more! I did start up the anime file in the zip, and got this message:

"invalid type in variable assignment. Value is 'nil'; 'number' expected."

Is this important? Or should I just ignore it? Or am I not doing something simple (most likely).

Regards,
J
You can't have everything. Where would you put it?
User avatar
JimmyC
Posts: 158
Joined: Thu Jul 05, 2007 5:10 pm
Location: UK

Post by JimmyC »

Happens to me too - same error - but only the first time in. It occurs around Frame 114. Some variable does not seem to have a value on the first time in.

Looks like a great script to me. Thanks for your work. I will know more about it in the future I hope :)
Genete
Posts: 3483
Joined: Tue Oct 17, 2006 3:27 pm
Location: España / Spain

Post by Genete »

Hi both!.
Same happened to me and no idea what does it means. It is a weird message because don't refers to any lua code line.
I have just created this script this evening in more or less half an hour, based on the previous 3Dgrid.
The fact is that although the message is happening the script works. Isn't it?

Please remember that some crash could happen and this is for experimenting. Backup your file previous to embed the script. I'll update the first post.

All comments are welcome.

I think that the 3D grid script is not suitable for complex models due to the amount of computation needed (almost my computer slow down a lot when using 500+ bones and 100+ shapes with z sort). So if we rig a 3D skeleton where we can hang on the clothes of our model then the script would work more light and is more suitable for animation.

To make a head turn it would be needed an skeleton that connect eyes, eyebrows, nose, ears, mouth, etc to the bones of the 3D skeleton. Then using actions create morph for the front, side left and side right. Later you can create new actions based on the already created actions just keyframing the point and bone movement (normal bone not scripted 3D bones) at an intermediate frame. Then record the action and that's all.
You should think on the .pt bones like a local coordinate system for your part of the head (or body). It would morph for each position / view using point and bone motion if needed. The 3D skeleton allow you move the parts of your head (body) properly in 3D.

I think it would let a more 3D look to the standard way of doing the things but without loosing the look and feel of a 2D vector animation.

A full 3D animation with vectors is useful to create props (specially with sharp angles) not for alive models.

I'll test the script with more layers to see if the error produces some other drawback. Meanwhile enjoy!

-G

PS: I have an idea of store the Z in other place instead of the bone itself. Maybe I need to include more code lines but fairly it would work better. Let's see what can I do.
User avatar
JimmyC
Posts: 158
Joined: Thu Jul 05, 2007 5:10 pm
Location: UK

Post by JimmyC »

Sounds very interesting. It would take a lot of work out of head turns.

I'll keep an eye on this thread. Great work!
User avatar
Mikdog
Posts: 1901
Joined: Tue Jul 05, 2005 3:51 pm
Location: South Africa
Contact:

Post by Mikdog »

Nice.

Any chance of a couple screenshots so that it is clear in a couple glances what the script does?

I see you and other dudes going nuts in the 3D head turn thread, but don't follow it because I'm not sure what the heel you guys are on about!

However, this looks interesting. Don't quite yet understand what problems it solves, etc...
Genete
Posts: 3483
Joined: Tue Oct 17, 2006 3:27 pm
Location: España / Spain

Post by Genete »

Mikdog wrote:Nice.

Any chance of a couple screenshots so that it is clear in a couple glances what the script does?

I see you and other dudes going nuts in the 3D head turn thread, but don't follow it because I'm not sure what the heel you guys are on about!

However, this looks interesting. Don't quite yet understand what problems it solves, etc...
I better give you a rough example. (ten minutes prepared sorry for the drawing and the bad layer hide. It is only for give a visual example of my intentions)

http://www.darthfurby.com/genete/Scripting/sample.anme

Hope it clarifies what I want.
-G
Post Reply