1 | /*==========================================================================
|
---|
2 | * (C) 2005 Universidad Jaime I de Castellón
|
---|
3 | *==========================================================================
|
---|
4 | * PROYECT: GAME TOOLS
|
---|
5 | *==========================================================================*/
|
---|
6 | /* CONTENT: Make triangle strips meshes from triangle list meshes.
|
---|
7 | *
|
---|
8 | *
|
---|
9 | * @file GeoMeshStripifier.h
|
---|
10 | *==========================================================================*/
|
---|
11 |
|
---|
12 | #ifndef __GEO_STRIPIFIER__
|
---|
13 | #define __GEO_STRIPIFIER__
|
---|
14 |
|
---|
15 | #include "GeoMesh.h"
|
---|
16 |
|
---|
17 | typedef int BOOL;
|
---|
18 | typedef void * PVOID;
|
---|
19 |
|
---|
20 |
|
---|
21 | namespace Geometry
|
---|
22 | {
|
---|
23 |
|
---|
24 | #define TRIANGLE 3
|
---|
25 | #define MAGNITUDE 1000000
|
---|
26 | #define MAX_TIE 60
|
---|
27 |
|
---|
28 | #define FALSE 0
|
---|
29 | #define TRUE 1
|
---|
30 | #define LISTHEAD 0
|
---|
31 | #define LISTTAIL 1
|
---|
32 |
|
---|
33 | typedef struct
|
---|
34 | {
|
---|
35 | void *Next;
|
---|
36 | void *Previous;
|
---|
37 | }
|
---|
38 | myNode, * PNODE;
|
---|
39 |
|
---|
40 | typedef struct List
|
---|
41 | {
|
---|
42 | /* link to the next Listinfo Structure */
|
---|
43 | myNode ListNode;
|
---|
44 |
|
---|
45 | /* user definable data */
|
---|
46 | }
|
---|
47 | ListInfo, *PLISTINFO;
|
---|
48 |
|
---|
49 | typedef struct LHead
|
---|
50 | {
|
---|
51 | PLISTINFO LHeaders[2];
|
---|
52 | int NumList;
|
---|
53 | }
|
---|
54 | ListHead, *PLISTHEAD;
|
---|
55 |
|
---|
56 | #define PEEKFROMHEAD( lh, ind ) ( PeekList( (lh), LISTHEAD, (ind) ) )
|
---|
57 | #define PEEKFROMTAIL( lh, ind ) ( PeekList( (lh), LISTTAIL, (ind) ) )
|
---|
58 | #define EMPTYLIST( lh ) ( ( (lh)->LHeaders[LISTHEAD] == NULL ) )
|
---|
59 | #define NumOnList(lh) ( ((lh)->NumList) )
|
---|
60 | #define GetNextNode(pli) ( ((pli)->ListNode.Next) )
|
---|
61 | #define GetPrevNode(pli) ( ((pli)->ListNode.Previous) )
|
---|
62 |
|
---|
63 | //-----
|
---|
64 |
|
---|
65 | /** polverts.h
|
---|
66 | */
|
---|
67 | typedef struct adjacencies
|
---|
68 | {
|
---|
69 | myNode ListNode;
|
---|
70 | int face_id;
|
---|
71 | }ADJACENCIES,*P_ADJACENCIES;
|
---|
72 |
|
---|
73 | typedef struct FVerts
|
---|
74 | {
|
---|
75 | myNode ListNode;
|
---|
76 | int *pPolygon;
|
---|
77 | int nPolSize;
|
---|
78 | int nId;
|
---|
79 | } F_VERTS, *PF_VERTS;
|
---|
80 |
|
---|
81 | /*Every time we need to use this, cast it ( ListInfo*)*/
|
---|
82 | typedef struct FEdges
|
---|
83 | {
|
---|
84 | myNode ListNode;
|
---|
85 | int edge[3];
|
---|
86 | }F_EDGES,*PF_EDGES;
|
---|
87 |
|
---|
88 | typedef struct FFaces
|
---|
89 | {
|
---|
90 | myNode ListNode;
|
---|
91 | int *pPolygon;
|
---|
92 | int *pNorms;
|
---|
93 | int seen;
|
---|
94 | int seen2;
|
---|
95 | int seen3;
|
---|
96 | int nPolSize;
|
---|
97 | int nOrgSize;
|
---|
98 | F_EDGES **VertandId;
|
---|
99 | int *marked;
|
---|
100 | int *walked;
|
---|
101 | }F_FACES,*PF_FACES;
|
---|
102 |
|
---|
103 | typedef struct FVertices
|
---|
104 | {
|
---|
105 | myNode ListNode;
|
---|
106 | PF_FACES face;
|
---|
107 | }F_VERTICES, *PF_VERTICES;
|
---|
108 |
|
---|
109 | typedef struct Strips
|
---|
110 | {
|
---|
111 | myNode ListNode;
|
---|
112 | int face_id;
|
---|
113 | }Strips,*P_STRIPS;
|
---|
114 |
|
---|
115 |
|
---|
116 | struct vert_added
|
---|
117 | {
|
---|
118 | int num;
|
---|
119 | int *normal;
|
---|
120 | };
|
---|
121 |
|
---|
122 | typedef struct face_adjacencies
|
---|
123 | {
|
---|
124 | P_ADJACENCIES pfNode;
|
---|
125 | int bucket;
|
---|
126 | ListHead *head;
|
---|
127 | }
|
---|
128 | FACE_ADJACENCIES, *P_FACE_ADJACENCIES;
|
---|
129 |
|
---|
130 | /** global.h
|
---|
131 | */
|
---|
132 | typedef std::vector<int> mi_vector_tipo;
|
---|
133 | //std::vector<mi_vector_tipo> mi_vector;
|
---|
134 | enum swap_type {ON,OFF};
|
---|
135 |
|
---|
136 | #define VRDATA double
|
---|
137 | #define MAX1 60
|
---|
138 |
|
---|
139 | #define GEO_PI 3.1415926573
|
---|
140 | #define ATOI(C) (C -'0')
|
---|
141 | #define EVEN(x) (((x) & 1) == 0)
|
---|
142 | #define MAX_BAND 10000
|
---|
143 |
|
---|
144 | struct vert_struct
|
---|
145 | {
|
---|
146 | VRDATA x, y, z; /* point coordinates */
|
---|
147 | };
|
---|
148 |
|
---|
149 | /// Stripifier interface class.
|
---|
150 | /** This module implements methods that extract triangle strips from triangle meshes.
|
---|
151 | \n
|
---|
152 |
|
---|
153 | Inputs:\n
|
---|
154 | - This module receives a pointer to a Geometry::Mesh object containing the model to be stripified.
|
---|
155 | .
|
---|
156 |
|
---|
157 | Outputs:\n
|
---|
158 | - The stripified mesh, contained also in a Geometry::Mesh object.
|
---|
159 | .
|
---|
160 |
|
---|
161 | */
|
---|
162 | class MeshStripifier
|
---|
163 | {
|
---|
164 | public:
|
---|
165 | /// Class constructor, receives as a parameter a const pointer to the object that describes a mesh.
|
---|
166 | MeshStripifier ();
|
---|
167 | MeshStripifier (const Geometry::Mesh *);
|
---|
168 |
|
---|
169 | /// virtual class destructor.
|
---|
170 | virtual ~MeshStripifier (void);
|
---|
171 |
|
---|
172 | /// Copy constructor
|
---|
173 | //MeshStripifier(const MeshStripifier&);
|
---|
174 |
|
---|
175 | /// Assignment operator
|
---|
176 | //MeshStripifier& operator =(const MeshStripifier&);
|
---|
177 |
|
---|
178 | /// Starts the stripification process. This is a pure virtual method and must be overloaded in a derived class that implements a stripification algorithm.
|
---|
179 | virtual int Stripify()=0;
|
---|
180 |
|
---|
181 | /// Returns the stripified mesh.
|
---|
182 | Mesh * GetMesh ();
|
---|
183 |
|
---|
184 | // Sets what is the mesh that stores the leaves
|
---|
185 | void setSubMeshLeaves(size_t);
|
---|
186 |
|
---|
187 | protected:
|
---|
188 |
|
---|
189 | // Progress bar function.
|
---|
190 | Geometry::TIPOFUNC mUPB;
|
---|
191 |
|
---|
192 | // Mesh object.
|
---|
193 | Geometry::Mesh *mGeoMesh;
|
---|
194 |
|
---|
195 | // Index of the submesh leaves.
|
---|
196 | size_t mSubMeshLeaves;
|
---|
197 | };
|
---|
198 |
|
---|
199 | class CustomStripifier : public MeshStripifier
|
---|
200 | {
|
---|
201 | private:
|
---|
202 |
|
---|
203 | /* Globals */
|
---|
204 | int mError; // 0 OK.
|
---|
205 | // 1 Error: The mesh is not Manifold.
|
---|
206 | int num_faces;
|
---|
207 | ListHead **PolFaces;
|
---|
208 | ListHead **PolEdges;
|
---|
209 | ListHead *array[60];
|
---|
210 | P_FACE_ADJACENCIES face_array; /* Pointers from face_id to face */
|
---|
211 | ListHead **Vertices; /* Pointers from vertex_id to face */
|
---|
212 | ListHead *strips[1];
|
---|
213 | int orient;
|
---|
214 | int num_tiras;
|
---|
215 | int ids[MAX1];
|
---|
216 | int norms[MAX1];
|
---|
217 | int *vert_norms;
|
---|
218 | int *vert_texture;
|
---|
219 | int out1;//= -1; // static.
|
---|
220 | int out2;//= -1; // static.
|
---|
221 | int ties_array[60]; // static.
|
---|
222 | int last;//= 0; // static.
|
---|
223 | int out1Ex;// = -1; // static.
|
---|
224 | int out2Ex;// = -1; // static.
|
---|
225 | int *vn;
|
---|
226 | int *vt;
|
---|
227 | int norm; // static.
|
---|
228 | int text; // static.
|
---|
229 | BOOL resetting;// = FALSE; // static.
|
---|
230 | int added_quad;// = 0; // static.
|
---|
231 | BOOL reversed;// = FALSE; // static.
|
---|
232 | int patch;// = 0; // static.
|
---|
233 |
|
---|
234 | /** global.h
|
---|
235 | */
|
---|
236 | std::vector<mi_vector_tipo> mi_vector;
|
---|
237 |
|
---|
238 | /** auxiliar.h
|
---|
239 | */
|
---|
240 | Geometry::Mesh *MeshGlobal;
|
---|
241 | // Structures for the object.
|
---|
242 | vert_struct *vertices;
|
---|
243 | vert_struct *nvertices;
|
---|
244 | vert_struct *pvertices;
|
---|
245 | vert_struct *pnvertices;
|
---|
246 |
|
---|
247 | /* General utility routines */
|
---|
248 | /* %%s QueRoutines */
|
---|
249 | BOOL InitList ( PLISTHEAD );
|
---|
250 |
|
---|
251 | /*****************************************************************
|
---|
252 | InitList : Initialize a new list structure for use with the List
|
---|
253 | routines
|
---|
254 |
|
---|
255 | INPUTS : LHead : a pointer to a ListHead structure.
|
---|
256 | OUTPUT : a boolean value TRUE if no errors occured FALSE
|
---|
257 | otherwise
|
---|
258 | ******************************************************************/
|
---|
259 |
|
---|
260 |
|
---|
261 | PLISTINFO PeekList( PLISTHEAD, int, int );
|
---|
262 |
|
---|
263 | /*****************************************************************
|
---|
264 | PeekList : This funciton peeks down a list for the N'th element
|
---|
265 | from the HEAD or TAIL of the list
|
---|
266 |
|
---|
267 | INPUTS : LHead : a pointer to a List head structure.
|
---|
268 | from : can either search from the HEAD or TAIL
|
---|
269 | of the list
|
---|
270 | where : how many nodes from the begining should the
|
---|
271 | List routines look.
|
---|
272 | OUTPUT : a pointer to a ListInfo structure identified by
|
---|
273 | from/where or NULL if an error occurred.
|
---|
274 | ******************************************************************/
|
---|
275 |
|
---|
276 |
|
---|
277 | PLISTINFO RemoveList( PLISTHEAD LHead, PLISTINFO LInfo );
|
---|
278 |
|
---|
279 |
|
---|
280 | /*****************************************************************
|
---|
281 | RemoveList: Remove a ListInfo structure from a List.
|
---|
282 |
|
---|
283 | INPUTS : LHead : a pointer to a ListHead structure.
|
---|
284 | LInfo : a pointer to the ListInfo structure to remove
|
---|
285 | from the list.
|
---|
286 | OUTPUT : a pointer to the ListInfo structure that was removed or
|
---|
287 | NULL if an error occurred.
|
---|
288 | ******************************************************************/
|
---|
289 |
|
---|
290 | BOOL InsertNode( PLISTHEAD LHead, int nPos, PLISTINFO LInfo );
|
---|
291 |
|
---|
292 | /*****************************************************************
|
---|
293 | InsertNode: add a node to a list after a given node
|
---|
294 |
|
---|
295 | INPUTS : LHead : a pointer to a ListHead structure.
|
---|
296 | nPos : the position to insert the node into
|
---|
297 | LInfo : a pointer to the new node to add to the list.
|
---|
298 | OUTPUT: a boolean value TRUE if all goes well false otherwise
|
---|
299 | *****************************************************************/
|
---|
300 |
|
---|
301 | BOOL AddHead ( PLISTHEAD, PLISTINFO );
|
---|
302 |
|
---|
303 | /*****************************************************************
|
---|
304 | AddHead : add a ListInfo structure to the HEAD of a list.
|
---|
305 |
|
---|
306 | INPUTS : LHead : a pointer to a ListHead structure of the list
|
---|
307 | to add to.
|
---|
308 | LInfo : a pointer to the ListInfo structure to add to
|
---|
309 | the list.
|
---|
310 | OUTPUT : A boolean value TRUE if no errors occurred FALSE
|
---|
311 | otherwise.
|
---|
312 | ******************************************************************/
|
---|
313 |
|
---|
314 |
|
---|
315 | BOOL AddTail ( PLISTHEAD, PLISTINFO );
|
---|
316 |
|
---|
317 | /*****************************************************************
|
---|
318 | AddTail : Add a ListInfo structure to the TAIL of a list.
|
---|
319 |
|
---|
320 | INPUTS : LHead : a pointer to a ListHead structure of the List
|
---|
321 | to add to.
|
---|
322 | LInfo : a pointer to the ListInfo structure to add to
|
---|
323 | the List.
|
---|
324 | OUTPUT : a boolean value TRUE if no errors occurred FALSE
|
---|
325 | otherwise.
|
---|
326 | ******************************************************************/
|
---|
327 |
|
---|
328 |
|
---|
329 | PLISTINFO RemTail ( PLISTHEAD );
|
---|
330 |
|
---|
331 | /*****************************************************************
|
---|
332 | RemTail : Remove a ListInfo structure from the TAIL of a List.
|
---|
333 |
|
---|
334 | INPUTS : LHead : a pointer to a ListHead structure of the List
|
---|
335 | to remove from.
|
---|
336 | OUTPUT : a pointer to the ListInfo structure that was removed
|
---|
337 | or NULL if an error occurred.
|
---|
338 | ******************************************************************/
|
---|
339 |
|
---|
340 |
|
---|
341 | PLISTINFO RemHead ( PLISTHEAD );
|
---|
342 |
|
---|
343 | /*****************************************************************
|
---|
344 | RemHead : Remove a ListInfo structure from the Head of a List.
|
---|
345 |
|
---|
346 | INPUTS : LHead : a pointer to a ListHead structure of the List
|
---|
347 | to remove from.
|
---|
348 | OUTPUT : a pointer to the ListInfo structure that was removed or
|
---|
349 | NULL if an error occurred.
|
---|
350 | ******************************************************************/
|
---|
351 |
|
---|
352 | PLISTINFO SearchList(
|
---|
353 | PLISTHEAD lpListHead,
|
---|
354 | PVOID lpSKey,
|
---|
355 | int ( * CompareCallBack) ( PVOID, PVOID ) );
|
---|
356 |
|
---|
357 | /*****************************************************************
|
---|
358 | SearchList:
|
---|
359 | Try to find a specific node in the queue whose key matches with
|
---|
360 | searching key. Return the pointer to that node if found, return NULL
|
---|
361 | otherwise
|
---|
362 |
|
---|
363 | Input:
|
---|
364 | lpHashTbl => a far pointer to the hash table
|
---|
365 | lpKey => a far poniter to searching key
|
---|
366 | CompareCallBack => comparision function
|
---|
367 |
|
---|
368 | Output: a far pointer to the node to be found
|
---|
369 |
|
---|
370 | ******************************************************************/
|
---|
371 |
|
---|
372 | /** init.h
|
---|
373 | */
|
---|
374 | BOOL InitVertexTable(int nSize);
|
---|
375 | BOOL InitFaceTable(int nSize);
|
---|
376 | BOOL InitEdgeTable(int nSize);
|
---|
377 | void BuildFaceTable(int nSize);
|
---|
378 | void BuildVertexTable(int nSize);
|
---|
379 | void BuildEdgeTable(int nSize);
|
---|
380 | void init_vert_norms(int num_vert);
|
---|
381 | void init_vert_texture(int num_vert);
|
---|
382 | void InitStripTable();
|
---|
383 | void Init_Table_SGI(int numfaces);
|
---|
384 | void Start_Vertex_Struct(int numverts);
|
---|
385 | void Start_Face_Struct(int numfaces);
|
---|
386 | void Start_Edge_Struct(int numverts);
|
---|
387 |
|
---|
388 | /** util.h
|
---|
389 | */
|
---|
390 | void switch_lower(int *x, int *y);
|
---|
391 | BOOL member(int x , int id1, int id2, int id3);
|
---|
392 | BOOL Exist(int face_id, int id1, int id2);
|
---|
393 | int Different( int id1,int id2,int id3,int id4,int id5,
|
---|
394 | int id6, int *x, int *y);
|
---|
395 | int Return_Other(int *index,int e1,int e2);
|
---|
396 | int Get_Other_Vertex(int id1,int id2,int id3,int *index);
|
---|
397 | PLISTINFO Done(int face_id, int *bucket);
|
---|
398 | void First_Edge(int *id1,int *id2, int *id3);
|
---|
399 | void Last_Edge(int *id1, int *id2, int *id3, BOOL save);
|
---|
400 |
|
---|
401 | void preserve_strip_orientation_with_normal(
|
---|
402 | int vertex1,
|
---|
403 | int normal1,
|
---|
404 | int vertex2,
|
---|
405 | int normal2,
|
---|
406 | int vertex3,
|
---|
407 | int normal3);
|
---|
408 |
|
---|
409 | void preserve_strip_orientation_with_texture(
|
---|
410 | int vertex1,
|
---|
411 | int texture1,
|
---|
412 | int vertex2,
|
---|
413 | int texture2,
|
---|
414 | int vertex3,
|
---|
415 | int texture3);
|
---|
416 |
|
---|
417 | void preserve_strip_orientation_with_texture_and_normal(
|
---|
418 | int vertex1,
|
---|
419 | int texture1,
|
---|
420 | int normal1,
|
---|
421 | int vertex2,
|
---|
422 | int texture2,
|
---|
423 | int normal2,
|
---|
424 | int vertex3,
|
---|
425 | int texture3,
|
---|
426 | int normal3);
|
---|
427 |
|
---|
428 | void preserve_strip_orientation(
|
---|
429 | int vertex1,
|
---|
430 | int vertex2,
|
---|
431 | int vertex3);
|
---|
432 |
|
---|
433 | void find_triangle_orientation( int vertex1,
|
---|
434 | int vertex2,
|
---|
435 | int vertex3,
|
---|
436 | int *original_vertex);
|
---|
437 |
|
---|
438 | /** local.h
|
---|
439 | */
|
---|
440 | void Find_StripsEx(int *ties, int tie, int triangulate, int swaps, int *next_id);
|
---|
441 | void SGI_Strip(int num_faces,int ties,int triangulate);
|
---|
442 |
|
---|
443 | /** outputex.h
|
---|
444 | */
|
---|
445 | void Output_TriEx(int id1, int id2, int id3, int flag,int where);
|
---|
446 | void Extend_BackwardsEx(int face_id, int *ties,
|
---|
447 | int tie, int triangulate,
|
---|
448 | int swaps,int *next_id);
|
---|
449 | void Polygon_OutputEx(P_ADJACENCIES temp,int face_id,int bucket,
|
---|
450 | ListHead *pListHead,
|
---|
451 | int *ties, int tie,int triangulate, int swaps,
|
---|
452 | int *next_id, int where);
|
---|
453 |
|
---|
454 | /** sgi_triang.h
|
---|
455 | */
|
---|
456 | int Adjacent(int id2,int id1, int *list, int size);
|
---|
457 | void Build_SGI_Table(int num_faces);
|
---|
458 | void Non_Blind_Triangulate( int size,int *index,
|
---|
459 | int next_face_id,
|
---|
460 | int face_id,int where,
|
---|
461 | int color1,int color2,int color3);
|
---|
462 | void Blind_Triangulate(int size, int *index, BOOL begin, int where);
|
---|
463 | void Rearrange_Index(int *index, int size); // static.
|
---|
464 | void Delete_From_List(int id,int *list, int *size); // static.
|
---|
465 | void Triangulate_Quad(int out_edge1,int out_edge2,int in_edge1,
|
---|
466 | int in_edge2,int size,int *index,
|
---|
467 | int reversed,int where); // static.
|
---|
468 | void Triangulate_Polygon( int out_edge1,int out_edge2,
|
---|
469 | int in_edge1, int in_edge2,
|
---|
470 | int size, int *index,
|
---|
471 | int reversed,
|
---|
472 | int face_id, int where,
|
---|
473 | int color1, int color2,
|
---|
474 | int color3); // static.
|
---|
475 |
|
---|
476 | void Triangulate( int out_edge1,int out_edge2,int in_edge1,
|
---|
477 | int in_edge2,int size,int *index,
|
---|
478 | int reversed,int face_id, int where,
|
---|
479 | int color1, int color2,int color3); // static.
|
---|
480 |
|
---|
481 | /** struct.h
|
---|
482 | */
|
---|
483 | int Get_Edge( int *edge1,int *edge2,
|
---|
484 | int *index,int face_id,
|
---|
485 | int size, int id1, int id2);
|
---|
486 | int Update_Adjacencies( int face_id,int *next_bucket,
|
---|
487 | int *e1,int *e2,int *ties);
|
---|
488 | void Update_Face( int *next_bucket, int *min_face,
|
---|
489 | int face_id, int *e1,
|
---|
490 | int *e2, int temp1,
|
---|
491 | int temp2, int *ties); // static.
|
---|
492 | void Delete_Adj(int id1, int id2,int *next_bucket,
|
---|
493 | int *min_face,int current_face,int *e1,
|
---|
494 | int *e2,int *ties); // static.
|
---|
495 | /** common.h
|
---|
496 | */
|
---|
497 | int Old_Adj(int face_id);
|
---|
498 | int Number_Adj(int id1, int id2, int curr_id);
|
---|
499 | int Min_Adj(int id);
|
---|
500 | void Check_In_Polygon(int face_id, int *min, int size);
|
---|
501 | void New_Face (int face_id, int v1, int v2, int v3);
|
---|
502 | void New_Size_Face(int face_id);
|
---|
503 | void Check_In_Quad(int face_id,int *min);
|
---|
504 | int Get_Output_Edge(int face_id, int size, int *index,int id2,int id3);
|
---|
505 | void Get_Input_Edge(int *index,int id1,
|
---|
506 | int id2,int id3,
|
---|
507 | int *new1,int *new2,
|
---|
508 | int size,int face_id);
|
---|
509 | int Find_Face(int current_face, int id1,
|
---|
510 | int id2, int *bucket);
|
---|
511 | BOOL Look_Up(int id1,int id2,int face_id);
|
---|
512 | void Add_Id_Strips(int id, int where);
|
---|
513 | int Num_Adj(int id1, int id2);
|
---|
514 | void Add_Sgi_Adj(int bucket,int face_id);
|
---|
515 | void Find_Adjacencies(int num_faces);
|
---|
516 | void Edge_Least(int *index,int *new1,
|
---|
517 | int *new2,int face_id,int size); // static.
|
---|
518 |
|
---|
519 | /** ties.h
|
---|
520 | */
|
---|
521 | void Clear_Ties();
|
---|
522 | void Add_Ties(int id);
|
---|
523 | int Get_Next_Face(int t, int face_id, int triangulate);
|
---|
524 | int Alternate_Tie(); // static.
|
---|
525 | int Random_Tie(); // static.
|
---|
526 | int Look_Ahead(int id); // static.
|
---|
527 | int Random_Look(int id[],int count); // static.
|
---|
528 | int Look_Ahead_Tie(); // static.
|
---|
529 | int Sequential_Tri(int *index); // static.
|
---|
530 | int Sequential_Quad(int *index, int triangulate); // static.
|
---|
531 | void Whole_Output(int in1, int *index, int size,
|
---|
532 | int *out1,int *out2); // static.
|
---|
533 | int Sequential_Poly(int size,int *index,int triangulate); // static.
|
---|
534 | int Sequential_Tie(int face_id,int triangulate); // static.
|
---|
535 |
|
---|
536 | /** add.h
|
---|
537 | */
|
---|
538 | BOOL norm_array(int id,int vertex,
|
---|
539 | double normal_difference,
|
---|
540 | struct vert_struct *n,int num_vert);
|
---|
541 | void add_texture(int id,BOOL vertex);
|
---|
542 | int add_vert_id(int id, int index_count);
|
---|
543 | void add_norm_id(int id, int index_count);
|
---|
544 | void AddNewFace(int ids[MAX1],int vert_count,
|
---|
545 | int face_id,int norms[MAX1]);
|
---|
546 | void CopyFace(int ids[MAX1],int vert_count,
|
---|
547 | int face_id,int norms[MAX1]);
|
---|
548 | void Add_AdjEdge( int v1,int v2,
|
---|
549 | int fnum,int index1);
|
---|
550 | BOOL new_vertex(double difference,int id1,
|
---|
551 | int id2,struct vert_struct *n); // static.
|
---|
552 | BOOL Check_VN(int vertex,int normal, struct vert_added *added); // static.
|
---|
553 |
|
---|
554 | /** options.h
|
---|
555 | */
|
---|
556 | enum file_options {ASCII,BINARY};
|
---|
557 | enum tie_options {FIRST, RANDOM, ALTERNA, LOOK, SEQUENTIAL};
|
---|
558 | enum triangulation_options {PARTIAL,WHOLE};
|
---|
559 |
|
---|
560 | void print_usage(void);
|
---|
561 | float get_options(int argc, char **argv,
|
---|
562 | int *f, int *t,
|
---|
563 | int *tr, int *group,
|
---|
564 | int *orientation);
|
---|
565 | int power_10(int power); // static.
|
---|
566 | float power_negative(int power); // static.
|
---|
567 | float convert_array(int num[],int stack_size); // static.
|
---|
568 |
|
---|
569 | /** sgi_triangex.h
|
---|
570 | */
|
---|
571 | int AdjacentEx(int id2,int id1, int *list, int size);
|
---|
572 | void Delete_From_ListEx(int id,int *list, int size);
|
---|
573 | void Triangulate_PolygonEx( int out_edge1,int out_edge2,int in_edge1,
|
---|
574 | int in_edge2,int size,int *index,
|
---|
575 | int reversed,int face_id,
|
---|
576 | int where);
|
---|
577 | void Non_Blind_TriangulateEx( int size,int *index,
|
---|
578 | int next_face_id,
|
---|
579 | int face_id,int where);
|
---|
580 | void Rearrange_IndexEx(int *index, int size);
|
---|
581 | void Blind_TriangulateEx( int size, int *index,
|
---|
582 | BOOL begin, int where);
|
---|
583 | void Triangulate_QuadEx(int out_edge1,int out_edge2,int in_edge1,
|
---|
584 | int in_edge2, int size, int *index,
|
---|
585 | int reversed, int where); // static.
|
---|
586 | void TriangulateEx( int out_edge1,int out_edge2,
|
---|
587 | int in_edge1, int in_edge2,
|
---|
588 | int size, int *index,
|
---|
589 | int reversed,
|
---|
590 | int face_id, int where); // static.
|
---|
591 |
|
---|
592 | /** structex.h
|
---|
593 | */
|
---|
594 | int Get_EdgeEx( int *edge1,int *edge2,int *index,int face_id,
|
---|
595 | int size, int id1, int id2);
|
---|
596 | void Delete_AdjEx(int id1, int id2,
|
---|
597 | int *next_bucket,int *min_face,
|
---|
598 | int current_face,int *e1,
|
---|
599 | int *e2,int *ties);
|
---|
600 | int Change_FaceEx(int face_id,int in1,int in2,
|
---|
601 | ListHead *pListHead, BOOL no_check);
|
---|
602 | int Update_AdjacenciesEx( int face_id,int *next_bucket,
|
---|
603 | int *e1, int *e2,
|
---|
604 | int *ties);
|
---|
605 | int Min_Face_AdjEx(int face_id,int *next_bucket,int *ties);
|
---|
606 |
|
---|
607 | void Update_FaceEx( int *next_bucket,int *min_face,
|
---|
608 | int face_id, int *e1,
|
---|
609 | int *e2,int temp1,
|
---|
610 | int temp2,int *ties); // static.
|
---|
611 |
|
---|
612 | void Find_Adj_TallyEx(int id1, int id2,
|
---|
613 | int *next_bucket, int *min_face,
|
---|
614 | int current_face, int *ties); // static.
|
---|
615 |
|
---|
616 | /** partial.h
|
---|
617 | */
|
---|
618 | void Partial_Triangulate(int size, int *index,
|
---|
619 | int next_face_id,
|
---|
620 | int face_id, int *next_id,
|
---|
621 | ListHead *pListHead,
|
---|
622 | P_ADJACENCIES temp, int where);
|
---|
623 |
|
---|
624 |
|
---|
625 | void Inside_Polygon(int size, int *index,
|
---|
626 | int face_id, ListHead *pListHead,
|
---|
627 | int where);
|
---|
628 |
|
---|
629 | void P_Triangulate_Quad(int out_edge1,int out_edge2,
|
---|
630 | int in_edge1, int in_edge2,
|
---|
631 | int size, int *index,
|
---|
632 | int reversed, int face_id,
|
---|
633 | ListHead *pListHead,
|
---|
634 | P_ADJACENCIES temp,
|
---|
635 | int where); // static.
|
---|
636 | void P_Triangulate_Polygon( int out_edge1,int out_edge2,
|
---|
637 | int in_edge1, int in_edge2,
|
---|
638 | int size, int *index,
|
---|
639 | int reversed,
|
---|
640 | int face_id, int *next_id,
|
---|
641 | ListHead *pListHead,
|
---|
642 | P_ADJACENCIES temp2,
|
---|
643 | int where); // static.
|
---|
644 | void P_Triangulate( int out_edge1,int out_edge2,int in_edge1,
|
---|
645 | int in_edge2, int size, int *index,
|
---|
646 | int reversed, int face_id,
|
---|
647 | int *next_id, ListHead *pListHead,
|
---|
648 | P_ADJACENCIES temp,int where); // static.
|
---|
649 | void Input_Edge(int face_id, int *index,
|
---|
650 | int size, int in_edge1,
|
---|
651 | int in_edge2, ListHead *pListHead,
|
---|
652 | int where); // static.
|
---|
653 |
|
---|
654 | /** output.h
|
---|
655 | */
|
---|
656 | int Finished(int *swap, int startnewstrip);
|
---|
657 | void Output_Tri(int id1, int id2, int id3,BOOL end);
|
---|
658 | int Extend_Face(int face_id,int e1,int e2,int *swaps,
|
---|
659 | int color1,int color2,int color3,int *vert_norm,
|
---|
660 | int normals,int *vert_texture,int texture);
|
---|
661 | int Polygon_Output( P_ADJACENCIES temp, int face_id,
|
---|
662 | int bucket, ListHead *pListHead,
|
---|
663 | BOOL first, int *swaps,
|
---|
664 | int color1, int color2,
|
---|
665 | int color3,
|
---|
666 | BOOL global, BOOL end); // static.
|
---|
667 | /** free.h
|
---|
668 | */
|
---|
669 | void Free_Strips();
|
---|
670 | void End_Face_Struct(int numfaces);
|
---|
671 | void End_Edge_Struct(int numverts);
|
---|
672 | void ParseAndFreeList( ListHead *pListHead ); // static.
|
---|
673 | void FreeFaceTable(int nSize); // static.
|
---|
674 | void FreeEdgeTable(int nSize); // static.
|
---|
675 |
|
---|
676 | /** newpolve.h
|
---|
677 | */
|
---|
678 | void Find_Bands(int numfaces, int *swaps, int *bands,
|
---|
679 | int *cost, int *tri, int norms, int *vert_norms,
|
---|
680 | int texture, int *vert_texture);
|
---|
681 | void Save_Walks(int numfaces);
|
---|
682 | void Save_Rest(int *numfaces);
|
---|
683 | int Calculate_Walks(int lastvert,int y, PF_FACES temp2); // static.
|
---|
684 | BOOL Check_Right( int last_seen,PF_FACES temp2,
|
---|
685 | int y,int face_id); // static.
|
---|
686 | int Update_and_Test(PF_FACES temp2,int y,
|
---|
687 | BOOL first,int distance,
|
---|
688 | int lastvert, int val); // static.
|
---|
689 | int Test_Adj( PF_FACES temp2,int x,
|
---|
690 | int north,int distance,
|
---|
691 | int lastvert, int value); // static.
|
---|
692 | int Find_Max( PF_FACES temp2, int lastvert,
|
---|
693 | int north, int left,
|
---|
694 | int *lastminup, int *lastminleft); // static.
|
---|
695 | void Mark_Face( PF_FACES temp2, int color1,
|
---|
696 | int color2, int color3,
|
---|
697 | BOOL end,
|
---|
698 | int *edge1, int *edge2,
|
---|
699 | int *face_id, int norms,
|
---|
700 | int texture); // static.
|
---|
701 | void Assign_Walk( int lastvert, PF_FACES temp2,
|
---|
702 | int front_walk, int y,
|
---|
703 | int back_walk); // static.
|
---|
704 | void Fast_Reset(int x); // static.
|
---|
705 | void Reset_Max( PF_FACES temp2,int face_id,
|
---|
706 | int north,int last_north,
|
---|
707 | int orientation,int last_left,
|
---|
708 | int color1,
|
---|
709 | int color2,int color3,
|
---|
710 | BOOL start); // static.
|
---|
711 | int Peel_Max( PF_FACES temp2,int face_id,
|
---|
712 | int north,int last_north,
|
---|
713 | int orientation,int last_left,
|
---|
714 | int color1,
|
---|
715 | int color2,int color3,
|
---|
716 | BOOL start, int *swaps_added,
|
---|
717 | int norms, int texture); // static.
|
---|
718 |
|
---|
719 | /** auxiliar.h
|
---|
720 | */
|
---|
721 | // FILE *OpenOutputFile(char *fname);
|
---|
722 | void AllocateStruct(int num_faces,
|
---|
723 | int num_vert,
|
---|
724 | int num_nvert,
|
---|
725 | int num_texture);
|
---|
726 | void miReadFile(char *fname, char *file_open, Geometry::SubMesh *geoSubMesh);
|
---|
727 | int stripify( char *fname,
|
---|
728 | Geometry::Mesh *geoMesh);
|
---|
729 |
|
---|
730 | public:
|
---|
731 | /// Class constructor, receives as a parameter a const pointer to the object that describes a mesh.
|
---|
732 | CustomStripifier();
|
---|
733 |
|
---|
734 | CustomStripifier(const Geometry::Mesh *geoMesh);
|
---|
735 |
|
---|
736 | /// Class destructor.
|
---|
737 | ~CustomStripifier(void);
|
---|
738 |
|
---|
739 | /// Copy constructor
|
---|
740 | //CustomStripifier(const CustomStripifier&);
|
---|
741 |
|
---|
742 | /// Assignment operator
|
---|
743 | //CustomStripifier& operator =(const CustomStripifier&);
|
---|
744 |
|
---|
745 | /// Starts the stripification process. This is a custom stripification method.
|
---|
746 | int Stripify();
|
---|
747 |
|
---|
748 | /// Returns the stripified mesh.
|
---|
749 | Mesh * GetMesh();
|
---|
750 |
|
---|
751 | // Set the progress bar function.
|
---|
752 | void SetProgressFunc(Geometry::TIPOFUNC upb);
|
---|
753 |
|
---|
754 | // Sets what is the submesh that stores the leaves
|
---|
755 | void SetSubMeshLeaves(size_t submesh);
|
---|
756 |
|
---|
757 | };
|
---|
758 |
|
---|
759 | }
|
---|
760 |
|
---|
761 | #endif
|
---|
762 |
|
---|