Genete! Springy bones 3D rotation with one bone.

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

Moderators: Víctor Paredes, Belgarath, slowtiger

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

Post by heyvern »

Genete,

As soon as they can follow the steps and run those scripts on their own creations people will get excited.

That's when I got excited!

It was funny. I was drawing RANDOM SHAPES! Just goofy weird shapes and running the scripts on it and making them "3D".

I can see this having another possible use: creating simple 3D objects for props or backgrounds. Just draw a front and side view, add the bones, rotate to the view you like, convert the bone motion to point motion on one key frame and you have a realistic simple "3D" mesh for your project. You don't even need to keep the bones. Or you could keep the file and use it for different angles.

Imagine a set of simple 3D props like chairs, tables etc. They would be "pre rigged" and you can rotate them and use the "static" vectors for scenes in another project file. This could work for any style.

It would be very cool if down the road a script could "export" the vector point motion of the bones to a new AS file.

EDIT:

You see why these experiments are so great? So many new directions and ideas come up.

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

Post by Genete »

Although I wouldn't want to remove any bone I would like you illuminate me with the script or the link to it what converts bone motion to point motion. I'm a little lazy lately 8) to search it in the forum.

Also regarding on this tip it would be very easy put the rotated layers inside a switch layer for those who only want some amount of rotation and don't care about its rotating velocity.

The idea of making 3D objects for props or backgrounds is very useful. You can make buildings very quickly (even its drop shadow). Just build them in orthogonal view and link its rotation masters to be constrained to a bigger master bone. Well current buildings done with rotated layers are limited to the classic parallelepiped or the dog house (always flat walls). If you want to do a more baroque one you can do it avoiding use real 3D obj and using instead this 3D rig.
The shadow can also follow the direction of some kind of sun masters bones. just rotating the masters bones and scaling the helper bones properly I'm sure a automatic drop shadow can be easily done.
You see why these experiments are so great? So many new directions and ideas come up.
Yes but I feel that I have a crossroad next to the last one and don't know which one select first. It is like a labyrinth extremely spread. Don't want to loose nothing undeveloped on the way...
-G

(I saw Rasheed yesterday logged in the forum during a few minutes... but he didn't say "hello, I'm back" :().
User avatar
dreeko13
Posts: 187
Joined: Fri Oct 13, 2006 8:29 am
Contact:

Post by dreeko13 »

i cant wait for this method to be perfected

i dream of creating side and front views of a head and having the 3d equivalent produced for me

keep up the good work for those of us who have no scripting power!
Genete
Posts: 3483
Joined: Tue Oct 17, 2006 3:27 pm
Location: España / Spain

Post by Genete »

dreeko13 wrote:i cant wait for this method to be perfected

i dream of creating side and front views of a head and having the 3d equivalent produced for me

keep up the good work for those of us who have no scripting power!
I'm working on the refining of the front / side view rig and in the automatic shape ordering. Maybe this weekend a small videotutorial would be finished. I'm having problems with shape management due to the problem to access to the points that belong to the shape (in fact the points belongs to the curves and a shape can share a lot of different curves not only one). I think I got the basic idea scripted but need sometime to be refined.

The scripts for front/side view are ready. Included the ability of making limbs (like the 3D tail). Also the automatic 3D rigger script works fine.
I don't want to post the final versions until I make a videotutorial to make you all understand how they work.

The shape ordering is a secondary issue that is not a roadblock to the 3D grid or the 3D automatic rigger.

Keep connected!
-G
User avatar
funksmaname
Posts: 3174
Joined: Tue May 29, 2007 11:31 am
Location: New Zealand

Post by funksmaname »

8) Cant wait for the video tutorial as, being late to the party, ive been too lazy to try and get my head around these 7 pages! :)

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

Post by Genete »

