Notifications
Clear all

[Closed] constrain dummy points to biped bones

 em3

Hello. I have some fairly tedious tasks I need to accomplish and I’d like to use maxscript to do it. Big picture here is I want to bake biped movement into bones. I’ve created a biped and animated it. I would like to write a script that

[ul]
[li]created a dummy point for each biped bone[/li][li]position and orientation constrain the created dummy to the biped bone[/li][li]give it the name of the biped bone suffixed with _p[/li][li]create (and name) bones from the hip to the left/right toe then position & orientation constrain each bone in the chain to it’s dummy buddy[/li][li]create (and name) bones up the spine then position & orientation constrain each bone in the chain to it’s dummy buddy[/li][li]create (and name) bones for each arm then position & orientation constrain each bone in the chain to it’s dummy buddy[/li][li]create (and name) the head and neck then position & orientation constrain each bone in the chain to it’s dummy buddy[/li][/ul]I’m not asking anyone to write this for me. I do a lot of vb/vba coding at work and am pretty framiliar with the basics of OO programming. Does that help me? Because after an hour of trying to collect object names into an array I am cursing myself for being too retarded to understand why it’s not working. I will keep pressing on but if anyone has any helpful hints I would appreciate it. Thanks

3 Replies

I had to do exactly this at my last job. A suggestion: first, don’t use bones, use point helpers. They are much more straightforward to do this with, since they really have such minimal information.

First task was to find the root bone (Bip01). Go through all objects (the word ‘objects’ is a collection of everything in the scene), and if it is Biped_Object class (classOf), and if it has no parent (.parent) or its parent is not Biped_Object, we know we have the root.

From there, write a recursive function that will go through all children (.children[i]), and do whatever you need to do: orient and position constrain, rename, and link/parent the dummy objects. This stuff is pretty straight forward, except the constraints if you are new to max. You can look at the scripts of others to learn or dig through help, but I have some useful constraint macros on my site.

Well I was going to give you a start, but this is pretty much all you need to do


fn assignPosConstraint conObj targetObj = (
	conObj.position.controller.appendTarget targetObj 50.0
)

fn assignRotConstraint conObj targetObj = (
	conObj.rotation.controller.appendTarget targetObj 50.0
)

fn recursiveConstraint oldBone = (
	pnt = Point()
	pnt.name = oldBone.name + "_p"
	pnt.position.controller = Position_Constraint ()
	pnt.rotation.controller = Orientation_Constraint ()
	
	assignPosConstraint pnt oldBone
	assignRotConstraint pnt oldBone
	
	for c in oldBone.children do (
		if classOf c == Biped_Object then recursiveConstraint c
	)
)

fn recursiveParent oldBone = (
	if oldBone.parent != undefined then (
		pntName = oldBone.name + "_p"
		pntParentName = (oldBone.parent.name +  "_p")
		exStr = ("$'" + pntName + "'.parent = $'" + pntParentName + "'")
		print exStr
		execute exStr
		
	)
	
	for c in oldBone.children do (
		if classOf c == Biped_Object then recursiveParent c
	)
)

for o in objects do (
	if (classOf o == Biped_Object) and ((o.parent == undefined) or (classOf o.parent != Biped_Object)) then (
		--we have the root object
		recursiveConstraint o
		
		--now we want to set up hierarchy
		recursiveParent o
	)
)

In the line “pnt = Point()” you can change it to “pnt = Point size:whatever” to set the settings properly (box and axis triped is what I recommend).

 em3

Professor420, you are my personal hero. This is truly a gift – thank you! I will post questions as they come up if that’s ok

Feel free… I don’t know enough math or MXS to help as much as some of the guys on this forum, so when I have the chance to return the favor on something more familiar, I take it (especially when I have all the free time I have now).