MultiMap


Multiple Mapping Channel MAXScript extension. Use at your own risk.
Copyright ©2000, Discreet
By Simon Feltman, simon@asylum-soft.com
Asylum Software, http://www.asylum-soft.com
Report any problems directly to me.



Methods:
 SetNumMaps
 GetNumMaps
 SetMapSupport
 GetMapSupport
 SetNumMapVerts
 GetNumMapVerts
 SetNumMapFaces
 GetNumMapFaces
 SetMapVert
 GetMapVert
 SetMapFace
 GetMapFace
 MakeMapPlanar
 GetIsoMapVerts
 DeleteMapVertSet
 DeleteIsoMapVerts
 FreeMapVerts
 ApplyUVWMap



The mesh mapping channel may be specified as one of the following:
 1: Vertex Color channel.
 2: Default mapping channel (the texture vertex array).
 3 to 100: The new mapping channels available in release 3.0.



SetNumMaps

Prototype:
 SetNumMaps <Mesh mesh> <Integer ct> [Boolean keep=false]

Remarks:
 Set the number of texture maps used by this Mesh. Note that this call is made automatically if SetMapSupport() is called.

Parameters:
 Integer ct
  The number to use. This is a value between 2 and 100.

 Boolean keep=false
  true to keep the old mapping information after the resize; false to discard it.

top


GetNumMaps

Prototype:
 Integer GetNumMaps <Mesh mesh>

Remarks:
 Returns the number of mapping channels in use.

top


SetMapSupport

Prototype:
 SetMapSupport <Mesh mesh> <Integer mp> [Boolean keep=false]

Remarks:
 Sets whether the specified mapping channels is supported or not.

Parameters:
 Integer mp
  Specifies the channel.

 Boolean support=true
  true to indicate the channel is supported; otherwise false.

top


GetMapSupport

Prototype:
 Boolean GetMapSupport <Mesh mesh> <Integer mp>

Remarks:
 Returns true if the specified mapping channel is supported; otherwise false.

Parameters:
 Integer mp
  Specifies the channel.

top


SetNumMapVerts

Prototype:
 SetNumMapVerts <Mesh mesh> <Integer mp> <Integer ct> [Boolean keep=false]

Remarks:
 Establishes the number of texture or vertex color verticies for the specified mapping channel of this mesh.

Parameters:
 Integer mp
  Specifies the channel.

 Integer ct
  The number of vertices to allocate.

 Boolean keep=FALSE
  If true previous values are kept; otherwise they are discarded.

top


GetNumMapVerts

Prototype:
 Integer GetNumMapVerts <Mesh mesh> <Integer mp>

Remarks:
 Returns the number of texture or vertex color verticies for the specified channel of this mesh.

Parameters:
 Integer mp
  Specifies the channel.

top


SetNumMapFaces

Prototype:
 SetNumMapFaces <Mesh mesh> <Integer mp> <Integer ct> [Boolean keep=false] [Integer oldCt=0]

Remarks:
 Establishes the number of texture or vertex color faces for the specified channel of this mesh.

Parameters:
 Integer mp
  Specifies the channel.

 Integer ct
  The number of faces to allocate.

 Boolean keep=false
  If true previous values are kept; otherwise they are discarded.

top


GetNumMapFaces

Prototype:
 Integer GetNumMapFaces <Mesh mesh> <Integer mp>

Remarks:
 Get the number of texture or vertex color faces in the specified channel of this mesh.

Parameters:
 Integer mp
  Specifies the channel.

top


SetMapVert

Prototype:
 SetMapVert <Mesh mesh> <Integer mp> <Integer i> <Point3 xyz>

Remarks:
 Sets a single texture or vertex color vertex value for the specified channel of this mesh.

Parameters:
 Integer mp
  Specifies the channel.

 Integer i
  The one based index of the vertex to set.

 Point3 xyz
  The value to set.

top


GetMapVert

Prototype:
 Point3 GetMapVert <Mesh mesh> <Integer mp> <Integer i>

Remarks:
 Gets a single texture or vertex color vertex value for the specified channel of this mesh.

