Class NURBSSurface

3DS Max Plug-In SDK

Class NURBSSurface

See Also: Class NURBSObject, NURBSTextureSurface, Template Class Tab, Class NURBSTextureChannelSet.

class NURBSSurface : public NURBSObject

Description:

This class is available in release 2.0 and later only.

This class describes the properties of a NURBS surface. This includes its material ID, texture/tiling options, renderable state, open/closed state, and normal inverted state. The Evaluate() method is used to compute points and tangents on the surface.

All methods of this class are implemented by the system.

Friend Classes:

friend class NURBSCVSurface;

friend class NURBSPointSurface;

friend class NURBSBlendSurface;

friend class NURBSNBlendSurface;

friend class NURBSOffsetSurface;

friend class NURBSXFormSurface;

friend class NURBSMirrorSurface;

friend class NURBSCapSurface;

friend class NURBSIsoCurve;

friend class NURBSProjectVectorCurve;

friend class NURBSProjectNormalCurve;

friend class NURBSSurfSurfIntersectionCurve;

friend class NURBSCurveOnSurface;

friend class NURBSPointCurveOnSurface;

friend class NURBSMultiCurveTrimSurface;

friend class NURBSTextureChannel;

friend class NURBSTextureChannelSet;

Data Members:

protected:

BOOL mGenUVs;

TRUE if the 'Generate Mapping Coordinates' checkbox is on; otherwise FALSE.

BOOL mFlipNormals;

TRUE if the surface normals are inverted; otherwise FALSE.

BOOL mRenderable;

TRUE if the surface may be rendered; otherwise FALSE.

int mMatID;

The material ID for the surface.

BOOL mClosedInU, mClosedInV;

The surface closed flags.

NURBSTextureChannelSet mTextureChannelSet;

This data member is available in release 3.0 and later only.

This is the set of texture mapping channels used by this surface.

BOOL mFlipNormals;

TRUE if normals are flipped for the surface; otherwise FALSE.

BOOL mRenderable;

TRUE if the surface is renderable; otherwise FALSE.

int mMatID;

The zero based material ID for the surface.

BOOL mClosedInU

TRUE if the surface is closed in U; otherwise FALSE.

BOOL mClosedInV;

TRUE if the surface is closed in V; otherwise FALSE.

TessApprox *mpVTess;

This data member is available in release 3.0 and later only.

Points to the TessApprox object for the viewport (optional).

TessApprox *mpRTess;

This data member is available in release 3.0 and later only.

Points to the TessApprox object for the production renderer (optional).

TessApprox *mpRTessDisp;

This data member is available in release 3.0 and later only.

Points to the TessApprox object for displacement mapping (optional).

TessApprox *mpVTessCurve;

This data member is available in release 3.0 and later only.

Points to the TessApprox object for tesselating curves in the viewports(optional).

TessApprox *mpRTessCurve;

This data member is available in release 3.0 and later only.

Points to the TessApprox object for tesselating curves in the production renderer (optional).

Methods:

Prototype:

NURBSSurface();

Remarks:

Constructor. The surface is initialized as follows:

 mKind = kNURBSSurface;

 mFlipNormals = FALSE;

 mRenderable = TRUE;

 mMatID = 1;

 mpVTess = NULL;

 mpRTess = NULL;

 mpRTessDisp = NULL;

 mpVTessCurve = NULL;

 mpRTessCurve = NULL;

Prototype:

~NURBSSurface();

Remarks:

Destructor. Any TessApprox objects are freed.

Prototype:

BOOL Renderable();

Remarks:

Returns TRUE if the surface is renderable; otherwise FALSE.

Prototype:

void Renderable(BOOL state);

Remarks:

Sets the renderable flag to the specified state.

Parameters:

BOOL state

TRUE for renderable; FALSE for non-renderable.

Prototype:

BOOL FlipNormals();

Remarks:

Returns the state of the flip normals flag.

Prototype:

void FlipNormals(BOOL state);

Remarks:

Set the state of the flip normals flag.

Parameters:

BOOL state

TRUE if the normals should be flipped; FALSE for not flipped.

Prototype:

BOOL GenerateUVs(int channel = 0);

Remarks:

Returns TRUE if the generate UV mapping coordinates flag is set for the specified channel; otherwise FALSE.

Parameters:

int channel = 0

