1 /*
2 Open Asset Import Library (assimp)
3 ----------------------------------------------------------------------
4 
5 Copyright (c) 2006-2015, assimp team
6 All rights reserved.
7 
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:
11 
12 * Redistributions of source code must retain the above
13   copyright notice, this list of conditions and the
14   following disclaimer.
15 
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.
20 
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.
25 
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.
37 
38 ----------------------------------------------------------------------
39 */
40 
41 /** @file  MS3DLoader.h
42  *  @brief Declaration of the MS3D importer class.
43  */
44 #ifndef AI_MS3DLOADER_H_INCLUDED
45 #define AI_MS3DLOADER_H_INCLUDED
46 
47 #include "BaseImporter.h"
48 #include "StreamReader.h"
49 struct aiNode;
50 
51 namespace Assimp    {
52 
53 // ----------------------------------------------------------------------------------------------
54 /** Milkshape 3D importer implementation */
55 // ----------------------------------------------------------------------------------------------
56 class MS3DImporter
57     : public BaseImporter
58 {
59 
60 public:
61 
62     MS3DImporter();
63     ~MS3DImporter();
64 
65 public:
66 
67     // -------------------------------------------------------------------
68     /** Returns whether the class can handle the format of the given file.
69     * See BaseImporter::CanRead() for details.  */
70     bool CanRead( const std::string& pFile, IOSystem* pIOHandler,
71         bool checkSig) const;
72 
73 protected:
74 
75     // -------------------------------------------------------------------
76     /** Return importer meta information.
77      * See #BaseImporter::GetInfo for the details */
78     const aiImporterDesc* GetInfo () const;
79 
80 
81     // -------------------------------------------------------------------
82     /** Imports the given file into the given scene structure.
83     * See BaseImporter::InternReadFile() for details */
84     void InternReadFile( const std::string& pFile, aiScene* pScene,
85         IOSystem* pIOHandler);
86 
87 
88 private:
89 
90     struct TempJoint;
91     void CollectChildJoints(const std::vector<TempJoint>& joints, std::vector<bool>& hadit, aiNode* nd,const aiMatrix4x4& absTrafo);
92     void CollectChildJoints(const std::vector<TempJoint>& joints, aiNode* nd);
93 
94     template<typename T> void ReadComments(StreamReaderLE& stream, std::vector<T>& outp);
95 private:
96 
97     aiScene* mScene;
98 
99 private:
100 
101     struct TempVertex
102     {
103         aiVector3D pos;
104         unsigned int bone_id[4], ref_cnt;
105         float weights[4];
106     };
107 
108     struct TempTriangle
109     {
110         unsigned int indices[3];
111         aiVector3D normals[3];
112         aiVector2D uv[3];
113 
114         unsigned int sg, group;
115     };
116 
117     struct TempGroup
118     {
119         char name[33]; // +0
120         std::vector<unsigned int> triangles;
121         unsigned int mat; // 0xff is no material
122         std::string comment;
123     };
124 
125     struct TempMaterial
126     {
127         // again, add an extra 0 character to all strings -
128         char name[33];
129         char texture[129];
130         char alphamap[129];
131 
132         aiColor4D diffuse,specular,ambient,emissive;
133         float shininess,transparency;
134         std::string comment;
135     };
136 
137     struct TempKeyFrame
138     {
139         float time;
140         aiVector3D value;
141     };
142 
143     struct TempJoint
144     {
145         char name[33];
146         char parentName[33];
147         aiVector3D rotation, position;
148 
149         std::vector<TempKeyFrame> rotFrames;
150         std::vector<TempKeyFrame> posFrames;
151         std::string comment;
152     };
153 
154     //struct TempModel {
155     //  std::string comment;
156     //};
157 };
158 
159 }
160 #endif
161