1 | /**********************************************************************
|
---|
2 | *<
|
---|
3 | FILE: mesh.h
|
---|
4 |
|
---|
5 | DESCRIPTION: Main include file for triangle meshes.
|
---|
6 |
|
---|
7 | CREATED BY: Don Brittain
|
---|
8 |
|
---|
9 | HISTORY:
|
---|
10 |
|
---|
11 | *> Copyright (c) 1994, All Rights Reserved.
|
---|
12 | **********************************************************************/
|
---|
13 |
|
---|
14 | #ifndef _MESH_H_
|
---|
15 |
|
---|
16 | #define _MESH_H_
|
---|
17 |
|
---|
18 | #include "channels.h"
|
---|
19 | #include "snap.h"
|
---|
20 | #include <ioapi.h>
|
---|
21 | #include "export.h"
|
---|
22 | #include "vedge.h" //DS
|
---|
23 |
|
---|
24 | typedef unsigned short MtlID;
|
---|
25 |
|
---|
26 | // This a UV coordinate. These cound be Point2s
|
---|
27 | typedef Point3 UVVert;
|
---|
28 |
|
---|
29 |
|
---|
30 | #define MESH_MULTI_PROCESSING TRUE // TRUE turns on mp vertex transformation
|
---|
31 |
|
---|
32 | class ISave;
|
---|
33 | class ILoad;
|
---|
34 |
|
---|
35 | #define NEWMESH
|
---|
36 |
|
---|
37 | class RNormal {
|
---|
38 | public:
|
---|
39 | RNormal() { smGroup = mtlIndex = 0; }
|
---|
40 | void setNormal(const Point3 &nor) { normal = nor; }
|
---|
41 | void addNormal(const Point3 &nor) { normal += nor; }
|
---|
42 | void normalize(void) { normal = Normalize(normal); }
|
---|
43 | Point3 & getNormal(void) { return normal; }
|
---|
44 | void setSmGroup(DWORD g) { smGroup = g; }
|
---|
45 | void addSmGroup(DWORD g) { smGroup |= g; }
|
---|
46 | DWORD getSmGroup(void) { return smGroup; }
|
---|
47 | void setMtlIndex(MtlID i){ mtlIndex = i; }
|
---|
48 | MtlID getMtlIndex(void) { return mtlIndex; }
|
---|
49 | void setRGB(Point3 &clr) { rgb = clr; };
|
---|
50 | Point3 & getRGB(void) { return rgb; }
|
---|
51 |
|
---|
52 | private:
|
---|
53 | Point3 normal;
|
---|
54 | DWORD smGroup;
|
---|
55 | MtlID mtlIndex;
|
---|
56 | Point3 rgb;
|
---|
57 | };
|
---|
58 |
|
---|
59 |
|
---|
60 |
|
---|
61 | // RVertex flags: contain clip flags, number of normals at the vertex
|
---|
62 | // and the number of normals that have already been rendered.
|
---|
63 | // fine PLANE_MASK 0x00003f00UL -- now in gfx.h
|
---|
64 | #define NORCT_MASK 0x000000ffUL
|
---|
65 | #define SPECIFIED_NORMAL 0x00004000UL
|
---|
66 | #define OUT_LEFT 0x00010000UL
|
---|
67 | #define OUT_RIGHT 0x00020000UL
|
---|
68 | #define OUT_TOP 0x00040000UL
|
---|
69 | #define OUT_BOTTOM 0x00080000UL
|
---|
70 | #define RECT_MASK 0x000f0000UL
|
---|
71 | #define RND_MASK 0xfff00000UL
|
---|
72 | #define RND_NOR0 0x00100000UL
|
---|
73 | #define RND_NOR(n) (RND_NOR0 << (n))
|
---|
74 |
|
---|
75 | class RVertex {
|
---|
76 | public:
|
---|
77 | RVertex() { rFlags = 0; ern = NULL; }
|
---|
78 | DllExport ~RVertex();
|
---|
79 |
|
---|
80 | DWORD rFlags;
|
---|
81 | union {
|
---|
82 | int iPos[3];
|
---|
83 | float fPos[3];
|
---|
84 | };
|
---|
85 | RNormal rn;
|
---|
86 | RNormal *ern;
|
---|
87 | };
|
---|
88 |
|
---|
89 |
|
---|
90 |
|
---|
91 | // Face Flags:
|
---|
92 | // 3 LSBs hold the edge visibility flags
|
---|
93 | // Bit 3 indicates the presence of texture verticies
|
---|
94 |
|
---|
95 | // if bit is 1, edge is visible
|
---|
96 | #define EDGE_VIS 1
|
---|
97 | #define EDGE_INVIS 0
|
---|
98 |
|
---|
99 | // first edge-visibility bit field
|
---|
100 | #define VIS_BIT 0x0001
|
---|
101 | #define VIS_MASK 0x0007
|
---|
102 |
|
---|
103 | #define EDGE_A (1<<0)
|
---|
104 | #define EDGE_B (1<<1)
|
---|
105 | #define EDGE_C (1<<2)
|
---|
106 | #define EDGE_ALL (EDGE_A|EDGE_B|EDGE_C)
|
---|
107 |
|
---|
108 | #define FACE_HIDDEN (1<<3)
|
---|
109 | #define HAS_TVERTS (1<<4)
|
---|
110 | #define FACE_WORK (1<<5) // used in various algorithms
|
---|
111 |
|
---|
112 | // The mat ID is stored in the HIWORD of the face flags
|
---|
113 | #define FACE_MATID_SHIFT 16
|
---|
114 | #define FACE_MATID_MASK 0xFFFF
|
---|
115 |
|
---|
116 |
|
---|
117 | class Face {
|
---|
118 | public:
|
---|
119 | DWORD v[3];
|
---|
120 | DWORD smGroup;
|
---|
121 | DWORD flags;
|
---|
122 |
|
---|
123 | Face() { flags = 0; }
|
---|
124 | MtlID getMatID() {return (int)((flags>>FACE_MATID_SHIFT)&FACE_MATID_MASK);}
|
---|
125 | void setMatID(MtlID id) {flags &= 0xFFFF; flags |= (DWORD)(id<<FACE_MATID_SHIFT);}
|
---|
126 | void setSmGroup(DWORD i) { smGroup = i; }
|
---|
127 | DWORD getSmGroup(void) { return smGroup; }
|
---|
128 | void setVerts(DWORD *vrt){ memcpy(v, vrt, 3*sizeof(DWORD)); }
|
---|
129 | void setVerts(int a, int b, int c) { v[0]=a; v[1]=b; v[2]=c; }
|
---|
130 | DllExport void setEdgeVis(int edge, int visFlag);
|
---|
131 | DllExport void setEdgeVisFlags(int va, int vb, int vc);
|
---|
132 | int getEdgeVis(int edge){ return flags & (VIS_BIT << edge); }
|
---|
133 | DWORD getVert(int index) { return v[index]; }
|
---|
134 | DWORD * getAllVerts(void) { return v; }
|
---|
135 | BOOL Hidden() {return flags&FACE_HIDDEN?TRUE:FALSE;}
|
---|
136 | void Hide() {flags|=FACE_HIDDEN;}
|
---|
137 | void Show() {flags&=~FACE_HIDDEN;}
|
---|
138 | void SetHide(BOOL hide) {if (hide) Hide(); else Show();}
|
---|
139 | };
|
---|
140 |
|
---|
141 |
|
---|
142 |
|
---|
143 | class TVFace {
|
---|
144 | public:
|
---|
145 | DWORD t[3]; // indices into tVerts
|
---|
146 |
|
---|
147 | TVFace() {}
|
---|
148 | TVFace(DWORD a, DWORD b, DWORD c) {t[0]=a; t[1]=b; t[2]=c;}
|
---|
149 | void setTVerts(DWORD *vrt){ memcpy(t, vrt, 3*sizeof(DWORD)); }
|
---|
150 | void setTVerts(int a, int b, int c) { t[0]=a; t[1]=b; t[2]=c; }
|
---|
151 | DWORD getTVert(int index) { return t[index]; }
|
---|
152 | DWORD * getAllTVerts(void) { return t; }
|
---|
153 | };
|
---|
154 |
|
---|
155 |
|
---|
156 |
|
---|
157 |
|
---|
158 |
|
---|
159 | // Flag definitions
|
---|
160 | #define MESH_EDGE_LIST 1
|
---|
161 |
|
---|
162 | #define COMP_TRANSFORM 0x0001 // forces recalc of model->screen transform; else will attempt to use cache
|
---|
163 | #define COMP_IGN_RECT 0x0002 // forces all polys to be rendered; else only those intersecting the box will be
|
---|
164 | #define COMP_LIGHTING 0x0004 // forces re-lighting of all verts (as when a light moves); else only relight moved verts
|
---|
165 |
|
---|
166 | #define COMP_ALL 0x00ff
|
---|
167 |
|
---|
168 | // If this bit is set then the node being displayed by this mesh is selected.
|
---|
169 | // Certain display flags only activate when this bit is set.
|
---|
170 | #define COMP_OBJSELECTED (1<<8)
|
---|
171 |
|
---|
172 |
|
---|
173 | typedef int (*INTRFUNC)();
|
---|
174 |
|
---|
175 | DllExport void setMeshIntrFunc(INTRFUNC fn);
|
---|
176 |
|
---|
177 |
|
---|
178 | class MeshSubHitRec {
|
---|
179 | private:
|
---|
180 | MeshSubHitRec *next;
|
---|
181 | public:
|
---|
182 | DWORD dist;
|
---|
183 | int index;
|
---|
184 | DWORD flags;
|
---|
185 |
|
---|
186 | MeshSubHitRec(DWORD dist, int index, MeshSubHitRec *next)
|
---|
187 | {this->dist = dist; this->index = index; this->next = next;}
|
---|
188 | MeshSubHitRec(DWORD dist, int index, DWORD flags, MeshSubHitRec *next)
|
---|
189 | {this->dist = dist; this->index = index; this->next = next;this->flags = flags;}
|
---|
190 |
|
---|
191 | MeshSubHitRec *Next() { return next; }
|
---|
192 | };
|
---|
193 |
|
---|
194 | class SubObjHitList {
|
---|
195 | private:
|
---|
196 | MeshSubHitRec *first;
|
---|
197 | public:
|
---|
198 | SubObjHitList() { first = NULL; }
|
---|
199 | ~SubObjHitList() {
|
---|
200 | MeshSubHitRec *ptr = first, *fptr;
|
---|
201 | while (ptr) {
|
---|
202 | fptr = ptr;
|
---|
203 | ptr = ptr->Next();
|
---|
204 | delete fptr;
|
---|
205 | }
|
---|
206 | first = NULL;
|
---|
207 | }
|
---|
208 |
|
---|
209 | MeshSubHitRec *First() { return first; }
|
---|
210 | void AddHit( DWORD dist, int index ) {
|
---|
211 | first = new MeshSubHitRec(dist,index,first);
|
---|
212 | }
|
---|
213 | };
|
---|
214 |
|
---|
215 |
|
---|
216 |
|
---|
217 | // Flags for sub object hit test
|
---|
218 |
|
---|
219 | // NOTE: these are the same bits used for object level.
|
---|
220 | #define SUBHIT_SELONLY (1<<0)
|
---|
221 | #define SUBHIT_UNSELONLY (1<<2)
|
---|
222 | #define SUBHIT_ABORTONHIT (1<<3)
|
---|
223 | #define SUBHIT_SELSOLID (1<<4)
|
---|
224 |
|
---|
225 | #define SUBHIT_USEFACESEL (1<<23) // When this bit is set, the sel only and unsel only tests will use the faces selection when doing a vertex level hit test
|
---|
226 | #define SUBHIT_VERTS (1<<24)
|
---|
227 | #define SUBHIT_FACES (1<<25)
|
---|
228 | #define SUBHIT_EDGES (1<<26)
|
---|
229 | #define SUBHIT_TYPEMASK (SUBHIT_VERTS|SUBHIT_FACES|SUBHIT_EDGES)
|
---|
230 |
|
---|
231 |
|
---|
232 | // Display flags
|
---|
233 | #define DISP_VERTTICKS (1<<0)
|
---|
234 | #define DISP_SELVERTS (1<<10)
|
---|
235 | #define DISP_SELFACES (1<<11)
|
---|
236 | #define DISP_SELEDGES (1<<12)
|
---|
237 | #define DISP_SELPOLYS (1<<13)
|
---|
238 |
|
---|
239 | // Selection level bits.
|
---|
240 | #define MESH_OBJECT (1<<0)
|
---|
241 | #define MESH_VERTEX (1<<1)
|
---|
242 | #define MESH_FACE (1<<2)
|
---|
243 | #define MESH_EDGE (1<<3)
|
---|
244 |
|
---|
245 | class MeshOpProgress;
|
---|
246 |
|
---|
247 | class MeshRenderData {
|
---|
248 | public:
|
---|
249 | virtual void DeleteThis()=0;
|
---|
250 | };
|
---|
251 |
|
---|
252 | class Mesh {
|
---|
253 | friend class Face;
|
---|
254 |
|
---|
255 | private:
|
---|
256 | #if MESH_MULTI_PROCESSING
|
---|
257 | static int refCount;
|
---|
258 | static HANDLE xfmThread;
|
---|
259 | static HANDLE xfmMutex;
|
---|
260 | static HANDLE xfmStartEvent;
|
---|
261 | static HANDLE xfmEndEvent;
|
---|
262 | friend DWORD WINAPI xfmFunc(LPVOID ptr);
|
---|
263 | static HANDLE fNorThread;
|
---|
264 | static HANDLE fNorMutex;
|
---|
265 | static HANDLE fNorStartEvent;
|
---|
266 | static HANDLE fNorEndEvent;
|
---|
267 | friend DWORD WINAPI fNorFunc(LPVOID ptr);
|
---|
268 | #endif
|
---|
269 | // derived data-- can be regenerated
|
---|
270 | RVertex *rVerts; // <<< instance specific.
|
---|
271 | GraphicsWindow *cacheGW; // identifies rVerts cache
|
---|
272 | Point3 *faceNormal; // object space--depends on geom+topo
|
---|
273 | Box3 bdgBox; // object space--depends on geom+topo
|
---|
274 | int numVisEdges; // depends on topo
|
---|
275 | int edgeListHasAll; // depends on topo
|
---|
276 | VEdge *visEdge; // depends on topo
|
---|
277 |
|
---|
278 | // Vertex and face work arrays -- for snap code
|
---|
279 | int snapVCt;
|
---|
280 | int snapFCt;
|
---|
281 | char *snapV;
|
---|
282 | char *snapF;
|
---|
283 |
|
---|
284 | // -------------------------------------
|
---|
285 | //
|
---|
286 | long flags; // work flags-
|
---|
287 |
|
---|
288 | float norScale; // scale of normals -- couldn't this be done
|
---|
289 | // automatically relative to bdgBox?
|
---|
290 |
|
---|
291 | // Rolf: these are instance specific and should be pulled out of here,
|
---|
292 | // and just passed in from the Node.
|
---|
293 | int dspNormals; // display surface normals--- put in flags?
|
---|
294 | int dspAllEdges; // shows hidden edges ---- put in flags?
|
---|
295 |
|
---|
296 | int renderFace(GraphicsWindow *gw, DWORD index, int *custVis=NULL);
|
---|
297 | int renderEdge(GraphicsWindow *gw, DWORD face, DWORD edge);
|
---|
298 | void calcNormal(int i);
|
---|
299 | void checkRVertsAlloc(void);
|
---|
300 | void setCacheGW(GraphicsWindow *gw) { cacheGW = gw; }
|
---|
301 | GraphicsWindow *getCacheGW(void) { return cacheGW; }
|
---|
302 |
|
---|
303 | void buildFaceNormals();
|
---|
304 | void checkNormals(int illum);
|
---|
305 |
|
---|
306 | void freeVerts();
|
---|
307 | void freeFaces();
|
---|
308 | void freeFaceNormals();
|
---|
309 | void freeRVerts();
|
---|
310 | void freeTVerts();
|
---|
311 | void freeT3DVerts();
|
---|
312 | void freeTVFaces();
|
---|
313 | void freeSnapData();
|
---|
314 | int buildSnapData(GraphicsWindow *gw,int verts,int edges);
|
---|
315 |
|
---|
316 | public:
|
---|
317 | // Topology
|
---|
318 | int numVerts;
|
---|
319 | int numFaces;
|
---|
320 | Face * faces;
|
---|
321 |
|
---|
322 | // Geometry
|
---|
323 | Point3 * verts;
|
---|
324 |
|
---|
325 | // Texture Coord assignment
|
---|
326 | int numTVerts;
|
---|
327 | UVVert * tVerts;
|
---|
328 | TVFace * tvFace;
|
---|
329 | Point3 * t3DVerts; // Snap shot of regular vertices before a deformation
|
---|
330 |
|
---|
331 | // Material assignment
|
---|
332 | MtlID mtlIndex; // object material
|
---|
333 | MtlID * faceMtlIndex; // material index per face.
|
---|
334 |
|
---|
335 | // Selection
|
---|
336 | BitArray vertSel; // selected vertices
|
---|
337 | BitArray faceSel; // selected faces
|
---|
338 | BitArray edgeSel; // selected edges, identified as 3*faceIndex + edgeIndex
|
---|
339 | BitArray vertHide; // Hide flags for vertices
|
---|
340 |
|
---|
341 | // Display attribute flags
|
---|
342 | DWORD dispFlags;
|
---|
343 |
|
---|
344 | // Selection level
|
---|
345 | DWORD selLevel;
|
---|
346 |
|
---|
347 | // true if normals have been built for the current mesh
|
---|
348 | int normalsBuilt;
|
---|
349 |
|
---|
350 | MeshRenderData* renderData; // used by the renderer
|
---|
351 |
|
---|
352 | DllExport Mesh();
|
---|
353 | DllExport Mesh(const Mesh& fromMesh);
|
---|
354 | DllExport ~Mesh();
|
---|
355 | void Init();
|
---|
356 |
|
---|
357 | DllExport Mesh& operator=(const Mesh& fromMesh);
|
---|
358 |
|
---|
359 | DllExport BOOL setNumVerts(int ct, BOOL keep=FALSE);
|
---|
360 | int getNumVerts(void) const { return numVerts; }
|
---|
361 |
|
---|
362 | DllExport BOOL setNumFaces(int ct, BOOL keep=FALSE);
|
---|
363 | int getNumFaces(void) const{ return numFaces; }
|
---|
364 |
|
---|
365 | DllExport BOOL setNumTVerts(int ct, BOOL keep=FALSE);
|
---|
366 | int getNumTVerts(void) const { return numTVerts; }
|
---|
367 |
|
---|
368 | // These are parallel to faces and vertices (repectively)
|
---|
369 | // These are called from setNumVets()/Faces() to maintain the same count.
|
---|
370 | //
|
---|
371 | // If they are NULL and keep = TRUE they stay NULL.
|
---|
372 | // If they are NULL and keep = FALSE they are allocated (3D verts also init themselves from the main vert array)
|
---|
373 | // If they are non-NULL and ct = 0 they are set to NULL (and freed)
|
---|
374 | // NOTE that T3DVerts are always initialized to either thier previous value (keep=1) or the vertex array
|
---|
375 | // The old count is the length of the existing array (usually equal to numVerts but not if verts have just been resized also)
|
---|
376 | DllExport BOOL setNumTVFaces(int ct, BOOL keep=FALSE, int oldCt=0);
|
---|
377 | DllExport BOOL setNumT3DVerts(int ct, BOOL keep=FALSE, int oldCt=0);
|
---|
378 |
|
---|
379 | void setVert(int i, const Point3 &xyz) { verts[i] = xyz; }
|
---|
380 | void setVert(int i, float x, float y, float z) { verts[i].x=x; verts[i].y=y; verts[i].z=z; }
|
---|
381 | void setTVert(int i, const UVVert &xyz) { tVerts[i] = xyz; }
|
---|
382 | void setTVert(int i, float x, float y, float z) { tVerts[i].x=x; tVerts[i].y=y; tVerts[i].z=z; }
|
---|
383 |
|
---|
384 | DllExport void setNormal(int i, const Point3 &xyz);
|
---|
385 | DllExport Point3 & getNormal(int i);
|
---|
386 |
|
---|
387 | void setFaceNormal(int i, const Point3 &xyz) { faceNormal[i] = xyz; }
|
---|
388 | Point3 & getFaceNormal(int i) { return faceNormal[i]; }
|
---|
389 |
|
---|
390 | Point3 & getVert(int i) { return verts[i]; }
|
---|
391 | Point3 * getVertPtr(int i) { return verts+i; }
|
---|
392 | UVVert & getTVert(int i) { return tVerts[i]; }
|
---|
393 | UVVert * getTVertPtr(int i) { return tVerts+i; }
|
---|
394 | RVertex & getRVert(int i) { return rVerts[i]; }
|
---|
395 | RVertex * getRVertPtr(int i) { return rVerts+i; }
|
---|
396 |
|
---|
397 | void setMtlIndex(MtlID i) { mtlIndex = i; }
|
---|
398 | MtlID getMtlIndex(void) { return mtlIndex; }
|
---|
399 |
|
---|
400 | // Face MtlIndex list methods;
|
---|
401 | DllExport void createFaceMtlIndexList();
|
---|
402 | void freeFaceMtlIndexList();
|
---|
403 | DllExport MtlID getFaceMtlIndex(int i); // { return faceMtlIndex? faceMtlIndex[i]: mtlIndex; }
|
---|
404 | DllExport void setFaceMtlIndex(int i, MtlID id);
|
---|
405 |
|
---|
406 | DllExport void buildNormals();
|
---|
407 | DllExport void buildRenderNormals(); // like buildNormals, but ignores mtlIndex
|
---|
408 |
|
---|
409 | DllExport void render(GraphicsWindow *gw, Material *ma, RECT *rp, int compFlags, int numMat=1);
|
---|
410 | DllExport BOOL select(GraphicsWindow *gw, Material *ma, HitRegion *hr, int abortOnHit = FALSE, int numMat=1);
|
---|
411 | DllExport void snap(GraphicsWindow *gw, SnapInfo *snap, IPoint2 *p, Matrix3 &tm);
|
---|
412 | DllExport BOOL SubObjectHitTest(GraphicsWindow *gw, Material *ma, HitRegion *hr,
|
---|
413 | DWORD flags, SubObjHitList& hitList, int numMat=1 );
|
---|
414 |
|
---|
415 | void displayNormals(int b, float sc) { dspNormals = b; if(sc != (float)0.0) norScale = sc; }
|
---|
416 | void displayAllEdges(int b) { dspAllEdges = b; }
|
---|
417 | DllExport void buildBoundingBox(void);
|
---|
418 | DllExport Box3 getBoundingBox(Matrix3 *tm=NULL); // RB: optional TM allows the box to be calculated in any space.
|
---|
419 | // NOTE: this will be slower becuase all the points must be transformed.
|
---|
420 |
|
---|
421 | DllExport void EnableEdgeList(int e);
|
---|
422 | DllExport void BuildVisEdgeList();
|
---|
423 | DllExport void DrawVisEdgeList(GraphicsWindow *gw, DWORD flags);
|
---|
424 | DllExport void HitTestVisEdgeList(GraphicsWindow *gw, int abortOnHit ); // RB
|
---|
425 | DllExport void InvalidateEdgeList(); // RB
|
---|
426 | DllExport void InvalidateGeomCache();
|
---|
427 | DllExport void FreeAll(); //DS
|
---|
428 |
|
---|
429 | // functions for use in data flow evaluation
|
---|
430 | DllExport void ShallowCopy(Mesh *amesh, unsigned long channels);
|
---|
431 | DllExport void DeepCopy(Mesh *amesh, unsigned long channels);
|
---|
432 | DllExport void NewAndCopyChannels(unsigned long channels);
|
---|
433 | DllExport void FreeChannels( unsigned long channels, int zeroOthers=1);
|
---|
434 |
|
---|
435 | // Display flags
|
---|
436 | void SetDispFlag(DWORD f) { dispFlags |= f; }
|
---|
437 | DWORD GetDispFlag(DWORD f) { return dispFlags & f; }
|
---|
438 | void ClearDispFlag(DWORD f) { dispFlags &= ~f; }
|
---|
439 |
|
---|
440 | // Selection access
|
---|
441 | BitArray& VertSel() { return vertSel; }
|
---|
442 | BitArray& FaceSel() { return faceSel; }
|
---|
443 |
|
---|
444 | // Constructs a vertex selection list based on the current selection level.
|
---|
445 | DllExport BitArray VertexTempSel();
|
---|
446 |
|
---|
447 | DllExport IOResult Save(ISave* isave);
|
---|
448 | DllExport IOResult Load(ILoad* iload);
|
---|
449 |
|
---|
450 | // RB: added so all objects can easily support the GeomObject method of the same name.
|
---|
451 | DllExport int IntersectRay(Ray& ray, float& at, Point3& norm);
|
---|
452 |
|
---|
453 | // RB: I couldn't resist adding these <g>
|
---|
454 | DllExport Mesh operator+(Mesh &mesh); // Union
|
---|
455 | DllExport Mesh operator-(Mesh &mesh); // Difference
|
---|
456 | DllExport Mesh operator*(Mesh &mesh); // Intersection
|
---|
457 |
|
---|
458 | DllExport void WeldCollinear(BitArray &set);
|
---|
459 |
|
---|
460 | DllExport void Optimize(
|
---|
461 | float normThresh, float edgeThresh,
|
---|
462 | float bias, DWORD flags, MeshOpProgress *prog=NULL);
|
---|
463 |
|
---|
464 | DllExport void ApplyUVWMap(int type,
|
---|
465 | float utile, float vtile, float wtile,
|
---|
466 | int uflip, int vflip, int wflip, int cap,
|
---|
467 | const Matrix3 &tm);
|
---|
468 |
|
---|
469 | DllExport void FlipNormal(int i);
|
---|
470 | DllExport void UnifyNormals(BOOL selOnly);
|
---|
471 | DllExport void AutoSmooth(float angle,BOOL useSel);
|
---|
472 |
|
---|
473 | DllExport Edge *MakeEdgeList(int *edgeCount, int flagdbls=0);
|
---|
474 | DllExport int DeleteFlaggedFaces(); // deletes all faces with FACE_WORK flag set
|
---|
475 |
|
---|
476 | // Returns TRUE if an equivalent face already exists.
|
---|
477 | DllExport BOOL DoesFaceExist(DWORD v0, DWORD v1, DWORD v2);
|
---|
478 |
|
---|
479 | // Removes faces that have two or more equal indices.
|
---|
480 | // Returns TRUE if any degenerate faces were found
|
---|
481 | DllExport BOOL RemoveDegenerateFaces();
|
---|
482 |
|
---|
483 | // Removes faces that have indices that are out of range
|
---|
484 | // Returns TRUE if any illegal faces were found
|
---|
485 | DllExport BOOL RemoveIllegalFaces();
|
---|
486 |
|
---|
487 | DllExport float AngleBetweenFaces(DWORD f0, DWORD f1);
|
---|
488 |
|
---|
489 | // Compute the barycentric coords of a point in the plane of
|
---|
490 | // a face relative to that face.
|
---|
491 | DllExport Point3 BaryCoords(DWORD face, Point3 p);
|
---|
492 |
|
---|
493 | // Some edge operations
|
---|
494 | DllExport void DivideEdge(DWORD edge);
|
---|
495 | DllExport void TurnEdge(DWORD edge);
|
---|
496 |
|
---|
497 | // used by the renderer
|
---|
498 | void SetRenderData(MeshRenderData *p) {renderData = p; }
|
---|
499 | MeshRenderData * GetRenderData() { return renderData; }
|
---|
500 | };
|
---|
501 |
|
---|
502 | // Mapping types passed to ApplyUVWMap()
|
---|
503 | #define MAP_PLANAR 0
|
---|
504 | #define MAP_CYLINDRICAL 1
|
---|
505 | #define MAP_SPHERICAL 2
|
---|
506 | #define MAP_BALL 3
|
---|
507 | #define MAP_BOX 4
|
---|
508 |
|
---|
509 |
|
---|
510 | // Optimize flags
|
---|
511 | #define OPTIMIZE_SAVEMATBOUNDRIES (1<<0)
|
---|
512 | #define OPTIMIZE_SAVESMOOTHBOUNDRIES (1<<1)
|
---|
513 | #define OPTIMIZE_AUTOEDGE (1<<2)
|
---|
514 |
|
---|
515 |
|
---|
516 | void DllExport setUseVisEdge(int b);
|
---|
517 | int DllExport getUseVisEdge();
|
---|
518 |
|
---|
519 | // a callback to update progress UI while doing a
|
---|
520 | // lengthy operation to a mesh
|
---|
521 | class MeshOpProgress {
|
---|
522 | public:
|
---|
523 | // called once with the total increments
|
---|
524 | virtual void Init(int total)=0;
|
---|
525 |
|
---|
526 | // Called to update progress. % done = p/total
|
---|
527 | virtual BOOL Progress(int p)=0;
|
---|
528 | };
|
---|
529 |
|
---|
530 | // Boolean operations for meshes:
|
---|
531 | #define MESHBOOL_UNION 1
|
---|
532 | #define MESHBOOL_INTERSECTION 2
|
---|
533 | #define MESHBOOL_DIFFERENCE 3
|
---|
534 |
|
---|
535 | //
|
---|
536 | // mesh = mesh1 op mesh2
|
---|
537 | // If tm1 or tm2 are non-NULL, the points of the corresponding
|
---|
538 | // mesh will be transformed by these tm before the bool op
|
---|
539 | // The mesh will be transformed back by either Inverse(tm1) or
|
---|
540 | // Inverse(tm2) depending whichInv (0=>tm1, 1=>tm2)
|
---|
541 | // unless whichInv is -1 in which case it will not be transformed
|
---|
542 | // back.
|
---|
543 | //
|
---|
544 | int DllExport CalcBoolOp(
|
---|
545 | Mesh &mesh, Mesh &mesh1, Mesh &mesh2, int op,
|
---|
546 | MeshOpProgress *prog = NULL,
|
---|
547 | Matrix3 *tm1 = NULL,
|
---|
548 | Matrix3 *tm2 = NULL,
|
---|
549 | int whichInv = 0,
|
---|
550 | int weld = TRUE);
|
---|
551 |
|
---|
552 |
|
---|
553 |
|
---|
554 | DllExport void SetSubSelColor(Point3 *clr);
|
---|
555 | DllExport Point3 GetSubSelColor();
|
---|
556 |
|
---|
557 | #endif // _MESH_H_
|
---|
558 |
|
---|