vrshoot

view libs/assimp/ACLoader.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 ACLoader.h
42 * @brief Declaration of the .ac importer class.
43 */
44 #ifndef AI_AC3DLOADER_H_INCLUDED
45 #define AI_AC3DLOADER_H_INCLUDED
47 #include <vector>
49 #include "BaseImporter.h"
50 #include "assimp/types.h"
52 namespace Assimp {
54 // ---------------------------------------------------------------------------
55 /** AC3D (*.ac) importer class
56 */
57 class AC3DImporter : public BaseImporter
58 {
59 public:
60 AC3DImporter();
61 ~AC3DImporter();
65 // Represents an AC3D material
66 struct Material
67 {
68 Material()
69 : rgb (0.6f,0.6f,0.6f)
70 , spec (1.f,1.f,1.f)
71 , shin (0.f)
72 , trans (0.f)
73 {}
75 // base color of the material
76 aiColor3D rgb;
78 // ambient color of the material
79 aiColor3D amb;
81 // emissive color of the material
82 aiColor3D emis;
84 // specular color of the material
85 aiColor3D spec;
87 // shininess exponent
88 float shin;
90 // transparency. 0 == opaque
91 float trans;
93 // name of the material. optional.
94 std::string name;
95 };
97 // Represents an AC3D surface
98 struct Surface
99 {
100 Surface()
101 : mat (0)
102 , flags (0)
103 {}
105 unsigned int mat,flags;
107 typedef std::pair<unsigned int, aiVector2D > SurfaceEntry;
108 std::vector< SurfaceEntry > entries;
109 };
111 // Represents an AC3D object
112 struct Object
113 {
114 Object()
115 : type (World)
116 , name( "" )
117 , children()
118 , texture( "" )
119 , texRepeat( 1.f, 1.f )
120 , texOffset( 0.0f, 0.0f )
121 , rotation()
122 , translation()
123 , vertices()
124 , surfaces()
125 , numRefs (0)
126 , subDiv (0)
127 {}
129 // Type description
130 enum Type
131 {
132 World = 0x0,
133 Poly = 0x1,
134 Group = 0x2,
135 Light = 0x4
136 } type;
138 // name of the object
139 std::string name;
141 // object children
142 std::vector<Object> children;
144 // texture to be assigned to all surfaces of the object
145 std::string texture;
147 // texture repat factors (scaling for all coordinates)
148 aiVector2D texRepeat, texOffset;
150 // rotation matrix
151 aiMatrix3x3 rotation;
153 // translation vector
154 aiVector3D translation;
156 // vertices
157 std::vector<aiVector3D> vertices;
159 // surfaces
160 std::vector<Surface> surfaces;
162 // number of indices (= num verts in verbose format)
163 unsigned int numRefs;
165 // number of subdivisions to be performed on the
166 // imported data
167 unsigned int subDiv;
169 // max angle limit for smoothing
170 float crease;
171 };
174 public:
176 // -------------------------------------------------------------------
177 /** Returns whether the class can handle the format of the given file.
178 * See BaseImporter::CanRead() for details.
179 */
180 bool CanRead( const std::string& pFile, IOSystem* pIOHandler,
181 bool checkSig) const;
183 protected:
185 // -------------------------------------------------------------------
186 /** Return importer meta information.
187 * See #BaseImporter::GetInfo for the details */
188 const aiImporterDesc* GetInfo () const;
190 // -------------------------------------------------------------------
191 /** Imports the given file into the given scene structure.
192 * See BaseImporter::InternReadFile() for details*/
193 void InternReadFile( const std::string& pFile, aiScene* pScene,
194 IOSystem* pIOHandler);
196 // -------------------------------------------------------------------
197 /** Called prior to ReadFile().
198 * The function is a request to the importer to update its configuration
199 * basing on the Importer's configuration property list.*/
200 void SetupProperties(const Importer* pImp);
202 private:
204 // -------------------------------------------------------------------
205 /** Get the next line from the file.
206 * @return false if the end of the file was reached*/
207 bool GetNextLine();
209 // -------------------------------------------------------------------
210 /** Load the object section. This method is called recursively to
211 * load subobjects, the method returns after a 'kids 0' was
212 * encountered.
213 * @objects List of output objects*/
214 void LoadObjectSection(std::vector<Object>& objects);
216 // -------------------------------------------------------------------
217 /** Convert all objects into meshes and nodes.
218 * @param object Current object to work on
219 * @param meshes Pointer to the list of output meshes
220 * @param outMaterials List of output materials
221 * @param materials Material list
222 * @param Scenegraph node for the object */
223 aiNode* ConvertObjectSection(Object& object,
224 std::vector<aiMesh*>& meshes,
225 std::vector<aiMaterial*>& outMaterials,
226 const std::vector<Material>& materials,
227 aiNode* parent = NULL);
229 // -------------------------------------------------------------------
230 /** Convert a material
231 * @param object Current object
232 * @param matSrc Source material description
233 * @param matDest Destination material to be filled */
234 void ConvertMaterial(const Object& object,
235 const Material& matSrc,
236 aiMaterial& matDest);
238 private:
241 // points to the next data line
242 const char* buffer;
244 // Configuration option: if enabled, up to two meshes
245 // are generated per material: those faces who have
246 // their bf cull flags set are separated.
247 bool configSplitBFCull;
249 // Configuration switch: subdivision surfaces are only
250 // evaluated if the value is true.
251 bool configEvalSubdivision;
253 // counts how many objects we have in the tree.
254 // basing on this information we can find a
255 // good estimate how many meshes we'll have in the final scene.
256 unsigned int mNumMeshes;
258 // current list of light sources
259 std::vector<aiLight*>* mLights;
261 // name counters
262 unsigned int lights, groups, polys, worlds;
263 };
265 } // end of namespace Assimp
267 #endif // AI_AC3DIMPORTER_H_INC