Class RVertex

3DS Max Plug-In SDK

Class RVertex

See Also: Class RNormal, Class Mesh, Class GraphicsWindow.

class RVertex

Description:

A RVertex is a rendered vertex. A vertex becomes a RVertex after it has been transformed. A RVertex has a position (x, y, z coordinate) that is stored in device coordinates. These are stored in the data member fPos[3].

One vertex in a Mesh can be shared between many different smoothing groups. In the 3ds max Mesh database, the vertices are shared, however the normals are not. This is why an RVertex has a RNormal data member. For example, if you had a sphere that had the top and bottom hemi-spheres smoothed separately (i.e. not smoothed across the equator), then the vertices across the equator would have two RNormals for each RVertex while the other vertices would have one. There may be as many RNormals as there are smoothing groups colliding at a vertex. However, it is by far the most common case to have one, and anything other than one or two is very rare.

For purposes of smoothing, as many RNormals are allocated as required and are stored in this class. RNormals are kept in this RVertex class since the RVertex is what gets rendered (lit). When you light a vertex you need to know its normal direction. Thus the RNormal(s) are stored in this class (using data member rn or *ern).

All methods of this class are implemented by the system.

Note: This class is used internally by 3ds max. Developers who need to compute face and vertex normals for a mesh should instead refer to the Advanced Topics section Computing Face and Vertex Normals.

Data Members:

public:

DWORD rFlags;

The flags contain the clip flags, the number of normals at the vertex, and the number of normals that have already been rendered. These are used internally. For example, the clipping flags are used to see if the RVertex can be either trivially accepted or rejected when rendering.

#define NORCT_MASK   0x000000ffUL

#define SPECIFIED_NORMAL 0x00004000UL

#define OUT_LEFT    0x00010000UL

#define OUT_RIGHT    0x00020000UL

#define OUT_TOP    0x00040000UL

#define OUT_BOTTOM   0x00080000UL

#define RECT_MASK    0x000f0000UL

#define RND_MASK    0xfff00000UL

#define RND_NOR0    0x00100000UL

#define RND_NOR(n)   (RND_NOR0 << (n))

union {

 int iPos[3];

// This position is no longer used.

 float fPos[3];

// This is used to store the position in device coordinates, [0]=x, [1]=y, [2]=z.

 };

RNormal rn;

If a single RNormal is used, it is stored here.

RNormal *ern;

In some cases, there may be two or more RNormals per vertex. If this is the case, these 'extra' RNormals are allocated and the pointer to the memory is stored here. If these are used, then data member rn is not used (rn is copied into ern[0]).

Methods:

Prototype:

RVertex();

Remarks:

Constructor. The flags are set to zero and the ern pointer is set to NULL.

Prototype:

~RVertex();

Remarks:

Destructor.