rev |
line source |
nuclear@0
|
1 /*
|
nuclear@0
|
2 Open Asset Import Library (assimp)
|
nuclear@0
|
3 ----------------------------------------------------------------------
|
nuclear@0
|
4
|
nuclear@0
|
5 Copyright (c) 2006-2012, assimp team
|
nuclear@0
|
6 All rights reserved.
|
nuclear@0
|
7
|
nuclear@0
|
8 Redistribution and use of this software in source and binary forms,
|
nuclear@0
|
9 with or without modification, are permitted provided that the
|
nuclear@0
|
10 following conditions are met:
|
nuclear@0
|
11
|
nuclear@0
|
12 * Redistributions of source code must retain the above
|
nuclear@0
|
13 copyright notice, this list of conditions and the
|
nuclear@0
|
14 following disclaimer.
|
nuclear@0
|
15
|
nuclear@0
|
16 * Redistributions in binary form must reproduce the above
|
nuclear@0
|
17 copyright notice, this list of conditions and the
|
nuclear@0
|
18 following disclaimer in the documentation and/or other
|
nuclear@0
|
19 materials provided with the distribution.
|
nuclear@0
|
20
|
nuclear@0
|
21 * Neither the name of the assimp team, nor the names of its
|
nuclear@0
|
22 contributors may be used to endorse or promote products
|
nuclear@0
|
23 derived from this software without specific prior
|
nuclear@0
|
24 written permission of the assimp team.
|
nuclear@0
|
25
|
nuclear@0
|
26 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
nuclear@0
|
27 "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
nuclear@0
|
28 LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
nuclear@0
|
29 A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
nuclear@0
|
30 OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
nuclear@0
|
31 SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
nuclear@0
|
32 LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
nuclear@0
|
33 DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
nuclear@0
|
34 THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
nuclear@0
|
35 (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
nuclear@0
|
36 OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
nuclear@0
|
37
|
nuclear@0
|
38 ----------------------------------------------------------------------
|
nuclear@0
|
39 */
|
nuclear@0
|
40
|
nuclear@0
|
41
|
nuclear@0
|
42 /** @file Defines the helper data structures for importing PLY files */
|
nuclear@0
|
43 #ifndef AI_PLYFILEHELPER_H_INC
|
nuclear@0
|
44 #define AI_PLYFILEHELPER_H_INC
|
nuclear@0
|
45
|
nuclear@0
|
46
|
nuclear@0
|
47 #include "ParsingUtils.h"
|
nuclear@0
|
48
|
nuclear@0
|
49
|
nuclear@0
|
50 namespace Assimp
|
nuclear@0
|
51 {
|
nuclear@0
|
52
|
nuclear@0
|
53 // http://local.wasp.uwa.edu.au/~pbourke/dataformats/ply/
|
nuclear@0
|
54 // http://w3.impa.br/~lvelho/outgoing/sossai/old/ViHAP_D4.4.2_PLY_format_v1.1.pdf
|
nuclear@0
|
55 // http://www.okino.com/conv/exp_ply.htm
|
nuclear@0
|
56 namespace PLY
|
nuclear@0
|
57 {
|
nuclear@0
|
58
|
nuclear@0
|
59
|
nuclear@0
|
60 // ---------------------------------------------------------------------------------
|
nuclear@0
|
61 /*
|
nuclear@0
|
62 name type number of bytes
|
nuclear@0
|
63 ---------------------------------------
|
nuclear@0
|
64 char character 1
|
nuclear@0
|
65 uchar unsigned character 1
|
nuclear@0
|
66 short short integer 2
|
nuclear@0
|
67 ushort unsigned short integer 2
|
nuclear@0
|
68 int integer 4
|
nuclear@0
|
69 uint unsigned integer 4
|
nuclear@0
|
70 float single-precision float 4
|
nuclear@0
|
71 double double-precision float 8
|
nuclear@0
|
72
|
nuclear@0
|
73 int8
|
nuclear@0
|
74 int16
|
nuclear@0
|
75 uint8 ... forms are also used
|
nuclear@0
|
76 */
|
nuclear@0
|
77 enum EDataType
|
nuclear@0
|
78 {
|
nuclear@0
|
79 EDT_Char = 0x0u,
|
nuclear@0
|
80 EDT_UChar,
|
nuclear@0
|
81 EDT_Short,
|
nuclear@0
|
82 EDT_UShort,
|
nuclear@0
|
83 EDT_Int,
|
nuclear@0
|
84 EDT_UInt,
|
nuclear@0
|
85 EDT_Float,
|
nuclear@0
|
86 EDT_Double,
|
nuclear@0
|
87
|
nuclear@0
|
88 // Marks invalid entries
|
nuclear@0
|
89 EDT_INVALID
|
nuclear@0
|
90 };
|
nuclear@0
|
91
|
nuclear@0
|
92 // ---------------------------------------------------------------------------------
|
nuclear@0
|
93 /** \brief Specifies semantics for PLY element properties
|
nuclear@0
|
94 *
|
nuclear@0
|
95 * Semantics define the usage of a property, e.g. x coordinate
|
nuclear@0
|
96 */
|
nuclear@0
|
97 enum ESemantic
|
nuclear@0
|
98 {
|
nuclear@0
|
99 //! vertex position x coordinate
|
nuclear@0
|
100 EST_XCoord = 0x0u,
|
nuclear@0
|
101 //! vertex position x coordinate
|
nuclear@0
|
102 EST_YCoord,
|
nuclear@0
|
103 //! vertex position x coordinate
|
nuclear@0
|
104 EST_ZCoord,
|
nuclear@0
|
105
|
nuclear@0
|
106 //! vertex normal x coordinate
|
nuclear@0
|
107 EST_XNormal,
|
nuclear@0
|
108 //! vertex normal y coordinate
|
nuclear@0
|
109 EST_YNormal,
|
nuclear@0
|
110 //! vertex normal z coordinate
|
nuclear@0
|
111 EST_ZNormal,
|
nuclear@0
|
112
|
nuclear@0
|
113 //! u texture coordinate
|
nuclear@0
|
114 EST_UTextureCoord,
|
nuclear@0
|
115 //! v texture coordinate
|
nuclear@0
|
116 EST_VTextureCoord,
|
nuclear@0
|
117
|
nuclear@0
|
118 //! vertex colors, red channel
|
nuclear@0
|
119 EST_Red,
|
nuclear@0
|
120 //! vertex colors, green channel
|
nuclear@0
|
121 EST_Green,
|
nuclear@0
|
122 //! vertex colors, blue channel
|
nuclear@0
|
123 EST_Blue,
|
nuclear@0
|
124 //! vertex colors, alpha channel
|
nuclear@0
|
125 EST_Alpha,
|
nuclear@0
|
126
|
nuclear@0
|
127 //! vertex index list
|
nuclear@0
|
128 EST_VertexIndex,
|
nuclear@0
|
129
|
nuclear@0
|
130 //! texture index
|
nuclear@0
|
131 EST_TextureIndex,
|
nuclear@0
|
132
|
nuclear@0
|
133 //! texture coordinates (stored as element of a face)
|
nuclear@0
|
134 EST_TextureCoordinates,
|
nuclear@0
|
135
|
nuclear@0
|
136 //! material index
|
nuclear@0
|
137 EST_MaterialIndex,
|
nuclear@0
|
138
|
nuclear@0
|
139 //! ambient color, red channel
|
nuclear@0
|
140 EST_AmbientRed,
|
nuclear@0
|
141 //! ambient color, green channel
|
nuclear@0
|
142 EST_AmbientGreen,
|
nuclear@0
|
143 //! ambient color, blue channel
|
nuclear@0
|
144 EST_AmbientBlue,
|
nuclear@0
|
145 //! ambient color, alpha channel
|
nuclear@0
|
146 EST_AmbientAlpha,
|
nuclear@0
|
147
|
nuclear@0
|
148 //! diffuse color, red channel
|
nuclear@0
|
149 EST_DiffuseRed,
|
nuclear@0
|
150 //! diffuse color, green channel
|
nuclear@0
|
151 EST_DiffuseGreen,
|
nuclear@0
|
152 //! diffuse color, blue channel
|
nuclear@0
|
153 EST_DiffuseBlue,
|
nuclear@0
|
154 //! diffuse color, alpha channel
|
nuclear@0
|
155 EST_DiffuseAlpha,
|
nuclear@0
|
156
|
nuclear@0
|
157 //! specular color, red channel
|
nuclear@0
|
158 EST_SpecularRed,
|
nuclear@0
|
159 //! specular color, green channel
|
nuclear@0
|
160 EST_SpecularGreen,
|
nuclear@0
|
161 //! specular color, blue channel
|
nuclear@0
|
162 EST_SpecularBlue,
|
nuclear@0
|
163 //! specular color, alpha channel
|
nuclear@0
|
164 EST_SpecularAlpha,
|
nuclear@0
|
165
|
nuclear@0
|
166 //! specular power for phong shading
|
nuclear@0
|
167 EST_PhongPower,
|
nuclear@0
|
168
|
nuclear@0
|
169 //! opacity between 0 and 1
|
nuclear@0
|
170 EST_Opacity,
|
nuclear@0
|
171
|
nuclear@0
|
172 //! Marks invalid entries
|
nuclear@0
|
173 EST_INVALID
|
nuclear@0
|
174 };
|
nuclear@0
|
175
|
nuclear@0
|
176 // ---------------------------------------------------------------------------------
|
nuclear@0
|
177 /** \brief Specifies semantics for PLY elements
|
nuclear@0
|
178 *
|
nuclear@0
|
179 * Semantics define the usage of an element, e.g. vertex or material
|
nuclear@0
|
180 */
|
nuclear@0
|
181 enum EElementSemantic
|
nuclear@0
|
182 {
|
nuclear@0
|
183 //! The element is a vertex
|
nuclear@0
|
184 EEST_Vertex = 0x0u,
|
nuclear@0
|
185
|
nuclear@0
|
186 //! The element is a face description (index table)
|
nuclear@0
|
187 EEST_Face,
|
nuclear@0
|
188
|
nuclear@0
|
189 //! The element is a tristrip description (index table)
|
nuclear@0
|
190 EEST_TriStrip,
|
nuclear@0
|
191
|
nuclear@0
|
192 //! The element is an edge description (ignored)
|
nuclear@0
|
193 EEST_Edge,
|
nuclear@0
|
194
|
nuclear@0
|
195 //! The element is a material description
|
nuclear@0
|
196 EEST_Material,
|
nuclear@0
|
197
|
nuclear@0
|
198 //! Marks invalid entries
|
nuclear@0
|
199 EEST_INVALID
|
nuclear@0
|
200 };
|
nuclear@0
|
201
|
nuclear@0
|
202 // ---------------------------------------------------------------------------------
|
nuclear@0
|
203 /** \brief Helper class for a property in a PLY file.
|
nuclear@0
|
204 *
|
nuclear@0
|
205 * This can e.g. be a part of the vertex declaration
|
nuclear@0
|
206 */
|
nuclear@0
|
207 class Property
|
nuclear@0
|
208 {
|
nuclear@0
|
209 public:
|
nuclear@0
|
210
|
nuclear@0
|
211 //! Default constructor
|
nuclear@0
|
212 Property()
|
nuclear@0
|
213 : eType (EDT_Int), bIsList(false), eFirstType(EDT_UChar)
|
nuclear@0
|
214 {}
|
nuclear@0
|
215
|
nuclear@0
|
216 //! Data type of the property
|
nuclear@0
|
217 EDataType eType;
|
nuclear@0
|
218
|
nuclear@0
|
219 //! Semantical meaning of the property
|
nuclear@0
|
220 ESemantic Semantic;
|
nuclear@0
|
221
|
nuclear@0
|
222 //! Of the semantic of the property could not be parsed:
|
nuclear@0
|
223 //! Contains the semantic specified in the file
|
nuclear@0
|
224 std::string szName;
|
nuclear@0
|
225
|
nuclear@0
|
226 //! Specifies whether the data type is a list where
|
nuclear@0
|
227 //! the first element specifies the size of the list
|
nuclear@0
|
228 bool bIsList;
|
nuclear@0
|
229 EDataType eFirstType;
|
nuclear@0
|
230
|
nuclear@0
|
231 // -------------------------------------------------------------------
|
nuclear@0
|
232 //! Parse a property from a string. The end of the
|
nuclear@0
|
233 //! string is either '\n', '\r' or '\0'. Return valie is false
|
nuclear@0
|
234 //! if the input string is NOT a valid property (E.g. does
|
nuclear@0
|
235 //! not start with the "property" keyword)
|
nuclear@0
|
236 static bool ParseProperty (const char* pCur, const char** pCurOut,
|
nuclear@0
|
237 Property* pOut);
|
nuclear@0
|
238
|
nuclear@0
|
239 // -------------------------------------------------------------------
|
nuclear@0
|
240 //! Parse a data type from a string
|
nuclear@0
|
241 static EDataType ParseDataType(const char* pCur,const char** pCurOut);
|
nuclear@0
|
242
|
nuclear@0
|
243 // -------------------------------------------------------------------
|
nuclear@0
|
244 //! Parse a semantic from a string
|
nuclear@0
|
245 static ESemantic ParseSemantic(const char* pCur,const char** pCurOut);
|
nuclear@0
|
246 };
|
nuclear@0
|
247
|
nuclear@0
|
248 // ---------------------------------------------------------------------------------
|
nuclear@0
|
249 /** \brief Helper class for an element in a PLY file.
|
nuclear@0
|
250 *
|
nuclear@0
|
251 * This can e.g. be the vertex declaration. Elements contain a
|
nuclear@0
|
252 * well-defined number of properties.
|
nuclear@0
|
253 */
|
nuclear@0
|
254 class Element
|
nuclear@0
|
255 {
|
nuclear@0
|
256 public:
|
nuclear@0
|
257
|
nuclear@0
|
258 //! Default constructor
|
nuclear@0
|
259 Element()
|
nuclear@0
|
260 : eSemantic (EEST_INVALID)
|
nuclear@0
|
261 , NumOccur(0)
|
nuclear@0
|
262 {}
|
nuclear@0
|
263
|
nuclear@0
|
264 //! List of properties assigned to the element
|
nuclear@0
|
265 //! std::vector to support operator[]
|
nuclear@0
|
266 std::vector<Property> alProperties;
|
nuclear@0
|
267
|
nuclear@0
|
268 //! Semantic of the element
|
nuclear@0
|
269 EElementSemantic eSemantic;
|
nuclear@0
|
270
|
nuclear@0
|
271 //! Of the semantic of the element could not be parsed:
|
nuclear@0
|
272 //! Contains the semantic specified in the file
|
nuclear@0
|
273 std::string szName;
|
nuclear@0
|
274
|
nuclear@0
|
275 //! How many times will the element occur?
|
nuclear@0
|
276 unsigned int NumOccur;
|
nuclear@0
|
277
|
nuclear@0
|
278
|
nuclear@0
|
279 // -------------------------------------------------------------------
|
nuclear@0
|
280 //! Parse an element from a string.
|
nuclear@0
|
281 //! The function will parse all properties contained in the
|
nuclear@0
|
282 //! element, too.
|
nuclear@0
|
283 static bool ParseElement (const char* pCur, const char** pCurOut,
|
nuclear@0
|
284 Element* pOut);
|
nuclear@0
|
285
|
nuclear@0
|
286 // -------------------------------------------------------------------
|
nuclear@0
|
287 //! Parse a semantic from a string
|
nuclear@0
|
288 static EElementSemantic ParseSemantic(const char* pCur,
|
nuclear@0
|
289 const char** pCurOut);
|
nuclear@0
|
290 };
|
nuclear@0
|
291
|
nuclear@0
|
292 // ---------------------------------------------------------------------------------
|
nuclear@0
|
293 /** \brief Instance of a property in a PLY file
|
nuclear@0
|
294 */
|
nuclear@0
|
295 class PropertyInstance
|
nuclear@0
|
296 {
|
nuclear@0
|
297 public:
|
nuclear@0
|
298
|
nuclear@0
|
299 //! Default constructor
|
nuclear@0
|
300 PropertyInstance ()
|
nuclear@0
|
301 {}
|
nuclear@0
|
302
|
nuclear@0
|
303 union ValueUnion
|
nuclear@0
|
304 {
|
nuclear@0
|
305
|
nuclear@0
|
306 //! uInt32 representation of the property. All
|
nuclear@0
|
307 // uint types are automatically converted to uint32
|
nuclear@0
|
308 uint32_t iUInt;
|
nuclear@0
|
309
|
nuclear@0
|
310 //! Int32 representation of the property. All
|
nuclear@0
|
311 // int types are automatically converted to int32
|
nuclear@0
|
312 int32_t iInt;
|
nuclear@0
|
313
|
nuclear@0
|
314 //! Float32 representation of the property
|
nuclear@0
|
315 float fFloat;
|
nuclear@0
|
316
|
nuclear@0
|
317 //! Float64 representation of the property
|
nuclear@0
|
318 double fDouble;
|
nuclear@0
|
319
|
nuclear@0
|
320 };
|
nuclear@0
|
321
|
nuclear@0
|
322 // -------------------------------------------------------------------
|
nuclear@0
|
323 //! List of all values parsed. Contains only one value
|
nuclear@0
|
324 // for non-list properties
|
nuclear@0
|
325 std::vector<ValueUnion> avList;
|
nuclear@0
|
326
|
nuclear@0
|
327 // -------------------------------------------------------------------
|
nuclear@0
|
328 //! Parse a property instance
|
nuclear@0
|
329 static bool ParseInstance (const char* pCur,const char** pCurOut,
|
nuclear@0
|
330 const Property* prop, PropertyInstance* p_pcOut);
|
nuclear@0
|
331
|
nuclear@0
|
332 // -------------------------------------------------------------------
|
nuclear@0
|
333 //! Parse a property instance in binary format
|
nuclear@0
|
334 static bool ParseInstanceBinary (const char* pCur,const char** pCurOut,
|
nuclear@0
|
335 const Property* prop, PropertyInstance* p_pcOut,bool p_bBE);
|
nuclear@0
|
336
|
nuclear@0
|
337 // -------------------------------------------------------------------
|
nuclear@0
|
338 //! Get the default value for a given data type
|
nuclear@0
|
339 static ValueUnion DefaultValue(EDataType eType);
|
nuclear@0
|
340
|
nuclear@0
|
341 // -------------------------------------------------------------------
|
nuclear@0
|
342 //! Parse a value
|
nuclear@0
|
343 static bool ParseValue(const char* pCur,const char** pCurOut,
|
nuclear@0
|
344 EDataType eType,ValueUnion* out);
|
nuclear@0
|
345
|
nuclear@0
|
346 // -------------------------------------------------------------------
|
nuclear@0
|
347 //! Parse a binary value
|
nuclear@0
|
348 static bool ParseValueBinary(const char* pCur,const char** pCurOut,
|
nuclear@0
|
349 EDataType eType,ValueUnion* out,bool p_bBE);
|
nuclear@0
|
350
|
nuclear@0
|
351 // -------------------------------------------------------------------
|
nuclear@0
|
352 //! Convert a property value to a given type TYPE
|
nuclear@0
|
353 template <typename TYPE>
|
nuclear@0
|
354 static TYPE ConvertTo(ValueUnion v, EDataType eType);
|
nuclear@0
|
355 };
|
nuclear@0
|
356
|
nuclear@0
|
357 // ---------------------------------------------------------------------------------
|
nuclear@0
|
358 /** \brief Class for an element instance in a PLY file
|
nuclear@0
|
359 */
|
nuclear@0
|
360 class ElementInstance
|
nuclear@0
|
361 {
|
nuclear@0
|
362 public:
|
nuclear@0
|
363
|
nuclear@0
|
364 //! Default constructor
|
nuclear@0
|
365 ElementInstance ()
|
nuclear@0
|
366 {}
|
nuclear@0
|
367
|
nuclear@0
|
368 //! List of all parsed properties
|
nuclear@0
|
369 std::vector< PropertyInstance > alProperties;
|
nuclear@0
|
370
|
nuclear@0
|
371 // -------------------------------------------------------------------
|
nuclear@0
|
372 //! Parse an element instance
|
nuclear@0
|
373 static bool ParseInstance (const char* pCur,const char** pCurOut,
|
nuclear@0
|
374 const Element* pcElement, ElementInstance* p_pcOut);
|
nuclear@0
|
375
|
nuclear@0
|
376 // -------------------------------------------------------------------
|
nuclear@0
|
377 //! Parse a binary element instance
|
nuclear@0
|
378 static bool ParseInstanceBinary (const char* pCur,const char** pCurOut,
|
nuclear@0
|
379 const Element* pcElement, ElementInstance* p_pcOut,bool p_bBE);
|
nuclear@0
|
380 };
|
nuclear@0
|
381
|
nuclear@0
|
382 // ---------------------------------------------------------------------------------
|
nuclear@0
|
383 /** \brief Class for an element instance list in a PLY file
|
nuclear@0
|
384 */
|
nuclear@0
|
385 class ElementInstanceList
|
nuclear@0
|
386 {
|
nuclear@0
|
387 public:
|
nuclear@0
|
388
|
nuclear@0
|
389 //! Default constructor
|
nuclear@0
|
390 ElementInstanceList ()
|
nuclear@0
|
391 {}
|
nuclear@0
|
392
|
nuclear@0
|
393 //! List of all element instances
|
nuclear@0
|
394 std::vector< ElementInstance > alInstances;
|
nuclear@0
|
395
|
nuclear@0
|
396 // -------------------------------------------------------------------
|
nuclear@0
|
397 //! Parse an element instance list
|
nuclear@0
|
398 static bool ParseInstanceList (const char* pCur,const char** pCurOut,
|
nuclear@0
|
399 const Element* pcElement, ElementInstanceList* p_pcOut);
|
nuclear@0
|
400
|
nuclear@0
|
401 // -------------------------------------------------------------------
|
nuclear@0
|
402 //! Parse a binary element instance list
|
nuclear@0
|
403 static bool ParseInstanceListBinary (const char* pCur,const char** pCurOut,
|
nuclear@0
|
404 const Element* pcElement, ElementInstanceList* p_pcOut,bool p_bBE);
|
nuclear@0
|
405 };
|
nuclear@0
|
406 // ---------------------------------------------------------------------------------
|
nuclear@0
|
407 /** \brief Class to represent the document object model of an ASCII or binary
|
nuclear@0
|
408 * (both little and big-endian) PLY file
|
nuclear@0
|
409 */
|
nuclear@0
|
410 class DOM
|
nuclear@0
|
411 {
|
nuclear@0
|
412 public:
|
nuclear@0
|
413
|
nuclear@0
|
414 //! Default constructor
|
nuclear@0
|
415 DOM()
|
nuclear@0
|
416 {}
|
nuclear@0
|
417
|
nuclear@0
|
418
|
nuclear@0
|
419 //! Contains all elements of the file format
|
nuclear@0
|
420 std::vector<Element> alElements;
|
nuclear@0
|
421 //! Contains the real data of each element's instance list
|
nuclear@0
|
422 std::vector<ElementInstanceList> alElementData;
|
nuclear@0
|
423
|
nuclear@0
|
424 //! Parse the DOM for a PLY file. The input string is assumed
|
nuclear@0
|
425 //! to be terminated with zero
|
nuclear@0
|
426 static bool ParseInstance (const char* pCur,DOM* p_pcOut);
|
nuclear@0
|
427 static bool ParseInstanceBinary (const char* pCur,
|
nuclear@0
|
428 DOM* p_pcOut,bool p_bBE);
|
nuclear@0
|
429
|
nuclear@0
|
430 //! Skip all comment lines after this
|
nuclear@0
|
431 static bool SkipComments (const char* pCur,const char** pCurOut);
|
nuclear@0
|
432
|
nuclear@0
|
433 private:
|
nuclear@0
|
434
|
nuclear@0
|
435 // -------------------------------------------------------------------
|
nuclear@0
|
436 //! Handle the file header and read all element descriptions
|
nuclear@0
|
437 bool ParseHeader (const char* pCur,const char** pCurOut);
|
nuclear@0
|
438
|
nuclear@0
|
439 // -------------------------------------------------------------------
|
nuclear@0
|
440 //! Read in all element instance lists
|
nuclear@0
|
441 bool ParseElementInstanceLists (const char* pCur,const char** pCurOut);
|
nuclear@0
|
442
|
nuclear@0
|
443 // -------------------------------------------------------------------
|
nuclear@0
|
444 //! Read in all element instance lists for a binary file format
|
nuclear@0
|
445 bool ParseElementInstanceListsBinary (const char* pCur,
|
nuclear@0
|
446 const char** pCurOut,bool p_bBE);
|
nuclear@0
|
447 };
|
nuclear@0
|
448
|
nuclear@0
|
449 // ---------------------------------------------------------------------------------
|
nuclear@0
|
450 /** \brief Helper class to represent a loaded PLY face
|
nuclear@0
|
451 */
|
nuclear@0
|
452 class Face
|
nuclear@0
|
453 {
|
nuclear@0
|
454 public:
|
nuclear@0
|
455
|
nuclear@0
|
456 Face()
|
nuclear@0
|
457 : iMaterialIndex(0xFFFFFFFF)
|
nuclear@0
|
458 {
|
nuclear@0
|
459 // set all indices to zero by default
|
nuclear@0
|
460 mIndices.resize(3,0);
|
nuclear@0
|
461 }
|
nuclear@0
|
462
|
nuclear@0
|
463 public:
|
nuclear@0
|
464
|
nuclear@0
|
465 //! List of vertex indices
|
nuclear@0
|
466 std::vector<unsigned int> mIndices;
|
nuclear@0
|
467
|
nuclear@0
|
468 //! Material index
|
nuclear@0
|
469 unsigned int iMaterialIndex;
|
nuclear@0
|
470 };
|
nuclear@0
|
471
|
nuclear@0
|
472 // ---------------------------------------------------------------------------------
|
nuclear@0
|
473 template <typename TYPE>
|
nuclear@0
|
474 inline TYPE PLY::PropertyInstance::ConvertTo(
|
nuclear@0
|
475 PLY::PropertyInstance::ValueUnion v, PLY::EDataType eType)
|
nuclear@0
|
476 {
|
nuclear@0
|
477 switch (eType)
|
nuclear@0
|
478 {
|
nuclear@0
|
479 case EDT_Float:
|
nuclear@0
|
480 return (TYPE)v.fFloat;
|
nuclear@0
|
481 case EDT_Double:
|
nuclear@0
|
482 return (TYPE)v.fDouble;
|
nuclear@0
|
483
|
nuclear@0
|
484 case EDT_UInt:
|
nuclear@0
|
485 case EDT_UShort:
|
nuclear@0
|
486 case EDT_UChar:
|
nuclear@0
|
487 return (TYPE)v.iUInt;
|
nuclear@0
|
488
|
nuclear@0
|
489 case EDT_Int:
|
nuclear@0
|
490 case EDT_Short:
|
nuclear@0
|
491 case EDT_Char:
|
nuclear@0
|
492 return (TYPE)v.iInt;
|
nuclear@0
|
493 default: ;
|
nuclear@0
|
494 };
|
nuclear@0
|
495 return (TYPE)0;
|
nuclear@0
|
496 }
|
nuclear@0
|
497
|
nuclear@0
|
498 } // Namespace PLY
|
nuclear@0
|
499 } // Namespace AssImp
|
nuclear@0
|
500
|
nuclear@0
|
501 #endif // !! include guard
|