vrshoot

view libs/assimp/PlyLoader.h @ 3:c179c72369be

rename candy->vr
author John Tsiombikas <nuclear@member.fsf.org>
date Mon, 03 Feb 2014 08:52:13 +0200
parents
children
line source
1 /*
2 Open Asset Import Library (assimp)
3 ----------------------------------------------------------------------
5 Copyright (c) 2006-2012, assimp team
6 All rights reserved.
8 Redistribution and use of this software in source and binary forms,
9 with or without modification, are permitted provided that the
10 following conditions are met:
12 * Redistributions of source code must retain the above
13 copyright notice, this list of conditions and the
14 following disclaimer.
16 * Redistributions in binary form must reproduce the above
17 copyright notice, this list of conditions and the
18 following disclaimer in the documentation and/or other
19 materials provided with the distribution.
21 * Neither the name of the assimp team, nor the names of its
22 contributors may be used to endorse or promote products
23 derived from this software without specific prior
24 written permission of the assimp team.
26 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
27 "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
28 LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
29 A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
30 OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
31 SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
32 LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
33 DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
34 THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
35 (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
36 OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
38 ----------------------------------------------------------------------
39 */
41 /** @file PLYLoader.h
42 * @brief Declaration of the .ply importer class.
43 */
44 #ifndef AI_PLYLOADER_H_INCLUDED
45 #define AI_PLYLOADER_H_INCLUDED
47 #include "BaseImporter.h"
48 #include "assimp/types.h"
50 struct aiNode;
52 #include "PlyParser.h"
54 namespace Assimp {
57 using namespace PLY;
59 // ---------------------------------------------------------------------------
60 /** Importer class to load the stanford PLY file format
61 */
62 class PLYImporter : public BaseImporter
63 {
64 public:
65 PLYImporter();
66 ~PLYImporter();
69 public:
71 // -------------------------------------------------------------------
72 /** Returns whether the class can handle the format of the given file.
73 * See BaseImporter::CanRead() for details.
74 */
75 bool CanRead( const std::string& pFile, IOSystem* pIOHandler,
76 bool checkSig) const;
78 protected:
80 // -------------------------------------------------------------------
81 /** Return importer meta information.
82 * See #BaseImporter::GetInfo for the details
83 */
84 const aiImporterDesc* GetInfo () const;
86 // -------------------------------------------------------------------
87 /** Imports the given file into the given scene structure.
88 * See BaseImporter::InternReadFile() for details
89 */
90 void InternReadFile( const std::string& pFile, aiScene* pScene,
91 IOSystem* pIOHandler);
93 protected:
96 // -------------------------------------------------------------------
97 /** Extract vertices from the DOM
98 */
99 void LoadVertices(std::vector<aiVector3D>* pvOut,
100 bool p_bNormals = false);
102 // -------------------------------------------------------------------
103 /** Extract vertex color channels from the DOM
104 */
105 void LoadVertexColor(std::vector<aiColor4D>* pvOut);
107 // -------------------------------------------------------------------
108 /** Extract texture coordinate channels from the DOM
109 */
110 void LoadTextureCoordinates(std::vector<aiVector2D>* pvOut);
112 // -------------------------------------------------------------------
113 /** Extract a face list from the DOM
114 */
115 void LoadFaces(std::vector<PLY::Face>* pvOut);
117 // -------------------------------------------------------------------
118 /** Extract a material list from the DOM
119 */
120 void LoadMaterial(std::vector<aiMaterial*>* pvOut);
123 // -------------------------------------------------------------------
124 /** Validate material indices, replace default material identifiers
125 */
126 void ReplaceDefaultMaterial(std::vector<PLY::Face>* avFaces,
127 std::vector<aiMaterial*>* avMaterials);
130 // -------------------------------------------------------------------
131 /** Convert all meshes into our ourer representation
132 */
133 void ConvertMeshes(std::vector<PLY::Face>* avFaces,
134 const std::vector<aiVector3D>* avPositions,
135 const std::vector<aiVector3D>* avNormals,
136 const std::vector<aiColor4D>* avColors,
137 const std::vector<aiVector2D>* avTexCoords,
138 const std::vector<aiMaterial*>* avMaterials,
139 std::vector<aiMesh*>* avOut);
142 // -------------------------------------------------------------------
143 /** Static helper to parse a color from four single channels in
144 */
145 static void GetMaterialColor(
146 const std::vector<PLY::PropertyInstance>& avList,
147 unsigned int aiPositions[4],
148 PLY::EDataType aiTypes[4],
149 aiColor4D* clrOut);
152 // -------------------------------------------------------------------
153 /** Static helper to parse a color channel value. The input value
154 * is normalized to 0-1.
155 */
156 static float NormalizeColorValue (
157 PLY::PropertyInstance::ValueUnion val,
158 PLY::EDataType eType);
161 /** Buffer to hold the loaded file */
162 unsigned char* mBuffer;
164 /** Document object model representation extracted from the file */
165 PLY::DOM* pcDOM;
166 };
168 } // end of namespace Assimp
170 #endif // AI_3DSIMPORTER_H_INC