Parameters:
 Integer mp
  Specifies the channel.

 Integer i
  The one based index of the vertex to get.

top


SetMapFace

Prototype:
 SetMapFace <Mesh mesh> <Integer mp> <Integer i> <Point3 face>

Remarks:
 Sets a single texture or vertex color face.

Parameters:
 Integer mp
  Specifies the channel.

 Integer i
  The one based index of the face to set.

 Point3 face
  The value to set.

top


GetMapFace

Prototype:
 Point3 GetMapFace <Mesh mesh> <Integer mp> <Integer i>

Remarks:
 Returns a single texture or vertex color face.

Parameters:
 Integer mp
  Specifies the channel.

 Integer i
  The one based index of the face to get.

top


MakeMapPlanar

Prototype:
 MakeMapPlanar <Mesh mesh> <Integer mp>

Remarks:
 Applies a simple planar mapping to the specified channel. This is done by copying the mesh topology and vertex locations into the map.

Parameters:
 Integer mp
  Specifies the channel.

top


GetIsoMapVerts

Prototype:
 BitArray GetIsoMapVerts <Mesh mesh> <Integer mp>

Remarks:
 Returns a BitArray with a bit set for each isolated vertex (unrefereced by any face) for the specified channel.

Parameters:
 Integer mp
  Specifies the channel.

top


DeleteMapVertSet

Prototype:
 DeleteMapVertSet <Mesh mesh> <Integer mp> <BitArray set>

Remarks:
 Deletes the map vertices indicated.

Parameters:
 Integer mp
  Specifies the channel.

 BitArray set
  Indicates which map verts should be deleted. set.GetSize() should equal this mesh's getNumMapVerts(mp).

top


DeleteIsoMapVerts

Prototype:
 DeleteIsoMapVerts <Mesh mesh> [Integer mp = 0]

Remarks:
 This method deletes each isolated vertex (unrefereced by any face) for the specified channel.

Parameters:
 Integer mp
  Specifies the channel. The default value of 0 indicates to do all active maps.

top


FreeMapVerts

Prototype:
 FreeMapVerts <Mesh mesh> <Integer mp>

Remarks:
 Deallocates the texture or vertex color verticies for the specified channel of this mesh.

Parameters:
 Integer mp
  Specifies the channel.

top


FreeMapFaces

Prototype:
 FreeMapFaces <Mesh mesh> <Integer mp>

Remarks:
 Deallocates the texture or vertex color faces for the specified channel of this mesh.

Parameters:
 Integer mp
  Specifies the channel.

top


ApplyUVWMap

Prototype:
 ApplyUVWMap <TriMesh mesh> <#map_planar | #map_cylindrical | #map_spherical | #map_ball | #map_box> <float utile> <float vtile> <float wtile> <integer uflip> <integer vflip> <integer wflip> <integer cap> <Matrix3 tm> [integer channel=1]

Remarks:
 This method may be called to map this Mesh with UVW mapping coordinates. It can be very usefull if you have a scripted plugin that supports "Generate UVW"

Parameters:
 float utile
  Number of tiles in the U direction.

 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.

 integer uflip
  If nonzero the U values are mirrored.

 integer vflip
  If nonzero the V values are mirrored.

 integer wflip
  If nonzero the W values are mirrored.

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

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

 integer channel=1
  This indicates which channel the mapping is applied to -- channel==1 corresponds to the original texture mapping channel.

top


Example:


-- Cheap chrome effect, uses vertex normals as texture coordinates.
fn ApplyCheapChrome msh chn =
(
	if (classOf msh) != Editable_mesh then
		return

	SetMapSupport msh chn true
	SetNumMapVerts msh chn (GetNumVerts msh)
	SetNumMapFaces msh chn (GetNumFaces msh)

	for i = 1 to (GetNumVerts msh) do
	(
		norm = GetNormal msh i
		norm.x = norm.x * 0.5 + 0.5
		norm.y = norm.y * 0.5 + 0.5
		norm.z = 0.0
		SetMapVert msh chn i norm
	)

	for i = 1 to (GetNumFaces msh) do
		SetMapFace msh chn i (GetFace msh i)
)

top