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