PDA

View Full Version : Editable Expression Curves


HayaiHa
09-09-2003, 04:51 PM
I was wondering if there was a way to convert an expression into a curve that could then be edited in the graph editor.
For example, if you create a spotlight there are options to add either an intensity or color curve to it. This then creates a lightinfo node and a curve which relates light intensity or color to the lightinfo's sampledistance. The curve can be edited in the graph editor so you can get the exact relationship between distance from the light and intensity at that point.

Another way to get a similar effect is to create the lightinfo node yourself, link it to the light and then write an expression that relates the sampledistance to the intensity. However, in this case all you have is the expression and no curve to edit.

Its possible to create an animation and then 'bake' the movements/rotations etc of an object against time into an editable curve (bake simulation). This then gives you greater control over tangents and positions of your animation curve to improve the final look of the motion.

(Almost there, just wanted to make it clear what I would like to do)

So, is it possible to create these curves for all sorts of things. Write an expression, say

float $distance = lightInfo1.sampleDistance;
pointLightShape1.intensity = sin($distance) ;

and then generate a graph of this expression which can be 'tweaked' in the graph editor to get exactly the relationship that you want?

Perhaps I have missed something glaringly obvious to do this, I'm sure Maya has the capabilities to have a graph of the relationship (as shown by the Intensity Curve for a spotlight button). Maybe its just not that simple to set up.

wrend
09-10-2003, 12:48 AM
yep, definitely doable.
not sure what you mighta missed along the way, so ill just make a few notes:
- you can bake pretty much any animated parameter, driven by whatever means ...not just transforms, and not just from simulations,
- you can visualise an expression in the graph editor with 'show results', non-editable curve (pitty you cant have this as a history node, but fair enough),
- you can mix animation crvs into your expressions.

so you could just do a static bake of your expression, and tweak the crv per-normal (for cases where it isnt reliant on parameters are going to vary on future runs), or for a more dynamic situation you could keep your expression live and mix its results with a curve you use to adjust it (simply by taking the crv's output into your expression, and deciding how you use its values to adjust the usual results of the expression).

HayaiHa
09-10-2003, 09:20 AM
I still can't achieve quite what I want. The bake options kinda can get it but they are all related to time/'some attribute'.
I want to have a graph of 'some attribute1'/'some attribute2'

Heres the intensity/sampledistance example again:

I hook up a pointlight's world matrix to a lightinfo's world matrix, then write an expression-
float $distance = lightInfo1.sampleDistance;
pointLightShape1.intensity = sin($distance);

I do not set any animation keys on the movement of the light or its intensity (eg there is no change in intensity or sampledistance over time). Then I want to bring up a graph which represents the expression relationship, purely a graph of how intensity varies against sampledistance.

If I try the 'show results' button in the graph editor then all it has is intensity/time (a straight line as nothing is set to change yet over time). I know that the graph editor can show relationships between two attributes without any time variables coming into it (from the 'Create Intensity Curve' button on a a few of the light types)

Now of course I could set some animation keys on one of the attributes, then show results for the attribute the changing one is connected to in an expression and get a good graph of the function from the expression. Although this graph would be a time/attribute one. I purely want to visualise the direct curve between the two attributes from the expression.

While this exercise is kinda pointless in a way, because with no variables over time then no animation is going to happen anyway, I still wanted to see if it was possible. Plus it might be handy in some situations, they did add color and intensity curves for lights after all.

wrend
09-10-2003, 11:22 AM
the default intensity/colour crv examples are static relations, obviously. the problem w your dynamic example is that the sampleDistance is only pulled at render time, and for each render sample, per frame at that!. so graphed results would be a bit strange anyway, and which i see now, is not what you really after ... your interested in not what an expression's results look like, but rather the relations you describe w/i them. so, yeah, do like you said - animate the non-dependent varaible and graph the results of the dependent. animate it to match time value, that way when you bake, its not really against time, but the linear increment of its dependent ...which i assume is the way you wish to be assessing the relationship (unless you got something funky in mind?). just incase you havent, have a look at Set Driven crvs (and their animCurveUU nodes), which the intensity crvs are but an example of.

HayaiHa
09-10-2003, 12:42 PM
Thanks for the replies. I think I will just have to stick to doing what you said.
I had no real aim in mind for this, I just liked the flexibility of having the relationship visualised before setting down keys. The end result that can be obtained would not really change.

CGTalk Moderation
01-16-2006, 02:00 AM
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.