Notifications
Clear all

[Closed] getValue ccCurve as MXS function?

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

[/left]
[left]
[/left]

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

[left]
[/left]
[left]I want to use it in a function so I can still get the value of the curve[size=2][size=2][size=2][size=2] at a given time without actually having to “read”[size=2] it direc[size=2]tly from the Curve Control UI. If I try to use th[size=2]e 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. [/size]
[/size][/size][/size][/size][/size][/size]
[/left]

[left]

[/left]

11 Replies

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;

i’m not sure that you ask ccurve value the right way. can you show more of your code?

Hi denis,

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

(getValue $box01.baseobject.custom_attributes.rollout.controls[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


 $box01.baseobject.custom_attributes.rollout.controls[1].curves[1]
 

path to control is wrong. it has to be:


$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?

 lo1

How about using a look-up table?

1 Reply
(@denist)
Joined: 11 months ago

Posts: 0

that’s a good idea. i did it many times. and i used the CurveControl to make look-up tables.

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.

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.

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.

1 Reply
(@pacermike)
Joined: 11 months ago

Posts: 0

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.