vrshoot
diff libs/assimp/ACLoader.h @ 0:b2f14e535253
initial commit
author | John Tsiombikas <nuclear@member.fsf.org> |
---|---|
date | Sat, 01 Feb 2014 19:58:19 +0200 |
parents | |
children |
line diff
1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/libs/assimp/ACLoader.h Sat Feb 01 19:58:19 2014 +0200 1.3 @@ -0,0 +1,267 @@ 1.4 +/* 1.5 +Open Asset Import Library (assimp) 1.6 +---------------------------------------------------------------------- 1.7 + 1.8 +Copyright (c) 2006-2012, assimp team 1.9 +All rights reserved. 1.10 + 1.11 +Redistribution and use of this software in source and binary forms, 1.12 +with or without modification, are permitted provided that the 1.13 +following conditions are met: 1.14 + 1.15 +* Redistributions of source code must retain the above 1.16 + copyright notice, this list of conditions and the 1.17 + following disclaimer. 1.18 + 1.19 +* Redistributions in binary form must reproduce the above 1.20 + copyright notice, this list of conditions and the 1.21 + following disclaimer in the documentation and/or other 1.22 + materials provided with the distribution. 1.23 + 1.24 +* Neither the name of the assimp team, nor the names of its 1.25 + contributors may be used to endorse or promote products 1.26 + derived from this software without specific prior 1.27 + written permission of the assimp team. 1.28 + 1.29 +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 1.30 +"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 1.31 +LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 1.32 +A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 1.33 +OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 1.34 +SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 1.35 +LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 1.36 +DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 1.37 +THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 1.38 +(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 1.39 +OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 1.40 + 1.41 +---------------------------------------------------------------------- 1.42 +*/ 1.43 + 1.44 +/** @file ACLoader.h 1.45 + * @brief Declaration of the .ac importer class. 1.46 + */ 1.47 +#ifndef AI_AC3DLOADER_H_INCLUDED 1.48 +#define AI_AC3DLOADER_H_INCLUDED 1.49 + 1.50 +#include <vector> 1.51 + 1.52 +#include "BaseImporter.h" 1.53 +#include "assimp/types.h" 1.54 + 1.55 +namespace Assimp { 1.56 + 1.57 +// --------------------------------------------------------------------------- 1.58 +/** AC3D (*.ac) importer class 1.59 +*/ 1.60 +class AC3DImporter : public BaseImporter 1.61 +{ 1.62 +public: 1.63 + AC3DImporter(); 1.64 + ~AC3DImporter(); 1.65 + 1.66 + 1.67 + 1.68 + // Represents an AC3D material 1.69 + struct Material 1.70 + { 1.71 + Material() 1.72 + : rgb (0.6f,0.6f,0.6f) 1.73 + , spec (1.f,1.f,1.f) 1.74 + , shin (0.f) 1.75 + , trans (0.f) 1.76 + {} 1.77 + 1.78 + // base color of the material 1.79 + aiColor3D rgb; 1.80 + 1.81 + // ambient color of the material 1.82 + aiColor3D amb; 1.83 + 1.84 + // emissive color of the material 1.85 + aiColor3D emis; 1.86 + 1.87 + // specular color of the material 1.88 + aiColor3D spec; 1.89 + 1.90 + // shininess exponent 1.91 + float shin; 1.92 + 1.93 + // transparency. 0 == opaque 1.94 + float trans; 1.95 + 1.96 + // name of the material. optional. 1.97 + std::string name; 1.98 + }; 1.99 + 1.100 + // Represents an AC3D surface 1.101 + struct Surface 1.102 + { 1.103 + Surface() 1.104 + : mat (0) 1.105 + , flags (0) 1.106 + {} 1.107 + 1.108 + unsigned int mat,flags; 1.109 + 1.110 + typedef std::pair<unsigned int, aiVector2D > SurfaceEntry; 1.111 + std::vector< SurfaceEntry > entries; 1.112 + }; 1.113 + 1.114 + // Represents an AC3D object 1.115 + struct Object 1.116 + { 1.117 + Object() 1.118 + : type (World) 1.119 + , name( "" ) 1.120 + , children() 1.121 + , texture( "" ) 1.122 + , texRepeat( 1.f, 1.f ) 1.123 + , texOffset( 0.0f, 0.0f ) 1.124 + , rotation() 1.125 + , translation() 1.126 + , vertices() 1.127 + , surfaces() 1.128 + , numRefs (0) 1.129 + , subDiv (0) 1.130 + {} 1.131 + 1.132 + // Type description 1.133 + enum Type 1.134 + { 1.135 + World = 0x0, 1.136 + Poly = 0x1, 1.137 + Group = 0x2, 1.138 + Light = 0x4 1.139 + } type; 1.140 + 1.141 + // name of the object 1.142 + std::string name; 1.143 + 1.144 + // object children 1.145 + std::vector<Object> children; 1.146 + 1.147 + // texture to be assigned to all surfaces of the object 1.148 + std::string texture; 1.149 + 1.150 + // texture repat factors (scaling for all coordinates) 1.151 + aiVector2D texRepeat, texOffset; 1.152 + 1.153 + // rotation matrix 1.154 + aiMatrix3x3 rotation; 1.155 + 1.156 + // translation vector 1.157 + aiVector3D translation; 1.158 + 1.159 + // vertices 1.160 + std::vector<aiVector3D> vertices; 1.161 + 1.162 + // surfaces 1.163 + std::vector<Surface> surfaces; 1.164 + 1.165 + // number of indices (= num verts in verbose format) 1.166 + unsigned int numRefs; 1.167 + 1.168 + // number of subdivisions to be performed on the 1.169 + // imported data 1.170 + unsigned int subDiv; 1.171 + 1.172 + // max angle limit for smoothing 1.173 + float crease; 1.174 + }; 1.175 + 1.176 + 1.177 +public: 1.178 + 1.179 + // ------------------------------------------------------------------- 1.180 + /** Returns whether the class can handle the format of the given file. 1.181 + * See BaseImporter::CanRead() for details. 1.182 + */ 1.183 + bool CanRead( const std::string& pFile, IOSystem* pIOHandler, 1.184 + bool checkSig) const; 1.185 + 1.186 +protected: 1.187 + 1.188 + // ------------------------------------------------------------------- 1.189 + /** Return importer meta information. 1.190 + * See #BaseImporter::GetInfo for the details */ 1.191 + const aiImporterDesc* GetInfo () const; 1.192 + 1.193 + // ------------------------------------------------------------------- 1.194 + /** Imports the given file into the given scene structure. 1.195 + * See BaseImporter::InternReadFile() for details*/ 1.196 + void InternReadFile( const std::string& pFile, aiScene* pScene, 1.197 + IOSystem* pIOHandler); 1.198 + 1.199 + // ------------------------------------------------------------------- 1.200 + /** Called prior to ReadFile(). 1.201 + * The function is a request to the importer to update its configuration 1.202 + * basing on the Importer's configuration property list.*/ 1.203 + void SetupProperties(const Importer* pImp); 1.204 + 1.205 +private: 1.206 + 1.207 + // ------------------------------------------------------------------- 1.208 + /** Get the next line from the file. 1.209 + * @return false if the end of the file was reached*/ 1.210 + bool GetNextLine(); 1.211 + 1.212 + // ------------------------------------------------------------------- 1.213 + /** Load the object section. This method is called recursively to 1.214 + * load subobjects, the method returns after a 'kids 0' was 1.215 + * encountered. 1.216 + * @objects List of output objects*/ 1.217 + void LoadObjectSection(std::vector<Object>& objects); 1.218 + 1.219 + // ------------------------------------------------------------------- 1.220 + /** Convert all objects into meshes and nodes. 1.221 + * @param object Current object to work on 1.222 + * @param meshes Pointer to the list of output meshes 1.223 + * @param outMaterials List of output materials 1.224 + * @param materials Material list 1.225 + * @param Scenegraph node for the object */ 1.226 + aiNode* ConvertObjectSection(Object& object, 1.227 + std::vector<aiMesh*>& meshes, 1.228 + std::vector<aiMaterial*>& outMaterials, 1.229 + const std::vector<Material>& materials, 1.230 + aiNode* parent = NULL); 1.231 + 1.232 + // ------------------------------------------------------------------- 1.233 + /** Convert a material 1.234 + * @param object Current object 1.235 + * @param matSrc Source material description 1.236 + * @param matDest Destination material to be filled */ 1.237 + void ConvertMaterial(const Object& object, 1.238 + const Material& matSrc, 1.239 + aiMaterial& matDest); 1.240 + 1.241 +private: 1.242 + 1.243 + 1.244 + // points to the next data line 1.245 + const char* buffer; 1.246 + 1.247 + // Configuration option: if enabled, up to two meshes 1.248 + // are generated per material: those faces who have 1.249 + // their bf cull flags set are separated. 1.250 + bool configSplitBFCull; 1.251 + 1.252 + // Configuration switch: subdivision surfaces are only 1.253 + // evaluated if the value is true. 1.254 + bool configEvalSubdivision; 1.255 + 1.256 + // counts how many objects we have in the tree. 1.257 + // basing on this information we can find a 1.258 + // good estimate how many meshes we'll have in the final scene. 1.259 + unsigned int mNumMeshes; 1.260 + 1.261 + // current list of light sources 1.262 + std::vector<aiLight*>* mLights; 1.263 + 1.264 + // name counters 1.265 + unsigned int lights, groups, polys, worlds; 1.266 +}; 1.267 + 1.268 +} // end of namespace Assimp 1.269 + 1.270 +#endif // AI_AC3DIMPORTER_H_INC