Mesh Operation - Overview

From The Foundry MODO SDK wiki
Revision as of 16:30, 27 June 2016 by Mattcox (Talk | contribs) (Added page on Mesh Operations)

(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search

The Mesh Operation is the main interface for procedural modelling. It is provided with an editable mesh, and it's expected to edit and return the modified mesh. These Mesh Operations are integrated into the procedural modelling system, by wrapping them in a Mesh Filter and applying them as layers on top of the base mesh. By passing the same editable mesh through a series of Mesh Operations, we have the basics of the procedural modelling system.

Interface

Evaluation

Evaluate
    LXxMETHOD( LxResult,
Evaluate) (
    LXtObjectID              self,
    LXtObjectID              mesh,
    LXtID4                   type,
    LXtMarkMode              mode);

The Evaluate function is used to perform the main evaluation. It is given an editable mesh, which should be edited in place, to perform the modeling operation. A selection mark mode and selection type is provided, to limit the operation to a particular subset of components.

SetTransform
    LXxMETHOD( LxResult,
SetTransform) (
    LXtObjectID              self,
    LXtMatrix4               matrix);

The SetTransform function provides the mesh operation with a transform matrix. This matrix stores the transform of the mesh that is being affected by the mesh operation.

Re-Evaluation

When a mesh operation creates new geometry, it can be inefficient to recreate the geometry for every evaluation. This set of optional functions allow the previous evaluation result to be used as a starting point for the current evaluation. For example, a bevel tool may use the initial evaluation to create the beveled polygons, and any further evaluation calls may simply offset the position of the beveled geometry. This would be much more efficient and result in improved performance.

Compare
    LXxMETHOD( int,
Compare) (
    LXtObjectID              self,
    LXtObjectID              other);

The Compare function is used to compare one mesh operation with another. The old mesh operation is passed to the new mesh operation and the attributes should be compared, to see if they are compatible. If the function returns LXiMESHOP_DIFFERENT, then the operation will be discarded and evaluated from scratch. If the function returns LXiMESHOP_COMPATIBLE, then the previous result will be used as a starting point for the next evaluation. If the function returns LXiMESHOP_IDENTICAL, then re-evaluation of the mesh operation will be skipped altogether, and the previous result will be used, as is.

Convert
    LXxMETHOD( LxResult,
Convert) (
    LXtObjectID              self,
    LXtObjectID              other);

If the previous mesh operation is compatible, then Convert will be called to transfer variables and user data from the old mesh operation to the new mesh operation. The function will be passed the old operation and any variables should be transferred.

ReEvaluate
    LXxMETHOD( LxResult,
ReEvaluate) (
    LXtObjectID              self,
    LXtObjectID              mesh,
    LXtID4                   type);

The ReEvaluate function is called to perform a fast update to a previous mesh. The mesh from the previous evaluation result is passed to the function, and the mesh operation is expected to simply update the mesh in place.

Item Type

The procedural modeling system works by evaluating a series of mesh operations, on a target mesh, to result in a final modified mesh. To integrate a mesh operation interface into the procedural modeling system, the mesh operations need to be associated with an item that can be managed by the user. The mesh operation item performs this duty. It contains a MeshOpObj channel which stores the mesh operation, and is evaluated by the procedural modeling system, to perform an edit to the mesh.

Mesh Operation items all derive from a common type. This type is extremely basic and has no transforms or position in 3D space. There are also three default channels on every Mesh Operation Item, defining things like selection type and the enable state.

#define LXsITYPE_MESHOP                 "meshoperation"
 
#define LXsICHAN_MESHOP_ENABLE          "enable"
#define LXsICHAN_MESHOP_OBJ             "meshOpObj"
#define LXsICHAN_MESHOP_SELTYPE         "selectionType"

Selection Type

Not all mesh operations support every selection type, for example, a Polygon Bevel only operates on Polygons. To prevent the user from attempting to use an incompatible selection operation with a mesh operation, the mesh operation can specify which selection types it supports, and only compatible selection operations will be permitted.

To limit a mesh operation to specific selection types, the following server tag should be defined on the mesh operation server. The value should be a comma separated list of supported selection types, if no types are supported, then the value "-" should be provided. If this tag is not present, then the system will assume that all selection types are supported.

#define LXsPMODEL_SELECTIONTYPES	"selectionoperation"
 
#define	LXsSELOP_TYPE_NONE		"-"
#define	LXsSELOP_TYPE_VERTEX		"VERX"
#define	LXsSELOP_TYPE_EDGE		"EDGE"
#define	LXsSELOP_TYPE_POLYGON		"POLY"

Creation Command

The Mesh Operation can provide a creation command that will be executed to handle the creation of the mesh operation. This allows things like dialogs to be created to ask the user for input, or to create graph connections on creation. To define a creation command, the following server tag should be added to the mesh operation server, the value of the tag should be the command to execute.

#define	LXsPKG_MESHOP_CREATECMD		"meshop.create"