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

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

Post by Genete »

It would take at minimum 30 minutes to an hour to place all those bones even on a SIMPLE mesh.
Yes, it took me about 6 / 7 hours in total to rig Elsa the giraffe. Well, I was also tunning the face shape and proportions and I was beginning to understand how to do it . It saves a LOT of time. :D

The only difficult (and where there should be an artist behind) is to draw the front and side views properly to be a nice figure and also to be filled by shapes to simulate the 3D volume. I needed crossing lines to perform the head volume of Elsa in this example (the example did not use this automatic script). And I think I have reached the effect (the head edge).

http://www.darthfurby.com/genete/Other/ ... afa13.anme
I didn't know you could program in lua??? I plan to steal your genius once again. I want to use this concept for modifying the positions of bones in my own rig.
In fact I don't. I know programming basics (c and c++ foundations) but the Lua libraries, and the MOHO API are (were) unknown to me. I had to permanently have a look to the Moho scripting help (and to other scripts because the help is bad written) to create this small code.

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

Post by Genete »

One of the problems are the mouth and eye bones and the amount of effort needed to adjust those for different characters. I could use this "technique" to automatically adjust those bones based on the positions of a user modified mouth position/width or eye bones.
For the original 2.5 rig? You're crazy man! Crazier than me!! :wink:
User avatar
heyvern
Posts: 7042
Joined: Fri Sep 02, 2005 4:49 am

Post by heyvern »

Genete wrote:
One of the problems are the mouth and eye bones and the amount of effort needed to adjust those for different characters. I could use this "technique" to automatically adjust those bones based on the positions of a user modified mouth position/width or eye bones.
For the original 2.5 rig? You're crazy man! Crazier than me!! :wink:
Not at all. I don't think this will be that hard.

The mouth posing bones on my rig are... based on position mostly. There are LOTS of bones in the mouth for changing the expressions... but they all are in exactly the same spot and have similar constraints to create the motion. Remember the "compound bone" technique I was using?

All I have to do is adjust the spacing of each mouth bone based on the length and position of a bone the user changes to match their own character drawing.

When I had modified these bones by hand all I did was to change the spacing when the mouth was a different size. I can just divide the "mouth spacing" bone's length by the number of bones in the mouth and redistribute them. Piece of cake.

The eyebrows are EXACTLY the same. One of my test characters had tiny short eyebrows that were higher up on the forehead. Took me ages to move all of those bones.

This could also work for different head shapes to modify those bones. Wider head, shorter head etc.

This is soooooo cool. So much fun. Usually I buy software and all the cool ideas are already done. Or I don't have the programming skills or tools to do anything anyway.

When I saw that script you wrote magically place all of those bones, with names, in the exact positions... I got goose bumps! It was very exciting to see.

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

Post by Genete »

The mouth posing bones on my rig are... based on position mostly
Ah! I remember. But face / head bones used not only position, also length and strength to perform the compound movement... How to script that? :roll:
Another issue is that cool bone offset that you used to avoid mixing the mouth bones with the rest of the face / head bones. You have to take that account when moving the bones by the script.
When I saw that script you wrote magically place all of those bones, with names, in the exact positions... I got goose bumps! It was very exciting to see.
Ha ha, goosebumps (a new world for my english vocabulary). Thanks!
-G
User avatar
heyvern
Posts: 7042
Joined: Fri Sep 02, 2005 4:49 am

Post by heyvern »

Ah! I remember. But face / head bones used not only position, also length and strength to perform the compound movement... How to script that?
Actually no. The bones used to deform the mouth never changed in length or strength when I adjusted for a different face.

Because of the overlap and the fact that most changes were not drastic nothing but adjusting translation was required.

Although I don't see why this couldn't be incorporated into the script. Make the bones slightly shorter for a small mouth, a little longer for a large mouth. In my rig all of these small bones are identical.

the trick was putting the mouth (separating top and bottom lips) into the same general area as the original "template" on frame 0.

The offset didn't change much either at least on my tests. If the bones were moved on frame 0 the offset is the same in relation to the original position. Offset isn't absolute, it is relative. If the bone is moved the offset moves the same amount.