The channel. This is a number in the range 0 and 98 which correspond to 1 to 99 in the user interface.

Prototype:

void SetGenerateUVs(BOOL state, int channel = 0);

Remarks:

Sets the state of the generate UV mapping coordinates flag.

Parameters:

BOOL state

TRUE for on; FALSE for off.

int channel = 0

The channel. This is a number in the range 0 and 98 which correspond to 1 to 99 in the user interface.

Prototype:

int MatID();

Remarks:

Returns the material ID.

Prototype:

void MatID(int id);

Remarks:

Sets the mateials ID to the specified value.

Parameters:

int id

Specifies the material ID to set.

Prototype:

Point2 GetTextureUVs(TimeValue t, int i, int channel = 0);

Remarks:

Returns the specified texture coordinate.

Parameters:

TimeValue t

The time to get the texture UVs.

int i

The zero based index of the coordinate to return. This value must be >=0 and < 4.

int channel = 0

The channel. This is a number in the range 0 and 98 which correspond to 1 to 99 in the user interface.

Prototype:

void SetTextureUVs(TimeValue t, int i, Point2 pt, int channel = 0);

Remarks:

Set the specified texture coordinate to the specified value.

Parameters:

TimeValue t

The time to set the texture UVs.

int i

The zero based index of the texture coordinate to set. This value must be >= 0 and < 4.

Point2 pt

The texture coordinate value to set.

int channel = 0

The channel. This is a number in the range 0 and 98 which correspond to 1 to 99 in the user interface.

Prototype:

void GetTileOffset(TimeValue t, float &ut, float &vt, float &uo, float &vo, int channel = 0);

Remarks:

Retrieves the texture tiling and offset values for the surface.

Parameters:

TimeValue t

The time to get the tile offset.

float &ut

The tiling value in the U direction.

float &vt

The tiling value in the V direction.

float &uo

The offset value in the U direction.

float &vo

The offset value in the V direction.

int channel = 0

The channel. This is a number in the range 0 and 98 which correspond to 1 to 99 in the user interface.

Prototype:

void SetTileOffset(TimeValue t, float ut, float vt, float uo, float vo, int channel = 0);

Remarks:

Sets the texture tiling and offset values for the surface.

Parameters:

TimeValue t

The time to set the tile offset.

float ut

The tiling value in the U direction.

float vt

The tiling value in the V direction.

float uo

The offset value in the U direction.

float vo

The offset value in the V direction.

int channel = 0

The channel. This is a number in the range 0 and 98 which correspond to 1 to 99 in the user interface.

Prototype:

NURBSTextureSurface& GetTextureSurface(int channel);

Remarks:

This method is available in release 3.0 and later only.

Returns a reference to the texture surface used by this surface for the specified channel.

Parameters:

int channel

The channel. This is a number in the range 0 and 98 which correspond to 1 to 99 in the user interface.

Prototype:

void SetTextureSurface(int channel, NURBSTextureSurface& texSurf);

Remarks:

This method is available in release 3.0 and later only.

Sets the texture surface used by this surface for the specified channel.

Parameters:

int channel

The channel. This is a number in the range 0 and 98 which correspond to 1 to 99 in the user interface.

NURBSTextureSurface& texSurf

The texture surface to set.

Prototype:

int NumChannels();

Remarks:

This method is available in release 3.0 and later only.

Returns the number of channels used by the surface.

Prototype:

int GetChannelFromIndex(int index);

Remarks:

This method is available in release 3.0 and later only.

Returns a channel number corresponding to the specified index into the NURBSTextureChannelSet.

Parameters:

int index

The zero based index into the NURBSTextureChannelSet.

Prototype:

BOOL IsClosedInU();

Remarks:

Returns TRUE if the surface is closed in the U direction; otherwise FALSE.

Prototype:

BOOL IsClosedInV();

Remarks:

Returns TRUE if the surface is closed in the V direction; otherwise FALSE.

Prototype:

BOOL Evaluate(TimeValue t, double u, double v, Point3& pt, Point3& dPdU, Point3& dPdV);

Remarks:

Retrieves the point on the surface, and the u and v derivatives based on the parameters u and v.

Parameters:

TimeValue t

The time at which to evaluate the surface.

double u

The value at which to evaluate the surface in u. This value must be between the uMin and uMax as returned from GetParameterRange().

double v

