1/*
2Open Asset Import Library (assimp)
3----------------------------------------------------------------------
4
5Copyright (c) 2006-2017, assimp team
6
7All rights reserved.
8
9Redistribution and use of this software in source and binary forms,
10with or without modification, are permitted provided that the
11following conditions are met:
12
13* Redistributions of source code must retain the above
14 copyright notice, this list of conditions and the
15 following disclaimer.
16
17* Redistributions in binary form must reproduce the above
18 copyright notice, this list of conditions and the
19 following disclaimer in the documentation and/or other
20 materials provided with the distribution.
21
22* Neither the name of the assimp team, nor the names of its
23 contributors may be used to endorse or promote products
24 derived from this software without specific prior
25 written permission of the assimp team.
26
27THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
28"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
29LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
30A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
31OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
32SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
33LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
34DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
35THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
36(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
37OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
38
39----------------------------------------------------------------------
40*/
41
42#ifndef AI_OGREIMPORTER_H_INC
43#define AI_OGREIMPORTER_H_INC
44
45#ifndef ASSIMP_BUILD_NO_OGRE_IMPORTER
46
47#include "BaseImporter.h"
48
49#include "OgreStructs.h"
50#include "OgreParsingUtils.h"
51
52#include <assimp/material.h>
53
54namespace Assimp
55{
56namespace Ogre
57{
58
59/** Importer for Ogre mesh, skeleton and material formats.
60 @todo Support vertex colors.
61 @todo Support poses/animations from the mesh file.
62 Currently only skeleton file animations are supported. */
63class OgreImporter : public BaseImporter
64{
65public:
66 /// BaseImporter override.
67 virtual bool CanRead(const std::string &pFile, IOSystem *pIOHandler, bool checkSig) const;
68
69 /// BaseImporter override.
70 virtual void InternReadFile(const std::string &pFile, aiScene *pScene, IOSystem *pIOHandler);
71
72 /// BaseImporter override.
73 virtual const aiImporterDesc *GetInfo() const;
74
75 /// BaseImporter override.
76 virtual void SetupProperties(const Importer *pImp);
77
78private:
79 /// Read materials referenced by the @c mesh to @c pScene.
80 void ReadMaterials(const std::string &pFile, Assimp::IOSystem *pIOHandler, aiScene *pScene, Mesh *mesh);
81 void ReadMaterials(const std::string &pFile, Assimp::IOSystem *pIOHandler, aiScene *pScene, MeshXml *mesh);
82 void AssignMaterials(aiScene *pScene, std::vector<aiMaterial*> &materials);
83
84 /// Reads material
85 aiMaterial* ReadMaterial(const std::string &pFile, Assimp::IOSystem *pIOHandler, const std::string &MaterialName);
86
87 // These functions parse blocks from a material file from @c ss. Starting parsing from "{" and ending it to "}".
88 bool ReadTechnique(const std::string &techniqueName, std::stringstream &ss, aiMaterial *material);
89 bool ReadPass(const std::string &passName, std::stringstream &ss, aiMaterial *material);
90 bool ReadTextureUnit(const std::string &textureUnitName, std::stringstream &ss, aiMaterial *material);
91
92 std::string m_userDefinedMaterialLibFile;
93 bool m_detectTextureTypeFromFilename;
94
95 std::map<aiTextureType, unsigned int> m_textures;
96};
97} // Ogre
98} // Assimp
99
100#endif // ASSIMP_BUILD_NO_OGRE_IMPORTER
101#endif // AI_OGREIMPORTER_H_INC
102