Creating New NURBS Objects

The NURBS classes can be used to create new NURBS scene objects. This is done by adding the objects (points, curves and surfaces) to an item called a NURBSSet and passing it to the function NURBSNode(). The NURBSSet is a container for the objects that define each element in the scene NURBS object. The function NURBSNode() makes an internal 3ds Max NURBS object from the specifications in the set. The function NURBSNode() is documented in Creating NURBS Scene Objects.

As an example, consider the following code fragment that creates a NURBSCVCurve object (with NURBSControlVertex sub-objects) and puts it in the scene:

Example:

-- create an empty NURBSSet object

nset = NURBSSet ()

-- create a new NURBSCVCurve and set the knots and CVs

c = NURBSCVCurve name:"CV Curve" order:4 numCVs:4 numKnots:8

for k in 1 to 4 do ( setKnot c k 0; setKnot c (k+4) 1 )

cv = NURBSControlVertex [0, 0, 50]

setCV c 1 cv

cv.pos = [-100, 0, 50]

setCV c 2 cv

cv.pos = [-100, 100, 50]

setCV c 3 cv

cv.pos = [0, 100, 50]

setCV c 4 cv

-- add the NURBSCVCurve object to the set

appendObject nset c

-- create the NURBS object from the NURBSSet

n = NURBSNode nset name:"nurbs01" pos:[10,0,0]

Note that the NURBSSet supplied to the NURBSNode() function will be modified by that function to be a relational representative for the newly created scene node which you can then use to modify the scene object -- you don't have to re-extract a fresh relational NURBSSet.