A couple of questions regarding the shape ordering.
I know how to run through the points of a particular shape. Accessing a point I can access to the bone and accessing to the .pt bone I have all the information to the rest of 3D information.
I have realized that the calculation of the Z dimension of the bone (point) can be done inside the 3Dgrid loop for every frame. Not so much additional computation but the Z value is always available. In that script I have available all the 3D data to easily calculate the Z value.
Where do you think I can store it? Directly to TboneSets matrix or to the bone itself like a custom variable? For future compatibility I think it is better to store it to the TboneSets matrix what is an independent variable.
I still haven't found how Moho store the order of the shapes. Is the order the ID? and that's the reason that the name of the shape is not a normal string but a LM_String?
I'm very close to decide to create a table with an table index, the shapes ID and the Z value. Then reorder the table by its Z value moving the shape IDs with the Z values. If you don't find something regarding shape order information 'll do it like that,

---
About the creation of the TboneSets matrix, making a loop searching by the skeleton and and its bone names and comparing them with the custom extensions... Why don't let the automatic 3D ri script do it? :D It would be very easy and straight. It would not work if you do the rig manually but you can always use the 3dgrid7_menu.lua script to do that job!! I'll put this idea in the TO DO list...

That's all for today.
-G
User avatar
heyvern
Posts: 7035
Joined: Fri Sep 02, 2005 4:49 am

Post by heyvern »

I have played around very little with shapes and scripting.

As far as I can tell shape IDs are much like everything else in AS/lua, the IDs represent the order of that shape at that moment. If you change the shapes order, raise it or lower it, the shape gets a "new" ID based on its new location.

I think all the shapes will need to be named. If a shape has no name it only has the ID which changes if you change its order. I have seen this with layers. Without a name a layer can't be "tracked" if you change the order.

I could be completely wrong about shape IDs. It could be the shape ID doesn't change. I am just assuming that shapes are similar to layers. A layer ID is based on the order in the layer palette. If it has a name though you can "find it".

Bones however can't have their "order" changed as far as I know, unless you delete and recreate them. Maybe shapes are like bones. They keep their ID based on WHEN they are created and if other shapes are deleted.

For instance with bones, if bone "boneName" has an ID of 12 and you delete bone ID 10 then bone "boneName" becomes bone ID 11. You could never make bone "boneName" have an ID of 6 with out deleting all the bones before it till it becomes ID 6. You can't change the ID of a bone but its ID can change.


Side note regarding Moho vs. ASP and bone IDs:

I discovered this when working on my copy/paste bone script with Moho. I could paste the bones in a new order because they were being created "new" by the script. If I did that all the IDs would change of course. This is what made the constraints issue difficult.

However this was in Moho not ASP. Apparently AS has a different way of handling bone IDs and constraints. Deleting bones in AS doesn't change constraints. The code for bone selection/deletion in the bone tool for AS is the same as far as I can tell. there is something else going on internally to AS that has changed from Moho. This might be true for shapes but I have no idea.

This will require some experimenting.

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

Post by Genete »

Genete wrote:About the creation of the TboneSets matrix, making a loop searching by the skeleton and and its bone names and comparing them with the custom extensions... Why don't let the automatic 3D ri script do it? :D It would be very easy and straight. It would not work if you do the rig manually but you can always use the 3dgrid7_menu.lua script to do that job!! I'll put this idea in the TO DO list...
-G
Forget this for the moment.
It is better that the creation of the TboneSets matrix is done AFTER the complete rig is done. The automatic front rig creation need that the selected bone be a root bone to properly set the value of the Rx and pt bones. It could be automated but is very complicated. Because it would need to check if the selected bone is a pt bone to make it root and later link it to its root bone again... I'll put it in te TODO list...
For the moment is better continue with this:
One script to do all the job: 3Dgrid7.lua
Two scripts to do all the job: 3Dgrid7_menu.lua and 3Dgrid7_embed.lua. The first store the TboneSets matrix and the second move the points.

Regarding to shapes... Aarrgh! it is a bad new if the Shape ID changes when the order changes.... It would be difficult to trace the shape ID ever time... Mmmm let me make a couple of tests and see what means the ID of the shape...
-G
Genete
Posts: 3483
Joined: Tue Oct 17, 2006 3:27 pm
Location: España / Spain

Post by Genete »

Aaaaarrgh! Shape ID is shape stack order!!!!!

So if I "lower to back" a shape it becomes to be ID = 0. How in the hell can I make a loop though the shapes in a mesh to lower to back one by one if they change its ID dynamically????. If I make a "lower to back" operation I loose all the ID of the shapes!!!!

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

