Public Member Functions | Public Attributes

UVWMapper Class Reference

Search for all occurrences

Detailed Description

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

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:
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.

#include <UVWMapper.h>

Inheritance diagram for UVWMapper:
Inheritance graph
[legend]

List of all members.

Public Member Functions

DllExport  UVWMapper ()
DllExport  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)
DllExport  UVWMapper (UVWMapper &m)
DllExport UVVert  MapPoint (Point3 p, const Point3 &norm, int *nan=NULL)
DllExport UVVert  TileFlip (UVVert uvw)
DllExport int  MainAxis (const Point3 &n)
bool  NormalMatters ()

Public Attributes

int  type
int  cap
float  utile
float  vtile
float  wtile
int  uflip
int  vflip
int  wflip
Matrix3  tm

Constructor & Destructor Documentation

DllExport 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();
DllExport 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.
DllExport UVWMapper ( UVWMapper m )
Remarks:
Constructor. The data members are initialized from the UVWMapper passed.

Member Function Documentation

DllExport 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.
Returns:
The mapped point.
DllExport 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.
Returns:
The modified UVVert.
DllExport 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.
Returns:
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.
bool NormalMatters ( ) [inline]
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.
{ return ((type==MAP_BOX || type==MAP_ACAD_BOX)||((type==MAP_CYLINDRICAL || type==MAP_ACAD_CYLINDRICAL )&&cap)) ? TRUE:FALSE; }

Member Data Documentation

int type
int cap
float utile
float vtile
float wtile
int uflip
int vflip
int wflip

UVWMapper UVWMapper UVWMapper UVWMapper UVWMapper UVWMapper UVWMapper UVWMapper UVWMapper UVWMapper
UVWMapper UVWMapper UVWMapper UVWMapper UVWMapper UVWMapper UVWMapper UVWMapper UVWMapper UVWMapper