3D rig!!!

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
synthsin75
Posts: 10266
Joined: Mon Jan 14, 2008 11:20 pm
Location: Oklahoma
Contact:

3D rig!!!

Post by synthsin75 »

I've been pm'ing Genete about his amazing 3D scripts, and thought I'd go ahead and post a thread so others might benefit from it. Here is what I did the first day I tried using these scripts. http://www.mediafire.com/?pw04dfxjmpd It's a 3MB AVI clip.

You can find Genete's tutorals for these scripts in this thread. I plan on doing a video tutorial once I develope enough beyond what Genete's tutorial covers. Hopefully this will draw more attention to these great scripts. I'm not sure if people know what they're missing.


Genete, I read the older tutorial text about what each bone created by the script does, but it must be out of date. Also, is there any way to create a second set of Master bones for the same layer? Or some way to make a shape immune to the auto-shape order script?

What I'm wanting to do is have a static shape for shading, but I need to be able to adjust its shape order manually.


I'm also working on doing lip-sync, so Vern feel free to chime in. :wink: I'm wondering if small sub-master groups (mX/mY) could be manipulated by their root bones for a lip-sync rig.


Anyway, I plan to post all of my questions and progress here. Wish me luck. :wink:
User avatar
heyvern
Posts: 7042
Joined: Fri Sep 02, 2005 4:49 am

Post by heyvern »

That looks great!

It's been ages since I've played with the 3D scripts genete created. Actually I've been on a short hiatus from ASP for a few weeks now. Real world intrudes... dang real world. ;)

As far as lip syncing... would have to go back and look at the scripts again. I think genete was working on some variations of to do animation of parts of a 3D object like for hands and arms and such.

The trick of this would be figuring out how to calculate new positions of the mouth vectors based on rotations of other bones.

Keep us up to date. Good job so far. You may want to look at the old threads on an offshoot of this with way fewer bones. There was a lot of interest in another "non scripted" rig for realistic head rotations.

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

Post by Genete »

Wow! nice job! It looks quite well although it has curved paths! ;)
Genete, I read the older tutorial text about what each bone created by the script does, but it must be out of date.


Yes it is. Making a user guide in a forum is a little difficult. If it were a wiki :/. Also I don't have enough time to dedicate to (in fact I have not enough time for a lot of things! :lol: or... maybe I have too many things to do?? ;))

I have to confess that lately I'm filled with enthusiast by Synfig (an open source 2D animation program). But, as you can see, I'm here continuing helping people in this amazing community.
Also, is there any way to create a second set of Master bones for the same layer?
There isn't with the current state of the script. But you can have as many mX and mY as you want and referred to any central bone you need...
Or some way to make a shape immune to the auto-shape order script?
Draw it and don't make it part of the 3D rigging. BUT it must be in the side view too!!!! if not the points gets renumbered and everything fails. Please tell me if it works. (*)

That animation is the proof of what can be done if you place the right tool in the right hands ;)

Good luck.
-G
Last edited by Genete on Tue May 13, 2008 10:04 am, edited 1 time in total.
Genete
Posts: 3483
Joined: Tue Oct 17, 2006 3:27 pm
Location: España / Spain

Post by Genete »

(*) I'm not sure if it would work. Shapes are sort based on its average Zdepth based on the point bones virtual Zdepth it has attached to. If a point of shape has not parent bone or ist parent bone has a nill Z value then it returns. That means that a shape can have some points 3D rigged and some not. Even a shape can have all its points with not valid parent bone and its total average Z depth is 0.0. So if a shape is not bound to a valid bone that has a Z vlaue it has always a value of 0.0.

If you want a shape to be always over or below the 3D rig place it in another vector layer in the bone folder. Otherwise you cannot grantee that the 3D model is not "cut" by the static shape.

Code: Select all

-- *******************************************
-- Embedded script for a vector layer
-- SORT THE SHAPES AUTOMATICALLY BASED IN THE 
-- AVERAGE Z VALUE OF ITS ASOCIATED POINTS
-- Version: 9.0
-- Created By Genete
-- Usage in combination with 3Dgrid9.lua or 3Dgrid9.lua embedded script for the bone layer.
-- *******************************************

-- Some code need optimization.

function LayerScript(moho)
	local mesh = moho:Mesh()
	if (mesh == nil) then
		return
	end
	if (mesh:CountShapes() == 0) then 
		return
	end
	for i = 0, mesh:CountShapes() -1 do
		local cvID, lastID = -1,-1
		local segID = -1
		local ptmax = 0
		local cve
		local selectedID
		local point
		local shp = mesh:Shape(i)
