constrain pos to a spherical radius

Become a member of the CGSociety

Connect, Share, and Learn with our Large Growing CG Art Community. It's Free!

THREAD CLOSED
 
Thread Tools Search this Thread Display Modes
Old 11 November 2013   #16
So your animators never need to make an animation preview before exporting to FBX?

Last edited by Archangel35757 : 11 November 2013 at 12:56 AM.
 
Old 11 November 2013   #17
Nope, we export and review in the engine.
 
Old 11 November 2013   #18
I posted a similar question at tech-art.org and got a clever solution that avoids change scripts entirely, using a scale script controller on a proxy object.
 
Old 02 February 2014   #19
a late thread bump. The solution linked to above worked quite well.
It basically involved 'cheating' with a scale script controller on an unrelated object.
I condensed the solution into a fn that I can pass the bone, ctrl object, and script holding object. It seems to be working quite well.


	fn radiusCtrlLimit theCtrl theBone theHolder=(
		/*
			theCtrl = object you wish to constrain to a radius
			theBone = a bone with w/ rotation lookat constrained to theCtrl, whose length will determine the radius
			theHolder = the object that will hold the script.

			objects and lookat constraints created elsewhere
		*/

		ScriptString= @"if distance bone point != bone_length then
		(
			with animate off
			(
				point.pos = (normalize (point.pos - bone.pos))*bone_length + bone.pos
			)
		)

		[1, 1, 1]"

		sc=scale_script()
		sc.addobject "point" theCtrl
		sc.addobject "bone" theBone
		sc.addconstant "bone_length" theBone.length
		sc.script=scriptString
		theHolder.scale.controller=sc
	),
 
Old 02 February 2014   #20
as i said earlier i'm not a fan of this type of rig but everything could be done much easier

delete objects
s = geosphere radius:20
d = dummy boxsize:[10,10,10] pos:[s.radius,0,0]

p = d.pos.controller = position_list()
p.weight[1] = 0

sc = p.available.controller = position_script()
sc.addtarget "radius" s.baseobject[#radius]	
sc.addobject "pos" p[1]
sc.setexpression "(normalize pos.value)*radius"

/* it's optional... if you want to constraint dummy to the sphere position */
d = p.available.controller = s.pos.controller
 
Old 02 February 2014   #21
sc.addobject "pos" p[1]


So instead of a third object to hold a hacked script, you are using a position_list
adding the position script d.pos.controller[2], and
passing the value of d.pos.controller[1]( position_XYZ ) to the script?

very clever, and simple. It is not obvious at all that this was possible, though I guess it makes sense.

Last edited by Mambo4 : 02 February 2014 at 12:30 AM.
 
Old 02 February 2014   #22
as i told... it's not a good practice to use some controller with not its real purpose. in your case it's a scale controller... unfortunately this technique was shown in the mxs help and some script developers copied it in their tutorials. but as i said - this is wrong!

Last edited by denisT : 02 February 2014 at 03:55 AM.
 
Old 02 February 2014   #23
Originally Posted by Mambo4:
sc.addobject "pos" p[1]


So instead of a third object to hold a hacked script, you are using a position_list
adding the position script d.pos.controller[2], and
passing the value of d.pos.controller[1]( position_XYZ ) to the script?

very clever, and simple. It is not obvious at all that this was possible, though I guess it makes sense.


and probably i wouldn't use extra object just for 'radius' control. i would add a custom attribute with 'radius' parameter to the constrainted object. this way will give you full control by only using this object's parameters(and controllers).

Last edited by denisT : 02 February 2014 at 03:57 AM.
 
Old 02 February 2014   #24
another good thing about my setup is that you can easily disable this constraint... if you set expression controller weight to 0, but real position controller's weight to 100...
 
Old 02 February 2014   #25
Denis' solution is nice and it gives you the circular arcs that you seem to be looking for and doesn't cause any "lagging" like the method I posted on Tech-Artist (I wasn't really sure what you were going for).

-Harry
__________________
LinkedIn | Website | Vimeo | YouTube | Twitter | Facebook
 
Old 02 February 2014   #26
Originally Posted by hazmondo: solution is nice and it gives you the circular arcs that you seem to be looking for and doesn't cause any "lagging" like the method I posted on Tech-Artist (I wasn't really sure what you were going for).

i haven't read your post on tech-art yet...

but my solution of course has to be improved. try to animate my solution and check the trajectory you will get.
you will see that the gotten path is not smooth. and, which is much more worth, it's not predictable.
the question is - what do we have to add to be able control 'smoothness' of on surface sliding?
 
Old 02 February 2014   #27
now i've read your post...

"this hack open a lot of doors and can be used to get round any dependency loop"

it's the big mistake. really it shuts doors by hiding or camouflaging the real dependency loop. i think this 'trick' has to be wiped from the mxs help.

i don't really know why and how it came to the max. probably it was born by someone 'maya driven'. in the maya everything is based on a 'node'. that's why 'maya' basic human skeleton is about 300 nodes, where the max's one is ~100.
 
Old 02 February 2014   #28
BTW does any one know or guess why the scale controller is usually picked as an 'accomplice' of this hack?
 
Old 02 February 2014   #29
Originally Posted by denisT: BTW does any one know or guess why the scale controller is usually picked as an 'accomplice' of this hack?


Because it's the last one evaluated when calculating the node transform and thus can modify the previous rotation or position controller values???
 
Old 02 February 2014   #30
Originally Posted by Archangel35757: Because it's the last one evaluated when calculating the node transform and thus can modify the previous rotation or position controller values???

correct!
..and also because people think that the scale is most useless controller
 
Thread Closed share thread



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
CGSociety
Society of Digital Artists
www.cgsociety.org

Powered by vBulletin
Copyright 2000 - 2006,
Jelsoft Enterprises Ltd.
Minimize Ads
Forum Jump
Miscellaneous

All times are GMT. The time now is 01:09 PM.


Powered by vBulletin
Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.