Mesh Object Agents

 

The Mesh() constructor can be called from any LScript, either Modeler or Layout. In Modeler, an exception exists that allows you to access the currently active mesh. By using an index value of zero (0), an Object Agent will be generated for the current mesh object.

obj    =    Mesh();           // Create a Mesh object
                                  // from the first object loaded.

obj    =    Mesh(0);      // Create a Mesh object
                               // from the currently selected object.

obj    =    Mesh("Cow");          // Create a Mesh object
                                          // from the object "Cow"

Note: Remember that not all of the common Data Members and Methods apply to Mesh Objects.

Data Members

id
id holds a string used internally by Modeler to uniquely identify the loaded object.

name
name holds a character string that represents the identifier for the object seen by the user in the interface.

filename
filename holds the full path filename for the object. If the object has yet to be saved to disc, then this value will be 'nil'.

layerloaded LW11.5 onwards
This returns the layer number of the selected mesh in Layout.

     selected = Scene().getSelect();
     layernumber = selected[1].layerloaded;

null
null contains a Boolean true/false to indicate if an object is a Null.

flags[ ]
The flags[] data member is an array of five elements. The first three elements duplicate the values found in the shadows[] data member. The remaining two elements, flags[4] and flags[5], indicate the object's current "Unseen By Camera" and "Unseeen By Rays" settings.

points[]
This is an array of the point identifiers that are contained by the object. It's maximum size is provided by the pointCount() method.

polygons[]
an array of polygon identifiers that are contained by the object. It's maximum size is provided by the polygonCount() method (which is also documented).

totallayers
This contains the integer count of the total number of layers in the object.

Methods

layerName([<layer>])
Returns the assigned name for the specified layer of the object. If the layer has yet to be assigned a name, then the method returns 'nil'.

layerVisible([<layer>])
Returns a Boolean true or false to indicate the visible state of the indicated layer.

pointCount([<layer>])
The pointCount([<layer>]) method reports the total number of points in the Mesh object, or optionally in an individual layer of Mesh (use the 'totallayers' data member to determine the valid layers in the object).

polygonCount([<layer>])
polygonCount([<layer>])reports the number of polygons in the object, or optionally in an individual layer of the Mesh.

layer(<point>|<polygon>)
layer(<point>|<polygon>)returns the integer layer number that contains the identified point or polygon.

position([<point>][<polygon>][<layer>])
The position([<point>][<polygon>][<layer>] method returns one of two types of values, depending upon the argument provided. If the argument is a point identifier, then the vector position of the point is returned. If the argument is a polygon identifier, then the bounding box of the polygon is returned as a low and high vector. If the argument is an integer layer identifier, then the bounding box of the mesh data found in that layer is returned as a low/high vector pair.

Finally, if no argument is provided, then the sum-total bounding box of all mesh data found in all valid layers is returned as a low/ high vector pair.

vertexCount(<polygon>)
vertexCount(<polygon>) reports the integer count of the number of vertices that comprise the identified Polygon.

vertex(<polygon>,<index>)
vertex(<polygon>,<index>)returns the Point identifier found at the indicated index offset of the identified Polygon.

select()
select()causes the object for which the Agent is proxy to become the current selection. In Layout, this selects the object in the scene. In Modeler, this switches the object into the active edit.

select(<point>|<polygon>) (MODELER ONLY)
select(<point>|<polygon>) selects the identified Polygon or Point. Because component selection is unique to mesh editing, this method is available only when executing under Modeler.

Examples:

This example works in Layout and creates a Mesh Object from the first object loaded. It then will display some of its properties.

@version 2.2
@warnings
@name MeshObjectAgent
@script generic

generic
{
    // Create a Mesh Object from first object loaded.
    mesh = Mesh() || error("No Object Loaded!");

// Data Members
info("name: ", mesh.name);
info("filename: ", mesh.filename);

// Methods
info("points: ", mesh.pointCount(1));
info("polygons: ", mesh.polygonCount(1));

}

Layout Commands

AddNull("<name>");
ClearAllObjects();
EditObjects();
LoadObject("<filename>");
LoadObjectLayer(,"<filename>");
MovePivotTool();
PivotPosition("<X>","<Y>","<Z>");
PivotRotation("<H>","<P>","<B>");
PositionServerByItemID("<H>","<P>","<B>");
RenameLayer();
SelectAllObjects();
Geometry Tab
MetaballResolution("<display>","<render>");
SubdivisionOrder("<order>");
SubPatchLevel("<display>","<render>");

Deform Tab
MorphAmount("<morph>");
MorphAmountTool();
MorphMTSE();
MorphSurfaces();
MorphTarget("<ID>");

Render Tab
MatteObject();
MatteColor("<red>","<green>","<blue>");
UnseenByAlphaChannel();
ObjectDissolve("<dissolve>");
DistanceDissolve();
MaxDissolveDistance("<distance>");(CI)
UnseenByRays();
UnseenByCamera();
UnseenByRadiosity();
UnaffectedByFog();
UnaffectedByFog();
SelfShadow();
CastShadow();
ReceiveShadow();

Edges Tab
PolygonEdgeColor("<red>","<green>","<blue>");
PolygonEdgeFlags("<flags>");
PolygonEdgeThickness("<silhouette>","<unshared>","<crease>","<surface>","<other>");
PolygonEdgeZScale("<scale>");
PolygonSize("<size>");
ShrinkEdgesWithDistance();

Lights Tab
ExcludeLight("<ID>");
IncludeLight("<ID>");

GI Tab
ObjGIUseGlobal("<ID>");
ObjGIRaysPerEvaluation("<ID>");
ObjGISecondaryBounceRays("<ID>");
ObjGIRadiosityTolerance("<ID>");
ObjGIMinPixelSpacing("<ID>");
ObjGIMinPixelSpacing("<ID>");