Required Changes To Patches

3DS Max Plug-In SDK

Required Changes To Patches

See Also: What's New in the MAX 3.0 SDK, Required Changes to MAX 2.0 Plug-Ins for MAX 3.0.

Overview

This section discusses some of the changes to the patch related classes in the SDK. The main changes relate to the fact that Patch objects became editable Patches objects and that patches now support more that two mapping channels.

Mapping Channel Changes

PatchMesh objects no longer use a hard coded PATCH_TEXTURE_CHANNELS number of maps, but rather a dynamically allocated amount up to MAX_MESHMAPS (100). The following data members have been changed from fixed-size arrays to tables:

// Texture Coord assignment

Tab<int> numTVerts;

Tab<UVVert *> tVerts;

Tab<TVPatch *> tvPatches;

As before, the patch is considered to have a map on channel 'i' if tvPatches[i] is not NULL. There are PatchMesh::numPatches elements in each tvPatches array, and numTVerts[i] UVVerts in array tVerts[i].

IMPORTANT NOTE: previously, developers could only have 2 map channels. Map channel 0 represented traditional texture verts and map channel 1 represented vertex colors. As with meshes, this has been reversed for R3: channel 0 in these tables and methods is the Vertex Color channel, and channels 1-99 are map channels 1-99.

To maintain the number of maps, the following method has been introduced:

void setNumMaps(int ct, BOOL keep=TRUE);

If keep is FALSE, all the existing maps will be freed; otherwise, only those over 'ct' will be freed. New map channels are initialized with NULL arrays and 0 numTVerts. (numTVerts, tVerts, and tvPatches

are all set to a size of 'ct'.)

However, most developers won't have to worry about calling this method, since it's called by setNumTVertsChannel(), which has been used to set the number of mapping verts in each channel.

There are now two versions of most methods handling maps in patches, to cope with a necessary change in map indexing between 3ds max 2.5 and 3.0 (This problem comes up in patches, but not meshes, since patches already had a channel indexing scheme in methods like setNumTVertsChannel(). Mesh only had methods like setNumTVerts(), with no channel argument.)

Old TV/VC methods are given with "TV" in the name. For these methods, channel 0 is the original map channel, while any nonzero channel is vertex colors. If no index is given, the original map channel is assumed. This is all consistent with usage in the 2.5 SDK.

New methods are given with "Map" in the name. For these methods, channel 0 is the VC channel, as it is now in Object. Channel 1 is the original map channel, while 2-99 are the new channels. The plan here is that the "Map" methods will be used in future, the "TV" methods will be considered obselete.

There is one incompatibility with the 2.5 SDK, in that the public data members numTVerts, tVerts, and tvPatches all now use the new indexing scheme, and are now Tab<> tables instead of simple arrays as noted above.

Links to Changed Classes:

PatchObject

Class PatchMesh

Class Patch

Class PatchVec

Class PatchVert

Class PatchEdge

Class TVPatch