vrshoot

annotate libs/assimp/ACLoader.h @ 1:e7ca128b8713

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