nuclear@0: /* nuclear@0: Open Asset Import Library (assimp) nuclear@0: ---------------------------------------------------------------------- nuclear@0: nuclear@0: Copyright (c) 2006-2012, assimp team nuclear@0: All rights reserved. nuclear@0: nuclear@0: Redistribution and use of this software in source and binary forms, nuclear@0: with or without modification, are permitted provided that the nuclear@0: following conditions are met: nuclear@0: nuclear@0: * Redistributions of source code must retain the above nuclear@0: copyright notice, this list of conditions and the nuclear@0: following disclaimer. nuclear@0: nuclear@0: * Redistributions in binary form must reproduce the above nuclear@0: copyright notice, this list of conditions and the nuclear@0: following disclaimer in the documentation and/or other nuclear@0: materials provided with the distribution. nuclear@0: nuclear@0: * Neither the name of the assimp team, nor the names of its nuclear@0: contributors may be used to endorse or promote products nuclear@0: derived from this software without specific prior nuclear@0: written permission of the assimp team. nuclear@0: nuclear@0: THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS nuclear@0: "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT nuclear@0: LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR nuclear@0: A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT nuclear@0: OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, nuclear@0: SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT nuclear@0: LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, nuclear@0: DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY nuclear@0: THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT nuclear@0: (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE nuclear@0: OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. nuclear@0: nuclear@0: ---------------------------------------------------------------------- nuclear@0: */ nuclear@0: nuclear@0: /** @file ACLoader.h nuclear@0: * @brief Declaration of the .ac importer class. nuclear@0: */ nuclear@0: #ifndef AI_AC3DLOADER_H_INCLUDED nuclear@0: #define AI_AC3DLOADER_H_INCLUDED nuclear@0: nuclear@0: #include nuclear@0: nuclear@0: #include "BaseImporter.h" nuclear@0: #include "assimp/types.h" nuclear@0: nuclear@0: namespace Assimp { nuclear@0: nuclear@0: // --------------------------------------------------------------------------- nuclear@0: /** AC3D (*.ac) importer class nuclear@0: */ nuclear@0: class AC3DImporter : public BaseImporter nuclear@0: { nuclear@0: public: nuclear@0: AC3DImporter(); nuclear@0: ~AC3DImporter(); nuclear@0: nuclear@0: nuclear@0: nuclear@0: // Represents an AC3D material nuclear@0: struct Material nuclear@0: { nuclear@0: Material() nuclear@0: : rgb (0.6f,0.6f,0.6f) nuclear@0: , spec (1.f,1.f,1.f) nuclear@0: , shin (0.f) nuclear@0: , trans (0.f) nuclear@0: {} nuclear@0: nuclear@0: // base color of the material nuclear@0: aiColor3D rgb; nuclear@0: nuclear@0: // ambient color of the material nuclear@0: aiColor3D amb; nuclear@0: nuclear@0: // emissive color of the material nuclear@0: aiColor3D emis; nuclear@0: nuclear@0: // specular color of the material nuclear@0: aiColor3D spec; nuclear@0: nuclear@0: // shininess exponent nuclear@0: float shin; nuclear@0: nuclear@0: // transparency. 0 == opaque nuclear@0: float trans; nuclear@0: nuclear@0: // name of the material. optional. nuclear@0: std::string name; nuclear@0: }; nuclear@0: nuclear@0: // Represents an AC3D surface nuclear@0: struct Surface nuclear@0: { nuclear@0: Surface() nuclear@0: : mat (0) nuclear@0: , flags (0) nuclear@0: {} nuclear@0: nuclear@0: unsigned int mat,flags; nuclear@0: nuclear@0: typedef std::pair SurfaceEntry; nuclear@0: std::vector< SurfaceEntry > entries; nuclear@0: }; nuclear@0: nuclear@0: // Represents an AC3D object nuclear@0: struct Object nuclear@0: { nuclear@0: Object() nuclear@0: : type (World) nuclear@0: , name( "" ) nuclear@0: , children() nuclear@0: , texture( "" ) nuclear@0: , texRepeat( 1.f, 1.f ) nuclear@0: , texOffset( 0.0f, 0.0f ) nuclear@0: , rotation() nuclear@0: , translation() nuclear@0: , vertices() nuclear@0: , surfaces() nuclear@0: , numRefs (0) nuclear@0: , subDiv (0) nuclear@0: {} nuclear@0: nuclear@0: // Type description nuclear@0: enum Type nuclear@0: { nuclear@0: World = 0x0, nuclear@0: Poly = 0x1, nuclear@0: Group = 0x2, nuclear@0: Light = 0x4 nuclear@0: } type; nuclear@0: nuclear@0: // name of the object nuclear@0: std::string name; nuclear@0: nuclear@0: // object children nuclear@0: std::vector children; nuclear@0: nuclear@0: // texture to be assigned to all surfaces of the object nuclear@0: std::string texture; nuclear@0: nuclear@0: // texture repat factors (scaling for all coordinates) nuclear@0: aiVector2D texRepeat, texOffset; nuclear@0: nuclear@0: // rotation matrix nuclear@0: aiMatrix3x3 rotation; nuclear@0: nuclear@0: // translation vector nuclear@0: aiVector3D translation; nuclear@0: nuclear@0: // vertices nuclear@0: std::vector vertices; nuclear@0: nuclear@0: // surfaces nuclear@0: std::vector surfaces; nuclear@0: nuclear@0: // number of indices (= num verts in verbose format) nuclear@0: unsigned int numRefs; nuclear@0: nuclear@0: // number of subdivisions to be performed on the nuclear@0: // imported data nuclear@0: unsigned int subDiv; nuclear@0: nuclear@0: // max angle limit for smoothing nuclear@0: float crease; nuclear@0: }; nuclear@0: nuclear@0: nuclear@0: public: nuclear@0: nuclear@0: // ------------------------------------------------------------------- nuclear@0: /** Returns whether the class can handle the format of the given file. nuclear@0: * See BaseImporter::CanRead() for details. nuclear@0: */ nuclear@0: bool CanRead( const std::string& pFile, IOSystem* pIOHandler, nuclear@0: bool checkSig) const; nuclear@0: nuclear@0: protected: nuclear@0: nuclear@0: // ------------------------------------------------------------------- nuclear@0: /** Return importer meta information. nuclear@0: * See #BaseImporter::GetInfo for the details */ nuclear@0: const aiImporterDesc* GetInfo () const; nuclear@0: nuclear@0: // ------------------------------------------------------------------- nuclear@0: /** Imports the given file into the given scene structure. nuclear@0: * See BaseImporter::InternReadFile() for details*/ nuclear@0: void InternReadFile( const std::string& pFile, aiScene* pScene, nuclear@0: IOSystem* pIOHandler); nuclear@0: nuclear@0: // ------------------------------------------------------------------- nuclear@0: /** Called prior to ReadFile(). nuclear@0: * The function is a request to the importer to update its configuration nuclear@0: * basing on the Importer's configuration property list.*/ nuclear@0: void SetupProperties(const Importer* pImp); nuclear@0: nuclear@0: private: nuclear@0: nuclear@0: // ------------------------------------------------------------------- nuclear@0: /** Get the next line from the file. nuclear@0: * @return false if the end of the file was reached*/ nuclear@0: bool GetNextLine(); nuclear@0: nuclear@0: // ------------------------------------------------------------------- nuclear@0: /** Load the object section. This method is called recursively to nuclear@0: * load subobjects, the method returns after a 'kids 0' was nuclear@0: * encountered. nuclear@0: * @objects List of output objects*/ nuclear@0: void LoadObjectSection(std::vector& objects); nuclear@0: nuclear@0: // ------------------------------------------------------------------- nuclear@0: /** Convert all objects into meshes and nodes. nuclear@0: * @param object Current object to work on nuclear@0: * @param meshes Pointer to the list of output meshes nuclear@0: * @param outMaterials List of output materials nuclear@0: * @param materials Material list nuclear@0: * @param Scenegraph node for the object */ nuclear@0: aiNode* ConvertObjectSection(Object& object, nuclear@0: std::vector& meshes, nuclear@0: std::vector& outMaterials, nuclear@0: const std::vector& materials, nuclear@0: aiNode* parent = NULL); nuclear@0: nuclear@0: // ------------------------------------------------------------------- nuclear@0: /** Convert a material nuclear@0: * @param object Current object nuclear@0: * @param matSrc Source material description nuclear@0: * @param matDest Destination material to be filled */ nuclear@0: void ConvertMaterial(const Object& object, nuclear@0: const Material& matSrc, nuclear@0: aiMaterial& matDest); nuclear@0: nuclear@0: private: nuclear@0: nuclear@0: nuclear@0: // points to the next data line nuclear@0: const char* buffer; nuclear@0: nuclear@0: // Configuration option: if enabled, up to two meshes nuclear@0: // are generated per material: those faces who have nuclear@0: // their bf cull flags set are separated. nuclear@0: bool configSplitBFCull; nuclear@0: nuclear@0: // Configuration switch: subdivision surfaces are only nuclear@0: // evaluated if the value is true. nuclear@0: bool configEvalSubdivision; nuclear@0: nuclear@0: // counts how many objects we have in the tree. nuclear@0: // basing on this information we can find a nuclear@0: // good estimate how many meshes we'll have in the final scene. nuclear@0: unsigned int mNumMeshes; nuclear@0: nuclear@0: // current list of light sources nuclear@0: std::vector* mLights; nuclear@0: nuclear@0: // name counters nuclear@0: unsigned int lights, groups, polys, worlds; nuclear@0: }; nuclear@0: nuclear@0: } // end of namespace Assimp nuclear@0: nuclear@0: #endif // AI_AC3DIMPORTER_H_INC