If offset does need to be modified at all this could be fairly simple to apply using the same script or the user could just do it by hand. All of these large groups of bones are children of a few bones at most.

For example all the mouth bones have only 3 bones that require an offset, a mouth bone an upper lip bone and a lower lip bone. The lip parents are children of the mouth. I could even eliminate one of the lip offsets by having it already in place in relation to the mouth bone, so then there would only be 2 bones requiring offset for the mouth.

All of this could be done by using a mesh with points to indicate bone position. Just move the points of a spline for the distance from the eyes to the nose to the mouth to the chin. Same for the distance between the ears and the width of the mouth.

Similar situation for the eyes and eyebrows.

I would think at most there would be 5 to 10 bones in my rig that need offset adjustment for a specific character if I use a script to do all the many tiny bone changes.

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

Post by Genete »

I have taken here one thing you have said in other thread...
Maybe I can store automatically Rx, Ry, alpha0 for a solid rig? instead of using the bone dynamics??
I just checked and you can store any type of new additional values in the bones table.

For instance there is the standard ones I mentioned:

Code: Select all

fTempPos 
fTempLength 
fTempAngle 
fTempScale 
But I just created a new one:

Code: Select all

boneName.vernsValue = "I like chips" 
It is stored in the bone just like the other values and I was able to retrieve it.

You could do this! If you are using the points of a mesh to build the rig anyway you could stick those values in there.

Hey! I don't need to build that crazy tool now for editing those bones for the rig! If rigging is scripted you don't need to touch those bones.

-vern
wait, wait, wait...
Are you telling me that I can store Rx, Ry and alpha0 inside the point itself? Can I do that? Really?
It means that no other bone than the control masters ones are needed?
It means that if I move the original points of the mesh I can modify the values of Rx, Ry and alpha0 just reading its position?

Glup!

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

Post by Genete »

http://www.darthfurby.com/genete/Script ... _3Drig.zip
http://www.darthfurby.com/genete/Script ... -fixed.lua
http://www.darthfurby.com/genete/Scripting/3Dstar.anme
http://www.darthfurby.com/genete/Scripting/3Dstar.swf

masterX and masterY bones must be manually done. Initial angle must be 0.
The central bone to rig the font and side views must have a name and must be the same name to both.
The side view must be a layer copy of the front view. Translated points at frame 0. Side view must have only modified its x coordinate.

The proof is in the pudding. :wink:

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

Post by Genete »

The thing what I'm going to say would send me finally to the hell...

Z buffer for shapes:

Once that Vern said that you can store other values in the Moho objects my mind didn't stop boiling...

The bones what I have created with the automatic script have an special name. They include the ID of the binded point. So accessing the bone you can access the point... And vice versa... If you read this value from the point object:

Code: Select all

fParent
you can directly access to the binder bone. And to its name... and then you can compose the corresponding Rx and Ry bones name search for it and access to its values: length and angle.

Using Rx length, and Ry length and angle (alpha0) and the values of alpha and beta I can calculate the current Z value of the considered point.

So I can write a subroutine that given a point it retrieves its current Z value.

Well,
Now imagine I do following:

I can access to a shape of the mesh and to its composing curve. By its curve to its composing point. And by the points to its Z values...
I can make an Z average of the points of a shape and store to it in a custom value (that's where Vern's idea roks!).
Later with a bubble sort subroutine (or similar) I can Z order the shapes from back to front to make them look correctly in the XY view. To trigger that Z order I'm planning to use a switch keyframe (what really do nothing because it will choose the same vector layer every time) and then it reduces the Z sorting to the minimum needed. It can be turned to be always on (on every frame) if you want.
The Z average calculation and the Z bubble sort should be performed inside a embedded script in the vector layer not the bone layer.

What do you think?
I would need some help to write this script I think.

It have been a sleepless night...
-G
User avatar
heyvern
Posts: 7042
Joined: Fri Sep 02, 2005 4:49 am

Post by heyvern »