----------------------------------------
		shp.Z = 0 -- initializes the Z value of the shape to 0.
----------------------------------------
		edmax= shp:CountEdges()-1
		if (shp.fFillAllowed) then -- closed shape --> Every point is called two times.
			for j=0, edmax do -- for all the edges of the shape
				cvID, segID = shp:GetEdge(j,cvID, segID) -- find the curve and the edge (edge = two points)
				cve = mesh:Curve(cvID)-- take the curve
				ptmax = cve:CountPoints() -1 -- calculate the maximum number of points of the curve
				point = cve:Point(segID) -- take the first point
				AddZToShape(shp, point, edmax, moho)
				if (segID <  ptmax) then -- decides if takes the following or the first of the curve.
					point = cve:Point(segID+1)
					selectedID = segID +1
				else
					point = cve:Point(0)
					selectedID = 0
				end
				AddZToShape(shp, point, edmax, moho)
			end
		else --not fillable shape (open curve)
			cvID, segID = shp:GetEdge(0,cvID, segID) -- take first curve and edge (0)
			cve = mesh:Curve(cvID)-- take the curve
			point = cve:Point(segID) -- take the first point
			ptmax = cve:CountPoints() -1 -- calculate the maximum number of points of the curve
			-- Call the fucntion here two times.
			AddZToShape(shp, point, edmax+1, moho)
			AddZToShape(shp, point, edmax+1, moho)
			if (segID <  ptmax) then -- decides if takes the the folowing or the 0.
				point = cve:Point(segID+1)
				selectedID = segID +1
			else
				point = cve:Point(0)
				selectedID = 0
			end
			AddZToShape(shp, point, edmax+1, moho)
			for j=1, edmax-1 do -- for all the edges except first and last
				cvID, segID = shp:GetEdge(j,cvID, segID) -- -- find the curve and the edge (edge = two points)
				cve = mesh:Curve(cvID)-- take the curve
				ptmax = cve:CountPoints() -1 -- calculate the maximum number of points of the curve
				point = cve:Point(segID) -- take the first point
				AddZToShape(shp, point, edmax+1, moho)
				if (segID <  ptmax) then -- decide si toma el siguiente o el cero.
					point = cve:Point(segID+1)
					selectedID = segID +1
				else
					point = cve:Point(0)
					selectedID = 0
				end
				AddZToShape(shp, point, edmax+1, moho)
			end
			cvID, segID = shp:GetEdge(edmax,cvID, segID) -- take last curve and edge
			cve = mesh:Curve(cvID)-- take the curve
			ptmax = cve:CountPoints() -1 -- calculate the maximum number of points of the curve
			point = cve:Point(segID) -- take the first point
			AddZToShape(shp, point, edmax+1, moho)
			if (segID <  ptmax) then -- decide if takes the last point or the beginning of the curve.
				point = cve:Point(segID+1)
				selectedID = segID +1
			else
				point = cve:Point(0)
				selectedID = 0
			end
			-- Call the function here two times for the last point .
			AddZToShape(shp, point, edmax+1, moho)
			AddZToShape(shp, point, edmax+1, moho)
		end -- if then else
	end -- for i
	SortShapes(moho)

end -- function


function AddZToShape(shp, point, edmax, moho)
	local zparent = 0
	local ptbone = moho:ParentSkeleton():Bone(point.fParent) -- localize the bone parent of the point
	if(ptbone == nil) then return end
	if(ptbone.fPos.z == nil) then  return end
	local ptboneparent = moho:ParentSkeleton():Bone(ptbone.fParent)
	while (string.find(string.sub(ptboneparent:Name(), -3), ".pt")) -- while its parent were a pt bone
	do
		zparent = zparent + ptboneparent.fPos.z
		ptboneparent = moho:ParentSkeleton():Bone(ptboneparent.fParent) -- localize its parent and assing to it.
	end
	shp.Z = shp.Z + zparent/edmax/2 + ptbone.fPos.z/edmax/2 --stores the z value divided by edmax and by two because it is called two times.
end


function SortShapes(moho)
	local mesh = moho:Mesh()
	local maxshp = mesh:CountShapes()
	for i=0, maxshp -2 do
		local ishp = mesh:Shape(i) -- assume the 0 to i shapes are sorted 
		for j=i+1, maxshp -1 do  --locate the next shapes in the stack. 
			local jshp = mesh:Shape(j)
			if (jshp.Z < ishp.Z) then
				for k= 0, j-i-1 do
					mesh:LowerShape(j-k, false) -- lower the shape as many times to put it below i shape.
				end
			end
		end
	end
