Mesh edit

 

MeshDataEdit Commands

editbegin
editbegin() is the entry point into the MeshDataEdit functions that LScript supports. While CommandSequence (CS/1.0) commands let you operate on points and polygons collectively, MeshDataEdit (MD/1.0) operations let you edit individual point and polygon data directly.

editbegin() places your LScript into MeshDataEdit mode. When you enter this mode, certain magical things happen:

1      CommandSequence (CS/1.0) commands and functions are now illegal. You may not invoke these types of procedures until you leave MeshDataEdit mode using editend().

2      Two new, automatic LScript arrays become available. The first, called points[], contains the point ids of all the selected object points. The second, called polygons[], contains the polygon ids of all the selected object polygons

In the case of the automatic arrays points[] and polygons[], if you declared arrays or variables with the same names within the scope of the MeshDataEdit mode, they will be hidden. They will become visible again when you terminate MeshDataEdit mode using editend().

editbegin() will return the count of points that are currently selected. This count will be equal to the size of the points[] automatic array.

prototype:      result editbegin()      (MD)

result            integer; count of selected points.

editend
editend() is used to terminate MeshDataEdit mode (initiated with editbegin()). When called, the automatic arrays points[] and polygons[] will disappear, and CommandSequence (CS/1.0) functions and commands are once again available.

During MeshDataEdit operations, Modeler "queues up" all changes you make to the object data; no changes are applied until you issue the editend() command. By default, if you provide no parameters to editend(), your changes are applied and processing continues. However, you can provide a parameter to editend() that will discard your accumulated changes, and leave your object unchanged. This parameter can be a constant, ABORT, or any non-zero value to indicate your wish to discard all changes.

prototype:      editend([status])      (MD)

status           constant; ABORT.

addpoint
addpoint() will add new point data to your object. By providing a valid vector, addpoint() will return a valid point id that you can give to other functions. If for some reason addpoint() fails to create a new point, nil will be returned.

prototype:      result addpoint(location)      (MD)

result            point id; the identifier for the new vector.

location         integer[3], vector or number; the location of the new point.

addpolygon
Use addpolygon() to add new polygons to your object data. You can provide one or more point ids to this function to generate the new polygon. If you provide more than one point id, they must be housed in an array.

The new polygon can be assigned to a surface name. If the surface parameter is omitted, then the new polygon will belong to the default surface identifier. If the specified surface name does not exist, it will be created.

If the addpolygon function is a success, it will return a polygon identifier. If the function fails, it will return (nil).

prototype:      result addpolygon(points [,surface])     (MD)

result            polygon id or nil; the identifier of the new polygon.

points            point id[] or point id; point identifiers of new polygon.

surface          string; surface name to which polygon should be assigned.

addcurve
addcurve() is identical to addpolygon() in both parameter types and counts. However, addcurve() will turn the provided point ids into a Modeler curve instead of a polygon. The difference between a polygon and a curve is that angles through curve points are smoothly interpolated, while angles through polygon points are strictly linear. To create a closed curve, the beginning and ending points provided must overlap.

prototype:      result addcurve(points [,surface [state]])      (MD)

result            polygon id or nil; the identifier of the new curve.

points            point id[] or point id; point identifiers of new curve.

surface          string; surface name to which curve should be assigned.

state             constant: START or END flags to indicate the control structure of the curve.

                    If no parameter is provided, then no controls will be applied to the curve.

addquad
addquad() is used to add quadrangular (four-point) polygons to your object’s mesh data. Point ids can be provided individually, or in an array of four elements.

prototype:      result addquad(points)      (MD)

result            Boolean; 0 == success.

points            point ids[4] or four individual point ids; points to use in constructing quadrangle.

addtriangle
addtriangle() is similar to addquad() in its parameter types, except it uses three point ids to construct the new polygon instead of four.

prototype:      result addtriangle(points)      (MD)

result            Boolean; 0 == success.

points           point ids[3] or three individual point ids; points to use in constructing triangle.

polyinfo
Use the polyinfo() function to gather information about individual polygons. polyinfo() returns a variable number of items whose first element is always the surface name to which the polygon is assigned. The remaining elements comprise the individual point ids that make up the polygon.

Not all polygons in an object will have the same number of points, so the point count of a polygon will likely vary from polygon to polygon. To help you determine the number of points a polygon contains, you can use the polypointcount() function (discussed next) to allocate an array of the appropriate size to hold the return value of polyinfo().

prototype:      result polyinfo(polygon)      (MD)

result            array[]; variable sized array whose first element is

surface          name, remaining elements are point ids.

polygon         polygon id; the polygon identifier for which you need information.

polynormal
polynormal() returns a vector that represents the surface normal of the specified polygon.

prototype:      status polynormal(polygon)      (MD)

status            boolean; if the operation succeeded.

polygon          polygon id; the polygon to change.

surface          string; surface name to which polygon is now assigned.

polypoints
Use polypoints() to assign a new set of points to a polygon. The original points that composed the polygon will not be automatically removed, and should be removed manually (using rempoint()) if no longer required.

prototype:      status polypoints(polygon, points)      (MD)

status           boolean; if the operation succeeded.

polygon         polygon id; polygon to change.

points            point ids[]; new points for polygon.

rempoint, rempoly
rempoint() and rempoly() will delete a point or polygon, respectively, from your objects mesh data. Note that in the case of rempoly(), the points comprising the polygon are not removed, and will remain as part of your mesh data.

prototype:      status rempoint(point)      (MD)

point             id; the point to be removed

prototype:      status rempoly(polygon) (MD)

polygon          id; the polygon to be removed.

pointmove
pointmove() will change the vector location of a point.

prototype:      status pointmove(point, location)

point             id; the point to be moved

location         integer[3], vector or number; the new location of the point.

polysurface
polysurface() allows the LScript to reassign a polygon surface name.

prototype:      status polysurface(polygon,surface)

polygon         string; surface name to which polygon is now assigned

surface          polygon id; the polygon to change

polypointcount
polypointcount() is used with polyinfo() to determine the number of points a polygon contains. You typically need this information when determining the size of an array to hold the information returned by polyinfo().

pcount = polypointcount(polygons[x]);
ppoints[pcount + 1];
// account for surface name [1]
ppoints = polyinfo(polygons[x]);

prototype:      result polypointcount(polygon)      (MD)

result             integer; point count.

polygon         polygon id; the polygon in question.

pointinfo
pointinfo() returns the location in 3D space where a point resides.

prototype:      result pointinfo(point)      (MD)

result            vector; location of point

point             point id; identifier of point in which you are interested.