vrshoot

diff libs/assimp/3DSLoader.h @ 0:b2f14e535253

initial commit
author John Tsiombikas <nuclear@member.fsf.org>
date Sat, 01 Feb 2014 19:58:19 +0200
parents
children
line diff
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/libs/assimp/3DSLoader.h	Sat Feb 01 19:58:19 2014 +0200
     1.3 @@ -0,0 +1,280 @@
     1.4 +
     1.5 +/*
     1.6 +Open Asset Import Library (assimp)
     1.7 +----------------------------------------------------------------------
     1.8 +
     1.9 +Copyright (c) 2006-2012, assimp team
    1.10 +All rights reserved.
    1.11 +
    1.12 +Redistribution and use of this software in source and binary forms, 
    1.13 +with or without modification, are permitted provided that the 
    1.14 +following conditions are met:
    1.15 +
    1.16 +* Redistributions of source code must retain the above
    1.17 +  copyright notice, this list of conditions and the
    1.18 +  following disclaimer.
    1.19 +
    1.20 +* Redistributions in binary form must reproduce the above
    1.21 +  copyright notice, this list of conditions and the
    1.22 +  following disclaimer in the documentation and/or other
    1.23 +  materials provided with the distribution.
    1.24 +
    1.25 +* Neither the name of the assimp team, nor the names of its
    1.26 +  contributors may be used to endorse or promote products
    1.27 +  derived from this software without specific prior
    1.28 +  written permission of the assimp team.
    1.29 +
    1.30 +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 
    1.31 +"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 
    1.32 +LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
    1.33 +A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 
    1.34 +OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
    1.35 +SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 
    1.36 +LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
    1.37 +DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 
    1.38 +THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 
    1.39 +(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 
    1.40 +OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
    1.41 +
    1.42 +----------------------------------------------------------------------
    1.43 +*/
    1.44 +
    1.45 +/** @file  3DSLoader.h
    1.46 + *  @brief 3DS File format loader
    1.47 + */
    1.48 +#ifndef AI_3DSIMPORTER_H_INC
    1.49 +#define AI_3DSIMPORTER_H_INC
    1.50 +
    1.51 +#include "BaseImporter.h"
    1.52 +#include "assimp/types.h"
    1.53 +
    1.54 +#ifndef ASSIMP_BUILD_NO_3DS_IMPORTER
    1.55 +
    1.56 +struct aiNode;
    1.57 +#include "3DSHelper.h"
    1.58 +
    1.59 +namespace Assimp	{
    1.60 +
    1.61 +
    1.62 +using namespace D3DS;
    1.63 +
    1.64 +// ---------------------------------------------------------------------------------
    1.65 +/** Importer class for 3D Studio r3 and r4 3DS files
    1.66 + */
    1.67 +class Discreet3DSImporter : public BaseImporter
    1.68 +{
    1.69 +public:
    1.70 +
    1.71 +	Discreet3DSImporter();
    1.72 +	~Discreet3DSImporter();
    1.73 +
    1.74 +public:
    1.75 +
    1.76 +	// -------------------------------------------------------------------
    1.77 +	/** Returns whether the class can handle the format of the given file. 
    1.78 +	 * See BaseImporter::CanRead() for details.	
    1.79 +	 */
    1.80 +	bool CanRead( const std::string& pFile, IOSystem* pIOHandler,
    1.81 +		bool checkSig) const;
    1.82 +
    1.83 +	// -------------------------------------------------------------------
    1.84 +	/** Called prior to ReadFile().
    1.85 +	 * The function is a request to the importer to update its configuration
    1.86 +	 * basing on the Importer's configuration property list.
    1.87 +	 */
    1.88 +	void SetupProperties(const Importer* pImp);
    1.89 +
    1.90 +protected:
    1.91 +
    1.92 +	// -------------------------------------------------------------------
    1.93 +	/** Return importer meta information.
    1.94 +	 * See #BaseImporter::GetInfo for the details
    1.95 +	 */
    1.96 +	const aiImporterDesc* GetInfo () const;
    1.97 +
    1.98 +	// -------------------------------------------------------------------
    1.99 +	/** Imports the given file into the given scene structure. 
   1.100 +	 * See BaseImporter::InternReadFile() for details
   1.101 +	 */
   1.102 +	void InternReadFile( const std::string& pFile, aiScene* pScene, 
   1.103 +		IOSystem* pIOHandler);
   1.104 +
   1.105 +	// -------------------------------------------------------------------
   1.106 +	/** Converts a temporary material to the outer representation 
   1.107 +	 */
   1.108 +	void ConvertMaterial(D3DS::Material& p_cMat,
   1.109 +		aiMaterial& p_pcOut);
   1.110 +
   1.111 +	// -------------------------------------------------------------------
   1.112 +	/** Read a chunk
   1.113 +	 *
   1.114 +	 *  @param pcOut Receives the current chunk
   1.115 +	 */
   1.116 +	void ReadChunk(Discreet3DS::Chunk* pcOut);
   1.117 +
   1.118 +	// -------------------------------------------------------------------
   1.119 +	/** Parse a percentage chunk. mCurrent will point to the next
   1.120 +	* chunk behind afterwards. If no percentage chunk is found
   1.121 +	* QNAN is returned.
   1.122 +	*/
   1.123 +	float ParsePercentageChunk();
   1.124 +
   1.125 +	// -------------------------------------------------------------------
   1.126 +	/** Parse a color chunk. mCurrent will point to the next
   1.127 +	* chunk behind afterwards. If no color chunk is found
   1.128 +	* QNAN is returned in all members.
   1.129 +	*/
   1.130 +	void ParseColorChunk(aiColor3D* p_pcOut,
   1.131 +		bool p_bAcceptPercent = true);
   1.132 +
   1.133 +
   1.134 +	// -------------------------------------------------------------------
   1.135 +	/** Skip a chunk in the file
   1.136 +	*/
   1.137 +	void SkipChunk();
   1.138 +
   1.139 +	// -------------------------------------------------------------------
   1.140 +	/** Generate the nodegraph
   1.141 +	*/
   1.142 +	void GenerateNodeGraph(aiScene* pcOut);
   1.143 +
   1.144 +	// -------------------------------------------------------------------
   1.145 +	/** Parse a main top-level chunk in the file
   1.146 +	*/
   1.147 +	void ParseMainChunk();
   1.148 +
   1.149 +	// -------------------------------------------------------------------
   1.150 +	/** Parse a top-level chunk in the file
   1.151 +	*/
   1.152 +	void ParseChunk(const char* name, unsigned int num);
   1.153 +
   1.154 +	// -------------------------------------------------------------------
   1.155 +	/** Parse a top-level editor chunk in the file
   1.156 +	*/
   1.157 +	void ParseEditorChunk();
   1.158 +
   1.159 +	// -------------------------------------------------------------------
   1.160 +	/** Parse a top-level object chunk in the file
   1.161 +	*/
   1.162 +	void ParseObjectChunk();
   1.163 +
   1.164 +	// -------------------------------------------------------------------
   1.165 +	/** Parse a material chunk in the file
   1.166 +	*/
   1.167 +	void ParseMaterialChunk();
   1.168 +
   1.169 +	// -------------------------------------------------------------------
   1.170 +	/** Parse a mesh chunk in the file
   1.171 +	*/
   1.172 +	void ParseMeshChunk();
   1.173 +
   1.174 +	// -------------------------------------------------------------------
   1.175 +	/** Parse a light chunk in the file
   1.176 +	*/
   1.177 +	void ParseLightChunk();
   1.178 +
   1.179 +	// -------------------------------------------------------------------
   1.180 +	/** Parse a camera chunk in the file
   1.181 +	*/
   1.182 +	void ParseCameraChunk();
   1.183 +
   1.184 +	// -------------------------------------------------------------------
   1.185 +	/** Parse a face list chunk in the file
   1.186 +	*/
   1.187 +	void ParseFaceChunk();
   1.188 +
   1.189 +	// -------------------------------------------------------------------
   1.190 +	/** Parse a keyframe chunk in the file
   1.191 +	*/
   1.192 +	void ParseKeyframeChunk();
   1.193 +
   1.194 +	// -------------------------------------------------------------------
   1.195 +	/** Parse a hierarchy chunk in the file
   1.196 +	*/
   1.197 +	void ParseHierarchyChunk(uint16_t parent);
   1.198 +
   1.199 +	// -------------------------------------------------------------------
   1.200 +	/** Parse a texture chunk in the file
   1.201 +	*/
   1.202 +	void ParseTextureChunk(D3DS::Texture* pcOut);
   1.203 +
   1.204 +	// -------------------------------------------------------------------
   1.205 +	/** Convert the meshes in the file
   1.206 +	*/
   1.207 +	void ConvertMeshes(aiScene* pcOut);
   1.208 +
   1.209 +	// -------------------------------------------------------------------
   1.210 +	/** Replace the default material in the scene
   1.211 +	*/
   1.212 +	void ReplaceDefaultMaterial();
   1.213 +
   1.214 +	// -------------------------------------------------------------------
   1.215 +	/** Convert the whole scene
   1.216 +	*/
   1.217 +	void ConvertScene(aiScene* pcOut);
   1.218 +
   1.219 +	// -------------------------------------------------------------------
   1.220 +	/** generate unique vertices for a mesh
   1.221 +	*/
   1.222 +	void MakeUnique(D3DS::Mesh& sMesh);
   1.223 +
   1.224 +	// -------------------------------------------------------------------
   1.225 +	/** Add a node to the node graph
   1.226 +	*/
   1.227 +	void AddNodeToGraph(aiScene* pcSOut,aiNode* pcOut,D3DS::Node* pcIn,
   1.228 +		aiMatrix4x4& absTrafo);
   1.229 +
   1.230 +	// -------------------------------------------------------------------
   1.231 +	/** Search for a node in the graph.
   1.232 +	* Called recursively
   1.233 +	*/
   1.234 +	void InverseNodeSearch(D3DS::Node* pcNode,D3DS::Node* pcCurrent);
   1.235 +
   1.236 +	// -------------------------------------------------------------------
   1.237 +	/** Apply the master scaling factor to the mesh
   1.238 +	*/
   1.239 +	void ApplyMasterScale(aiScene* pScene);
   1.240 +
   1.241 +	// -------------------------------------------------------------------
   1.242 +	/** Clamp all indices in the file to a valid range
   1.243 +	*/
   1.244 +	void CheckIndices(D3DS::Mesh& sMesh);
   1.245 +
   1.246 +	// -------------------------------------------------------------------
   1.247 +	/** Skip the TCB info in a track key
   1.248 +	*/
   1.249 +	void SkipTCBInfo();
   1.250 +
   1.251 +protected:
   1.252 +
   1.253 +	/** Stream to read from */
   1.254 +	StreamReaderLE* stream;
   1.255 +
   1.256 +	/** Last touched node index */
   1.257 +	short mLastNodeIndex;
   1.258 +
   1.259 +	/** Current node, root node */
   1.260 +	D3DS::Node* mCurrentNode, *mRootNode;
   1.261 +
   1.262 +	/** Scene under construction */
   1.263 +	D3DS::Scene* mScene;
   1.264 +
   1.265 +	/** Ambient base color of the scene */
   1.266 +	aiColor3D mClrAmbient;
   1.267 +
   1.268 +	/** Master scaling factor of the scene */
   1.269 +	float mMasterScale;
   1.270 +
   1.271 +	/** Path to the background image of the scene */
   1.272 +	std::string mBackgroundImage;
   1.273 +	bool bHasBG;
   1.274 +
   1.275 +	/** true if PRJ file */
   1.276 +	bool bIsPrj;
   1.277 +};
   1.278 +
   1.279 +#endif // !! ASSIMP_BUILD_NO_3DS_IMPORTER
   1.280 +
   1.281 +} // end of namespace Assimp
   1.282 +
   1.283 +#endif // AI_3DSIMPORTER_H_INC