View Full Version : specify curve type bezier?

 PeterRabel10-09-2010, 10:18 AMI am writing a script that will create a bezier curve. The command to create a curve is the same whether it is an EP, bezier, etc... Does anyone know how to specify the curve as a bezier?
Robert Bateman
10-11-2010, 05:16 PM
What type of bezier curve?

Linear? [curve -d 1 -k 0 -k 1]
Quadratic? [curve -d 2 -k 0 -k 0 -k 1 -k 1]
Cubic? [curve -d 3 -k 0 -k 0 -k 0 -k 1 -k 1 -k 1]

Other?

PeterRabel
10-11-2010, 08:05 PM
Cubic. The points need 2 tangents (save the first and last points which only have one).
For instance:
curve -p 0 1 0 -p 1 0 1 -p 1 1 1 -p 1 2 1 -p 1 3 1 -p 0 0 0 -p 0 -1 0 -k 0 -k 0 -k 0 -k 1 -k 1 -k 1 -k 2 -k 2 -k 2;
creates an EP curve. I have found a way around the problem though. I create it as an EP curve, then convert it to a bezier with nurbsCurveToBezier.

Robert Bateman
10-12-2010, 01:58 AM
Cubic. The points need 2 tangents (save the first and last points which only have one).

A cubic hermite curve.... (or rather a pair of them, because it sounds like you want an input and an output tangent at each control point, one for each curve segment? A bit like the way maya's anim curves....)

For instance:
curve -p 0 1 0 -p 1 0 1 -p 1 1 1 -p 1 2 1 -p 1 3 1 -p 0 0 0 -p 0 -1 0 -k 0 -k 0 -k 0 -k 1 -k 1 -k 1 -k 2 -k 2 -k 2;

Aside from the fact a cubic bezier curve has 4 control points....

I've not got maya handy at the moment, but that knot vector looks suspiciously like 2 bezier curves to me? Can't you just create 2 cubic beziers directly here?

i.e.

curve -p 0 1 0 -p 1 0 1 -p 1 1 1 -p 1 2 1 -k 0 -k 0 -k 0 -k 1 -k 1 -k 1;
curve -p 1 2 1 -p 1 3 1 -p 0 0 0 -p 0 -1 0 -k 0 -k 0 -k 0 -k 1 -k 1 -k 1;

creates an EP curve. I have found a way around the problem though. I create it as an EP curve, then convert it to a bezier with nurbsCurveToBezier.

Which I'm guessing just inserts knots at the span points in the knot vector (in your case there is only 1 in the middle of the curve at t=1). I'm assuming maya's algorithm is clever enough to notice the kink though, so that probably ok from a performance point of view. Worst case it'll evaluate a few additional points on the curve and generate a bit of extra undo crap.

PeterRabel
10-12-2010, 07:28 AM
The code you wrote does produce the same result with 2 EP curves. I am writing a script to make an editable motion trail that updates the fCurves as you edit the bezier in the viewport. I need the curve to be a bezier to coincide with the handles of the fCurves.

There is indeed a lot of undo crap to deal with when I convert it to a bezier. That's why it would be nice to just create a bezier to begin with.

Robert Bateman
10-12-2010, 09:13 AM
The code you wrote does produce the same result with 2 EP curves. I am writing a script to make an editable motion trail that updates the fCurves as you edit the bezier in the viewport. I need the curve to be a bezier to coincide with the handles of the fCurves.

There is indeed a lot of undo crap to deal with when I convert it to a bezier. That's why it would be nice to just create a bezier to begin with.

Wouldn't it just be easier to leave the curve as an EP curve with ever increasing knot vectors in multiples of 3? Would at least allow you to move a single keyframe value and have it update two curve segments. Seems a bit silly to convert from (a restricted form of NURBS) to the bezier form when they are identical....

CGTalk Moderation
10-12-2010, 09:13 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.

1