wait, wait, wait...
Are you telling me that I can store Rx, Ry and alpha0 inside the point itself? Can I do that? Really?
It means that no other bone than the control masters ones are needed?
Yes, as far as I can tell this should work. This should be done on frame 0 or some base frame to set those values so they won't change during the animation. Remember that those bones angles would change during the animation and if these variables are "linked" they would change as well messing everything up. The value should always be pulled from frame 0 or whichever frame has the proper values on the bones.

-----------------
What do you think?
I would need some help to write this script I think.
It sounds cool as heck... I just barely understand it...

What you are saying is that you can "assign a shape" to the bones that control that part of the mesh and then determine from the bone rotations where that shape should be in the z order of the layer?

The switch layer is where I get confused. I think you are saying the switch key frame will trigger the sorting only when set by the "animator" to avoid having the shape layer constantly being reordered on every frame. Is this close?

If so it doesn't have to be a switch key frame, it could be a bone's animated position similar to my flipper script. If a bone is left or right of a certain point it would trigger the reorder. That is how my flipper works. It doesn't reorder unless there is a change in a bones location.

The vector layer script could check a bones key frame on the parent bone layer and trigger the shape ordering. This would eliminate the need for the switch if it works.

Similar to my new bone selection tool. Building the list slowed it down so I limited it to only rebuild when something changed in the list of bones like adding or deleting.

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

Post by Genete »

What you are saying is that you can "assign a shape" to the bones that control that part of the mesh and then determine from the bone rotations where that shape should be in the z order of the layer?
No, the shapes still linked to the points as Moho has stated from the begining. The new thing is that I can calculate the "Z center" of the shape based in an average of the Z points values that hold that shape. As well as every point have a bone (and every bone have a theoretical math Z value) then every point have a Z value and a shape have an average of Z values. It could be similar to the layer sort by true depth done by the depth of the center of each layer. In my case that "Z center" is an average.
I think you are saying the switch key frame will trigger the sorting only when set by the "animator" to avoid having the shape layer constantly being reordered on every frame. Is this close?
Yes that's right. But it can be disabled and continuous ordering can be done if needed.
If so it doesn't have to be a switch key frame, it could be a bone's animated position similar to my flipper script. If a bone is left or right of a certain point it would trigger the reorder. That is how my flipper works. It doesn't reorder unless there is a change in a bones location.
Yes, but your bone comparison is done by something like: if bone1.x is bigger than bone2.x then trigger the sort from lef to right if not then trigger the sort form right to left. In my case the keyframe have not sense on what is the switch value, only if it exists then it makes a ordering based in z values. You can do the same with a bone. If there is any translation keyframe (maybe only the same keyframe) in a particular bone then trigger the ordering, if not keyframe then not trigger. It is the same.

Before attack this issue I want to finish the way to perform limbs with the 3Dgrid.lua script. I have to refinish the theory to write the script (you or me :wink:)
-G
User avatar
heyvern
Posts: 7042
Joined: Fri Sep 02, 2005 4:49 am

Post by heyvern »

Well here is a practical application:

http://www.lowrestv.com/moho_stuff/3D_tire3.anme

http://www.lowrestv.com/moho_stuff/3D_tire3.mov

I will have to wait for the shape ordering to be able to turn the wheel while it "turns" if you follow me. And I still can't quite figure out how to "fill in" the tread of the wheels.

The shapes of the treads kind of... get swapped around. There are only two shapes at the moment, half the treads in the back half in the front. I will have to make each tread a separate shape to get the ordering.

I basically did everything on one vector layer then duplicated it after the bones were applied to get the separate sidewalls and tread layers.

I used a circle that I ran split points on to get the placement for the treads for the side and front view. It was a simple matter of lining up the tread points with the points on the circle horizontally.

I have a big tractor that I will need to animate evenutally.

I want to try out that script that converts bone motion to point motion with this rig just for fun. That might make some of the "anti-3D" people excited. Us the rig, convert to point motion, delete the bones. Be a great way to create point motion turns for those who prefer it.

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

Post by Genete »

Mmm 563 bones makes my computer to go a little slow.... :wink:

I'm happy you have used the union of both scripts. It saves a LOT of time.
There is a 3Dgrid5-fixed2.lua missing. Have you modified something interesting?
If you are happy with the -fixed can you post it a the first post.
I want be sure everyone use always the same script to catch some bug if someone else uses it.