Post by Genete »

Well, not so bad new at all...
The Z value need to be stored inside the shape object. In this way I can perform a double loop stack sort just considering the Z value of the current shape.

One question: If there is a bone layer with embedded script and a vector layer inside with a embedded script also... What script is called first? the vector one or the bone layer one?
This is important because the bone layer embedded script calculates the Z of the points and the embedded script for the vector layer would do the shape Z order based in the Z values of the points that can be obsolete.... Well it would be only one frame in the worst case.

I'm very close to finish the shape sort script ... almost I believe it...

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

Post by Genete »

Heyvern!

PLEASE try this files and let me know what you think.
http://www.darthfurby.com/genete/Script ... _trial.zip

There are tree files there:

3Dgrid8.lua : A modified version of the embedded script that stores the z value in the bone object. It do it at ptbone.fPos.z. Very risky but works. 8)

sample.lua: A menu script that read the shapes existing in the vector layer and locate its points and add the Z value of the associated parent bone of each point of the shape. It must be called with a vector layer selected. It is prepared to convert it to a embedded script. Don't return nothing only store the average Z value to the shape object. The code to run through the points of the shape is mainly taken form fazek's utility file code. THANKS FAZEK!. YOU'RE THE BEST! There are lots of waste code lines commented from previous trials. Just to erase them...

sample2.lua: A menu script that read the Z value of the shapes of the current vector layer. Only for testing. It must be called with a vector layer selected.

Usage:
a) Create a 3Drig as usual.
b) Embed the new 3Dgrid8.lua instead the previous version.
c) Once rigged call the sample.lua script via menu. Do it at any other frame than 0 to be sure that the embedded script have been called almost once.
d) Then call the sample2.lua menu script. It will show you the average Z value of the shapes.
e) Move the shapes in 3D.
f) Repeat steps c) and d) to obtain a new Z of the shapes.

Also you can play with the Raise up and down buttons to see how the ID of the shape changes but not its Z value.

I'm so close to create the automatic shape order based in its 3D position of the associated bones. :D
-G
User avatar
heyvern
Posts: 7035
Joined: Fri Sep 02, 2005 4:49 am

Post by heyvern »

I will give this a try!

Don't forget shape names don't change. So if you could somehow store the initial z value with the name you could use the name of the shape to change order.

Use the name "as the z value". I don't know how you would do this or if it would be better than what you have already done.

Plus the shapes would need to be "renamed" by the script. It would be a pain for the user to have to figure out what shape to edit based on a scripted name that is just a number.

Maybe the z value could be "added" to the name of the shape like an extension when the script is first run?

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

Post by heyvern »

Worked perfectly on the first try without any problems!

I haven't looked at your lua code yet but that is a good sign! ;)

EDIT:

Ooops!

Did I do something wrong?

Going to the bone layer to rotate the master bones erases the z values. They become nil when I then click on the vector layer and try to read the z values.

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

Post by Genete »

Mmm It is strange.. I cannot repeat what you say. I only obtain "Z = nil" when call the read script without have been called the store script before. Or if I call the read script being on the wrong layer.
If the error persist please show me how to repeat it.
Thanks Vern!
Let's see if I can finish the Z sorting...
-G
Genete
Posts: 3483
Joined: Tue Oct 17, 2006 3:27 pm
Location: España / Spain

Post by Genete »

And finally...
Here it is!!!

Woooohoooooh!!!!

It makes me goosebumps!!!!

YEEEEAAAAAAH!

http://www.darthfurby.com/genete/Script ... script.swf
http://www.darthfurby.com/genete/Script ... script.swf
http://www.darthfurby.com/genete/Script ... Sample.zip

The zip files contains:
SortShapeSample.anme: the sample file.
sort_shapes8.lua: the embedded script to put in the vector layer.
It could be refined to make the code more efficient but it WORKS!!!
and 3Dgrid8.lua: the embedded script to put in the bone layer.

Just draw, rig, and animate and forget about shape order!!!

:D :D :D :D :D :D :D :D
-G
Post Reply