|
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Working with MeshesAs you did with 2D objects, you will also need to manipulate 3D objects using the Editable Mesh object. It is the only way to access and manipulate vertex and face information. Converting Objects to Editable MeshesUnlike 2D shapes, 3D objects cannot be created directly as editable meshes. Some importers, like the 3DS Importer, will import geometry as editable meshes, but the user cannot start creating faces and vertices. Geometry must come from a converted Object. You can convert objects to editable mesh in two ways: using the COLLAPSESTACK or the CONVERTTOMESH commands. When you convert an object to editable mesh, either using MAXScript or the Edit Stack button, if the object was modified by space warps or world space modifiers, their effects will be discarded. To convert an object to editable mesh and consider the effects of the space warps, you can use the Snapshot tool or the SNAPSHOT command in MAXScript. Lets say you have b = box(); these are the three ways you can convert it to an editable mesh: b = converttomesh b b = snapshot b b = collapsestack b
Mesh PropertiesIts important to know certain information about meshes (such as the number of faces and vertices, which ones are selected, etc.) so you can manipulate a series of vertices, edges, or faces. Some of these properties are:
You can use simple commands to attach objects, create Booleans, and adjust simple parameters in editable meshes. To attach objects, use the ATTACH command; you need an editable mesh and any other object. If its a 2D object, NURBS, or patch, it will be converted to editable mesh and attached. For instance, to create two objects and attach them: a = sphere() b = box pos:[30,0,0] c = converttomesh a attach c b Creating Simple Booleans You create simple Booleans using simple math formulas (addition, subtraction, and intersection) on nodes, but the resulting object will be an editable mesh, as seen in Figure 14.16. To use the Boolean compound object and retain all sub-objects, use BOOLOBJ.CREATEBOOLEANOBJECT.
To use simple Booleans, treat objects as part of a math operation. For instance: a = box pos:[-10,10,0] b = sphere radius:20 c = a + b delete b When the Boolean is processed, the first operand is deleted and any others remain. Thats why weve deleted b. The other two operations, subtraction and intersection, can be made with the use of the minus (-) and the multiply (*) symbols. You can perform more than one operation in a single command: a = box pos:[-10,0,0] b = sphere radius:15 c = box pos:[0,15,0] d = a * b - c delete b delete c You can also create compound Booleans using MAXScript: a = box pos:[-10,0,0] b = sphere radius:15 c = boolobj.createbooleanobject a b 1 1 boolobj.setboolop c 1 delete b In createbooleanobject, you need to specify two objects:
In setboolop, you specify which Boolean operation will occur (1Union, 2Inter-section, 3A-B, 4B-A, 5Cut).
Accessing Vertex, Face, and Edge InformationSometimes its useful to have access to and manipulate Vertex, Face, and Edge information. Lets look at some of these commands and some examples. Getting Vertex Data Some vertex commands are replicated from properties in an editable mesh. These commands are: GETNUMVERTS, GETVERTSELECTION, and GETNUMTVERTS. You can use either object.numverts or getnumverts obj. You can read several other types of information from vertices, including these:
This information is very useful for writing scripts. All these commands have a SET command related to them that will write new data to each property. For instance, if you want to move a certain vertex [10,2,4], you can do it this way: s = sphere() s1 = converttomesh s pt = getvert s1 1 setvert s1 1 (pt + [10,2,4]) update s1
© 2000, Frol (selection, edition, publication) |
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||