end
I can believe I have written that code... :shock:
User avatar
synthsin75
Posts: 10266
Joined: Mon Jan 14, 2008 11:20 pm
Location: Oklahoma
Contact:

Post by synthsin75 »

Genete wrote:That animation is the proof of what can be done if you place the right tool in the right hands
HeyVern wrote:That looks great!
Thanks guys. I hope to continue to impress.
Genete wrote:Otherwise you cannot grantee that the 3D model is not "cut" by the static shape.
That's exactly what I want it to do. 'Cut' the 3D model. I tried adding a shape to front view after setting up the model, and it kinda works, but like you say, it stays at 0.0 Z-depth.

Here's what I got so far.

I'll try it with the shape in both views during setup. Thanks for what little time you do have to spare. :)
Genete
Posts: 3483
Joined: Tue Oct 17, 2006 3:27 pm
Location: España / Spain

Post by Genete »

Awesome...
Can you share the anme file? :roll:
User avatar
synthsin75
Posts: 10266
Joined: Mon Jan 14, 2008 11:20 pm
Location: Oklahoma
Contact:

Post by synthsin75 »

Sure! Here it is!

I haven't done anything else to it yet, just the last animation I posted. If I can get it to work, the idea is to use several transparent shading shapes at varying 'z-depths' (I assume this z-depth is only simulated since it happens in one layer). If I use enough of these shapes, perhaps it won't look so much like the shapes are 'jumping' in front of one another.


These scripts are brilliant work, Genete! Now if I could only find a 3D app that operates along these lines. That's my problem with 3D apps. The automatically calculated curved surfaces means you never get 'exactly' what you draw. :wink:
User avatar
heyvern
Posts: 7042
Joined: Fri Sep 02, 2005 4:49 am

Post by heyvern »

Yeehaa! That shading trick is pretty cool.

Wracking my brain trying to think of how to make it... more "shaded"... it's been awhile since I looked at those scripts.

So basically you have that big square shadow shape at a single point in 3D space. As the head shapes "rotate" that shape overlaps them creating a pseudo 3D shading... (I write this down to help me think)

I was thinking about using multiple shading "shapes" at different values. Each at a different spot in the 3D space... Each shape would have a slightly higher/lower transparency/color value. It would create a sort of "banded" shading effect.

It won't require scripting so I may play with this myself for a few hours tonight... I deserve a break from the daily grind. ;)

------

Genete... I do that all the time. Look at a script I created a long time ago and can't believe I wrote it! ;)

I really should do some scripting soon so I don't forget everything I learned.

-vern
User avatar
synthsin75
Posts: 10266
Joined: Mon Jan 14, 2008 11:20 pm
Location: Oklahoma
Contact:

Post by synthsin75 »

I was thinking about using multiple shading "shapes" at different values. Each at a different spot in the 3D space... Each shape would have a slightly higher/lower transparency/color value. It would create a sort of "banded" shading effect.
Yeah, that's what I'm trying to accomplish. Just crashed ASP trying to use a root bone of one 3D object for a sub-object. :roll: Still figuring out the 'rules of use'. :wink: If I can 3D rotate my shading shapes, I'm thinking I could even simulate a 'moving' light source.

We'll see how it goes. :)
Genete
Posts: 3483
Joined: Tue Oct 17, 2006 3:27 pm
Location: España / Spain

Post by Genete »

He he, interesting thing that half transparent shape at Z = 0.

Mmmm I think that you can place that shape at ant Z. Only bind it to a bone with a particular static Z. How? control the model with a pair of mX and ,mY bones and set other pair to that static shapes. Don't use masterX and masterY any more.

You would need to rig a coordinate system that can be static and not visible and then emerging from it you can 3D rig your model and any other kind of shapes that you simply don't move with any rotating bone. only left them in a fixed Z. It is like if the model were a limb (mY and mY) of your global coordinate system (master X and master Y).

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

Post by Genete »

synthsin75 wrote:
I was thinking about using multiple shading "shapes" at different values. Each at a different spot in the 3D space... Each shape would have a slightly higher/lower transparency/color value. It would create a sort of "banded" shading effect.
Yeah, that's what I'm trying to accomplish. Just crashed ASP trying to use a root bone of one 3D object for a sub-object. :roll: Still figuring out the 'rules of use'. :wink: If I can 3D rotate my shading shapes, I'm thinking I could even simulate a 'moving' light source.

