vrshoot

diff libs/assimp/XFileParser.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/XFileParser.h	Sat Feb 01 19:58:19 2014 +0200
     1.3 @@ -0,0 +1,162 @@
     1.4 +/*
     1.5 +Open Asset Import Library (assimp)
     1.6 +----------------------------------------------------------------------
     1.7 +
     1.8 +Copyright (c) 2006-2012, assimp team
     1.9 +All rights reserved.
    1.10 +
    1.11 +Redistribution and use of this software in source and binary forms, 
    1.12 +with or without modification, are permitted provided that the 
    1.13 +following conditions are met:
    1.14 +
    1.15 +* Redistributions of source code must retain the above
    1.16 +  copyright notice, this list of conditions and the
    1.17 +  following disclaimer.
    1.18 +
    1.19 +* Redistributions in binary form must reproduce the above
    1.20 +  copyright notice, this list of conditions and the
    1.21 +  following disclaimer in the documentation and/or other
    1.22 +  materials provided with the distribution.
    1.23 +
    1.24 +* Neither the name of the assimp team, nor the names of its
    1.25 +  contributors may be used to endorse or promote products
    1.26 +  derived from this software without specific prior
    1.27 +  written permission of the assimp team.
    1.28 +
    1.29 +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 
    1.30 +"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 
    1.31 +LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
    1.32 +A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 
    1.33 +OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
    1.34 +SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 
    1.35 +LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
    1.36 +DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 
    1.37 +THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 
    1.38 +(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 
    1.39 +OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
    1.40 +
    1.41 +----------------------------------------------------------------------
    1.42 +*/
    1.43 +
    1.44 +/** @file Helper class to parse a XFile into a temporary structure */
    1.45 +#ifndef AI_XFILEPARSER_H_INC
    1.46 +#define AI_XFILEPARSER_H_INC
    1.47 +
    1.48 +#include <string>
    1.49 +#include <vector>
    1.50 +
    1.51 +#include "assimp/types.h"
    1.52 +
    1.53 +namespace Assimp
    1.54 +{
    1.55 +	namespace XFile
    1.56 +	{
    1.57 +		struct Node;
    1.58 +		struct Mesh;
    1.59 +		struct Scene;
    1.60 +		struct Material;
    1.61 +		struct Animation;
    1.62 +		struct AnimBone;
    1.63 +	}
    1.64 +
    1.65 +/** The XFileParser reads a XFile either in text or binary form and builds a temporary 
    1.66 + * data structure out of it. 
    1.67 + */
    1.68 +class XFileParser
    1.69 +{
    1.70 +public:
    1.71 +	/** Constructor. Creates a data structure out of the XFile given in the memory block. 
    1.72 +	 * @param pBuffer Null-terminated memory buffer containing the XFile
    1.73 +	 */
    1.74 +	XFileParser( const std::vector<char>& pBuffer);
    1.75 +
    1.76 +	/** Destructor. Destroys all imported data along with it */
    1.77 +	~XFileParser();
    1.78 +
    1.79 +	/** Returns the temporary representation of the imported data */
    1.80 +	XFile::Scene* GetImportedData() const { return mScene; }
    1.81 +
    1.82 +protected:
    1.83 +	void ParseFile();
    1.84 +	void ParseDataObjectTemplate();
    1.85 +	void ParseDataObjectFrame( XFile::Node *pParent);
    1.86 +	void ParseDataObjectTransformationMatrix( aiMatrix4x4& pMatrix);
    1.87 +	void ParseDataObjectMesh( XFile::Mesh* pMesh);
    1.88 +	void ParseDataObjectSkinWeights( XFile::Mesh* pMesh);
    1.89 +	void ParseDataObjectSkinMeshHeader( XFile::Mesh* pMesh);
    1.90 +	void ParseDataObjectMeshNormals( XFile::Mesh* pMesh);
    1.91 +	void ParseDataObjectMeshTextureCoords( XFile::Mesh* pMesh);
    1.92 +	void ParseDataObjectMeshVertexColors( XFile::Mesh* pMesh);
    1.93 +	void ParseDataObjectMeshMaterialList( XFile::Mesh* pMesh);
    1.94 +	void ParseDataObjectMaterial( XFile::Material* pMaterial);
    1.95 +	void ParseDataObjectAnimTicksPerSecond();
    1.96 +	void ParseDataObjectAnimationSet();
    1.97 +	void ParseDataObjectAnimation( XFile::Animation* pAnim);
    1.98 +	void ParseDataObjectAnimationKey( XFile::AnimBone *pAnimBone);
    1.99 +	void ParseDataObjectTextureFilename( std::string& pName);
   1.100 +	void ParseUnknownDataObject();
   1.101 +
   1.102 +	//! places pointer to next begin of a token, and ignores comments
   1.103 +	void FindNextNoneWhiteSpace();
   1.104 +
   1.105 +	//! returns next parseable token. Returns empty string if no token there
   1.106 +	std::string GetNextToken();
   1.107 +
   1.108 +	//! reads header of dataobject including the opening brace.
   1.109 +	//! returns false if error happened, and writes name of object
   1.110 +	//! if there is one
   1.111 +	void readHeadOfDataObject( std::string* poName = NULL);
   1.112 +
   1.113 +	//! checks for closing curly brace, throws exception if not there
   1.114 +	void CheckForClosingBrace();
   1.115 +
   1.116 +	//! checks for one following semicolon, throws exception if not there
   1.117 +	void CheckForSemicolon();
   1.118 +
   1.119 +	//! checks for a separator char, either a ',' or a ';'
   1.120 +	void CheckForSeparator();
   1.121 +
   1.122 +  /// tests and possibly consumes a separator char, but does nothing if there was no separator
   1.123 +  void TestForSeparator();
   1.124 +
   1.125 +	//! reads a x file style string
   1.126 +	void GetNextTokenAsString( std::string& poString);
   1.127 +
   1.128 +	void ReadUntilEndOfLine();
   1.129 +
   1.130 +	unsigned short ReadBinWord();
   1.131 +	unsigned int ReadBinDWord();
   1.132 +	unsigned int ReadInt();
   1.133 +	float ReadFloat();
   1.134 +	aiVector2D ReadVector2();
   1.135 +	aiVector3D ReadVector3();
   1.136 +	aiColor3D ReadRGB();
   1.137 +	aiColor4D ReadRGBA();
   1.138 +
   1.139 +	/** Throws an exception with a line number and the given text. */
   1.140 +	void ThrowException( const std::string& pText);
   1.141 +
   1.142 +	/** Filters the imported hierarchy for some degenerated cases that some exporters produce.
   1.143 +	 * @param pData The sub-hierarchy to filter
   1.144 +	 */
   1.145 +	void FilterHierarchy( XFile::Node* pNode);
   1.146 +
   1.147 +protected:
   1.148 +	unsigned int mMajorVersion, mMinorVersion; ///< version numbers
   1.149 +	bool mIsBinaryFormat; ///< true if the file is in binary, false if it's in text form
   1.150 +	unsigned int mBinaryFloatSize; ///< float size, either 32 or 64 bits
   1.151 +	// counter for number arrays in binary format
   1.152 +	unsigned int mBinaryNumCount;
   1.153 +
   1.154 +	const char* P;
   1.155 +	const char* End;
   1.156 +
   1.157 +	/// Line number when reading in text format
   1.158 +	unsigned int mLineNumber;
   1.159 +
   1.160 +	/// Imported data
   1.161 +	XFile::Scene* mScene;	
   1.162 +};
   1.163 +
   1.164 +}
   1.165 +#endif // AI_XFILEPARSER_H_INC