Although it is pending a full explanation with samples (or even a video tutorial) from my side of the scripts from
http://www.darthfurby.com/genete/Script ... _3Drig.zip
you can pot it also at the beginning of the thread.
Please add this stuff:
Genete's automatic 3D rig.
ge_auto_3Drig.zip

Usage:
1) unpack the file and copy the lua files into a folder in the AS-home-folder/scripts/menu/Bones folder. (or what ever other folder name you prefer)
2) Create a bone layer or a switch layer.
3) Inside the bone or switch layer create 4 root bones "masterX" "masterY" and a third and fourth ones with a name. It does'n matter what the name is but both must have the same name.
4) Create a vector layer. Draw your FRONT view of the model.
5) Duplicate the vector layer. Don't add or remove any point in this layer and not do that also in the original vector layer. The original and the copy must have the same amount of points. If don't just remove the duplicated and duplicate the original again.
6) In the duplicated vector layer move the points only modifying the X coordinate. Do it using the original LM translate points with the SHIFT key pressed. Move the points to its position as they were in the SIDE view. Do it moving turning the model "as it were looking left" (its left).
7) Place the 3rd and 4th bones with the same name to be the center of rotation of the SIDE and the FRONT views. One for each. Be sure that both bones have the same Y coordinate.
8.) Select the points from the FRONT view that are going to be rigged (there can be more points that don't belong to the rig). Select at the same time the 3rd bone (the one that's the center of this FRONT view). To do that use the bind points tool. Run the "GE: 3D Rig a mesh of points. FRONT" menu script.
9) Do the same with the SIDE view but run the corresponding script ("GE: 3D Rig a mesh of points. SIDE").

That's all. Just play with masterX and masterY beyond frame 0 and you wil lhave a 3D grid in movement.
---
Regarding to the 3D tire it is a pity you cannot put all the points in the same vector layer due to the announced automatic shape ordering is not ready.
It also would save a lot of bones because you have repeated the rig two times for points that are placed a the same position.
Also I use to set the strength of the non binding bone to zero. I think it reduces a little the computation. Also use two different bones for the front and side rigs . It allow to separate them far away just moving its center far away. Once rigged it doesn't matter its position. It makes clearer the model.

Please we I think it is more important to follow the limbs idea rather than continue the automatic shape order. Be patient. My time is limited.
I promise that I'll concentrate this week into the limbs and once finished I'll try the shape ordering.

It is glad to work in collaboration with you.

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

Post by heyvern »

I renamed the script because I have one I was editing that I didn't want to orverwrite... I should have renamed MY version but I forgot.

That script referenced in mine is the same as yours it just has a different name (with the "2" in it).

This was a fun experiment, 500 bones! I didn't even count them. that is how GREAT your scripts are. They work so fast and easily you don't even KNOW what horrible things are being produced! ;) 500 bones is way too many but for an emergency situation it could be used.

Imagine how long it would take to add 500 bones by hand with out even worrying about what they are named or what they do!!!

Yes I struggled with how to produce those sidewall shapes correctly without duplicating the bones and I think I figured it out!

"Stitch" the shapes together so there is only ONE point. Then when I duplicate the layers I break and delete the vectors not needed for each layer but those points are still bound to the correct bones.

So I could create the circle shape CONNECTED to the treads when I run the script, then duplicate that layer and delete just the treads so I have the sidewalls. Go to the treads and delete the side wall shapes. Eliminate at least a third of the bones or more.

Yes, I am not actually that interested in the shape ordering just yet. It would be a very nice script but I am happy using layer flipping for now.

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

Post by Genete »

Continuing with the idea of the 3Dgrid and its limbs concept development.

1) I think we can avoid to do the collection of pt, Rx, Ry and masterX and masterY bones EVERY TIME the embedded script is called. BTW, the embedded script is called three times each frame movement. I don't know why but it is. I have tested a simple menu script and a simple embedded script to verify if a menu call can set a variable to a determined value where the embedded script can take access from. The answer is yes.
I have made a menu script called:
ge_test.lua

