Class UVWMapper

3DS Max Plug-In SDK

Class UVWMapper

See Also: Class Mesh, Class Matrix3, Class Point3.

class UVWMapper

Description:

This class is available in release 3.0 and later only.

Prior to release 3.0, developers could implement Object::ApplyUVWMap() in their objects, but didn't have access to the algorithm 3ds max uses internally to turn the mapping types (MAP_BOX, MAP_PLANE, etc) into an actual vertex-to-mapping-coordinate function. This class now makes this available.

The constructors for the class initialize the data members with information about the mapping desired. The main method, MapPoint(), maps a point in object space into the UVW map defined by this mapper.

Note: typedef Point3 UVVert;

Data Members:

public:

int type;

The mapping type. One of the following values:

MAP_PLANAR

MAP_CYLINDRICAL

MAP_SPHERICAL

MAP_BALL

MAP_BOX

MAP_FACE

int cap;

This is used with MAP_CYLINDRICAL. If nonzero, then any face normal that is pointing more vertically than horizontally will be mapped using planar coordinates.

float utile;

Number of tiles in the U direction.

float vtile;

Number of tiles in the V direction.

float wtile;

Number of tiles in the W direction.

int uflip;

If nonzero the U values are mirrored.

int vflip

If nonzero the V values are mirrored.

int wflip;

If nonzero the W values are mirrored.

Matrix3 tm;

This defines the mapping space. As each point is mapped, it is multiplied by this matrix, and then it is mapped.

Methods:

public:

Prototype:

UVWMapper();

Remarks:

Constructor. The data members are initialized as follows:

 type = MAP_BOX;

 utile = 1.0f;

 vtile = 1.0f;

 wtile = 1.0f;

 uflip = 0;

 vflip = 0;

 wflip = 0;

 cap = 0;

 tm.IdentityMatrix();

Prototype:

UVWMapper(int type, const Matrix3 &tm, int cap=FALSE, float utile=1.0f, float vtile=1.0f, float wtile=1.0f,int uflip=FALSE, int vflip=FALSE, int wflip=FALSE);

Remarks:

Constructor. The data members are initialized to the values passed.

Prototype:

UVWMapper(UVWMapper& m);

Remarks:

Constructor. The data members are initialized from the UVWMapper passed.

Prototype:

UVVert MapPoint(Point3 p, const Point3 & norm, int *nan=NULL);

Remarks:

This method maps a point in object space into the UVW map defined by this mapper. This gives the UVW coordinates for the specified point according to this mapper's mapping scheme.

Parameters:

Point3 p

The location of a vertex, i.e. the point being mapped. This point should NOT be transformed by the UVWMapper's tm, as this happens internally.

const Point3 & norm

The direction of the surface normal at p. This information is only required for types MAP_BOX or MAP_CYLINDRICAL. See the method NormalMatters() below.

int *nan=NULL

If non-NULL, this points to an int which should be set to FALSE if this mapping is good for all faces using this vertex, or TRUE if different faces should have different mapping coordinates. This is generally set to TRUE more often than absolutely necessary to make sure nothing is missed.

Return Value:

The mapped point.

Prototype:

UVVert TileFlip(UVVert uvw);

Remarks:

Applies the UVWMap's tile and flip parameters to the given UVVert, and returns the result..

Parameters:

UVVert uvw

The input UVVert.

Return Value:

The modified UVVert.

Prototype:

int MainAxis(const Point3 & n);

Remarks:

This method indicates which direction the given vector "chiefly points", after vector transformation by the UVWMapper's transform.

Parameters:

const Point3 & n

The input vector whose main axis is determined.

Return Value:

One of the following values:

0: tm.VectorTransform(n) points mainly in the +x direction.

1: tm.VectorTransform(n) points mainly in the +y direction.

2: tm.VectorTransform(n) points mainly in the +z direction.

3: tm.VectorTransform(n) points mainly in the -x direction.

4: tm.VectorTransform(n) points mainly in the -y direction.

5: tm.VectorTransform(n) points mainly in the -z direction.

Prototype:

bool NormalMatters();

Remarks:

This method lets you know whether the current mapping type uses the normal information. If FALSE, it doesn't matter what value you pass as a normal to MapPoint. If TRUE, the MainAxis of the normal is used to determine the mapping.