vrshoot

annotate libs/assimp/3DSLoader.h @ 1:e7ca128b8713

looks nice :)
author John Tsiombikas <nuclear@member.fsf.org>
date Sun, 02 Feb 2014 00:35:22 +0200
parents
children
rev   line source
nuclear@0 1
nuclear@0 2 /*
nuclear@0 3 Open Asset Import Library (assimp)
nuclear@0 4 ----------------------------------------------------------------------
nuclear@0 5
nuclear@0 6 Copyright (c) 2006-2012, assimp team
nuclear@0 7 All rights reserved.
nuclear@0 8
nuclear@0 9 Redistribution and use of this software in source and binary forms,
nuclear@0 10 with or without modification, are permitted provided that the
nuclear@0 11 following conditions are met:
nuclear@0 12
nuclear@0 13 * Redistributions of source code must retain the above
nuclear@0 14 copyright notice, this list of conditions and the
nuclear@0 15 following disclaimer.
nuclear@0 16
nuclear@0 17 * Redistributions in binary form must reproduce the above
nuclear@0 18 copyright notice, this list of conditions and the
nuclear@0 19 following disclaimer in the documentation and/or other
nuclear@0 20 materials provided with the distribution.
nuclear@0 21
nuclear@0 22 * Neither the name of the assimp team, nor the names of its
nuclear@0 23 contributors may be used to endorse or promote products
nuclear@0 24 derived from this software without specific prior
nuclear@0 25 written permission of the assimp team.
nuclear@0 26
nuclear@0 27 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
nuclear@0 28 "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
nuclear@0 29 LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
nuclear@0 30 A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
nuclear@0 31 OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
nuclear@0 32 SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
nuclear@0 33 LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
nuclear@0 34 DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
nuclear@0 35 THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
nuclear@0 36 (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
nuclear@0 37 OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
nuclear@0 38
nuclear@0 39 ----------------------------------------------------------------------
nuclear@0 40 */
nuclear@0 41
nuclear@0 42 /** @file 3DSLoader.h
nuclear@0 43 * @brief 3DS File format loader
nuclear@0 44 */
nuclear@0 45 #ifndef AI_3DSIMPORTER_H_INC
nuclear@0 46 #define AI_3DSIMPORTER_H_INC
nuclear@0 47
nuclear@0 48 #include "BaseImporter.h"
nuclear@0 49 #include "assimp/types.h"
nuclear@0 50
nuclear@0 51 #ifndef ASSIMP_BUILD_NO_3DS_IMPORTER
nuclear@0 52
nuclear@0 53 struct aiNode;
nuclear@0 54 #include "3DSHelper.h"
nuclear@0 55
nuclear@0 56 namespace Assimp {
nuclear@0 57
nuclear@0 58
nuclear@0 59 using namespace D3DS;
nuclear@0 60
nuclear@0 61 // ---------------------------------------------------------------------------------
nuclear@0 62 /** Importer class for 3D Studio r3 and r4 3DS files
nuclear@0 63 */
nuclear@0 64 class Discreet3DSImporter : public BaseImporter
nuclear@0 65 {
nuclear@0 66 public:
nuclear@0 67
nuclear@0 68 Discreet3DSImporter();
nuclear@0 69 ~Discreet3DSImporter();
nuclear@0 70
nuclear@0 71 public:
nuclear@0 72
nuclear@0 73 // -------------------------------------------------------------------
nuclear@0 74 /** Returns whether the class can handle the format of the given file.
nuclear@0 75 * See BaseImporter::CanRead() for details.
nuclear@0 76 */
nuclear@0 77 bool CanRead( const std::string& pFile, IOSystem* pIOHandler,
nuclear@0 78 bool checkSig) const;
nuclear@0 79
nuclear@0 80 // -------------------------------------------------------------------
nuclear@0 81 /** Called prior to ReadFile().
nuclear@0 82 * The function is a request to the importer to update its configuration
nuclear@0 83 * basing on the Importer's configuration property list.
nuclear@0 84 */
nuclear@0 85 void SetupProperties(const Importer* pImp);
nuclear@0 86
nuclear@0 87 protected:
nuclear@0 88
nuclear@0 89 // -------------------------------------------------------------------
nuclear@0 90 /** Return importer meta information.
nuclear@0 91 * See #BaseImporter::GetInfo for the details
nuclear@0 92 */
nuclear@0 93 const aiImporterDesc* GetInfo () const;
nuclear@0 94
nuclear@0 95 // -------------------------------------------------------------------
nuclear@0 96 /** Imports the given file into the given scene structure.
nuclear@0 97 * See BaseImporter::InternReadFile() for details
nuclear@0 98 */
nuclear@0 99 void InternReadFile( const std::string& pFile, aiScene* pScene,
nuclear@0 100 IOSystem* pIOHandler);
nuclear@0 101
nuclear@0 102 // -------------------------------------------------------------------
nuclear@0 103 /** Converts a temporary material to the outer representation
nuclear@0 104 */
nuclear@0 105 void ConvertMaterial(D3DS::Material& p_cMat,
nuclear@0 106 aiMaterial& p_pcOut);
nuclear@0 107
nuclear@0 108 // -------------------------------------------------------------------
nuclear@0 109 /** Read a chunk
nuclear@0 110 *
nuclear@0 111 * @param pcOut Receives the current chunk
nuclear@0 112 */
nuclear@0 113 void ReadChunk(Discreet3DS::Chunk* pcOut);
nuclear@0 114
nuclear@0 115 // -------------------------------------------------------------------
nuclear@0 116 /** Parse a percentage chunk. mCurrent will point to the next
nuclear@0 117 * chunk behind afterwards. If no percentage chunk is found
nuclear@0 118 * QNAN is returned.
nuclear@0 119 */
nuclear@0 120 float ParsePercentageChunk();
nuclear@0 121
nuclear@0 122 // -------------------------------------------------------------------
nuclear@0 123 /** Parse a color chunk. mCurrent will point to the next
nuclear@0 124 * chunk behind afterwards. If no color chunk is found
nuclear@0 125 * QNAN is returned in all members.
nuclear@0 126 */
nuclear@0 127 void ParseColorChunk(aiColor3D* p_pcOut,
nuclear@0 128 bool p_bAcceptPercent = true);
nuclear@0 129
nuclear@0 130
nuclear@0 131 // -------------------------------------------------------------------
nuclear@0 132 /** Skip a chunk in the file
nuclear@0 133 */
nuclear@0 134 void SkipChunk();
nuclear@0 135
nuclear@0 136 // -------------------------------------------------------------------
nuclear@0 137 /** Generate the nodegraph
nuclear@0 138 */
nuclear@0 139 void GenerateNodeGraph(aiScene* pcOut);
nuclear@0 140
nuclear@0 141 // -------------------------------------------------------------------
nuclear@0 142 /** Parse a main top-level chunk in the file
nuclear@0 143 */
nuclear@0 144 void ParseMainChunk();
nuclear@0 145
nuclear@0 146 // -------------------------------------------------------------------
nuclear@0 147 /** Parse a top-level chunk in the file
nuclear@0 148 */
nuclear@0 149 void ParseChunk(const char* name, unsigned int num);
nuclear@0 150
nuclear@0 151 // -------------------------------------------------------------------
nuclear@0 152 /** Parse a top-level editor chunk in the file
nuclear@0 153 */
nuclear@0 154 void ParseEditorChunk();
nuclear@0 155
nuclear@0 156 // -------------------------------------------------------------------
nuclear@0 157 /** Parse a top-level object chunk in the file
nuclear@0 158 */
nuclear@0 159 void ParseObjectChunk();
nuclear@0 160
nuclear@0 161 // -------------------------------------------------------------------
nuclear@0 162 /** Parse a material chunk in the file
nuclear@0 163 */
nuclear@0 164 void ParseMaterialChunk();
nuclear@0 165
nuclear@0 166 // -------------------------------------------------------------------
nuclear@0 167 /** Parse a mesh chunk in the file
nuclear@0 168 */
nuclear@0 169 void ParseMeshChunk();
nuclear@0 170
nuclear@0 171 // -------------------------------------------------------------------
nuclear@0 172 /** Parse a light chunk in the file
nuclear@0 173 */
nuclear@0 174 void ParseLightChunk();
nuclear@0 175
nuclear@0 176 // -------------------------------------------------------------------
nuclear@0 177 /** Parse a camera chunk in the file
nuclear@0 178 */
nuclear@0 179 void ParseCameraChunk();
nuclear@0 180
nuclear@0 181 // -------------------------------------------------------------------
nuclear@0 182 /** Parse a face list chunk in the file
nuclear@0 183 */
nuclear@0 184 void ParseFaceChunk();
nuclear@0 185
nuclear@0 186 // -------------------------------------------------------------------
nuclear@0 187 /** Parse a keyframe chunk in the file
nuclear@0 188 */
nuclear@0 189 void ParseKeyframeChunk();
nuclear@0 190
nuclear@0 191 // -------------------------------------------------------------------
nuclear@0 192 /** Parse a hierarchy chunk in the file
nuclear@0 193 */
nuclear@0 194 void ParseHierarchyChunk(uint16_t parent);
nuclear@0 195
nuclear@0 196 // -------------------------------------------------------------------
nuclear@0 197 /** Parse a texture chunk in the file
nuclear@0 198 */
nuclear@0 199 void ParseTextureChunk(D3DS::Texture* pcOut);
nuclear@0 200
nuclear@0 201 // -------------------------------------------------------------------
nuclear@0 202 /** Convert the meshes in the file
nuclear@0 203 */
nuclear@0 204 void ConvertMeshes(aiScene* pcOut);
nuclear@0 205
nuclear@0 206 // -------------------------------------------------------------------
nuclear@0 207 /** Replace the default material in the scene
nuclear@0 208 */
nuclear@0 209 void ReplaceDefaultMaterial();
nuclear@0 210
nuclear@0 211 // -------------------------------------------------------------------
nuclear@0 212 /** Convert the whole scene
nuclear@0 213 */
nuclear@0 214 void ConvertScene(aiScene* pcOut);
nuclear@0 215
nuclear@0 216 // -------------------------------------------------------------------
nuclear@0 217 /** generate unique vertices for a mesh
nuclear@0 218 */
nuclear@0 219 void MakeUnique(D3DS::Mesh& sMesh);
nuclear@0 220
nuclear@0 221 // -------------------------------------------------------------------
nuclear@0 222 /** Add a node to the node graph
nuclear@0 223 */
nuclear@0 224 void AddNodeToGraph(aiScene* pcSOut,aiNode* pcOut,D3DS::Node* pcIn,
nuclear@0 225 aiMatrix4x4& absTrafo);
nuclear@0 226
nuclear@0 227 // -------------------------------------------------------------------
nuclear@0 228 /** Search for a node in the graph.
nuclear@0 229 * Called recursively
nuclear@0 230 */
nuclear@0 231 void InverseNodeSearch(D3DS::Node* pcNode,D3DS::Node* pcCurrent);
nuclear@0 232
nuclear@0 233 // -------------------------------------------------------------------
nuclear@0 234 /** Apply the master scaling factor to the mesh
nuclear@0 235 */
nuclear@0 236 void ApplyMasterScale(aiScene* pScene);
nuclear@0 237
nuclear@0 238 // -------------------------------------------------------------------
nuclear@0 239 /** Clamp all indices in the file to a valid range
nuclear@0 240 */
nuclear@0 241 void CheckIndices(D3DS::Mesh& sMesh);
nuclear@0 242
nuclear@0 243 // -------------------------------------------------------------------
nuclear@0 244 /** Skip the TCB info in a track key
nuclear@0 245 */
nuclear@0 246 void SkipTCBInfo();
nuclear@0 247
nuclear@0 248 protected:
nuclear@0 249
nuclear@0 250 /** Stream to read from */
nuclear@0 251 StreamReaderLE* stream;
nuclear@0 252
nuclear@0 253 /** Last touched node index */
nuclear@0 254 short mLastNodeIndex;
nuclear@0 255
nuclear@0 256 /** Current node, root node */
nuclear@0 257 D3DS::Node* mCurrentNode, *mRootNode;
nuclear@0 258
nuclear@0 259 /** Scene under construction */
nuclear@0 260 D3DS::Scene* mScene;
nuclear@0 261
nuclear@0 262 /** Ambient base color of the scene */
nuclear@0 263 aiColor3D mClrAmbient;
nuclear@0 264
nuclear@0 265 /** Master scaling factor of the scene */
nuclear@0 266 float mMasterScale;
nuclear@0 267
nuclear@0 268 /** Path to the background image of the scene */
nuclear@0 269 std::string mBackgroundImage;
nuclear@0 270 bool bHasBG;
nuclear@0 271
nuclear@0 272 /** true if PRJ file */
nuclear@0 273 bool bIsPrj;
nuclear@0 274 };
nuclear@0 275
nuclear@0 276 #endif // !! ASSIMP_BUILD_NO_3DS_IMPORTER
nuclear@0 277
nuclear@0 278 } // end of namespace Assimp
nuclear@0 279
nuclear@0 280 #endif // AI_3DSIMPORTER_H_INC