We'll see how it goes. :)
Forgive me for not document it properly. Give me an opportunity. I'm so busy... :(
DarthFurby
Posts: 510
Joined: Sat Jul 29, 2006 1:34 pm
Location: New York City
Contact:

Post by DarthFurby »

Nice job! I'd always planned on using these scripts at some point to build simple props, like a hat or something, but never dared attempt a full head model. Very impressive. Lots of unexplored territory here.
User avatar
synthsin75
Posts: 10266
Joined: Mon Jan 14, 2008 11:20 pm
Location: Oklahoma
Contact:

Post by synthsin75 »

Genete wrote:Mmmm I think that you can place that shape at ant Z. Only bind it to a bone with a particular static Z. How? control the model with a pair of mX and ,mY bones and set other pair to that static shapes. Don't use masterX and masterY any more.
I'm not sure I understand. I'm trying to make the shade shape the Master 3D object. Then I select one of its pt bones to make the sub-object (mX/mY). I must be doing something wrong because I am consistantly crashing AS.

Okay, I figured out why I was crashing AS, but still don't see how I can change the z-depth of that shade shape. I'll keep working on it. :roll: :wink: Perhaps bind the whole shade shape to one set of 3D bones?

DarthFurby wrote:Nice job! I'd always planned on using these scripts at some point to build simple props, like a hat or something, but never dared attempt a full head model. Very impressive. Lots of unexplored territory here.
:oops: Wow thanks. I'm flattered by all the pros taking note. :)
Genete
Posts: 3483
Joined: Tue Oct 17, 2006 3:27 pm
Location: España / Spain

Post by Genete »

synthsin75 wrote:I'm not sure I understand. I'm trying to make the shade shape the Master 3D object. Then I select one of its pt bones to make the sub-object (mX/mY). I must be doing something wrong
because I am consistantly crashing AS.

Okay, I figured out why I was crashing AS, but still don't see how I can change the z-depth of that shade shape. I'll keep working on it. :roll: :wink: Perhaps bind the whole shade shape to one set of 3D
bones?
IIRC, to create mX and mY bones you should select an already existing pt bone (the horizontal one in the front view) and with the bind points tool select the sub set of points that is going to pivot around this bone.

That's the reason I suggested you to create the model in this way:

1) Create a 3D (front and side views) coordinate origin. Three perpendicular straight lines emulating the X,Y,Y axis. The most important one is the Origin. It should lie exactly at the origin of the Central
bone (the one you first create and the one that gives the root name to the rest of the bones.
2) 3D rig only those 6 points (two per line) and create the master bones for them. This would allow to rotate the entire model (head and shading planes included). Don't weld the origin points just place them very close to (0,0)
3) Then selecting the pt bone of the one of the origin points do the 3D
rig of the face as usual. In this case don't select "create master X and master Y bones" but select the "create the mX and mY" ones. Then the rotating bones for the head would be the mX and mY.
4) Select now other of the the pt bones of the origin and do the 3D rig of a plane. This plane should be controlled by another set of mX and mY bones

You can place the shading plane at any Z even you can orientate it as you prefer. Did you notice that you can translate the plane in any of the axis just moving the point bones (Rx and RY) of its corners? That would allow emulate lights / shadow changes as you predicted without rotate the head model.

Please let me know if you cannot create and use those mX and mY bones. I'll try to make a video tutorial for that... ;)

-G
User avatar
synthsin75
Posts: 10266
Joined: Mon Jan 14, 2008 11:20 pm
Location: Oklahoma
Contact:

Post by synthsin75 »

Okay. I did something slightly different than what you suggested Genete. Check out the .anme file here.

If you zoom in really close on the layer's origin, you'll see that I made an origin Master object. I just made sure it had enough points/bones for all the sub-objects (mX/mY). This seems to be working really well!! I'm very excited.

After several crashes, I finally figured out that I can't use the front/side menu scripts with the 3Dgrid embedded. :roll: But I'm learning. :) The script is still complaining occasionally, but it doesn't seem to be lethal. :wink: One is LM's select bone tool complaining something about 'first message', but I don't think that one is any trouble since it is a one time error.
When you first start using the bones just after opening the file, it complains about 'performing arithmetic', but this one also seems to be a one time error only after opening.

I wouldn't worry about these. I LOVE these scripts!!


I still need to tweek my modeling and shading, but I think I can produce some seriously cool stuff here.


Let me know if you have any other suggestions. :)

Edit:Here's an updated one with masked shading
Post Reply