vrshoot
view libs/assimp/UnrealLoader.h @ 2:334d17aed7de
visual studio project files
author | John Tsiombikas <nuclear@member.fsf.org> |
---|---|
date | Sun, 02 Feb 2014 18:36:38 +0200 |
parents | |
children |
line source
1 /*
2 Open Asset Import Library (assimp)
3 ----------------------------------------------------------------------
5 Copyright (c) 2006-2012, assimp team
6 All rights reserved.
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:
12 * Redistributions of source code must retain the above
13 copyright notice, this list of conditions and the
14 following disclaimer.
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.
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.
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.
38 ----------------------------------------------------------------------
39 */
41 /** @file UnrealLoader.h
42 * @brief Declaration of the .3d (UNREAL) importer class.
43 */
44 #ifndef INCLUDED_AI_3D_LOADER_H
45 #define INCLUDED_AI_3D_LOADER_H
47 #include "BaseImporter.h"
48 namespace Assimp {
49 namespace Unreal {
51 /*
52 0 = Normal one-sided
53 1 = Normal two-sided
54 2 = Translucent two-sided
55 3 = Masked two-sided
56 4 = Modulation blended two-sided
57 8 = Placeholder triangle for weapon positioning (invisible)
58 */
59 enum MeshFlags {
60 MF_NORMAL_OS = 0,
61 MF_NORMAL_TS = 1,
62 MF_NORMAL_TRANS_TS = 2,
63 MF_NORMAL_MASKED_TS = 3,
64 MF_NORMAL_MOD_TS = 4,
65 MF_WEAPON_PLACEHOLDER = 8
66 };
68 // a single triangle
69 struct Triangle {
70 uint16_t mVertex[3]; // Vertex indices
71 char mType; // James' Mesh Type
72 char mColor; // Color for flat and Gourand Shaded
73 unsigned char mTex[3][2]; // Texture UV coordinates
74 unsigned char mTextureNum; // Source texture offset
75 char mFlags; // Unreal Mesh Flags (unused)
77 unsigned int matIndex;
78 };
80 // temporary representation for a material
81 struct TempMat {
82 TempMat()
83 : numFaces (0)
84 {}
86 TempMat(const Triangle& in)
87 : type ((Unreal::MeshFlags)in.mType)
88 , tex (in.mTextureNum)
89 , numFaces (0)
90 {}
92 // type of mesh
93 Unreal::MeshFlags type;
95 // index of texture
96 unsigned int tex;
98 // number of faces using us
99 unsigned int numFaces;
101 // for std::find
102 bool operator == (const TempMat& o ) {
103 return (tex == o.tex && type == o.type);
104 }
105 };
107 struct Vertex
108 {
109 int32_t X : 11;
110 int32_t Y : 11;
111 int32_t Z : 10;
112 };
114 // UNREAL vertex compression
115 inline void CompressVertex(const aiVector3D& v, uint32_t& out)
116 {
117 union {
118 Vertex n;
119 int32_t t;
120 };
121 n.X = (int32_t)v.x;
122 n.Y = (int32_t)v.y;
123 n.Z = (int32_t)v.z;
124 out = t;
125 }
127 // UNREAL vertex decompression
128 inline void DecompressVertex(aiVector3D& v, int32_t in)
129 {
130 union {
131 Vertex n;
132 int32_t i;
133 };
134 i = in;
136 v.x = (float)n.X;
137 v.y = (float)n.Y;
138 v.z = (float)n.Z;
139 }
141 } // end namespace Unreal
143 // ---------------------------------------------------------------------------
144 /** @brief Importer class to load UNREAL files (*.3d)
145 */
146 class UnrealImporter : public BaseImporter
147 {
148 public:
149 UnrealImporter();
150 ~UnrealImporter();
153 public:
155 // -------------------------------------------------------------------
156 /** @brief Returns whether we can handle the format of the given file
157 *
158 * See BaseImporter::CanRead() for details.
159 **/
160 bool CanRead( const std::string& pFile, IOSystem* pIOHandler,
161 bool checkSig) const;
163 protected:
165 // -------------------------------------------------------------------
166 /** @brief Called by Importer::GetExtensionList()
167 *
168 * See #BaseImporter::GetInfo for the details
169 */
170 const aiImporterDesc* GetInfo () const;
173 // -------------------------------------------------------------------
174 /** @brief Setup properties for the importer
175 *
176 * See BaseImporter::SetupProperties() for details
177 */
178 void SetupProperties(const Importer* pImp);
181 // -------------------------------------------------------------------
182 /** @brief Imports the given file into the given scene structure.
183 *
184 * See BaseImporter::InternReadFile() for details
185 */
186 void InternReadFile( const std::string& pFile, aiScene* pScene,
187 IOSystem* pIOHandler);
189 private:
191 //! frame to be loaded
192 uint32_t configFrameID;
194 //! process surface flags
195 bool configHandleFlags;
197 }; // !class UnrealImporter
199 } // end of namespace Assimp
200 #endif // AI_UNREALIMPORTER_H_INC