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 | #define MAX_ADJ 60 |
---|
18 | |
---|
19 | namespace Geometry |
---|
20 | { |
---|
21 | typedef struct |
---|
22 | { |
---|
23 | int array[3]; |
---|
24 | } |
---|
25 | vector3; |
---|
26 | |
---|
27 | typedef struct |
---|
28 | { |
---|
29 | int finish; |
---|
30 | int NumAdj; |
---|
31 | } |
---|
32 | adj; |
---|
33 | |
---|
34 | typedef std::vector<int> vector_int; |
---|
35 | typedef std::vector<vector3> vector_vector3; |
---|
36 | |
---|
37 | /// Stripifier interface class. |
---|
38 | /** This module implements methods that extract triangle strips from triangle meshes. |
---|
39 | \n |
---|
40 | |
---|
41 | Inputs:\n |
---|
42 | - This module receives a pointer to a Geometry::Mesh object containing the model to be stripified. |
---|
43 | . |
---|
44 | |
---|
45 | Outputs:\n |
---|
46 | - The stripified mesh, contained also in a Geometry::Mesh object. |
---|
47 | . |
---|
48 | |
---|
49 | */ |
---|
50 | class MeshStripifier |
---|
51 | { |
---|
52 | public: |
---|
53 | /// Class constructor, receives as a parameter a const pointer to the object that describes a mesh. |
---|
54 | MeshStripifier (); |
---|
55 | MeshStripifier (const Geometry::Mesh *); |
---|
56 | |
---|
57 | /// virtual class destructor. |
---|
58 | virtual ~MeshStripifier (void); |
---|
59 | |
---|
60 | /// Copy constructor |
---|
61 | //MeshStripifier(const MeshStripifier&); |
---|
62 | |
---|
63 | /// Assignment operator |
---|
64 | //MeshStripifier& operator =(const MeshStripifier&); |
---|
65 | |
---|
66 | /// Starts the stripification process. This is a pure virtual method and must be overloaded in a derived class that implements a stripification algorithm. |
---|
67 | virtual int Stripify()=0; |
---|
68 | |
---|
69 | /// Returns the stripified mesh. |
---|
70 | Mesh * GetMesh (); |
---|
71 | |
---|
72 | // Sets what is the mesh that stores the leaves |
---|
73 | void setSubMeshLeaves(size_t); |
---|
74 | |
---|
75 | protected: |
---|
76 | |
---|
77 | // Progress bar function. |
---|
78 | Geometry::TIPOFUNC mUPB; |
---|
79 | |
---|
80 | // Mesh object. |
---|
81 | Geometry::Mesh *mGeoMesh; |
---|
82 | |
---|
83 | // Index of the submesh leaves. |
---|
84 | size_t mSubMeshLeaves; |
---|
85 | }; |
---|
86 | |
---|
87 | class CustomStripifier : public MeshStripifier |
---|
88 | { |
---|
89 | private: |
---|
90 | |
---|
91 | // Globals |
---|
92 | int mError; |
---|
93 | int num_faces; |
---|
94 | |
---|
95 | std::vector<vector3> StripFaces; |
---|
96 | std::vector<vector_vector3> StripEdges; |
---|
97 | |
---|
98 | vector_int StripArray[MAX_ADJ]; |
---|
99 | |
---|
100 | adj* StripFaceAdj; |
---|
101 | |
---|
102 | std::vector<vector_int> StripVertices; |
---|
103 | |
---|
104 | vector_int Strips; |
---|
105 | |
---|
106 | int num_tiras; |
---|
107 | int ids[3]; |
---|
108 | int lastTri[3]; |
---|
109 | int ties_array[60]; |
---|
110 | int last; |
---|
111 | |
---|
112 | std::vector<vector_int> my_vector; |
---|
113 | |
---|
114 | Geometry::Mesh *MeshGlobal; |
---|
115 | |
---|
116 | int stripify( Geometry::Mesh *geoMesh); |
---|
117 | |
---|
118 | void GetLower(int *x, int *y); |
---|
119 | int Different(int id1,int id2,int id3,int id4,int id5, int id6, int *x, int *y); |
---|
120 | void Orient(int vertex1,int vertex2,int vertex3); |
---|
121 | void StoreAdjacencies(int num_faces); |
---|
122 | void ReadData(Geometry::SubMesh *geoSubMesh,int num_faces, int num_vert); |
---|
123 | void Stripification(); |
---|
124 | void AddTri(int id1, int id2, int id3, int flag, int where); |
---|
125 | void GoBack(int face_id, int *ties,int tie); |
---|
126 | void StoreTri(int face_id,int NumAdj, int original_adj, int *ties, int tie, int where); |
---|
127 | |
---|
128 | int GetNumAdjacencies(int id1, int id2, int curr_id); |
---|
129 | int MinimumAd(int id); |
---|
130 | int Find_Face(int current_face, int id1,int id2, int *NumAdj); |
---|
131 | int Look_Up(int id1,int id2,int face_id); |
---|
132 | void StoreStrip(int id, int where); |
---|
133 | int NumAdj(int id1, int id2); |
---|
134 | void FindAdjacencies(int num_faces, int num_verts); |
---|
135 | void StoreAdjacency(int NumAdj,int face_id); |
---|
136 | int Prediction(); |
---|
137 | void AddNewFace(int ids[3],int face_id); |
---|
138 | void AddAdjEdge(int v1,int v2, int fnum); |
---|
139 | int GetEdge( int *edge1,int *edge2,int *index,int face_id); |
---|
140 | void DeleteAdj(int id1, int id2, int *next_NumAdj,int *min_face, |
---|
141 | int current_face,int *e1,int *e2,int *ties); |
---|
142 | int UpdateAdjacencies(int face_id,int *next_NumAdj, int *e1, int *e2,int *ties); |
---|
143 | void UpdateFaces(int *next_NumAdj,int *min_face, int face_id, int *e1,int *e2,int temp1, int temp2,int *ties); |
---|
144 | int Finished(); |
---|
145 | |
---|
146 | |
---|
147 | |
---|
148 | public: |
---|
149 | /// Class constructor, receives as a parameter a const pointer to the object that describes a mesh. |
---|
150 | CustomStripifier(); |
---|
151 | |
---|
152 | CustomStripifier(const Geometry::Mesh *geoMesh); |
---|
153 | |
---|
154 | /// Class destructor. |
---|
155 | ~CustomStripifier(void); |
---|
156 | |
---|
157 | /// Copy constructor |
---|
158 | //CustomStripifier(const CustomStripifier&); |
---|
159 | |
---|
160 | /// Assignment operator |
---|
161 | //CustomStripifier& operator =(const CustomStripifier&); |
---|
162 | |
---|
163 | /// Starts the stripification process. This is a custom stripification method. |
---|
164 | int Stripify(); |
---|
165 | |
---|
166 | /// Returns the stripified mesh. |
---|
167 | Mesh * GetMesh(); |
---|
168 | |
---|
169 | // Set the progress bar function. |
---|
170 | void SetProgressFunc(Geometry::TIPOFUNC upb); |
---|
171 | |
---|
172 | // Sets what is the submesh that stores the leaves |
---|
173 | void SetSubMeshLeaves(size_t submesh); |
---|
174 | |
---|
175 | }; |
---|
176 | |
---|
177 | } |
---|
178 | |
---|
179 | #endif |
---|
180 | |
---|