getValue ccCurve as MXS function?

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 2012   #1
getValue ccCurve as MXS function?

Can anyone with access to the SDK tell me the math that's happening under the hood with this method on the Curve Control?


getValue ccCurve <time_value> [lookup:<false>]
Returns a Point2 value corresponding to the specified X position along the curve at the specified time.

I want to use it in a function so I can still get the value of the curve at a given time without actually having to "read" it directly from the Curve Control UI. If I try to use the getValue method in a script controller it throws and error as soon as the Curve Control isn't visible in the viewport anymore because the controller can't "see" it.




 
Old 11 November 2012   #2
are we talking about ICurve::GetValue ? if we are then having access to the SDK is not the same as have access to the Source.
this is the mxs interface... for said func


Value* MAXCurve::getValue_vf(Value** arg_list, int count)
{
   // getValue <ccCurve>   [lookup:]
   check_gen_arg_count_with_keys(getValue, 3, count+1);
   BOOL lookup = key_arg_or_default(bezier, &false_value)->to_bool();
   return Float::intern(curve->GetValue(arg_list[0]->to_timevalue(),
	  arg_list[1]->to_float(), FOREVER, lookup));
}


where

ICurve		*curve;
 
Old 11 November 2012   #3
Originally Posted by Pacermike:
I want to use it in a function so I can still get the value of the curve at a given time without actually having to "read" it directly from the Curve Control UI. If I try to use the getValue method in a script controller it throws and error as soon as the Curve Control isn't visible in the viewport anymore because the controller can't "see" it.

i'm not sure that you ask ccurve value the right way. can you show more of your code?
 
Old 11 November 2012   #4
Hi denis,

This is how I was asking the ccurve for info inside a script controller:

(getValue $box01.baseobject.custom_attributes.rollout.contro  ls[1].curves[1] 0 (spinner/100))*100


"controls[1].curves[1]" was the ccurve UI, 0 was the time value (still not totally sure why, but it worked) and "spinner" was the input coming from a spinner in the scene. So the spinner could control $box0.pos.z for example, but instead of the linear 1-100 value of the spinner it would return the acceleration or deceleration dictated by the ccurve. This did work but I'd lose communication with ccurve a lot. Especially if I close and reopen the scene. Plus I'd rather not use the ccurve in a custom attribute. I just want to snapshot the curve data and use that to calculate my easing data.

Hi claude,
I guess I did mean the source... I think. I'm just trying to figure out in plain math what's happening when getValue is called on the ccurve. I thought if I had all the curve information (points, in and out tangents, etc) I could just use Bezier math to achieve the same thing but I haven't been able to yet. I can use Bezier equations to "redraw" the curve, but can't figure out what the Y coordinate would be if the X coordinate was known. In my case the X coordinate would be the value of the spinner.

In Maya it seems pretty easy for animators and riggers to filter their values through curves but in Max it seems like the only thing that does it is the Reaction Manager and I'd really, really like to avoid that. It's buggy and really hard to work with.

Thanks guys

Last edited by Pacermike : 11 November 2012 at 09:03 PM.
 
Old 11 November 2012   #5

 $box01.baseobject.custom_attributes.rollout.contro  ls[1].curves[1]
 

path to control is wrong. it has to be:

$box01.baseobject.custattributes[<attr_index>].<rollout_name>.<curvecontrol_name>.curves[1]
 
Old 11 November 2012   #6
Originally Posted by denisT:

   path to control is wrong. it has to be:
   [code]
   $box01.baseobject.custattributes[<attr_index>].<rollout_name>.<curvecontrol_name>.curves[1]
   


Sorry, that's right. I changed it for this example and forgot to put the attr_index back in. In my other trials I did use the correct path, and it did work, but I'd lose communication with the curve when I'd reopen the scene, etc.

Once I write the curve data to an array I'd really like to remove ccurve from the equation altogether. I just want to use ccurve to "snapshot" the point and tangent data and use a scripted math function to find the curve's Y coordinate at given X. I don't want to have to rely on the script controller being able to "see" the ccurve ever. Does that make sense?
 
Old 11 November 2012   #7
How about using a look-up table?
 
Old 11 November 2012   #8
Originally Posted by Pacermike: Once I write the curve data to an array I'd really like to remove ccurve from the equation altogether. I just want to use ccurve to "snapshot" the point and tangent data and use a scripted math function to find the curve's Y coordinate at given X. I don't want to have to rely on the script controller being able to "see" the ccurve ever. Does that make sense?

why do you not want to use just Bezier controller? if you want to use CurveControl to edit the data you can convert ccurve to bezier curve. i showed how to do it on this forum.

Last edited by denisT : 11 November 2012 at 03:00 PM.
 
Old 11 November 2012   #9
Originally Posted by lo: How about using a look-up table?

that's a good idea. i did it many times. and i used the CurveControl to make look-up tables.
Attached Images
File Type: png Capture_02.PNG (68.9 KB, 17 views)

Last edited by denisT : 11 November 2012 at 02:53 PM.
 
Old 11 November 2012   #10
lo,
I wrote a function that does what I want but is INSANELY slow because it's basically a loop that goes from 0.0 to 1.0 by .001 trying to compare every possible time value to the given X value to find a match. I'm reading about look-up tables now and it might be exactly what I need. Thanks for suggesting them, I never knew what one was before. Sounds like it could finally solve this thing for me!

denis,
I didn't want to use a Bezier controller because all I want to do is what the Reaction Manager does or what you can do in Maya... which is supply an input value, manipulate the value with a curve, and give the result to another object's controller, without having to add an extra controller. A good example would be trying to apply ease in and ease out of a morph channel, or trying to cushion an eyelid as it opens or closes independent of the value driving the movement. Even if the driving object is animated with linear keys you'd still get a nice ease in or out. I'm not sure how else to explain it.


 
Old 11 November 2012   #11
Originally Posted by Pacermike: I didn't want to use a Bezier controller because all I want to do is what the Reaction Manager does or what you can do in Maya...

you don't have to use bezier controller to control the wired value. you can use it to store the CCurve data. If ccurve is a part of you CA for example you can store the cc data in bezier curve every time when cc changes, and restore the cc on CA load (or update) event.
instead of CCurve the max curve (controller) will be stored with CA and scene.
 
Old 11 November 2012   #12
Originally Posted by denisT: you don't have to use bezier controller to control the wired value. you can use it to store the CCurve data. If ccurve is a part of you CA for example you can store the cc data in bezier curve every time when cc changes, and restore the cc on CA load (or update) event.
instead of CCurve the max curve (controller) will be stored with CA and scene.


Oh! That's a good idea. I remember the thread where you showed how to update a Bezier with the ccurve, too. I'm gonna play around with that idea... and play with a look up table also, just because I want to know how to do it. Hopefully I'll post back with some progress.
 
Old 11 November 2012   #13
Thread automatically closed

This thread has been automatically closed as it remained inactive for 12 months. If you wish to continue the discussion, please create a new thread in the appropriate forum.
 
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:06 AM.


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