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(FILE *output,
|
---|
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( FILE *output,
|
---|
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( FILE *output,
|
---|
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(FILE *output,
|
---|
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( FILE *output, int *ties,
|
---|
441 | int tie, int triangulate,
|
---|
442 | int swaps, int *next_id);
|
---|
443 | void SGI_Strip(int num_faces,FILE *output, int ties,int triangulate);
|
---|
444 |
|
---|
445 | /** outputex.h
|
---|
446 | */
|
---|
447 | void Output_TriEx(int id1, int id2, int id3, FILE *output,
|
---|
448 | int flag,int where);
|
---|
449 | void Extend_BackwardsEx(int face_id, FILE *output, int *ties,
|
---|
450 | int tie, int triangulate,
|
---|
451 | int swaps,int *next_id);
|
---|
452 | void Polygon_OutputEx(P_ADJACENCIES temp,int face_id,int bucket,
|
---|
453 | ListHead *pListHead, FILE *output,
|
---|
454 | int *ties, int tie,int triangulate, int swaps,
|
---|
455 | int *next_id, int where);
|
---|
456 |
|
---|
457 | /** sgi_triang.h
|
---|
458 | */
|
---|
459 | int Adjacent(int id2,int id1, int *list, int size);
|
---|
460 | void Build_SGI_Table(int num_faces);
|
---|
461 | void Non_Blind_Triangulate( int size,int *index,
|
---|
462 | FILE *output,int next_face_id,
|
---|
463 | int face_id,int where,
|
---|
464 | int color1,int color2,int color3);
|
---|
465 | void Blind_Triangulate(int size, int *index, BOOL begin, int where);
|
---|
466 | void Rearrange_Index(int *index, int size); // static.
|
---|
467 | void Delete_From_List(int id,int *list, int *size); // static.
|
---|
468 | void Triangulate_Quad(int out_edge1,int out_edge2,int in_edge1,
|
---|
469 | int in_edge2,int size,int *index,
|
---|
470 | int reversed,int where); // static.
|
---|
471 | void Triangulate_Polygon( int out_edge1,int out_edge2,
|
---|
472 | int in_edge1, int in_edge2,
|
---|
473 | int size, int *index,
|
---|
474 | FILE *output, int reversed,
|
---|
475 | int face_id, int where,
|
---|
476 | int color1, int color2,
|
---|
477 | int color3); // static.
|
---|
478 |
|
---|
479 | void Triangulate( int out_edge1,int out_edge2,int in_edge1,
|
---|
480 | int in_edge2,int size,int *index,
|
---|
481 | FILE *output,int reversed,int face_id, int where,
|
---|
482 | int color1, int color2,int color3); // static.
|
---|
483 |
|
---|
484 | /** struct.h
|
---|
485 | */
|
---|
486 | int Get_Edge( int *edge1,int *edge2,
|
---|
487 | int *index,int face_id,
|
---|
488 | int size, int id1, int id2);
|
---|
489 | int Update_Adjacencies( int face_id,int *next_bucket,
|
---|
490 | int *e1,int *e2,int *ties);
|
---|
491 | void Update_Face( int *next_bucket, int *min_face,
|
---|
492 | int face_id, int *e1,
|
---|
493 | int *e2, int temp1,
|
---|
494 | int temp2, int *ties); // static.
|
---|
495 | void Delete_Adj(int id1, int id2,int *next_bucket,
|
---|
496 | int *min_face,int current_face,int *e1,
|
---|
497 | int *e2,int *ties); // static.
|
---|
498 | /** common.h
|
---|
499 | */
|
---|
500 | int Old_Adj(int face_id);
|
---|
501 | int Number_Adj(int id1, int id2, int curr_id);
|
---|
502 | int Min_Adj(int id);
|
---|
503 | void Check_In_Polygon(int face_id, int *min, int size);
|
---|
504 | void New_Face (int face_id, int v1, int v2, int v3);
|
---|
505 | void New_Size_Face(int face_id);
|
---|
506 | void Check_In_Quad(int face_id,int *min);
|
---|
507 | int Get_Output_Edge(int face_id, int size, int *index,int id2,int id3);
|
---|
508 | void Get_Input_Edge(int *index,int id1,
|
---|
509 | int id2,int id3,
|
---|
510 | int *new1,int *new2,
|
---|
511 | int size,int face_id);
|
---|
512 | int Find_Face(int current_face, int id1,
|
---|
513 | int id2, int *bucket);
|
---|
514 | BOOL Look_Up(int id1,int id2,int face_id);
|
---|
515 | void Add_Id_Strips(int id, int where);
|
---|
516 | int Num_Adj(int id1, int id2);
|
---|
517 | void Add_Sgi_Adj(int bucket,int face_id);
|
---|
518 | void Find_Adjacencies(int num_faces);
|
---|
519 | void Edge_Least(int *index,int *new1,
|
---|
520 | int *new2,int face_id,int size); // static.
|
---|
521 |
|
---|
522 | /** ties.h
|
---|
523 | */
|
---|
524 | void Clear_Ties();
|
---|
525 | void Add_Ties(int id);
|
---|
526 | int Get_Next_Face(int t, int face_id, int triangulate);
|
---|
527 | int Alternate_Tie(); // static.
|
---|
528 | int Random_Tie(); // static.
|
---|
529 | int Look_Ahead(int id); // static.
|
---|
530 | int Random_Look(int id[],int count); // static.
|
---|
531 | int Look_Ahead_Tie(); // static.
|
---|
532 | int Sequential_Tri(int *index); // static.
|
---|
533 | int Sequential_Quad(int *index, int triangulate); // static.
|
---|
534 | void Whole_Output(int in1, int *index, int size,
|
---|
535 | int *out1,int *out2); // static.
|
---|
536 | int Sequential_Poly(int size,int *index,int triangulate); // static.
|
---|
537 | int Sequential_Tie(int face_id,int triangulate); // static.
|
---|
538 |
|
---|
539 | /** add.h
|
---|
540 | */
|
---|
541 | BOOL norm_array(int id,int vertex,
|
---|
542 | double normal_difference,
|
---|
543 | struct vert_struct *n,int num_vert);
|
---|
544 | void add_texture(int id,BOOL vertex);
|
---|
545 | int add_vert_id(int id, int index_count);
|
---|
546 | void add_norm_id(int id, int index_count);
|
---|
547 | void AddNewFace(int ids[MAX1],int vert_count,
|
---|
548 | int face_id,int norms[MAX1]);
|
---|
549 | void CopyFace(int ids[MAX1],int vert_count,
|
---|
550 | int face_id,int norms[MAX1]);
|
---|
551 | void Add_AdjEdge( int v1,int v2,
|
---|
552 | int fnum,int index1);
|
---|
553 | BOOL new_vertex(double difference,int id1,
|
---|
554 | int id2,struct vert_struct *n); // static.
|
---|
555 | BOOL Check_VN(int vertex,int normal, struct vert_added *added); // static.
|
---|
556 |
|
---|
557 | /** options.h
|
---|
558 | */
|
---|
559 | enum file_options {ASCII,BINARY};
|
---|
560 | enum tie_options {FIRST, RANDOM, ALTERNA, LOOK, SEQUENTIAL};
|
---|
561 | enum triangulation_options {PARTIAL,WHOLE};
|
---|
562 |
|
---|
563 | void print_usage(void);
|
---|
564 | float get_options(int argc, char **argv,
|
---|
565 | int *f, int *t,
|
---|
566 | int *tr, int *group,
|
---|
567 | int *orientation);
|
---|
568 | int power_10(int power); // static.
|
---|
569 | float power_negative(int power); // static.
|
---|
570 | float convert_array(int num[],int stack_size); // static.
|
---|
571 |
|
---|
572 | /** sgi_triangex.h
|
---|
573 | */
|
---|
574 | int AdjacentEx(int id2,int id1, int *list, int size);
|
---|
575 | void Delete_From_ListEx(int id,int *list, int size);
|
---|
576 | void Triangulate_PolygonEx( int out_edge1,int out_edge2,int in_edge1,
|
---|
577 | int in_edge2,int size,int *index,
|
---|
578 | FILE *fp,int reversed,int face_id,
|
---|
579 | int where);
|
---|
580 | void Non_Blind_TriangulateEx( int size,int *index,
|
---|
581 | FILE *output,int next_face_id,
|
---|
582 | int face_id,int where);
|
---|
583 | void Rearrange_IndexEx(int *index, int size);
|
---|
584 | void Blind_TriangulateEx( int size, int *index,
|
---|
585 | BOOL begin, int where);
|
---|
586 | void Triangulate_QuadEx(int out_edge1,int out_edge2,int in_edge1,
|
---|
587 | int in_edge2, int size, int *index,
|
---|
588 | int reversed, int where); // static.
|
---|
589 | void TriangulateEx( int out_edge1,int out_edge2,
|
---|
590 | int in_edge1, int in_edge2,
|
---|
591 | int size, int *index,
|
---|
592 | FILE *output, int reversed,
|
---|
593 | int face_id, int where); // static.
|
---|
594 |
|
---|
595 | /** structex.h
|
---|
596 | */
|
---|
597 | int Get_EdgeEx( int *edge1,int *edge2,int *index,int face_id,
|
---|
598 | int size, int id1, int id2);
|
---|
599 | void Delete_AdjEx(int id1, int id2,
|
---|
600 | int *next_bucket,int *min_face,
|
---|
601 | int current_face,int *e1,
|
---|
602 | int *e2,int *ties);
|
---|
603 | int Change_FaceEx(int face_id,int in1,int in2,
|
---|
604 | ListHead *pListHead, BOOL no_check);
|
---|
605 | int Update_AdjacenciesEx( int face_id,int *next_bucket,
|
---|
606 | int *e1, int *e2,
|
---|
607 | int *ties);
|
---|
608 | int Min_Face_AdjEx(int face_id,int *next_bucket,int *ties);
|
---|
609 |
|
---|
610 | void Update_FaceEx( int *next_bucket,int *min_face,
|
---|
611 | int face_id, int *e1,
|
---|
612 | int *e2,int temp1,
|
---|
613 | int temp2,int *ties); // static.
|
---|
614 |
|
---|
615 | void Find_Adj_TallyEx(int id1, int id2,
|
---|
616 | int *next_bucket, int *min_face,
|
---|
617 | int current_face, int *ties); // static.
|
---|
618 |
|
---|
619 | /** partial.h
|
---|
620 | */
|
---|
621 | void Partial_Triangulate(int size, int *index,
|
---|
622 | FILE *output, int next_face_id,
|
---|
623 | int face_id, int *next_id,
|
---|
624 | ListHead *pListHead,
|
---|
625 | P_ADJACENCIES temp, int where);
|
---|
626 |
|
---|
627 |
|
---|
628 | void Inside_Polygon(int size, int *index,
|
---|
629 | int face_id, ListHead *pListHead,
|
---|
630 | int where);
|
---|
631 |
|
---|
632 | void P_Triangulate_Quad(int out_edge1,int out_edge2,
|
---|
633 | int in_edge1, int in_edge2,
|
---|
634 | int size, int *index,
|
---|
635 | int reversed, int face_id,
|
---|
636 | ListHead *pListHead,
|
---|
637 | P_ADJACENCIES temp,
|
---|
638 | int where); // static.
|
---|
639 | void P_Triangulate_Polygon( int out_edge1,int out_edge2,
|
---|
640 | int in_edge1, int in_edge2,
|
---|
641 | int size, int *index,
|
---|
642 | FILE *fp, int reversed,
|
---|
643 | int face_id, int *next_id,
|
---|
644 | ListHead *pListHead,
|
---|
645 | P_ADJACENCIES temp2,
|
---|
646 | int where); // static.
|
---|
647 | void P_Triangulate( int out_edge1,int out_edge2,int in_edge1,
|
---|
648 | int in_edge2, int size, int *index,
|
---|
649 | FILE *output, int reversed, int face_id,
|
---|
650 | int *next_id, ListHead *pListHead,
|
---|
651 | P_ADJACENCIES temp,int where); // static.
|
---|
652 | void Input_Edge(int face_id, int *index,
|
---|
653 | int size, int in_edge1,
|
---|
654 | int in_edge2, ListHead *pListHead,
|
---|
655 | int where); // static.
|
---|
656 |
|
---|
657 | /** output.h
|
---|
658 | */
|
---|
659 | int Finished(int *swap, FILE *output, int startnewstrip);
|
---|
660 | void Output_Tri(int id1, int id2, int id3,BOOL end);
|
---|
661 | int Extend_Face(int face_id,int e1,int e2,int *swaps,FILE *bands,
|
---|
662 | int color1,int color2,int color3,int *vert_norm,
|
---|
663 | int normals,int *vert_texture,int texture);
|
---|
664 | int Polygon_Output( P_ADJACENCIES temp, int face_id,
|
---|
665 | int bucket, ListHead *pListHead,
|
---|
666 | BOOL first, int *swaps,
|
---|
667 | FILE *bands, int color1,
|
---|
668 | int color2, int color3,
|
---|
669 | BOOL global, BOOL end); // static.
|
---|
670 | /** free.h
|
---|
671 | */
|
---|
672 | void Free_Strips();
|
---|
673 | void End_Face_Struct(int numfaces);
|
---|
674 | void End_Edge_Struct(int numverts);
|
---|
675 | void ParseAndFreeList( ListHead *pListHead ); // static.
|
---|
676 | void FreeFaceTable(int nSize); // static.
|
---|
677 | void FreeEdgeTable(int nSize); // static.
|
---|
678 |
|
---|
679 | /** newpolve.h
|
---|
680 | */
|
---|
681 | void Find_Bands(int numfaces, FILE *output_file, int *swaps, int *bands,
|
---|
682 | int *cost, int *tri, int norms, int *vert_norms,
|
---|
683 | int texture, int *vert_texture);
|
---|
684 | void Save_Walks(int numfaces);
|
---|
685 | void Save_Rest(int *numfaces);
|
---|
686 | int Calculate_Walks(int lastvert,int y, PF_FACES temp2); // static.
|
---|
687 | BOOL Check_Right( int last_seen,PF_FACES temp2,
|
---|
688 | int y,int face_id); // static.
|
---|
689 | int Update_and_Test(PF_FACES temp2,int y,
|
---|
690 | BOOL first,int distance,
|
---|
691 | int lastvert, int val); // static.
|
---|
692 | int Test_Adj( PF_FACES temp2,int x,
|
---|
693 | int north,int distance,
|
---|
694 | int lastvert, int value); // static.
|
---|
695 | int Find_Max( PF_FACES temp2, int lastvert,
|
---|
696 | int north, int left,
|
---|
697 | int *lastminup, int *lastminleft); // static.
|
---|
698 | void Mark_Face( PF_FACES temp2, int color1,
|
---|
699 | int color2, int color3,
|
---|
700 | FILE *output_file, BOOL end,
|
---|
701 | int *edge1, int *edge2,
|
---|
702 | int *face_id, int norms,
|
---|
703 | int texture); // static.
|
---|
704 | void Assign_Walk( int lastvert, PF_FACES temp2,
|
---|
705 | int front_walk, int y,
|
---|
706 | int back_walk); // static.
|
---|
707 | void Fast_Reset(int x); // static.
|
---|
708 | void Reset_Max( PF_FACES temp2,int face_id,
|
---|
709 | int north,int last_north,
|
---|
710 | int orientation,int last_left,
|
---|
711 | FILE *output_file,int color1,
|
---|
712 | int color2,int color3,
|
---|
713 | BOOL start); // static.
|
---|
714 | int Peel_Max( PF_FACES temp2,int face_id,
|
---|
715 | int north,int last_north,
|
---|
716 | int orientation,int last_left,
|
---|
717 | FILE *output_file,int color1,
|
---|
718 | int color2,int color3,
|
---|
719 | BOOL start, int *swaps_added,
|
---|
720 | int norms, int texture); // static.
|
---|
721 |
|
---|
722 | /** auxiliar.h
|
---|
723 | */
|
---|
724 | FILE *OpenOutputFile(char *fname);
|
---|
725 | void AllocateStruct(int num_faces,
|
---|
726 | int num_vert,
|
---|
727 | int num_nvert,
|
---|
728 | int num_texture);
|
---|
729 | void miReadFile(char *fname, char *file_open, FILE *bands,Geometry::SubMesh *geoSubMesh);
|
---|
730 | int stripify( char *fname,
|
---|
731 | Geometry::Mesh *geoMesh);
|
---|
732 |
|
---|
733 | public:
|
---|
734 | /// Class constructor, receives as a parameter a const pointer to the object that describes a mesh.
|
---|
735 | CustomStripifier();
|
---|
736 |
|
---|
737 | CustomStripifier(const Geometry::Mesh *geoMesh);
|
---|
738 |
|
---|
739 | /// Class destructor.
|
---|
740 | ~CustomStripifier(void);
|
---|
741 |
|
---|
742 | /// Copy constructor
|
---|
743 | //CustomStripifier(const CustomStripifier&);
|
---|
744 |
|
---|
745 | /// Assignment operator
|
---|
746 | //CustomStripifier& operator =(const CustomStripifier&);
|
---|
747 |
|
---|
748 | /// Starts the stripification process. This is a custom stripification method.
|
---|
749 | int Stripify();
|
---|
750 |
|
---|
751 | /// Returns the stripified mesh.
|
---|
752 | Mesh * GetMesh();
|
---|
753 |
|
---|
754 | // Set the progress bar function.
|
---|
755 | void SetProgressFunc(Geometry::TIPOFUNC upb);
|
---|
756 |
|
---|
757 | // Sets what is the submesh that stores the leaves
|
---|
758 | void SetSubMeshLeaves(size_t submesh);
|
---|
759 |
|
---|
760 | };
|
---|
761 |
|
---|
762 | }
|
---|
763 |
|
---|
764 | #endif
|
---|
765 |
|
---|