The value at which to evaluate the surface in v. This value must be between the vMin and vMax as returned from GetParameterRange().

Point3& pt

The point on the surface.

Point3& dPdU

The derivative along u.

Point3& dPdV

The derivative along v.

Return Value:

TRUE if the method was able to evaluate the surface; otherwise FALSE.

Prototype:

BOOL Evaluate(TimeValue t, double u, double v, Point3& pt, Point3& dPdU, Point3& dPdV, Point3& d2PdU2, Point3& d2PdV2, Point3& d2PdUdV);

Remarks:

Retrieves the point on the surface, and the u and v derivatives and second derivatives based on the parameters u and v.

Parameters:

TimeValue t

The time at which to evaluate the surface.

double u

The value at which to evaluate the surface in u. This value must be between the uMin and uMax as returned from GetParameterRange().

double v

The value at which to evaluate the surface in v. This value must be between the vMin and vMax as returned from GetParameterRange().

Point3& pt

The point on the surface.

Point3& dPdU

The derivative along u.

Point3& dPdV

The derivative along v.

Point3& d2PdU2

The second derivative along u.

Point3& d2PdV2

The second derivative along v.

Point3& d2PdUdV

Return Value:

TRUE if the method was able to evaluate the surface; otherwise FALSE.

Prototype:

void GetParameterRange(TimeValue t, double& uMin, double& uMax, double& vMin, double& vMax);

Remarks:

Retrieves the minimum and maximum valid values for u and v as passed to Evaluate().

Parameters:

TimeValue t

The time at which to get the parameter range.

double& uMin

The minimum value in u is returned here.

double& uMax

The maximum value in v is returned here.

double& vMin

The minimum value in u is returned here.

double& vMax

The maximum value in v is returned here.

Prototype:

BOOL GetNURBSData(TimeValue t, int& degreeInU, int& degreeInV, int& numInU, int& numInV, NURBSCVTab& cvs, int& numKnotsInU, int& numKnotsInV, NURBSKnotTab uKnots, NURBSKnotTab vKnots);

Remarks:

This method is available in release 2.5 and later only.

Retrieves data about the NURBSSurface at the specified time.

Parameters:

TimeValue t

The time at which to get the NURBS information.

int& degreeInU

The degree of the surface in U.

int& degreeInV

The degree of the surface in V.

int& numInU

The number of CVs in U.

int& numInV

The number of CVs in V.

NURBSCVTab& cvs

The table of CVs. Note: typedef Tab<NURBSControlVertex> NURBSCVTab;

int& numKnotsInU

The number of knots in U.

int& numKnotsInV

The number of knots in V.

NURBSKnotTab uKnots

A table of knots in U. Note: typedef Tab<double> NURBSKnotTab;

NURBSKnotTab vKnots

A table of knots in V.

Return Value:

TRUE if the data was retrieved; otherwise FALSE.

Prototype:

BOOL GetCLPTextureSurfaceData(TimeValue t, int channel, int& degreeInU, int& degreeInV, int& numInU, int& numInV, NURBSCVTab& cvs, int& numKnotsInU, int& numKnotsInV, NURBSKnotTab uKnots, NURBSKnotTab vKnots);

Remarks:

This method is available in release 2.5 and later only.

This method retrieves the Chord Length Parameterization Texture Surface data.

Parameters:

TimeValue t

The time at which to retrieve the data.

int channel

The texture channel. This is a number in the range 0 and 98 which correspond to 1 to 99 in the user interface.

int& degreeInU

The degree of the surface in U.

int& degreeInV

The degree in V.

int& numInU

The number of CVs in U.

int& numInV

The number of CVs in V.

NURBSCVTab& cvs

The table of CVs. Note: typedef Tab<NURBSControlVertex> NURBSCVTab;

int& numKnotsInU

The number of knots in U.

int& numKnotsInV

The number of knots in V.

NURBSKnotTab uKnots

A table of knots in U. Note: typedef Tab<double> NURBSKnotTab;

NURBSKnotTab vKnots

A table of knots in V.

Return Value:

TRUE if the data was retrieved; otherwise FALSE.

Prototype:

int NumTrimLoops(TimeValue t);

Remarks:

This method is available in release 2.5 and later only.

Returns the number of trim loops at the specified time. Each loop may be made up of several curves.

Parameters:

TimeValue t

The time at which to return the number.