Code: Select all

-- **************************************************
-- Provide Moho with the name of this script object
-- **************************************************

ScriptName = "GE_Test"

-- **************************************************
-- General information about this script
-- **************************************************

GE_Test = {}

function GE_Test:Name()
	return "Test"
end

function GE_Test:Version()
	return "1.0"
end

function GE_Test:Description()
	return "Test sample"
end

function GE_Test:Creator()
	return "Genete"
end

function GE_Test:UILabel()
	return("Test sample...")
end

--------------------------------------------------
GE_Test.myvalue = nil
--------------------------------------------------

-- **************************************************
-- The guts of this script
-- **************************************************

function GE_Test:Run(moho)
	local b
	if(GE_Test.myvalue == nil) then 
		print ("seting...")
		GE_Test.myvalue = 0
	else
		print ("value =" .. GE_Test.myvalue)
	end
	local skel = moho:Skeleton()
	if (skel == nil) then 
		return
	end
	b = skel:Bone(0)
	b.myvalue = 77 -- arbitrary value
end
and a simple embedded script (test.lua)

Code: Select all

function LayerScript(moho)

	local bone
	local skel = moho:Skeleton()	
	if (GE_Test.myvalue ~= nil) then
		print ("GE_Test.myvalue =" .. GE_Test.myvalue)
	else
		print ("no value")
	end
	bone = skel:Bone(0)
	print ("Bone.myvalue =" .. bone.myvalue)
end
The two interesting things:
a) You can store values to your menu script instance that can be accessed by other scripts. GE_Test.myvalue is the example. It is filled by the menu script and retrieved by the embedded script.
b) You can also modify the moho objects with your particular variables as you have said it to me (That's great). It would be loose everytime you open the file but if you maintain the bones there, the information could be redone

Also I have made some test to try to find the global angle of a bone. I have used the samples from the master (LM the legend!) in the original announcing of the Embedded Script feature.
Here is the sample files.

http://darthfurby.com/genete/Scripting/angle-test.zip

Open the angle.anme file and manipulate the bones beyond frame 0. You will see the lua console showing the global angle of the bone number 2 (ID= 1), in degrees.

So my proposal is:

1) Create a menu script just extracting the code lines from 3Dgrid script first part. The values of RX, RY, masterX, masterY, etc. can be stored in the menu object instance. Every time you call the menu script it refill the corrects values to a matrix that is attached to the menu script object. It is the same than the embedded script but run only once. Also it sets a on/off variable that tell the embedded script if the menu script has been called or not. Even you can store more information about the found values (for example the amount of pt bones, etc.) specific information to make the embedded run faster.
2) Obviously the embedded script should take account that and make its job as far as possible.
3) Once I can retrieve the global angle of a bone I can play with the new concepts for the limbs.

---

Rules:

a) A pt bone can be a rotation center of other pt bones. The only condition to do that is that the pt bones should be its children.
b) A pt bone can be part of a local mesh. it only need to know if it have a parent ad his parent is a pt bone. If his parent is a pt bone then the alpha and beta don't come from masterX and masterY. They come from bonename.mX and bonename.mY being bonename the name of its pt parent. It will retrieve the global angle of bonename.mX/Y. if the bonename.mX or bonename.mY bones don's exists then it will move as the masterX and masterY move (it can be a mix of master and bonename). It is a responsability of the designer to create and setup the bonename.mX or Y bones. It could be automated but seems to be difficult.
c) The masterX and the subsequent bonename1.mX/Y, bonename2.mX/Y, etc. would be linked as normal skeletons. I this way you can manipulate bones with IK and the 3D model would response properly in his rotation angle.
d) The masterX and masterY bones only would have sense to those bones that are not part of the sub meshes.

For example body can be manipulated by masterX/Y bones and arms and rest of limbs can be manipulated by other .mX/Y bones.

Makes it sense? :?

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

Post by Genete »

Ooops!
With this feature of dividing the embedded script into two (the menu part and the embedded one) the ability of morph the bones through the time is lost.
Maybe the original one can be maintained.
What do you think?
-G
Post Reply