PDA

View Full Version : How do you find out a curves -k knot values?


niic
09-26-2009, 06:54 PM
Hi guys,

I am wondering if anyone has any suggestions on how I can capture an existing curves construction and put that it into Mel so I can rebuild it via a script. I'm creating my own autoRigger for some creatures and trying to build up my puppet controllers through the script.

I can find out the CV location easy enough through getAttr "curve1.cv
2; but I am unsure how to then work out the knot vector of each cv.

At the moment I have my curve looking like this:


curve -n myCurve -d 3 -p 0 0 0.632721 -p 0 0 0 -p 0 -0.223701 -0.0926597 -p 0 -0.31636 -0.31636 -p 0 -0.223701 -0.540061 -p 0 0 -0.632721 -p 0 0.223701 -0.540061 -p 0 0.31636 -0.31636 -p 0 0.223701 -0.0926597 -p 0 0 0 -p 0 -0.223701 -0.0926597 -p 0 0.223701 -0.540061 -p 0 0 -0.632721 -p 0 -0.223701 -0.540061 -p 0 0.223701 -0.0926597;

closeCurve -ch 1 -ps 0 -rpo 1 -bb 0.5 -bki 0 -p 0.1;

Problem is I don't want it to be smooth. I am trying to get each vert to be cubic so it gives me a hard corner! So I need to set the -k knot values? I'm just not sure how I work that out.

At the moment when I try and work out the knots I am getting the below error so im not understanding the way to do it correctly.
//Error: Knot vector is too short. Must have length (#CVs + degree - 1)

Thanks for any help guys! Much appreciated.
Nick.

Robert Bateman
09-28-2009, 09:31 AM
If you have a curve and you just want the knots, see this page. You don't need to create the first and last knot as I do in the example here (it's only done because every other NURBS package out there specifies the knots fully. Maya, by design, ignores the first and last ones), but instead you can just get the results from the curveInfo node and pass it straight back into the curve command.

http://nccastaff.bournemouth.ac.uk/jmacey/RobTheBloke/www/mel/DATA_ncurve.html


If you don't care about re-creating the curve exactly....

For a Cubic Curve

For a cubic curve (degree=3, order=4) that touches it's end points...

4xCVs 0 0 0 1 1 1
5xCVs 0 0 0 1 2 2 2
6xCVs 0 0 0 1 2 3 3 3
7xCVs 0 0 0 1 2 3 4 4 4
8xCVs 0 0 0 1 2 3 4 5 5 5
etc

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

(If this was any package other than maya, you'd duplicate the first and last knots!)


For a Linear Curve (Straight line)

If you want hard edges in the curve (i.e. a line), then use -degree = 1 (which is a linear curve)

so...

2xCVs 0 1
3xCVs 0 1 2
4xCVs 0 1 2 3
5xCVs 0 1 2 3 4
6xCVs 0 1 2 3 4 5

curve -d 1 -p 0 0 0 -p 1 0 0 -k 0 -k 1 ;

niic
10-08-2009, 01:41 PM
Hey Rob,

Thanks for the detailed reply! I am struggling to understand the syntax. Would you mind explaining it a bit more - I'm a noob to Mel. Really appreciate it mate thanks.

e.g: 4xCVs 0 0 0 1 1 1
curve -d 3 -p 0 0 0 -p 1 0 0 -p 1 1 0 -p 0 1 0 -k 0 -k 0 -k 0 -k 1 -k 1 -k 1;

What is actually going on when you have values of 0 0 0 and 1 1 1 with the same -k flag.

Struggle to find any mel explaination in the help docs.

Thanks mate,
Nick.

CGTalk Moderation
10-08-2009, 01:41 PM
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.