Vertex Map Object Agents
The constructor for VMap Object Agents is called VMap(), and in most cases it can be used globally.
vmap = VMap(<VMap Type>);
This constructor returns a VMap Object Agent. VMaps can be identified by name string or by integer index of a particular VMap type. These VMap types are described below:
VMap() will return 'nil' if no Vertex Maps of that type exist in the system. Invoking VMap() without a specific Vertex Map type argument will cause VMap() to return the first Vertex Map it encounters in the system. From this starting Vertex Map, you can iterate through all other maps with the next() method. The next() method disregards type boundaries, so if you want to process specific types of Vertex Maps, you must watch for them.
The VMap Object Agent can also create user-defined vertex maps in Modeler. The method used is nearly identical to the method for creating a new vertex map from a pre-defined type. To generate a custom vertex map, you must provide a custom map type instead of a pre-defined type identifier. Custom map types are a unique four-character sequence, housed in an initialization block.
For example, to generate a vertex map of type NMBK, named my_normals, with two data elements per point, you use the following code:
@define VMAP_NMBK @'N','M','B','K'@
normMap = VMap(VMAP_NMBK,"my_normals",2);
Be aware that custom vertex maps will not appear anywhere in the application's interface. Because the types are not known to the application, no allocation is made for them. They will, however, be stored into the object file when it is saved, and will continue to be transported within the object file.
The VMap() constructor will return 'nil' if it fails to generate the new vertex map, regardless of its mode (custom or pre-defined).
The LScript VMap Object Agent
lacking any mechanism for directly accessing custom VMaps defined in an
object. This has been rectified by allowing custom type
identities to be used when referencing a VMap either by index:
The currently selected Weight,
Texture or Morph vertex map can now be acquired in Modeler by providing
an index value of zero (0) to the VMap()
constructor when specifying one of the three vertex map types:
An array of values can also be provided as the values for the point identifier. If no optional index is included, then each element in the array will be placed into the corresponding value slot for the point identifier in the Vertex Map. If an index is provided, then elements in the array will begin populating the values for the point identifier at the indicated index offset.
Modification of a Vertex Map using the setValue() method is considered mesh editing, and can only be performed within Modeler LScript. Consequently, this method does not exist in Object Agents generated from Layout LScripts. Further, you must be within an initiated Mesh Data Edit session before you can successfully invoke this method.
The following is an example Modeler LScript that allows the user to select an existing Weight VMap, and will then apply a scaling factor uniformly to each of its values:
= VMap(vmapnames[vndx]) || error("Could not instance