# Manually making a NURBSCurve

I’m in need of making a NURBSCurve for a motion path… but it looks like the best tool I have for making one is Notepad.

I’ve read the manual but I’m still a bit puzzled about how I should do it.

I probably need a Vertex Pool with some verts in it:

``````<VertexPool> verts {
<Vertex> 0 {
1 2 3
}
<Vertex> 1 {
3 4 5
}
<Vertex> 2 {
6 7 8
}
}``````

But the manual says:

Dose that mean I should put 4 coordinates for each Vertex if I want my curve in 3d not 2d? Something like this:

``````<VertexPool> verts {
<Vertex> 0 {
1 2 3 1
}
<Vertex> 1 {
3 4 5 1
}
<Vertex> 2 {
6 7 8 1
}
}``````

Next, the … I don’t even know what a “degree of the polynomial basis” is… but the manual says it should be an int between 1 and 4, so putting 2 should be safe.

In I’d put my vertex, like this:

``<VertexRef> { 0 1 2 <Ref> { verts } }   ``

…em…well… what do I put here?

type … it’s not mandatory, but what does XYZ, HPR, or T actually mean?

Or maybe someone has a valid egg with a NURBSCurve that I could take a look at?

NURBS are more-or-less standard math in 3-D graphics, though they’re not as common now as they were at the top of their hype curve. Try this page for an introduction to some of the concepts: http://www.rhino3d.com/nurbs.htm

Usually, your NURBS curves will be order 4 (which is degree 3, as described on the above page).

Your knot vector is usually a sequence of increasing integers, with the first three and last three numbers all the same (if you have order 4 curve). For instance, 0 0 0 1 2 3 4 5 5 5. You have to match the number of knots to the number of vertices you have. You can do other tricks with different knot vectors, but that’s more advanced.

You have the right idea with the four-component vertices. Usually you just tack on a 1 at the end. You can do other tricks with a different value than 1, but that’s more advanced too.

XYZ, HPR, and T describe the intended meaning of the components of your curve. For a curve in space, it will be type XYZ. HPR means that the three components refer to the H,P,R components of a rotation, instead of the X,Y,Z components of a point in space. This kind of curve can’t be rendered, but you can use it to modify an object’s rotation according to a given value of t. A “T” curve uses only the X component and ignores Y and Z, and understands the X component to be another value of T: this is a mapping of time to time, otherwise called a “timewarp” curve, which is an advanced concept and rarely used.

David

I’ve managed to get something working. My egg looks like this:

``````<CoordinateSystem> { Z-Up }
<VertexPool> verts {
<Vertex> 0 {
0 0 0 1
}
<Vertex> 1 {
0 0.5 0.5 1
}
<Vertex> 2 {
1 0 1 1
}
<Vertex> 3 {
0 -1.5 1.5 1
}
<Vertex> 4 {
-2 0 2 1
}
<Vertex> 5 {
2 2.5 2.5 1
}
<Vertex> 6 {
3 0 3 1
}
<Vertex> 7 {
0 -3.5 3.5 1
}
}
<NURBSCurve> {
<Order> {3}
<VertexRef> { 0 1 2 3 4 5 6 <Ref> { verts } }
<Knots>{0 1 2 3 4 5 6 7 8 9}
}``````

and Panda is happy with that. I’ve tried to make it visible adding subdiv { 4 } to the file, but nothing seems to be rendered. When used as a mopath, a model moves more or less in a way I’d expect (a kind of spiral).

Knots still puzzle me. I’ve used two vectors to compare, one is:0 1 2 3 4 5 6 7 8 9 and the other: 0 0 1 1 2 2 3 3 4 4. When I use them as mopaths then the shape my object fly is more or less the same (it’s hard to tell if you can’t see them), but the second one is much faster (in terms of movement speed not FPS).

In order for the subdiv trick to work, you have to be using the new-style nurbs object. You can switch to the new style by setting: