Mesh Info

The LWMeshInfo structure describes the geometry of an object. You can get one of these from the Scene Objects and Object Info globals and from the access structure passed to the displacement handler evaluate function. What it contains can vary depending on how and when you obtain it. This structure is defined in the lwmeshes.h header file.

   typedef int LWPntScanFunc (void *, LWPntID);
   typedef int LWPolScanFunc (void *, LWPolID);

   typedef struct st_LWMeshInfo {
      void         *priv;
      void         (*destroy)     (LWMeshInfoID);
      int          (*numPoints)   (LWMeshInfoID);
      int          (*numPolygons) (LWMeshInfoID);
      int          (*scanPoints)  (LWMeshInfoID, LWPntScanFunc *, void *);
      int          (*scanPolys)   (LWMeshInfoID, LWPolScanFunc *, void *);
      void         (*pntBasePos)  (LWMeshInfoID, LWPntID, LWFVector pos);
      void         (*pntOtherPos) (LWMeshInfoID, LWPntID, LWFVector pos);
      void *       (*pntVLookup)  (LWMeshInfoID, LWID, const char *);
      int          (*pntVSelect)  (LWMeshInfoID, void *);
      int          (*pntVGet)     (LWMeshInfoID, LWPntID, float *vector);
      LWID         (*polType)     (LWMeshInfoID, LWPolID);
      int          (*polSize)     (LWMeshInfoID, LWPolID);
      LWPntID      (*polVertex)   (LWMeshInfoID, LWPolID, int);
      const char * (*polTag)      (LWMeshInfoID, LWPolID, LWID);
      int          (*pntVPGet)    (LWMeshInfoID, LWPntID, LWPolID,
                                     float *vector);
      unsigned int (*polFlags)    (LWMeshInfoID, LWPolID);
      int          (*pntVIDGet)   (LWMeshInfoID, LWPntID, float *vector,
                                     void *);
      int          (*pntVPIDGet)  (LWMeshInfoID, LWPntID, LWPolID,
                                     float *vector, void *);
   } LWMeshInfo;
priv
An opaque pointer to private data used internally by the mesh info functions.
destroy( meshinfo )
Frees resources allocated by the process that created this LWMeshInfo. Call this when you're finished with the mesh info. Note that this field may be NULL, indicating that you shouldn't attempt to free the mesh info. Test the value of this field before trying to use it.
npts = numPoints( meshinfo )
Returns the number of points in the object. If the object contains dynamically created geometry, e.g. subdivision patches or metaballs, this number may include both the control points and the points created by subdividing.
npols = numPolygons( meshinfo )
Returns the number of polygons in the object, which may include polygons created by subdividing.
result = scanPoints( meshinfo, pointscan_func, mydata )
Enumerate the points in the object. The callback you supply is called for each point in the object. The mydata argument is passed to the callback and can be anything it might require. Enumeration stops if your callback returns a non-zero value, and this value is then returned by scanPoints. Otherwise it returns 0.
result = scanPolys( meshinfo, polyscan_func, mydata )
Enumerate the polygons in the object.
pntBasePos( meshinfo, point, pos )
Get the base, or initial, position of a point.
pntOtherPos( meshinfo, point, pos )
Get an alternate position for the point. This may be the same as the base position or it may be the position of the point after some transformation. The nature of the alternate position depends on how the mesh info was created.
vmap = pntVLookup( meshinfo, vmap_type, vmap_name )
Select a vertex map for reading by pntVGet. The vmap is given by its four-character identifier and its name string. The function returns a pointer that can be used later in pntVSelect to quickly select this vmap again. The pointer is NULL if no vmap was found with the given ID and name. The Scene Objects global allows you to examine the vmap database and retrieve the names of existing vmaps of a given type.
dim = pntVSelect( meshinfo, vmap )
Select a vmap for reading vectors. The vmap is identified by a pointer returned by pntVLookup. The function returns the vmap's dimension (the number of values per point).
ismapped = pntVGet( meshinfo, point, val )
Read the vmap vector for a point. The vector is read from the vmap selected by a previous call to pntVSelect. If the point is mapped (has a vmap value in the selected vmap), the val array is filled with the vmap vector for the point, and pntVGet returns true. The val array must have at least as many elements as the number returned by pntVSelect. See also pntVIDGet.
type = polType( meshinfo, polygon )
Returns the type of a polygon. "Polygon" here refers to a number of different kinds of geometric atoms, including things like curves and bones. The polygon type codes are an extensible set of four-character identifiers. The header file lwmeshes.h defines the most common ones.

LWPOLTYPE_FACE - face
LWPOLTYPE_CURV - higher order curve
LWPOLTYPE_PTCH - subdivision control cage polygon
LWPOLTYPE_MBAL - metaball
LWPOLTYPE_BONE - bone

nvert = polSize( meshinfo, polygon )
Returns the number of vertices belonging to the polygon.
point = polVertex( meshinfo, polygon, vert_index )
Returns the point ID for a polygon vertex. Vertex indexes range from 0 to nvert - 1.
tagname = polTag( meshinfo, polygon, tagID )
Returns the tag string of the given type associated with the polygon. A null string pointer means that the polygon does not have a tag of that type. lwmeshes.h defines the most common polygon tags.
LWPTAG_SURF
The name of the surface applied to the polygon.
LWPTAG_PART
The name of the polygon group the polygon belongs to.
ismapped = pntVPGet( meshinfo, point, polygon, val )
Like pntVGet, but reads the per-polygon, or discontinuous, vmap vector for a polygon vertex. See also pntVPIDGet.
flags = polFlags( meshinfo, polygon )
Returns the flags associated with the polygon. the EDPF_CCSTART and EDDF_CCEND bits determine whether the first and last points in LWPOLTYPE_CURV polygons are control points rather than actual vertices. (The constants for these flags are defined in lwmeshedt.h.)
ismapped = pntVIDGet( meshinfo, point, val, vmap )
ismapped = pntVPIDGet( meshinfo, point, polygon, val, vmap )
Like pntVGet and pntVPGet, but these take the vertex map ID as an additional argument, so that it isn't necessary to first call pntVSelect to select the vertex map. This is important when your plug-in might be running in multiple threads, since the thread may change between the pntVSelect call and the pntVGet or pntVPGet calls.

Example

The SceneScan sample uses an LWMeshInfo obtained from the Object Info global to build arrays of points and polygons for an object, including vmap and surface data. See the getObjectDB function in objectdb.c.