Prototype:

int NumCurvesInLoop(TimeValue t, int loop);

Remarks:

This method is available in release 2.5 and later only.

Returns the number of curves in the specified trim loop.

Parameters:

TimeValue t

The time at which to return the number.

int loop

The zero based index of the trim loop.

Prototype:

BOOL Get2dTrimCurveData(TimeValue t, int loop, int curve, int& degree, int& numCVs, NURBSCVTab& cvs, int& numKnots, NURBSKnotTab knots);

Remarks:

This method is available in release 2.5 and later only.

Retrieves data about the specified 2D trim curve in use by the surface.

Parameters:

TimeValue t

The time at which to retrieve the data.

int loop

The zero based index of the trim loop.

int curve

The zero based index of the trim curve within the loop.

int& degree

The degree of the curve is returned here.

int& numCVs

The number of CVs.

NURBSCVTab& cvs

The table of CVs. Note: typedef Tab<NURBSControlVertex> NURBSCVTab;

int& numKnots

The number of knots.

NURBSKnotTab knots

A table of knots. Note: typedef Tab<double> NURBSKnotTab;

Return Value:

TRUE if the data was retrieved; otherwise FALSE.

Prototype:

BOOL Get3dTrimCurveData(TimeValue t, int loop, int curve, int& degree, int& numCVs, NURBSCVTab& cvs, int& numKnots, NURBSKnotTab knots);

Remarks:

This method is available in release 2.5 and later only.

Retrieves data about the specified 2D trim curve in use by the surface.

Parameters:

TimeValue t

The time at which to retrieve the data.

int loop

The zero based index of the trim loop.

int curve

The zero based index of the trim curve within the loop.

int& degree

The degree of the curve is returned here.

int& numCVs

The number of CVs.

NURBSCVTab& cvs

The table of CVs. Note: typedef Tab<NURBSControlVertex> NURBSCVTab;

int& numKnots

The number of knots.

NURBSKnotTab knots

A table of knots. Note: typedef Tab<double> NURBSKnotTab;

Return Value:

TRUE if the data was retrieved; otherwise FALSE.

Prototype:

TessApprox* GetProdTess(NURBSTessType type=kNTessSurface);

Remarks:

This method is available in release 3.0 and later only.

Returns a pointer to the TessApprox object used for production rendering of the specified type.

Parameters:

NURBSTessType type=kNTessSurface

The tesselation type. See List of NURBSTessTypes.

Prototype:

TessApprox* GetViewTess(NURBSTessType type=kNTessSurface);

Remarks:

This method is available in release 3.0 and later only.

Returns a pointer to the TessApprox object used for viewport rendering of the specified type.

Parameters:

NURBSTessType type=kNTessSurface

The tesselation type. See List of NURBSTessTypes.

Prototype:

void SetProdTess(TessApprox& tess, NURBSTessType type=kNTessSurface);

Remarks:

This method is available in release 3.0 and later only.

Sets the TessApprox object used for production rendering of the specified type.

Parameters:

TessApprox& tess

The object to set.

NURBSTessType type=kNTessSurface

The tesselation type. See List of NURBSTessTypes.

Prototype:

void SetViewTess(TessApprox& tess, NURBSTessType type=kNTessSurface);

Remarks:

This method is available in release 3.0 and later only.

Sets the TessApprox object used for viewport rendering of the specified type.

Parameters:

TessApprox& tess

The object to set.

NURBSTessType type=kNTessSurface

The tesselation type. See List of NURBSTessTypes.

Prototype:

void ClearViewTess(NURBSTessType type=kNTessSurface);

Remarks:

This method is available in release 3.0 and later only.

Clears (deletes) the TessApprox object used for viewport rendering of the specified type.

Parameters:

NURBSTessType type=kNTessSurface

The tesselation type. See List of NURBSTessTypes.

Prototype:

void ClearProdTess(NURBSTessType type=kNTessSurface);

Remarks:

This method is available in release 3.0 and later only.

Clears (deletes) the TessApprox object used for production rendering of the specified type.

Parameters:

NURBSTessType type=kNTessSurface

The tesselation type. See List of NURBSTessTypes.

Operators:

Prototype:

NURBSSurface & operator=(const NURBSSurface& curve);

Remarks:

Assignment operator.

Parameters:

const NURBSSurface& curve

The surface to assign.