Initiual commit: AssetImporter source moved from ZFXCE repository to its own repository. PLease do not use the ZFXCE repo any more.
git-svn-id: https://assimp.svn.sourceforge.net/svnroot/assimp/trunk@1 67173fc5-114c-0410-ac8e-9d2fd5bffc1f
This commit is contained in:
222
include/Compiler/VisualStudio/stdint.h
Normal file
222
include/Compiler/VisualStudio/stdint.h
Normal file
@@ -0,0 +1,222 @@
|
||||
// ISO C9x compliant stdint.h for Microsoft Visual Studio
|
||||
// Based on ISO/IEC 9899:TC2 Committee draft (May 6, 2005) WG14/N1124
|
||||
//
|
||||
// Copyright (c) 2006 Alexander Chemeris
|
||||
//
|
||||
// Redistribution and use in source and binary forms, with or without
|
||||
// modification, are permitted provided that the following conditions are met:
|
||||
//
|
||||
// 1. Redistributions of source code must retain the above copyright notice,
|
||||
// this list of conditions and the following disclaimer.
|
||||
//
|
||||
// 2. Redistributions in binary form must reproduce the above copyright
|
||||
// notice, this list of conditions and the following disclaimer in the
|
||||
// documentation and/or other materials provided with the distribution.
|
||||
//
|
||||
// 3. The name of the author may be used to endorse or promote products
|
||||
// derived from this software without specific prior written permission.
|
||||
//
|
||||
// THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED
|
||||
// WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
||||
// MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO
|
||||
// EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
||||
// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
|
||||
// OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
|
||||
// WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
|
||||
// OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
||||
// ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
//
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#ifndef _MSC_VER // [
|
||||
#error "Use this header only with Microsoft Visual C++ compilers!"
|
||||
#endif // _MSC_VER ]
|
||||
|
||||
#ifndef _MSC_STDINT_H_ // [
|
||||
#define _MSC_STDINT_H_
|
||||
|
||||
#if _MSC_VER > 1000
|
||||
#pragma once
|
||||
#endif
|
||||
|
||||
#include <limits.h>
|
||||
|
||||
// For Visual Studio 6 in C++ mode wrap <wchar.h> include with 'extern "C++" {}'
|
||||
// or compiler give many errors like this:
|
||||
// error C2733: second C linkage of overloaded function 'wmemchr' not allowed
|
||||
#if (_MSC_VER < 1300) && defined(__cplusplus)
|
||||
extern "C++" {
|
||||
#endif
|
||||
# include <wchar.h>
|
||||
#if (_MSC_VER < 1300) && defined(__cplusplus)
|
||||
}
|
||||
#endif
|
||||
|
||||
// 7.18.1 Integer types
|
||||
|
||||
// 7.18.1.1 Exact-width integer types
|
||||
typedef __int8 int8_t;
|
||||
typedef __int16 int16_t;
|
||||
typedef __int32 int32_t;
|
||||
typedef __int64 int64_t;
|
||||
typedef unsigned __int8 uint8_t;
|
||||
typedef unsigned __int16 uint16_t;
|
||||
typedef unsigned __int32 uint32_t;
|
||||
typedef unsigned __int64 uint64_t;
|
||||
|
||||
// 7.18.1.2 Minimum-width integer types
|
||||
typedef int8_t int_least8_t;
|
||||
typedef int16_t int_least16_t;
|
||||
typedef int32_t int_least32_t;
|
||||
typedef int64_t int_least64_t;
|
||||
typedef uint8_t uint_least8_t;
|
||||
typedef uint16_t uint_least16_t;
|
||||
typedef uint32_t uint_least32_t;
|
||||
typedef uint64_t uint_least64_t;
|
||||
|
||||
// 7.18.1.3 Fastest minimum-width integer types
|
||||
typedef int8_t int_fast8_t;
|
||||
typedef int16_t int_fast16_t;
|
||||
typedef int32_t int_fast32_t;
|
||||
typedef int64_t int_fast64_t;
|
||||
typedef uint8_t uint_fast8_t;
|
||||
typedef uint16_t uint_fast16_t;
|
||||
typedef uint32_t uint_fast32_t;
|
||||
typedef uint64_t uint_fast64_t;
|
||||
|
||||
// 7.18.1.4 Integer types capable of holding object pointers
|
||||
#ifdef _WIN64 // [
|
||||
typedef __int64 intptr_t;
|
||||
typedef unsigned __int64 uintptr_t;
|
||||
#else // _WIN64 ][
|
||||
typedef int intptr_t;
|
||||
typedef unsigned int uintptr_t;
|
||||
#endif // _WIN64 ]
|
||||
|
||||
// 7.18.1.5 Greatest-width integer types
|
||||
typedef int64_t intmax_t;
|
||||
typedef uint64_t uintmax_t;
|
||||
|
||||
|
||||
// 7.18.2 Limits of specified-width integer types
|
||||
|
||||
#if !defined(__cplusplus) || defined(__STDC_LIMIT_MACROS) // [ See footnote 220 at page 257 and footnote 221 at page 259
|
||||
|
||||
// 7.18.2.1 Limits of exact-width integer types
|
||||
#define INT8_MIN ((int8_t)_I8_MIN)
|
||||
#define INT8_MAX _I8_MAX
|
||||
#define INT16_MIN ((int16_t)_I16_MIN)
|
||||
#define INT16_MAX _I16_MAX
|
||||
#define INT32_MIN ((int32_t)_I32_MIN)
|
||||
#define INT32_MAX _I32_MAX
|
||||
#define INT64_MIN ((int64_t)_I64_MIN)
|
||||
#define INT64_MAX _I64_MAX
|
||||
#define UINT8_MAX _UI8_MAX
|
||||
#define UINT16_MAX _UI16_MAX
|
||||
#define UINT32_MAX _UI32_MAX
|
||||
#define UINT64_MAX _UI64_MAX
|
||||
|
||||
// 7.18.2.2 Limits of minimum-width integer types
|
||||
#define INT_LEAST8_MIN INT8_MIN
|
||||
#define INT_LEAST8_MAX INT8_MAX
|
||||
#define INT_LEAST16_MIN INT16_MIN
|
||||
#define INT_LEAST16_MAX INT16_MAX
|
||||
#define INT_LEAST32_MIN INT32_MIN
|
||||
#define INT_LEAST32_MAX INT32_MAX
|
||||
#define INT_LEAST64_MIN INT64_MIN
|
||||
#define INT_LEAST64_MAX INT64_MAX
|
||||
#define UINT_LEAST8_MAX UINT8_MAX
|
||||
#define UINT_LEAST16_MAX UINT16_MAX
|
||||
#define UINT_LEAST32_MAX UINT32_MAX
|
||||
#define UINT_LEAST64_MAX UINT64_MAX
|
||||
|
||||
// 7.18.2.3 Limits of fastest minimum-width integer types
|
||||
#define INT_FAST8_MIN INT8_MIN
|
||||
#define INT_FAST8_MAX INT8_MAX
|
||||
#define INT_FAST16_MIN INT16_MIN
|
||||
#define INT_FAST16_MAX INT16_MAX
|
||||
#define INT_FAST32_MIN INT32_MIN
|
||||
#define INT_FAST32_MAX INT32_MAX
|
||||
#define INT_FAST64_MIN INT64_MIN
|
||||
#define INT_FAST64_MAX INT64_MAX
|
||||
#define UINT_FAST8_MAX UINT8_MAX
|
||||
#define UINT_FAST16_MAX UINT16_MAX
|
||||
#define UINT_FAST32_MAX UINT32_MAX
|
||||
#define UINT_FAST64_MAX UINT64_MAX
|
||||
|
||||
// 7.18.2.4 Limits of integer types capable of holding object pointers
|
||||
#ifdef _WIN64 // [
|
||||
# define INTPTR_MIN INT64_MIN
|
||||
# define INTPTR_MAX INT64_MAX
|
||||
# define UINTPTR_MAX UINT64_MAX
|
||||
#else // _WIN64 ][
|
||||
# define INTPTR_MIN INT32_MIN
|
||||
# define INTPTR_MAX INT32_MAX
|
||||
# define UINTPTR_MAX UINT32_MAX
|
||||
#endif // _WIN64 ]
|
||||
|
||||
// 7.18.2.5 Limits of greatest-width integer types
|
||||
#define INTMAX_MIN INT64_MIN
|
||||
#define INTMAX_MAX INT64_MAX
|
||||
#define UINTMAX_MAX UINT64_MAX
|
||||
|
||||
// 7.18.3 Limits of other integer types
|
||||
|
||||
#ifdef _WIN64 // [
|
||||
# define PTRDIFF_MIN _I64_MIN
|
||||
# define PTRDIFF_MAX _I64_MAX
|
||||
#else // _WIN64 ][
|
||||
# define PTRDIFF_MIN _I32_MIN
|
||||
# define PTRDIFF_MAX _I32_MAX
|
||||
#endif // _WIN64 ]
|
||||
|
||||
#define SIG_ATOMIC_MIN INT_MIN
|
||||
#define SIG_ATOMIC_MAX INT_MAX
|
||||
|
||||
#ifndef SIZE_MAX // [
|
||||
# ifdef _WIN64 // [
|
||||
# define SIZE_MAX _UI64_MAX
|
||||
# else // _WIN64 ][
|
||||
# define SIZE_MAX _UI32_MAX
|
||||
# endif // _WIN64 ]
|
||||
#endif // SIZE_MAX ]
|
||||
|
||||
// WCHAR_MIN and WCHAR_MAX are also defined in <wchar.h>
|
||||
#ifndef WCHAR_MIN // [
|
||||
# define WCHAR_MIN 0
|
||||
#endif // WCHAR_MIN ]
|
||||
#ifndef WCHAR_MAX // [
|
||||
# define WCHAR_MAX _UI16_MAX
|
||||
#endif // WCHAR_MAX ]
|
||||
|
||||
#define WINT_MIN 0
|
||||
#define WINT_MAX _UI16_MAX
|
||||
|
||||
#endif // __STDC_LIMIT_MACROS ]
|
||||
|
||||
|
||||
// 7.18.4 Limits of other integer types
|
||||
|
||||
#if !defined(__cplusplus) || defined(__STDC_CONSTANT_MACROS) // [ See footnote 224 at page 260
|
||||
|
||||
// 7.18.4.1 Macros for minimum-width integer constants
|
||||
|
||||
#define INT8_C(val) val##i8
|
||||
#define INT16_C(val) val##i16
|
||||
#define INT32_C(val) val##i32
|
||||
#define INT64_C(val) val##i64
|
||||
|
||||
#define UINT8_C(val) val##ui8
|
||||
#define UINT16_C(val) val##ui16
|
||||
#define UINT32_C(val) val##ui32
|
||||
#define UINT64_C(val) val##ui64
|
||||
|
||||
// 7.18.4.2 Macros for greatest-width integer constants
|
||||
#define INTMAX_C INT64_C
|
||||
#define UINTMAX_C UINT64_C
|
||||
|
||||
#endif // __STDC_CONSTANT_MACROS ]
|
||||
|
||||
|
||||
#endif // _MSC_STDINT_H_ ]
|
||||
111
include/IOStream.h
Normal file
111
include/IOStream.h
Normal file
@@ -0,0 +1,111 @@
|
||||
|
||||
/** @file File I/O wrappers for C++. Use interfaces instead of function
|
||||
* pointers to be sure even the silliest men on earth can work with this
|
||||
*/
|
||||
|
||||
#ifndef AI_IOSTREAM_H_INC
|
||||
#define AI_IOSTREAM_H_INC
|
||||
|
||||
#include <string>
|
||||
#include <stddef.h>
|
||||
|
||||
#include "aiTypes.h"
|
||||
#include "aiFileIO.h"
|
||||
|
||||
#ifndef __cplusplus
|
||||
#error This header requires C++ to be used.
|
||||
#endif
|
||||
|
||||
namespace Assimp
|
||||
{
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
/** Class to handle file I/O for C++
|
||||
*
|
||||
* Derive an own implementation from this interface to provide custom IO handling
|
||||
* to the Importer. If you implement this interface, be sure to also provide an
|
||||
* implementation for IOSystem that creates instances of your custom IO class.
|
||||
*/
|
||||
// ---------------------------------------------------------------------------
|
||||
class IOStream
|
||||
{
|
||||
protected:
|
||||
/** Constructor protected, use IOSystem::Open() to create an instance. */
|
||||
IOStream(void);
|
||||
|
||||
public:
|
||||
// -------------------------------------------------------------------
|
||||
/** Destructor. Deleting the object closes the underlying file,
|
||||
* alternatively you may use IOSystem::Close() to release the file.
|
||||
*/
|
||||
virtual ~IOStream(void);
|
||||
|
||||
// -------------------------------------------------------------------
|
||||
/** Read from the file
|
||||
*
|
||||
* See fread() for more details
|
||||
* This fails for write-only files
|
||||
*/
|
||||
// -------------------------------------------------------------------
|
||||
virtual size_t Read(
|
||||
void* pvBuffer,
|
||||
size_t pSize,
|
||||
size_t pCount) = 0;
|
||||
|
||||
|
||||
// -------------------------------------------------------------------
|
||||
/** Write to the file
|
||||
*
|
||||
* See fwrite() for more details
|
||||
* This fails for read-only files
|
||||
*/
|
||||
// -------------------------------------------------------------------
|
||||
virtual size_t Write(
|
||||
const void* pvBuffer,
|
||||
size_t pSize,
|
||||
size_t pCount) = 0;
|
||||
|
||||
|
||||
// -------------------------------------------------------------------
|
||||
/** Set the read/write cursor of the file
|
||||
*
|
||||
* See fseek() for more details
|
||||
*/
|
||||
// -------------------------------------------------------------------
|
||||
virtual aiReturn Seek(
|
||||
size_t pOffset,
|
||||
aiOrigin pOrigin) = 0;
|
||||
|
||||
|
||||
// -------------------------------------------------------------------
|
||||
/** Get the current position of the read/write cursor
|
||||
*
|
||||
* See ftell() for more details
|
||||
*/
|
||||
// -------------------------------------------------------------------
|
||||
virtual size_t Tell(void) const = 0;
|
||||
|
||||
// -------------------------------------------------------------------
|
||||
/** Returns filesize
|
||||
*
|
||||
* Returns the filesize
|
||||
*/
|
||||
// -------------------------------------------------------------------
|
||||
virtual size_t FileSize() const = 0;
|
||||
};
|
||||
// ----------------------------------------------------------------------------
|
||||
inline IOStream::IOStream()
|
||||
{
|
||||
// empty
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
inline IOStream::~IOStream()
|
||||
{
|
||||
// empty
|
||||
}
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
} //!ns Assimp
|
||||
|
||||
#endif //!!AI_IOSTREAM_H_INC
|
||||
90
include/IOSystem.h
Normal file
90
include/IOSystem.h
Normal file
@@ -0,0 +1,90 @@
|
||||
/** @file Filesystem wrapper for C++. Inherit this class to supply custom file handling
|
||||
* logic to the Import library.
|
||||
*/
|
||||
|
||||
#ifndef AI_IOSYSTEM_H_INC
|
||||
#define AI_IOSYSTEM_H_INC
|
||||
|
||||
#ifndef __cplusplus
|
||||
#error This header requires C++ to be used.
|
||||
#endif
|
||||
|
||||
#include <string>
|
||||
|
||||
namespace Assimp
|
||||
{
|
||||
|
||||
class IOStream;
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
/** Interface to the file system.
|
||||
*
|
||||
* Derive an own implementation from this interface to supply custom file handling
|
||||
* to the importer library. If you implement this interface, you also want to
|
||||
* supply a custom implementation for IOStream.
|
||||
*/
|
||||
class IOSystem
|
||||
{
|
||||
public:
|
||||
/** Constructor. Create an instance of your derived class and assign it to
|
||||
* the #Importer instance by calling Importer::SetIOHandler().
|
||||
*/
|
||||
IOSystem();
|
||||
|
||||
/** Destructor. */
|
||||
virtual ~IOSystem();
|
||||
|
||||
// -------------------------------------------------------------------
|
||||
/** Tests for the existence of a file at the given path.
|
||||
*
|
||||
* @param pFile Path to the file
|
||||
* @return true if there is a file with this path, else false.
|
||||
*/
|
||||
virtual bool Exists( const std::string& pFile) const = 0;
|
||||
|
||||
// -------------------------------------------------------------------
|
||||
/** Returns the system specific directory separator
|
||||
* @return System specific directory separator
|
||||
*/
|
||||
virtual std::string getOsSeparator() const = 0;
|
||||
|
||||
// -------------------------------------------------------------------
|
||||
/** Open a new file with a given path. When the access to the file is finished,
|
||||
* call Close() to release all associated resources.
|
||||
*
|
||||
* @param pFile Path to the file
|
||||
* @param pMode Desired file I/O mode. Required are: "wb", "w", "wt",
|
||||
* "rb", "r", "rt".
|
||||
*
|
||||
* @return New IOStream interface allowing the lib to access
|
||||
* the underlying file.
|
||||
* @note When implementing this class to provide custom IO handling, you propably
|
||||
* have to supply an own implementation of IOStream as well.
|
||||
*/
|
||||
virtual IOStream* Open(
|
||||
const std::string& pFile,
|
||||
const std::string& pMode = std::string("rb")) = 0;
|
||||
|
||||
// -------------------------------------------------------------------
|
||||
/** Closes the given file and releases all resources associated with it.
|
||||
* @param pFile The file instance previously created by Open().
|
||||
*/
|
||||
virtual void Close( IOStream* pFile) = 0;
|
||||
};
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
inline IOSystem::IOSystem()
|
||||
{
|
||||
// empty
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
inline IOSystem::~IOSystem()
|
||||
{
|
||||
// empty
|
||||
}
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
} //!ns Assimp
|
||||
|
||||
#endif //AI_IOSYSTEM_H_INC
|
||||
68
include/ObjFileParser.h
Normal file
68
include/ObjFileParser.h
Normal file
@@ -0,0 +1,68 @@
|
||||
#ifndef OBJ_FILEPARSER_H_INC
|
||||
#define OBJ_FILEPARSER_H_INC
|
||||
|
||||
#include <vector>
|
||||
#include <string>
|
||||
#include "aiTypes.h"
|
||||
|
||||
/*struct aiVector2D_t;
|
||||
struct aiVector3D_t;*/
|
||||
|
||||
namespace Assimp
|
||||
{
|
||||
|
||||
namespace ObjFile
|
||||
{
|
||||
struct Model;
|
||||
struct Object;
|
||||
struct Material;
|
||||
struct Point3;
|
||||
struct Point2;
|
||||
}
|
||||
class ObjFileImporter;
|
||||
|
||||
class ObjFileParser
|
||||
{
|
||||
public:
|
||||
static const size_t BUFFERSIZE = 1024;
|
||||
typedef std::vector<char> DataArray;
|
||||
typedef std::vector<char>::iterator DataArrayIt;
|
||||
typedef std::vector<char>::const_iterator ConstDataArrayIt;
|
||||
|
||||
public:
|
||||
ObjFileParser(std::vector<char> &Data, const std::string &strAbsPath, const std::string &strModelName);
|
||||
~ObjFileParser();
|
||||
ObjFile::Model *GetModel() const;
|
||||
|
||||
private:
|
||||
void parseFile();
|
||||
void copyNextWord(char *pBuffer, size_t length);
|
||||
void copyNextLine(char *pBuffer, size_t length);
|
||||
void getVector3(std::vector<aiVector3D_t*> &point3d_array);
|
||||
void getVector2(std::vector<aiVector2D_t*> &point2d_array);
|
||||
void skipLine();
|
||||
void getFace();
|
||||
void getMaterialDesc();
|
||||
void getComment();
|
||||
void getMaterialLib();
|
||||
void getNewMaterial();
|
||||
void getGroupName();
|
||||
void getGroupNumber();
|
||||
void getObjectName();
|
||||
void createObject(const std::string &strObjectName);
|
||||
void reportErrorTokenInFace();
|
||||
void extractExtension(const std::string strFile, std::string &strExt);
|
||||
|
||||
private:
|
||||
std::string m_strAbsPath;
|
||||
DataArrayIt m_DataIt;
|
||||
DataArrayIt m_DataItEnd;
|
||||
ObjFile::Model *m_pModel;
|
||||
unsigned int m_uiLine;
|
||||
char m_buffer[BUFFERSIZE];
|
||||
|
||||
};
|
||||
|
||||
} // Namespace Assimp
|
||||
|
||||
#endif
|
||||
118
include/aiAnim.h
Normal file
118
include/aiAnim.h
Normal file
@@ -0,0 +1,118 @@
|
||||
/** @file Defines the data structures in which the imported animations are returned. */
|
||||
#ifndef AI_ANIM_H_INC
|
||||
#define AI_ANIM_H_INC
|
||||
|
||||
#include "aiTypes.h"
|
||||
#include "aiQuaternion.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/** A time-value pair specifying a certain 3D vector for the given time. */
|
||||
struct aiVectorKey
|
||||
{
|
||||
double mTime; ///< The time of this key
|
||||
aiVector3D_t mValue; ///< The value of this key
|
||||
};
|
||||
|
||||
/** A time-value pair specifying a rotation for the given time. For joint animations
|
||||
* the rotation is usually expressed using a quaternion.
|
||||
*/
|
||||
struct aiQuatKey
|
||||
{
|
||||
double mTime; ///< The time of this key
|
||||
aiQuaternion_t mValue; ///< The value of this key
|
||||
};
|
||||
|
||||
/** Describes the animation of a single bone. The name specifies the bone which is affected by this
|
||||
* animation channel. The keyframes are given in three separate series of values, one each for
|
||||
* position, rotation and scaling.
|
||||
*/
|
||||
struct aiBoneAnim
|
||||
{
|
||||
/** The name of the bone affected by this animation. */
|
||||
aiString mBoneName;
|
||||
|
||||
/** The number of position keys */
|
||||
unsigned int mNumPositionKeys;
|
||||
/** The position keys of this animation channel. Positions are specified as 3D vector.
|
||||
* The array is mNumPositionKeys in size.
|
||||
*/
|
||||
aiVectorKey* mPositionKeys;
|
||||
|
||||
/** The number of rotation keys */
|
||||
unsigned int mNumRotationKeys;
|
||||
/** The rotation keys of this animation channel. Rotations are given as quaternions,
|
||||
* which are 4D vectors. The array is mNumRotationKeys in size.
|
||||
*/
|
||||
aiQuatKey* mRotationKeys;
|
||||
|
||||
/** The number of scaling keys */
|
||||
unsigned int mNumScalingKeys;
|
||||
/** The scaling keys of this animation channel. Scalings are specified as 3D vector.
|
||||
* The array is mNumScalingKeys in size.
|
||||
*/
|
||||
aiVectorKey* mScalingKeys;
|
||||
|
||||
#ifdef __cplusplus
|
||||
aiBoneAnim()
|
||||
{
|
||||
mNumPositionKeys = 0; mPositionKeys = NULL;
|
||||
mNumRotationKeys= 0; mRotationKeys = NULL;
|
||||
mNumScalingKeys = 0; mScalingKeys = NULL;
|
||||
}
|
||||
|
||||
~aiBoneAnim()
|
||||
{
|
||||
delete [] mPositionKeys;
|
||||
delete [] mRotationKeys;
|
||||
delete [] mScalingKeys;
|
||||
}
|
||||
#endif // __cplusplus
|
||||
};
|
||||
|
||||
/** An animation consists of keyframe data for a number of bones. For each bone affected by the animation
|
||||
* a separate series of data is given.
|
||||
*/
|
||||
struct aiAnimation
|
||||
{
|
||||
/** The name of the animation. If the modelling package this data was exported from does support
|
||||
* only a single animation channel, this name is usually empty (length is zero).
|
||||
*/
|
||||
aiString mName;
|
||||
|
||||
/** Duration of the animation in ticks. */
|
||||
double mDuration;
|
||||
/** Ticks per second. 0 if not specified in the imported file */
|
||||
double mTicksPerSecond;
|
||||
|
||||
/** The number of bone animation channels. Each channel affects a single bone. */
|
||||
unsigned int mNumBones;
|
||||
/** The bone animation channels. Each channel affects a single bone. The array
|
||||
* is mNumBones in size.
|
||||
*/
|
||||
aiBoneAnim** mBones;
|
||||
|
||||
#ifdef __cplusplus
|
||||
aiAnimation()
|
||||
{
|
||||
mDuration = 0;
|
||||
mTicksPerSecond = 0;
|
||||
mNumBones = 0; mBones = NULL;
|
||||
}
|
||||
|
||||
~aiAnimation()
|
||||
{
|
||||
for( unsigned int a = 0; a < mNumBones; a++)
|
||||
delete mBones[a];
|
||||
delete [] mBones;
|
||||
}
|
||||
#endif // __cplusplus
|
||||
};
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif // AI_ANIM_H_INC
|
||||
28
include/aiAssert.h
Normal file
28
include/aiAssert.h
Normal file
@@ -0,0 +1,28 @@
|
||||
#ifndef AI_DEBUG_H_INC
|
||||
#define AI_DEBUG_H_INC
|
||||
|
||||
#include <string>
|
||||
|
||||
#ifndef __cplusplus
|
||||
#error This header requires C++ to be used.
|
||||
#endif
|
||||
|
||||
namespace Assimp {
|
||||
|
||||
//! \brief ASSIMP specific assertion test, just works in debug mode
|
||||
//! \param uiLine Line in file
|
||||
//! \param file Source file
|
||||
void aiAssert (bool expression, const std::string &message, unsigned int uiLine, const std::string &file);
|
||||
|
||||
|
||||
//! \def ai_assert
|
||||
//! \brief ASSIM specific assertion test
|
||||
#ifdef DEBUG
|
||||
# define ai_assert(expression) aiAssert (expression, #expression, __LINE__, __FILE__);
|
||||
#else
|
||||
# define ai_assert(expression)
|
||||
#endif
|
||||
|
||||
} // Namespace Assimp
|
||||
|
||||
#endif
|
||||
23
include/aiDefs.h
Normal file
23
include/aiDefs.h
Normal file
@@ -0,0 +1,23 @@
|
||||
|
||||
|
||||
/** @file Helper macros for the library
|
||||
*/
|
||||
#ifndef AI_DEF_H_INC
|
||||
#define AI_DEF_H_INC
|
||||
|
||||
|
||||
/** Namespace helper macros for c++ compilers
|
||||
*/
|
||||
#ifdef __cplusplus
|
||||
#define AI_NAMESPACE_START namespace Assimp {
|
||||
#define AI_NAMESPACE_END };
|
||||
#else
|
||||
#define AI_NAMESPACE_START
|
||||
#define AI_NAMESPACE_END
|
||||
#endif
|
||||
|
||||
#ifdef _DEBUG
|
||||
# define ASSIMP_DEBUG
|
||||
#endif
|
||||
|
||||
#endif //!!AI_DEF_H_INC
|
||||
63
include/aiFileIO.h
Normal file
63
include/aiFileIO.h
Normal file
@@ -0,0 +1,63 @@
|
||||
|
||||
/** @file Defines generic routines to access memory-mapped files
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef AI_FILEIO_H_INC
|
||||
#define AI_FILEIO_H_INC
|
||||
|
||||
#include "aiTypes.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
|
||||
struct aiFileIO;
|
||||
//enum aiOrigin;
|
||||
typedef aiFileIO (*aiFileOpenProc)(aiFileIO*, const char*, const char*);
|
||||
typedef aiReturn (*aiFileCloseProc)(aiFileIO*);
|
||||
typedef unsigned long (*aiFileReadWriteProc)(aiFileIO*, char*, unsigned int, unsigned int);
|
||||
typedef unsigned long (*aiFileTellProc)(aiFileIO*);
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
/** Define seek origins in fseek()-style.
|
||||
*/
|
||||
// ---------------------------------------------------------------------------
|
||||
enum aiOrigin
|
||||
{
|
||||
aiOrigin_SET = 0x0, //!< Set position
|
||||
aiOrigin_CUR = 0x1, //!< Current position
|
||||
aiOrigin_END = 0x2 //!< End of file
|
||||
};
|
||||
|
||||
typedef aiReturn (*aiFileSeek)(aiFileIO*, unsigned long, aiOrigin);
|
||||
|
||||
typedef char* aiUserData;
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
/** Data structure to wrap a set of fXXXX (e.g fopen) replacement functions
|
||||
*
|
||||
* The functions behave the same way as their appropriate fXXXX
|
||||
* counterparts in the CRT.
|
||||
*/
|
||||
// ---------------------------------------------------------------------------
|
||||
struct aiFileIO
|
||||
{
|
||||
aiUserData UserData;
|
||||
|
||||
aiFileOpenProc OpenFunc;
|
||||
aiFileCloseProc CloseFunc;
|
||||
aiFileReadWriteProc ReadFunc;
|
||||
aiFileReadWriteProc WriteFunc;
|
||||
aiFileTellProc TellProc;
|
||||
aiFileSeek SeekProc;
|
||||
};
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
#endif // AI_FILEIO_H_INC
|
||||
476
include/aiMaterial.h
Normal file
476
include/aiMaterial.h
Normal file
@@ -0,0 +1,476 @@
|
||||
|
||||
|
||||
/** @file Defines the material system of the library
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef AI_MATERIAL_H_INC
|
||||
#define AI_MATERIAL_H_INC
|
||||
|
||||
#include "aiTypes.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
/** Defines type identifiers for use within the material system.
|
||||
*
|
||||
*/
|
||||
// ---------------------------------------------------------------------------
|
||||
enum aiPropertyTypeInfo
|
||||
{
|
||||
/** Array of single-precision floats
|
||||
*/
|
||||
aiPTI_Float = 0x1,
|
||||
|
||||
|
||||
/** aiString data structure
|
||||
*/
|
||||
aiPTI_String = 0x3,
|
||||
|
||||
|
||||
/** Array of Integers
|
||||
*/
|
||||
aiPTI_Integer = 0x4,
|
||||
|
||||
|
||||
/** Simple binary buffer
|
||||
*/
|
||||
aiPTI_Buffer = 0x5,
|
||||
};
|
||||
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
/** Defines algorithms for generating UVW-coords (for texture sampling)
|
||||
* procedurally.
|
||||
*/
|
||||
// ---------------------------------------------------------------------------
|
||||
enum aiTexUVWGen
|
||||
{
|
||||
/** The view vector will be reflected to a pixel's normal.
|
||||
*
|
||||
* The result is used as UVW-coordinate for
|
||||
* accessing a cubemap
|
||||
*/
|
||||
aiTexUVWGen_VIEWREFLEFT = 0x800001,
|
||||
|
||||
|
||||
/** The view vector will be used as UVW-src
|
||||
*
|
||||
* The view vector is used as UVW-coordinate for
|
||||
* accessing a cubemap
|
||||
*/
|
||||
aiTexUVWGen_VIEW = 0x800002,
|
||||
|
||||
|
||||
/** The view vector will be refracted to the pixel's normal.
|
||||
*
|
||||
* If this is used, the refraction index to be applied should
|
||||
* also be contained in the material description.
|
||||
* The result is used as UVW-coordinate for
|
||||
* accessing a cubemap.
|
||||
*/
|
||||
aiTexUVWGen_VIEWREFRACT = 0x800003
|
||||
};
|
||||
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
/** Defines all shading models supported by the library
|
||||
*
|
||||
* @note The list of shading modes has been taken from Blender3D.
|
||||
* See Blender3D documentation for more information. The API does
|
||||
* not distinguish between "specular" and "diffuse" shaders (thus the
|
||||
* specular term for diffuse shading models like Oren-Nayar remains
|
||||
* undefined)
|
||||
*/
|
||||
// ---------------------------------------------------------------------------
|
||||
enum aiShadingMode
|
||||
{
|
||||
/** Flat shading. Shading is done on per-face base,
|
||||
* diffuse only.
|
||||
*/
|
||||
aiShadingMode_Flat = 0x1,
|
||||
|
||||
|
||||
/** Diffuse gouraud shading. Shading on per-vertex base
|
||||
*/
|
||||
aiShadingMode_Gouraud = 0x2,
|
||||
|
||||
|
||||
/** Diffuse/Specular Phong-Shading
|
||||
*
|
||||
* Shading is applied on per-pixel base. This is the
|
||||
* slowest algorithm, but generates the best results.
|
||||
*/
|
||||
aiShadingMode_Phong = 0x3,
|
||||
|
||||
|
||||
/** Diffuse/Specular Phong-Blinn-Shading
|
||||
*
|
||||
* Shading is applied on per-pixel base. This is a little
|
||||
* bit faster than phong and in some cases even
|
||||
* more realistic
|
||||
*/
|
||||
aiShadingMode_Blinn = 0x4,
|
||||
|
||||
|
||||
/** Toon-Shading per pixel
|
||||
*
|
||||
* Shading is applied on per-pixel base. The output looks
|
||||
* like a comic. Often combined with edge detection.
|
||||
*/
|
||||
aiShadingMode_Toon = 0x5,
|
||||
|
||||
|
||||
/** OrenNayar-Shading per pixel
|
||||
*
|
||||
* Extension to standard lambertian shading, taking the
|
||||
* roughness of the material into account
|
||||
*
|
||||
*/
|
||||
aiShadingMode_OrenNayar = 0x6,
|
||||
|
||||
|
||||
/** Minnaert-Shading per pixel
|
||||
*
|
||||
* Extension to standard lambertian shading, taking the
|
||||
* "darkness" of the material into account
|
||||
*/
|
||||
aiShadingMode_Minnaert = 0x7,
|
||||
|
||||
|
||||
/** CookTorrance-Shading per pixel
|
||||
*/
|
||||
aiShadingMode_CookTorrance = 0x8,
|
||||
|
||||
|
||||
/** No shading at all
|
||||
*/
|
||||
aiShadingMode_NoShading = 0x8
|
||||
};
|
||||
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
/** Data structure for a single property inside a material
|
||||
*
|
||||
* @see aiMaterial
|
||||
*/
|
||||
// ---------------------------------------------------------------------------
|
||||
struct aiMaterialProperty
|
||||
{
|
||||
/** Specifies the name of the property (key)
|
||||
*
|
||||
* Keys are case insensitive.
|
||||
*/
|
||||
aiString* mKey;
|
||||
|
||||
|
||||
/** Size of the buffer mData is pointing to, in bytes
|
||||
*/
|
||||
unsigned int mDataLength;
|
||||
|
||||
|
||||
/** Type information for the property.
|
||||
*
|
||||
* Defines the data layout inside the
|
||||
* data buffer. This is used by the library
|
||||
* internally to perform debug checks.
|
||||
*/
|
||||
aiPropertyTypeInfo mType;
|
||||
|
||||
|
||||
/** Binary buffer to hold the property's value
|
||||
*
|
||||
* The buffer has no terminal character. However,
|
||||
* if a string is stored inside it may use 0 as terminal,
|
||||
* but it would be contained in mDataLength.
|
||||
*/
|
||||
char* mData;
|
||||
};
|
||||
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
/** Data structure for a material
|
||||
*
|
||||
* Material data is stored using a key-value structure, called property
|
||||
* (to guarant that the system is maximally flexible).
|
||||
* The library defines a set of standard keys, which should be enough
|
||||
* for nearly all purposes.
|
||||
*/
|
||||
// ---------------------------------------------------------------------------
|
||||
#ifdef __cplusplus
|
||||
class aiMaterial
|
||||
{
|
||||
protected:
|
||||
aiMaterial() {}
|
||||
public:
|
||||
#else
|
||||
struct aiMaterial
|
||||
{
|
||||
#endif // __cplusplus
|
||||
/** List of all material properties loaded.
|
||||
*/
|
||||
aiMaterialProperty** mProperties;
|
||||
|
||||
/** Number of properties loaded
|
||||
*/
|
||||
unsigned int mNumProperties;
|
||||
unsigned int mNumAllocated;
|
||||
};
|
||||
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
/** @def AI_MATKEY_NAME
|
||||
* Defines the name of the material (aiString)
|
||||
*/
|
||||
#define AI_MATKEY_NAME "$mat.name"
|
||||
|
||||
/** @def AI_MATKEY_SHADING_MODE
|
||||
* Defines the shading model to use (aiShadingMode)
|
||||
*/
|
||||
#define AI_MATKEY_SHADING_MODEL "$mat.shadingm"
|
||||
|
||||
/** @def AI_MATKEY_OPACITY
|
||||
* Defines the base opacity of the material
|
||||
*/
|
||||
#define AI_MATKEY_OPACITY "$mat.opacity"
|
||||
|
||||
/** @def AI_MATKEY_BUMPSCALING
|
||||
* Defines the height scaling of a bump map (for stuff like Parallax
|
||||
* Occlusion Mapping)
|
||||
*/
|
||||
#define AI_MATKEY_BUMPSCALING "$mat.bumpscaling"
|
||||
|
||||
/** @def AI_MATKEY_SHININESS
|
||||
* Defines the base shininess of the material
|
||||
*/
|
||||
#define AI_MATKEY_SHININESS "$mat.shininess"
|
||||
|
||||
/** @def AI_MATKEY_COLOR_DIFFUSE
|
||||
* Defines the diffuse base color of the material
|
||||
*/
|
||||
#define AI_MATKEY_COLOR_DIFFUSE "$clr.diffuse"
|
||||
|
||||
/** @def AI_MATKEY_COLOR_AMBIENT
|
||||
* Defines the ambient base color of the material
|
||||
*/
|
||||
#define AI_MATKEY_COLOR_AMBIENT "$clr.ambient"
|
||||
|
||||
/** @def AI_MATKEY_COLOR_SPECULAR
|
||||
* Defines the specular base color of the material
|
||||
*/
|
||||
#define AI_MATKEY_COLOR_SPECULAR "$clr.specular"
|
||||
|
||||
/** @def AI_MATKEY_COLOR_EMISSIVE
|
||||
* Defines the emissive base color of the material
|
||||
*/
|
||||
#define AI_MATKEY_COLOR_EMISSIVE "$clr.emissive"
|
||||
|
||||
/** @def AI_MATKEY_TEXTURE_DIFFUSE
|
||||
* Defines a specified diffuse texture channel of the material
|
||||
*/
|
||||
#define AI_MATKEY_TEXTURE_DIFFUSE(N) "$tex.file.diffuse["#N"]"
|
||||
#define AI_MATKEY_TEXTURE_DIFFUSE_ "$tex.file.diffuse"
|
||||
|
||||
/** @def AI_MATKEY_TEXTURE_AMBIENT
|
||||
* Defines a specified ambient texture channel of the material
|
||||
*/
|
||||
#define AI_MATKEY_TEXTURE_AMBIENT(N) "$tex.file.ambient["#N"]"
|
||||
#define AI_MATKEY_TEXTURE_AMBIENT_ "$tex.file.ambient"
|
||||
|
||||
/** @def AI_MATKEY_TEXTURE_SPECULAR
|
||||
* Defines a specified specular texture channel of the material
|
||||
*/
|
||||
#define AI_MATKEY_TEXTURE_SPECULAR(N) "$tex.file.specular["#N"]"
|
||||
#define AI_MATKEY_TEXTURE_SPECULAR_ "$tex.file.specular"
|
||||
|
||||
/** @def AI_MATKEY_TEXTURE_EMISSIVE
|
||||
* Defines a specified emissive texture channel of the material
|
||||
*/
|
||||
#define AI_MATKEY_TEXTURE_EMISSIVE(N) "$tex.file.emissive["#N"]"
|
||||
#define AI_MATKEY_TEXTURE_EMISSIVE_ "$tex.file.emissive"
|
||||
|
||||
/** @def AI_MATKEY_TEXTURE_NORMALS
|
||||
* Defines a specified normal texture channel of the material
|
||||
*/
|
||||
#define AI_MATKEY_TEXTURE_NORMALS(N) "$tex.file.normals["#N"]"
|
||||
#define AI_MATKEY_TEXTURE_NORMALS_ "$tex.file.normals"
|
||||
|
||||
/** @def AI_MATKEY_TEXTURE_BUMP
|
||||
* Defines a specified bumpmap texture (=heightmap) channel of the material
|
||||
* This is very similar to #AI_MATKEY_TEXTURE_NORMALS. It is provided
|
||||
* to allow applications to determine whether the input data for
|
||||
* normal mapping is already a normal map or needs to be converted to
|
||||
* a heightmap.
|
||||
*/
|
||||
#define AI_MATKEY_TEXTURE_BUMP(N) "$tex.file.bump["#N"]"
|
||||
#define AI_MATKEY_TEXTURE_BUMP_ "$tex.file.bump"
|
||||
|
||||
/** @def AI_MATKEY_TEXTURE_SHININESS
|
||||
* Defines a specified shininess texture channel of the material
|
||||
*/
|
||||
#define AI_MATKEY_TEXTURE_SHININESS(N) "$tex.file.shininess["#N"]"
|
||||
#define AI_MATKEY_TEXTURE_SHININESS_ "$tex.file.shininess"
|
||||
|
||||
/** @def AI_MATKEY_TEXTURE_OPACITY
|
||||
* Defines a specified opacity texture channel of the material
|
||||
*/
|
||||
#define AI_MATKEY_TEXTURE_OPACITY(N) "$tex.file.opacity["#N"]"
|
||||
#define AI_MATKEY_TEXTURE_OPACITY_ "$tex.file.opacity"
|
||||
|
||||
|
||||
#define AI_MATKEY_TEXOP_DIFFUSE(N) "$tex.op.diffuse["#N"]"
|
||||
#define AI_MATKEY_TEXOP_AMBIENT(N) "$tex.op.ambient["#N"]"
|
||||
#define AI_MATKEY_TEXOP_SPECULAR(N) "$tex.op.specular["#N"]"
|
||||
#define AI_MATKEY_TEXOP_EMISSIVE(N) "$tex.op.emissive["#N"]"
|
||||
#define AI_MATKEY_TEXOP_NORMALS(N) "$tex.op.normals["#N"]"
|
||||
#define AI_MATKEY_TEXOP_BUMP(N) "$tex.op.bump["#N"]"
|
||||
#define AI_MATKEY_TEXOP_SHININESS(N) "$tex.op.shininess["#N"]"
|
||||
#define AI_MATKEY_TEXOP_OPACITY(N) "$tex.op.opacity["#N"]"
|
||||
|
||||
#define AI_MATKEY_UVWSRC_DIFFUSE(N) "$tex.uvw.diffuse["#N"]"
|
||||
#define AI_MATKEY_UVWSRC_AMBIENT(N) "$tex.uvw.ambient["#N"]"
|
||||
#define AI_MATKEY_UVWSRC_SPECULAR(N) "$tex.uvw.specular["#N"]"
|
||||
#define AI_MATKEY_UVWSRC_EMISSIVE(N) "$tex.uvw.emissive["#N"]"
|
||||
#define AI_MATKEY_UVWSRC_NORMALS(N) "$tex.uvw.normals["#N"]"
|
||||
#define AI_MATKEY_UVWSRC_BUMP(N) "$tex.uvw.bump["#N"]"
|
||||
#define AI_MATKEY_UVWSRC_SHININESS(N) "$tex.uvw.shininess["#N"]"
|
||||
#define AI_MATKEY_UVWSRC_OPACITY(N) "$tex.uvw.opacity["#N"]"
|
||||
|
||||
#define AI_MATKEY_REFRACTI_DIFFUSE(N) "$tex.refracti.diffuse["#N"]"
|
||||
#define AI_MATKEY_REFRACTI_AMBIENT(N) "$tex.refracti.ambient["#N"]"
|
||||
#define AI_MATKEY_REFRACTI_SPECULAR(N) "$tex.refracti.specular["#N"]"
|
||||
#define AI_MATKEY_REFRACTI_EMISSIVE(N) "$tex.refracti.emissive["#N"]"
|
||||
#define AI_MATKEY_REFRACTI_NORMALS(N) "$tex.refracti.normals["#N"]"
|
||||
#define AI_MATKEY_REFRACTI_BUMP(N) "$tex.refracti.bump["#N"]"
|
||||
#define AI_MATKEY_REFRACTI_SHININESS(N) "$tex.refracti.shininess["#N"]"
|
||||
#define AI_MATKEY_REFRACTI_OPACITY(N) "$tex.refracti.opacity["#N"]"
|
||||
|
||||
#define AI_MATKEY_TEXBLEND_DIFFUSE(N) "$tex.blend.diffuse["#N"]"
|
||||
#define AI_MATKEY_TEXBLEND_AMBIENT(N) "$tex.blend.ambient["#N"]"
|
||||
#define AI_MATKEY_TEXBLEND_SPECULAR(N) "$tex.blend.specular["#N"]"
|
||||
#define AI_MATKEY_TEXBLEND_EMISSIVE(N) "$tex.blend.emissive["#N"]"
|
||||
#define AI_MATKEY_TEXBLEND_NORMALS(N) "$tex.blend.normals["#N"]"
|
||||
#define AI_MATKEY_TEXBLEND_BUMP(N) "$tex.blend.bump["#N"]"
|
||||
#define AI_MATKEY_TEXBLEND_SHININESS(N) "$tex.blend.shininess["#N"]"
|
||||
#define AI_MATKEY_TEXBLEND_OPACITY(N) "$tex.blend.opacity["#N"]"
|
||||
|
||||
|
||||
#define AI_MATKEY_ORENNAYAR_ROUGHNESS "$shading.orennayar.roughness"
|
||||
#define AI_MATKEY_MINNAERT_DARKNESS "$shading.minnaert.darkness"
|
||||
#define AI_MATKEY_COOK_TORRANCE_REFRACTI "$shading.cookt.refracti"
|
||||
#define AI_MATKEY_COOK_TORRANCE_PARAM "$shading.cookt.param"
|
||||
|
||||
|
||||
/** @def AI_MATKEY_GLOBAL_BACKGROUND_IMAGE
|
||||
* Global property defined by some loaders. Contains the path to
|
||||
* the image file to be used as background image.
|
||||
*/
|
||||
#define AI_MATKEY_GLOBAL_BACKGROUND_IMAGE "$global.bg.image2d"
|
||||
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
/** Retrieve a material property with a specific key from the material
|
||||
*
|
||||
* @param pMat Pointer to the input material. May not be NULL
|
||||
* @param pKey Key to search for. One of the AI_MATKEY_XXX constants.
|
||||
* @param pPropOut Pointer to receive a pointer to a valid aiMaterialProperty
|
||||
* structure or NULL if the key has not been found.
|
||||
*/
|
||||
// ---------------------------------------------------------------------------
|
||||
aiReturn aiGetMaterialProperty(const aiMaterial* pMat,
|
||||
const char* pKey,
|
||||
const aiMaterialProperty** pPropOut);
|
||||
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
/** Retrieve an array of float values with a specific key
|
||||
* from the material
|
||||
*
|
||||
* @param pMat Pointer to the input material. May not be NULL
|
||||
* @param pKey Key to search for. One of the AI_MATKEY_XXX constants.
|
||||
* @param pOut Pointer to a buffer to receive the result.
|
||||
* @param pMax Specifies the size of the given buffer, in float's.
|
||||
* Receives the number of values (not bytes!) read.
|
||||
*/
|
||||
// ---------------------------------------------------------------------------
|
||||
aiReturn aiGetMaterialFloatArray(const aiMaterial* pMat,
|
||||
const char* pKey,
|
||||
float* pOut,
|
||||
unsigned int* pMax);
|
||||
|
||||
#ifdef __cplusplus
|
||||
// inline it
|
||||
inline aiReturn aiGetMaterialFloat(const aiMaterial* pMat,
|
||||
const char* pKey,
|
||||
float* pOut)
|
||||
{return aiGetMaterialFloatArray(pMat,pKey,pOut,(unsigned int*)0x0);}
|
||||
#else
|
||||
// use our friend, the C preprocessor
|
||||
#define aiGetMaterialFloat (pMat, pKey, pOut) \
|
||||
aiGetMaterialFloatArray(pMat, pKey, pOut, NULL)
|
||||
#endif //!__cplusplus
|
||||
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
/** Retrieve an array of integer values with a specific key
|
||||
* from the material
|
||||
*
|
||||
* @param pMat Pointer to the input material. May not be NULL
|
||||
* @param pKey Key to search for. One of the AI_MATKEY_XXX constants.
|
||||
* @param pOut Pointer to a buffer to receive the result.
|
||||
* @param pMax Specifies the size of the given buffer, in int's.
|
||||
* Receives the number of values (not bytes!) read.
|
||||
*/
|
||||
// ---------------------------------------------------------------------------
|
||||
aiReturn aiGetMaterialIntegerArray(const aiMaterial* pMat,
|
||||
const char* pKey,
|
||||
int* pOut,
|
||||
unsigned int* pMax);
|
||||
|
||||
#ifdef __cplusplus
|
||||
// inline it
|
||||
inline aiReturn aiGetMaterialInteger(const aiMaterial* pMat,
|
||||
const char* pKey,
|
||||
int* pOut)
|
||||
{return aiGetMaterialIntegerArray(pMat,pKey,pOut,(unsigned int*)0x0);}
|
||||
#else
|
||||
// use our friend, the C preprocessor
|
||||
#define aiGetMaterialInteger (pMat, pKey, pOut) \
|
||||
aiGetMaterialIntegerArray(pMat, pKey, pOut, NULL)
|
||||
#endif //!__cplusplus
|
||||
|
||||
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
/** Retrieve a color value from the material property table
|
||||
*
|
||||
* @param pMat Pointer to the input material. May not be NULL
|
||||
* @param pKey Key to search for. One of the AI_MATKEY_XXX constants.
|
||||
* @param pOut Pointer to a buffer to receive the result.
|
||||
*/
|
||||
// ---------------------------------------------------------------------------
|
||||
aiReturn aiGetMaterialColor(const aiMaterial* pMat,
|
||||
const char* pKey,
|
||||
aiColor4D* pOut);
|
||||
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
/** Retrieve a string from the material property table
|
||||
*
|
||||
* @param pMat Pointer to the input material. May not be NULL
|
||||
* @param pKey Key to search for. One of the AI_MATKEY_XXX constants.
|
||||
* @param pOut Pointer to a buffer to receive the result.
|
||||
*/
|
||||
// ---------------------------------------------------------------------------
|
||||
aiReturn aiGetMaterialString(const aiMaterial* pMat,
|
||||
const char* pKey,
|
||||
aiString* pOut);
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif //!__cplusplus
|
||||
|
||||
#endif //!!AI_MATERIAL_H_INC
|
||||
50
include/aiMatrix3x3.h
Normal file
50
include/aiMatrix3x3.h
Normal file
@@ -0,0 +1,50 @@
|
||||
/** @file Definition of a 3x3 matrix, including operators when compiling in C++ */
|
||||
#ifndef AI_MATRIX3x3_H_INC
|
||||
#define AI_MATRIX3x3_H_INC
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
struct aiMatrix4x4;
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
/** Represents a column-major 3x3 matrix
|
||||
*/
|
||||
// ---------------------------------------------------------------------------
|
||||
typedef struct aiMatrix3x3
|
||||
{
|
||||
#ifdef __cplusplus
|
||||
aiMatrix3x3 () :
|
||||
a1(1.0f), a2(0.0f), a3(0.0f),
|
||||
b1(0.0f), b2(1.0f), b3(0.0f),
|
||||
c1(0.0f), c2(0.0f), c3(1.0f) {}
|
||||
|
||||
aiMatrix3x3 ( float _a1, float _a2, float _a3,
|
||||
float _b1, float _b2, float _b3,
|
||||
float _c1, float _c2, float _c3) :
|
||||
a1(_a1), a2(_a2), a3(_a3),
|
||||
b1(_b1), b2(_b2), b3(_b3),
|
||||
c1(_c1), c2(_c2), c3(_c3)
|
||||
{}
|
||||
|
||||
/** Construction from a 4x4 matrix. The remaining parts of the matrix are ignored. */
|
||||
explicit aiMatrix3x3( const aiMatrix4x4& pMatrix);
|
||||
|
||||
aiMatrix3x3& operator *= (const aiMatrix3x3& m);
|
||||
aiMatrix3x3 operator* (const aiMatrix3x3& m) const;
|
||||
aiMatrix3x3& Transpose();
|
||||
|
||||
#endif // __cplusplus
|
||||
|
||||
|
||||
float a1, a2, a3;
|
||||
float b1, b2, b3;
|
||||
float c1, c2, c3;
|
||||
} aiMatrix3x3_t;
|
||||
|
||||
#ifdef __cplusplus
|
||||
} // end of extern C
|
||||
#endif
|
||||
|
||||
#endif // AI_MATRIX3x3_H_INC
|
||||
54
include/aiMatrix3x3.inl
Normal file
54
include/aiMatrix3x3.inl
Normal file
@@ -0,0 +1,54 @@
|
||||
/** @file Inline implementation of the 3x3 matrix operators */
|
||||
#ifndef AI_MATRIX3x3_INL_INC
|
||||
#define AI_MATRIX3x3_INL_INC
|
||||
|
||||
#include "aiMatrix3x3.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
#include "aiMatrix4x4.h"
|
||||
#include <algorithm>
|
||||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
// Construction from a 4x4 matrix. The remaining parts of the matrix are ignored.
|
||||
inline aiMatrix3x3::aiMatrix3x3( const aiMatrix4x4& pMatrix)
|
||||
{
|
||||
a1 = pMatrix.a1; a2 = pMatrix.a2; a3 = pMatrix.a3;
|
||||
b1 = pMatrix.b1; b2 = pMatrix.b2; b3 = pMatrix.b3;
|
||||
c1 = pMatrix.c1; c2 = pMatrix.c2; c3 = pMatrix.c3;
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
inline aiMatrix3x3& aiMatrix3x3::operator *= (const aiMatrix3x3& m)
|
||||
{
|
||||
*this = aiMatrix3x3(
|
||||
m.a1 * a1 + m.b1 * a2 + m.c1 * a3,
|
||||
m.a2 * a1 + m.b2 * a2 + m.c2 * a3,
|
||||
m.a3 * a1 + m.b3 * a2 + m.c3 * a3,
|
||||
m.a1 * b1 + m.b1 * b2 + m.c1 * b3,
|
||||
m.a2 * b1 + m.b2 * b2 + m.c2 * b3,
|
||||
m.a3 * b1 + m.b3 * b2 + m.c3 * b3,
|
||||
m.a1 * c1 + m.b1 * c2 + m.c1 * c3,
|
||||
m.a2 * c1 + m.b2 * c2 + m.c2 * c3,
|
||||
m.a3 * c1 + m.b3 * c2 + m.c3 * c3);
|
||||
return *this;
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
inline aiMatrix3x3 aiMatrix3x3::operator* (const aiMatrix3x3& m) const
|
||||
{
|
||||
aiMatrix3x3 temp( *this);
|
||||
temp *= m;
|
||||
return temp;
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
inline aiMatrix3x3& aiMatrix3x3::Transpose()
|
||||
{
|
||||
std::swap( a2, b1);
|
||||
std::swap( a3, c1);
|
||||
std::swap( b3, c2);
|
||||
}
|
||||
|
||||
|
||||
#endif // __cplusplus
|
||||
#endif // AI_MATRIX3x3_INL_INC
|
||||
77
include/aiMatrix4x4.h
Normal file
77
include/aiMatrix4x4.h
Normal file
@@ -0,0 +1,77 @@
|
||||
/** @file 4x4 matrix structure, including operators when compiling in C++ */
|
||||
#ifndef AI_MATRIX4X4_H_INC
|
||||
#define AI_MATRIX4X4_H_INC
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
struct aiMatrix3x3;
|
||||
|
||||
// Set packing to 4
|
||||
#if defined(_MSC_VER) || defined(__BORLANDC__) || defined (__BCPLUSPLUS__)
|
||||
#pragma pack(push,4)
|
||||
#define PACK_STRUCT
|
||||
#elif defined( __GNUC__ )
|
||||
#define PACK_STRUCT __attribute__((packed))
|
||||
#else
|
||||
#error Compiler not supported
|
||||
#endif
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
/** Represents a column-major 4x4 matrix,
|
||||
* use this for homogenious coordinates
|
||||
*/
|
||||
// ---------------------------------------------------------------------------
|
||||
typedef struct aiMatrix4x4
|
||||
{
|
||||
#ifdef __cplusplus
|
||||
aiMatrix4x4 () :
|
||||
a1(1.0f), a2(0.0f), a3(0.0f), a4(0.0f),
|
||||
b1(0.0f), b2(1.0f), b3(0.0f), b4(0.0f),
|
||||
c1(0.0f), c2(0.0f), c3(1.0f), c4(0.0f),
|
||||
d1(0.0f), d2(0.0f), d3(0.0f), d4(1.0f){}
|
||||
|
||||
aiMatrix4x4 ( float _a1, float _a2, float _a3, float _a4,
|
||||
float _b1, float _b2, float _b3, float _b4,
|
||||
float _c1, float _c2, float _c3, float _c4,
|
||||
float _d1, float _d2, float _d3, float _d4) :
|
||||
a1(_a1), a2(_a2), a3(_a3), a4(_a4),
|
||||
b1(_b1), b2(_b2), b3(_b3), b4(_b4),
|
||||
c1(_c1), c2(_c2), c3(_c3), c4(_c4),
|
||||
d1(_d1), d2(_d2), d3(_d3), d4(_d4)
|
||||
{}
|
||||
|
||||
/** Constructor from 3x3 matrix. The remaining elements are set to identity. */
|
||||
explicit aiMatrix4x4( const aiMatrix3x3& m);
|
||||
|
||||
aiMatrix4x4& operator *= (const aiMatrix4x4& m);
|
||||
aiMatrix4x4 operator* (const aiMatrix4x4& m) const;
|
||||
aiMatrix4x4& Transpose();
|
||||
aiMatrix4x4& Inverse();
|
||||
float Determinant() const;
|
||||
|
||||
float* operator[](unsigned int p_iIndex);
|
||||
const float* operator[](unsigned int p_iIndex) const;
|
||||
#endif // __cplusplus
|
||||
|
||||
float a1, a2, a3, a4;
|
||||
float b1, b2, b3, b4;
|
||||
float c1, c2, c3, c4;
|
||||
float d1, d2, d3, d4;
|
||||
|
||||
} PACK_STRUCT aiMatrix4x4_t;
|
||||
|
||||
|
||||
// Reset packing
|
||||
#if defined(_MSC_VER) || defined(__BORLANDC__) || defined (__BCPLUSPLUS__)
|
||||
#pragma pack( pop )
|
||||
#endif
|
||||
#undef PACK_STRUCT
|
||||
|
||||
#ifdef __cplusplus
|
||||
} // end extern "C"
|
||||
|
||||
|
||||
#endif // __cplusplus
|
||||
#endif // AI_MATRIX4X4_H_INC
|
||||
136
include/aiMatrix4x4.inl
Normal file
136
include/aiMatrix4x4.inl
Normal file
@@ -0,0 +1,136 @@
|
||||
/** @file Inline implementation of the 4x4 matrix operators */
|
||||
#ifndef AI_MATRIX4x4_INL_INC
|
||||
#define AI_MATRIX4x4_INL_INC
|
||||
|
||||
#include "aiMatrix4x4.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
#include "aiMatrix3x3.h"
|
||||
|
||||
#include <algorithm>
|
||||
#include <limits>
|
||||
#include <math.h>
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
inline aiMatrix4x4::aiMatrix4x4( const aiMatrix3x3& m)
|
||||
{
|
||||
a1 = m.a1; a2 = m.a2; a3 = m.a3; a4 = 0.0f;
|
||||
b1 = m.b1; b2 = m.b2; b3 = m.b3; b4 = 0.0f;
|
||||
c1 = m.c1; c2 = m.c2; c3 = m.c3; c4 = 0.0f;
|
||||
d1 = 0.0f; d2 = 0.0f; d3 = 0.0f; d4 = 1.0f;
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
inline aiMatrix4x4& aiMatrix4x4::operator *= (const aiMatrix4x4& m)
|
||||
{
|
||||
*this = aiMatrix4x4(
|
||||
m.a1 * a1 + m.b1 * a2 + m.c1 * a3 + m.d1 * a4,
|
||||
m.a2 * a1 + m.b2 * a2 + m.c2 * a3 + m.d2 * a4,
|
||||
m.a3 * a1 + m.b3 * a2 + m.c3 * a3 + m.d3 * a4,
|
||||
m.a4 * a1 + m.b4 * a2 + m.c4 * a3 + m.d4 * a4,
|
||||
m.a1 * b1 + m.b1 * b2 + m.c1 * b3 + m.d1 * b4,
|
||||
m.a2 * b1 + m.b2 * b2 + m.c2 * b3 + m.d2 * b4,
|
||||
m.a3 * b1 + m.b3 * b2 + m.c3 * b3 + m.d3 * b4,
|
||||
m.a4 * b1 + m.b4 * b2 + m.c4 * b3 + m.d4 * b4,
|
||||
m.a1 * c1 + m.b1 * c2 + m.c1 * c3 + m.d1 * c4,
|
||||
m.a2 * c1 + m.b2 * c2 + m.c2 * c3 + m.d2 * c4,
|
||||
m.a3 * c1 + m.b3 * c2 + m.c3 * c3 + m.d3 * c4,
|
||||
m.a4 * c1 + m.b4 * c2 + m.c4 * c3 + m.d4 * c4,
|
||||
m.a1 * d1 + m.b1 * d2 + m.c1 * d3 + m.d1 * d4,
|
||||
m.a2 * d1 + m.b2 * d2 + m.c2 * d3 + m.d2 * d4,
|
||||
m.a3 * d1 + m.b3 * d2 + m.c3 * d3 + m.d3 * d4,
|
||||
m.a4 * d1 + m.b4 * d2 + m.c4 * d3 + m.d4 * d4);
|
||||
return *this;
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
inline aiMatrix4x4 aiMatrix4x4::operator* (const aiMatrix4x4& m) const
|
||||
{
|
||||
aiMatrix4x4 temp( *this);
|
||||
temp *= m;
|
||||
return temp;
|
||||
}
|
||||
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
inline aiMatrix4x4& aiMatrix4x4::Transpose()
|
||||
{
|
||||
std::swap( (float&)b1, (float&)a2);
|
||||
std::swap( (float&)c1, (float&)a3);
|
||||
std::swap( (float&)c2, (float&)b3);
|
||||
std::swap( (float&)d1, (float&)a4);
|
||||
std::swap( (float&)d2, (float&)b4);
|
||||
std::swap( (float&)d3, (float&)c4);
|
||||
return *this;
|
||||
}
|
||||
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
inline float aiMatrix4x4::Determinant() const
|
||||
{
|
||||
return a1*b2*c3*d4 - a1*b2*c4*d3 + a1*b3*c4*d2 - a1*b3*c2*d4
|
||||
+ a1*b4*c2*d3 - a1*b4*c3*d2 - a2*b3*c4*d1 + a2*b3*c1*d4
|
||||
- a2*b4*c1*d3 + a2*b4*c3*d1 - a2*b1*c3*d4 + a2*b1*c4*d3
|
||||
+ a3*b4*c1*d2 - a3*b4*c2*d1 + a3*b1*c2*d4 - a3*b1*c4*d2
|
||||
+ a3*b2*c4*d1 - a3*b2*c1*d4 - a4*b1*c2*d3 + a4*b1*c3*d2
|
||||
- a4*b2*c3*d1 + a4*b2*c1*d3 - a4*b3*c1*d2 + a4*b3*c2*d1;
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
inline aiMatrix4x4& aiMatrix4x4::Inverse()
|
||||
{
|
||||
// Compute the reciprocal determinant
|
||||
float det = Determinant();
|
||||
if(det == 0.0f)
|
||||
{
|
||||
*this = aiMatrix4x4(
|
||||
std::numeric_limits<float>::quiet_NaN(),std::numeric_limits<float>::quiet_NaN(),
|
||||
std::numeric_limits<float>::quiet_NaN(),std::numeric_limits<float>::quiet_NaN(),
|
||||
std::numeric_limits<float>::quiet_NaN(),std::numeric_limits<float>::quiet_NaN(),
|
||||
std::numeric_limits<float>::quiet_NaN(),std::numeric_limits<float>::quiet_NaN(),
|
||||
std::numeric_limits<float>::quiet_NaN(),std::numeric_limits<float>::quiet_NaN(),
|
||||
std::numeric_limits<float>::quiet_NaN(),std::numeric_limits<float>::quiet_NaN(),
|
||||
std::numeric_limits<float>::quiet_NaN(),std::numeric_limits<float>::quiet_NaN(),
|
||||
std::numeric_limits<float>::quiet_NaN(),std::numeric_limits<float>::quiet_NaN());
|
||||
return *this;
|
||||
}
|
||||
|
||||
float invdet = 1.0f / det;
|
||||
|
||||
aiMatrix4x4 res;
|
||||
res.a1 = invdet * (b2 * (c3 * d4 - c4 * d3) + b3 * (c4 * d2 - c2 * d4) + b4 * (c2 * d3 - c3 * d2));
|
||||
res.a2 = -invdet * (a2 * (c3 * d4 - c4 * d3) + a3 * (c4 * d2 - c2 * d4) + a4 * (c2 * d3 - c3 * d2));
|
||||
res.a3 = invdet * (a2 * (b3 * d4 - b4 * d3) + a3 * (b4 * d2 - b2 * d4) + a4 * (b2 * d3 - b3 * d2));
|
||||
res.a4 = -invdet * (a2 * (b3 * c4 - b4 * c3) + a3 * (b4 * c2 - b2 * c4) + a4 * (b2 * c3 - b3 * c2));
|
||||
res.b1 = -invdet * (b1 * (c3 * d4 - c4 * d3) + b3 * (c4 * d1 - c1 * d4) + b4 * (c1 * d3 - c3 * d1));
|
||||
res.b2 = invdet * (a1 * (c3 * d4 - c4 * d3) + a3 * (c4 * d1 - c1 * d4) + a4 * (c1 * d3 - c3 * d1));
|
||||
res.b3 = -invdet * (a1 * (b3 * d4 - b4 * d3) + a3 * (b4 * d1 - b1 * d4) + a4 * (b1 * d3 - b3 * d1));
|
||||
res.b4 = invdet * (a1 * (b3 * c4 - b4 * c3) + a3 * (b4 * c1 - b1 * c4) + a4 * (b1 * c3 - b3 * c1));
|
||||
res.c1 = invdet * (b1 * (c2 * d4 - c4 * d2) + b2 * (c4 * d1 - c1 * d4) + b4 * (c1 * d2 - c2 * d1));
|
||||
res.c2 = -invdet * (a1 * (c2 * d4 - c4 * d2) + a2 * (c4 * d1 - c1 * d4) + a4 * (c1 * d2 - c2 * d1));
|
||||
res.c3 = invdet * (a1 * (b2 * d4 - b4 * d2) + a2 * (b4 * d1 - b1 * d4) + a4 * (b1 * d2 - b2 * d1));
|
||||
res.c4 = -invdet * (a1 * (b2 * c4 - b4 * c2) + a2 * (b4 * c1 - b1 * c4) + a4 * (b1 * c2 - b2 * c1));
|
||||
res.d1 = -invdet * (b1 * (c2 * d3 - c3 * d2) + b2 * (c3 * d1 - c1 * d3) + b3 * (c1 * d2 - c2 * d1));
|
||||
res.d2 = invdet * (a1 * (c2 * d3 - c3 * d2) + a2 * (c3 * d1 - c1 * d3) + a3 * (c1 * d2 - c2 * d1));
|
||||
res.d3 = -invdet * (a1 * (b2 * d3 - b3 * d2) + a2 * (b3 * d1 - b1 * d3) + a3 * (b1 * d2 - b2 * d1));
|
||||
res.d4 = invdet * (a1 * (b2 * c3 - b3 * c2) + a2 * (b3 * c1 - b1 * c3) + a3 * (b1 * c2 - b2 * c1));
|
||||
*this = res;
|
||||
|
||||
return *this;
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
inline float* aiMatrix4x4::operator[](unsigned int p_iIndex)
|
||||
{
|
||||
return &this->a1 + p_iIndex * 4;
|
||||
}
|
||||
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
inline const float* aiMatrix4x4::operator[](unsigned int p_iIndex) const
|
||||
{
|
||||
return &this->a1 + p_iIndex * 4;
|
||||
}
|
||||
|
||||
#endif // __cplusplus
|
||||
#endif // AI_MATRIX4x4_INL_INC
|
||||
268
include/aiMesh.h
Normal file
268
include/aiMesh.h
Normal file
@@ -0,0 +1,268 @@
|
||||
/** @file Defines the data structures in which the imported geometry is returned. */
|
||||
#ifndef AI_MESH_H_INC
|
||||
#define AI_MESH_H_INC
|
||||
|
||||
#include "aiTypes.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
/** A single face in a mesh, referring to multiple vertices.
|
||||
* If mNumIndices is 3, the face is a triangle, for mNumIndices > 3 it's a polygon.
|
||||
*/
|
||||
// ---------------------------------------------------------------------------
|
||||
struct aiFace
|
||||
{
|
||||
unsigned int mNumIndices; ///< Number of indices defining this face. 3 for a triangle, >3 for polygon
|
||||
unsigned int* mIndices; ///< Pointer to the indices array. Size of the array is given in numIndices.
|
||||
|
||||
#ifdef __cplusplus
|
||||
aiFace()
|
||||
{
|
||||
mNumIndices = 0; mIndices = NULL;
|
||||
}
|
||||
|
||||
~aiFace()
|
||||
{
|
||||
delete [] mIndices;
|
||||
}
|
||||
|
||||
aiFace( const aiFace& o)
|
||||
{
|
||||
mIndices = NULL;
|
||||
*this = o;
|
||||
}
|
||||
|
||||
const aiFace& operator = ( const aiFace& o)
|
||||
{
|
||||
if (&o == this)
|
||||
return *this;
|
||||
|
||||
delete mIndices;
|
||||
mNumIndices = o.mNumIndices;
|
||||
mIndices = new unsigned int[mNumIndices];
|
||||
memcpy( mIndices, o.mIndices, mNumIndices * sizeof( unsigned int));
|
||||
return *this;
|
||||
}
|
||||
|
||||
#endif // __cplusplus
|
||||
};
|
||||
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
/** A single influence of a bone on a vertex. */
|
||||
// ---------------------------------------------------------------------------
|
||||
struct aiVertexWeight
|
||||
{
|
||||
unsigned int mVertexId; ///< Index of the vertex which is influenced by the bone.
|
||||
float mWeight; ///< The strength of the influence in the range (0...1). The influence from all bones at one vertex amounts to 1.
|
||||
|
||||
#ifdef __cplusplus
|
||||
aiVertexWeight() { }
|
||||
aiVertexWeight( unsigned int pID, float pWeight) : mVertexId( pID), mWeight( pWeight) { }
|
||||
#endif // __cplusplus
|
||||
};
|
||||
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
/** A single bone of a mesh. A bone has a name by which it can be found
|
||||
* in the frame hierarchy and by which it can be addressed by animations.
|
||||
* In addition it has a number of influences on vertices.
|
||||
*/
|
||||
// ---------------------------------------------------------------------------
|
||||
struct aiBone
|
||||
{
|
||||
aiString mName; ///< The name of the bone.
|
||||
unsigned int mNumWeights; ///< The number of vertices affected by this bone
|
||||
aiVertexWeight* mWeights; ///< The vertices affected by this bone
|
||||
aiMatrix4x4 mOffsetMatrix; ///< Matrix that transforms from mesh space to bone space in bind pose
|
||||
|
||||
#ifdef __cplusplus
|
||||
aiBone()
|
||||
{
|
||||
mNumWeights = 0; mWeights = NULL;
|
||||
}
|
||||
|
||||
~aiBone()
|
||||
{
|
||||
delete [] mWeights;
|
||||
}
|
||||
#endif // __cplusplus
|
||||
};
|
||||
|
||||
|
||||
/** Maximum number of vertex color sets per mesh.
|
||||
*
|
||||
* Diffuse, specular, ambient and emissive
|
||||
*/
|
||||
#define AI_MAX_NUMBER_OF_COLOR_SETS 0x4
|
||||
|
||||
|
||||
/** Maximum number of texture coord sets (UV channels) per mesh
|
||||
*/
|
||||
#define AI_MAX_NUMBER_OF_TEXTURECOORDS 0x4
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
/** A mesh represents a geometry or model with a single material.
|
||||
*
|
||||
* It usually consists of a number of vertices and a series of primitives/faces
|
||||
* referencing the vertices. In addition there might be a series of bones, each
|
||||
* of them addressing a number of vertices with a certain weight. Vertex data is
|
||||
* presented in channels with each channel containing a single per-vertex
|
||||
* information such as a set of texture coords or a normal vector.
|
||||
* If a data pointer is non-null, the corresponding data stream is present.
|
||||
* From C++-programs you can also use the comfort functions Has*() to
|
||||
* test for the presence of various data streams.
|
||||
*
|
||||
* A Mesh uses only a single material which is referenced by a material ID.
|
||||
*/
|
||||
struct aiMesh
|
||||
{
|
||||
/** The number of vertices in this mesh.
|
||||
* This is also the size of all of the per-vertex data arrays
|
||||
*/
|
||||
unsigned int mNumVertices;
|
||||
|
||||
/** The number of primitives (triangles, polygones, lines) in this mesh.
|
||||
* This is also the size of the mFaces array
|
||||
*/
|
||||
unsigned int mNumFaces;
|
||||
|
||||
/** Vertex positions.
|
||||
* This array is always present in a mesh. The array is
|
||||
* mNumVertices in size.
|
||||
*/
|
||||
aiVector3D_t* mVertices;
|
||||
|
||||
/** Vertex normals.
|
||||
* The array contains normalized vectors, NULL if not present.
|
||||
* The array is mNumVertices in size.
|
||||
*/
|
||||
aiVector3D_t* mNormals;
|
||||
|
||||
/** Vertex tangents.
|
||||
* The tangent of a vertex points in the direction of the positive
|
||||
* X texture axis. The array contains normalized vectors, NULL if
|
||||
* not present. The array is mNumVertices in size.
|
||||
* @note If the mesh contains tangents, it automatically also
|
||||
* contains bitangents.
|
||||
*/
|
||||
aiVector3D_t* mTangents;
|
||||
|
||||
/** Vertex bitangents.
|
||||
* The bitangent of a vertex points in the direction of the positive
|
||||
* Y texture axis. The array contains normalized vectors, NULL if not
|
||||
* present. The array is mNumVertices in size.
|
||||
* @note If the mesh contains tangents, it automatically also contains
|
||||
* bitangents.
|
||||
*/
|
||||
aiVector3D_t* mBitangents;
|
||||
|
||||
/** Vertex color sets.
|
||||
* A mesh may contain 0 to #AI_MAX_NUMBER_OF_COLOR_SETS vertex
|
||||
* colors per vertex. NULL if not present. Each array is
|
||||
* mNumVertices in size if present.
|
||||
*/
|
||||
aiColor4D_t* mColors[AI_MAX_NUMBER_OF_COLOR_SETS];
|
||||
|
||||
/** Vertex texture coords, also known as UV channels.
|
||||
* A mesh may contain 0 to AI_MAX_NUMBER_OF_TEXTURECOORDS per
|
||||
* vertex. NULL if not present. The array is mNumVertices in size.
|
||||
*/
|
||||
aiVector3D_t* mTextureCoords[AI_MAX_NUMBER_OF_TEXTURECOORDS];
|
||||
|
||||
/** Specifies the number of components for a given UV channel.
|
||||
* Up to three channels are supported (UVW, for accessing volume
|
||||
* or cube maps). If the value is 2 for a given channel n, the
|
||||
* component p.z of mTextureCoords[n][p] is set to 0.0f.
|
||||
* If the value is 1 for a given channel, p.y is set to 0.0f, too.
|
||||
* @note 4D coords are not supported
|
||||
*/
|
||||
unsigned int mNumUVComponents[AI_MAX_NUMBER_OF_TEXTURECOORDS];
|
||||
|
||||
/** The faces the mesh is contstructed from.
|
||||
* Each face referres to a number of vertices by their indices.
|
||||
* This array is always present in a mesh, its size is given
|
||||
* in mNumFaces.
|
||||
*/
|
||||
aiFace* mFaces;
|
||||
|
||||
/** The number of bones this mesh contains.
|
||||
* Can be 0, in which case the mBones array is NULL.
|
||||
*/
|
||||
unsigned int mNumBones;
|
||||
|
||||
/** The bones of this mesh.
|
||||
* A bone consists of a name by which it can be found in the
|
||||
* frame hierarchy and a set of vertex weights.
|
||||
*/
|
||||
aiBone** mBones;
|
||||
|
||||
/** The material used by this mesh.
|
||||
* A mesh does use only a single material. If an imported model uses multiple materials,
|
||||
* the import splits up the mesh. Use this value as index into the scene's material list.
|
||||
*/
|
||||
unsigned int mMaterialIndex;
|
||||
|
||||
#ifdef __cplusplus
|
||||
aiMesh()
|
||||
{
|
||||
mNumVertices = 0; mNumFaces = 0;
|
||||
mVertices = NULL; mFaces = NULL;
|
||||
mNormals = NULL; mTangents = NULL;
|
||||
mBitangents = NULL;
|
||||
for( unsigned int a = 0; a < AI_MAX_NUMBER_OF_TEXTURECOORDS; a++)
|
||||
{
|
||||
mNumUVComponents[a] = 0;
|
||||
mTextureCoords[a] = NULL;
|
||||
}
|
||||
for( unsigned int a = 0; a < AI_MAX_NUMBER_OF_COLOR_SETS; a++)
|
||||
mColors[a] = NULL;
|
||||
mNumBones = 0; mBones = NULL;
|
||||
mMaterialIndex = 0;
|
||||
}
|
||||
|
||||
~aiMesh()
|
||||
{
|
||||
delete [] mVertices;
|
||||
delete [] mFaces;
|
||||
delete [] mNormals;
|
||||
delete [] mTangents;
|
||||
delete [] mBitangents;
|
||||
for( unsigned int a = 0; a < AI_MAX_NUMBER_OF_TEXTURECOORDS; a++)
|
||||
delete [] mTextureCoords[a];
|
||||
for( unsigned int a = 0; a < AI_MAX_NUMBER_OF_COLOR_SETS; a++)
|
||||
delete [] mColors[a];
|
||||
for( unsigned int a = 0; a < mNumBones; a++)
|
||||
delete mBones[a];
|
||||
delete [] mBones;
|
||||
}
|
||||
|
||||
bool HasNormals() const { return mNormals != NULL; }
|
||||
bool HasTangentsAndBitangents() const { return mTangents != NULL && mBitangents != NULL; }
|
||||
bool HasVertexColors( unsigned int pIndex)
|
||||
{
|
||||
if( pIndex >= AI_MAX_NUMBER_OF_COLOR_SETS)
|
||||
return false;
|
||||
else
|
||||
return mColors[pIndex] != NULL;
|
||||
}
|
||||
bool HasTextureCoords( unsigned int pIndex)
|
||||
{
|
||||
if( pIndex > AI_MAX_NUMBER_OF_TEXTURECOORDS)
|
||||
return false;
|
||||
else
|
||||
return mTextureCoords[pIndex] != NULL;
|
||||
}
|
||||
bool HasBones() const { return mBones != NULL; }
|
||||
|
||||
#endif // __cplusplus
|
||||
};
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif // AI_MESH_H_INC
|
||||
78
include/aiPostProcess.h
Normal file
78
include/aiPostProcess.h
Normal file
@@ -0,0 +1,78 @@
|
||||
/** @file Definitions for import post processing steps */
|
||||
#ifndef AI_POSTPROCESS_H_INC
|
||||
#define AI_POSTPROCESS_H_INC
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/** Defines the flags for all possible post processing steps. */
|
||||
enum aiPostProcessSteps
|
||||
{
|
||||
/** Calculates the binormals and tangents for the imported meshes. Does nothing
|
||||
* if a mesh does not have normals. You might want this post processing step to be
|
||||
* executed if you plan to use tangent space calculations such as normal mapping
|
||||
* applied to the meshes.
|
||||
*/
|
||||
aiProcess_CalcTangentSpace = 1,
|
||||
|
||||
/** Identifies and joins identical vertex data sets within all imported meshes.
|
||||
* After this step is run each mesh does contain only unique vertices anymore,
|
||||
* so a vertex is possibly used by multiple faces. You propably always want
|
||||
* to use this post processing step.*/
|
||||
aiProcess_JoinIdenticalVertices = 2,
|
||||
|
||||
/** Converts all the imported data to a left-handed coordinate space such as
|
||||
* the DirectX coordinate system. By default the data is returned in a right-handed
|
||||
* coordinate space which for example OpenGL preferres. In this space, +X points to the
|
||||
* right, +Y points upwards and +Z points to the viewer. In the DirectX coordinate space
|
||||
* +X points to the right, +Y points upwards and +Z points away from the viewer
|
||||
* into the screen.
|
||||
*/
|
||||
aiProcess_ConvertToLeftHanded = 4,
|
||||
|
||||
/** Triangulates all faces of all meshes. By default the imported mesh data might
|
||||
* contain faces with more than 3 indices. For rendering a mesh you usually need
|
||||
* all faces to be triangles. This post processing step splits up all higher faces
|
||||
* to triangles.
|
||||
*/
|
||||
aiProcess_Triangulate = 8,
|
||||
|
||||
|
||||
/** Omits all normals found in the file. This can be used together
|
||||
* with either the aiProcess_GenNormals or the aiProcess_GenSmoothNormals
|
||||
* flag to force the recomputation of the normals.
|
||||
*/
|
||||
aiProcess_KillNormals = 0x10,
|
||||
|
||||
|
||||
/** Generates normals for all faces of all meshes. The normals are shared
|
||||
* between the three vertices of a face. This is ignored
|
||||
* if normals are already existing. This flag may not be specified together
|
||||
* with aiProcess_GenSmoothNormals
|
||||
*/
|
||||
aiProcess_GenNormals = 0x20,
|
||||
|
||||
|
||||
/** Generates smooth normals for all vertices in the mesh. This is ignored
|
||||
* if normals are already existing. This flag may not be specified together
|
||||
* with aiProcess_GenNormals
|
||||
*/
|
||||
aiProcess_GenSmoothNormals = 0x40,
|
||||
|
||||
|
||||
/** Splits large meshes into submeshes
|
||||
* This is quite useful for realtime rendering where the number of vertices
|
||||
* is usually limited by the video driver.
|
||||
*
|
||||
* A mesh is split if it consists of more than 1 * 10^6 vertices. This is defined
|
||||
* in the internal SplitLargeMeshes.h header as AI_SLM_MAX_VERTICES.
|
||||
*/
|
||||
aiProcess_SplitLargeMeshes = 0x80
|
||||
};
|
||||
|
||||
#ifdef __cplusplus
|
||||
} // end of extern "C"
|
||||
#endif
|
||||
|
||||
#endif // AI_POSTPROCESS_H_INC
|
||||
96
include/aiQuaternion.h
Normal file
96
include/aiQuaternion.h
Normal file
@@ -0,0 +1,96 @@
|
||||
/** @file Quaternion structure, including operators when compiling in C++ */
|
||||
#ifndef AI_QUATERNION_H_INC
|
||||
#define AI_QUATERNION_H_INC
|
||||
|
||||
#include <math.h>
|
||||
#include "aiTypes.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
/** Represents a quaternion in a 4D vector. */
|
||||
typedef struct aiQuaternion
|
||||
{
|
||||
#ifdef __cplusplus
|
||||
aiQuaternion() : w(0.0f), x(0.0f), y(0.0f), z(0.0f) {}
|
||||
aiQuaternion(float _w, float _x, float _y, float _z) : w(_w), x(_x), y(_y), z(_z) {}
|
||||
/** Construct from rotation matrix. Result is undefined if the matrix is not orthonormal. */
|
||||
aiQuaternion( const aiMatrix3x3& pRotMatrix);
|
||||
|
||||
/** Returns a matrix representation of the quaternion */
|
||||
aiMatrix3x3 GetMatrix() const;
|
||||
#endif // __cplusplus
|
||||
|
||||
float w, x, y, z;
|
||||
} aiQuaternion_t;
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
// Constructs a quaternion from a rotation matrix
|
||||
inline aiQuaternion::aiQuaternion( const aiMatrix3x3 &pRotMatrix)
|
||||
{
|
||||
float t = 1 + pRotMatrix.a1 + pRotMatrix.b2 + pRotMatrix.c3;
|
||||
|
||||
// large enough
|
||||
if( t > 0.00001f)
|
||||
{
|
||||
float s = sqrt( t) * 2.0f;
|
||||
x = (pRotMatrix.b3 - pRotMatrix.c2) / s;
|
||||
y = (pRotMatrix.c1 - pRotMatrix.a3) / s;
|
||||
z = (pRotMatrix.a2 - pRotMatrix.b1) / s;
|
||||
w = 0.25f * s;
|
||||
} // else we have to check several cases
|
||||
else if( pRotMatrix.a1 > pRotMatrix.b2 && pRotMatrix.a1 > pRotMatrix.c3 )
|
||||
{
|
||||
// Column 0:
|
||||
float s = sqrt( 1.0f + pRotMatrix.a1 - pRotMatrix.b2 - pRotMatrix.c3) * 2.0f;
|
||||
x = 0.25f * s;
|
||||
y = (pRotMatrix.a2 + pRotMatrix.b1) / s;
|
||||
z = (pRotMatrix.c1 + pRotMatrix.a3) / s;
|
||||
w = (pRotMatrix.b3 - pRotMatrix.c2) / s;
|
||||
} else
|
||||
if( pRotMatrix.b2 > pRotMatrix.c3)
|
||||
{
|
||||
// Column 1:
|
||||
float s = sqrt( 1.0f + pRotMatrix.b2 - pRotMatrix.a1 - pRotMatrix.c3) * 2.0f;
|
||||
x = (pRotMatrix.a2 + pRotMatrix.b1) / s;
|
||||
y = 0.25f * s;
|
||||
z = (pRotMatrix.b3 + pRotMatrix.c2) / s;
|
||||
w = (pRotMatrix.c1 - pRotMatrix.a3) / s;
|
||||
} else
|
||||
{
|
||||
// Column 2:
|
||||
float s = sqrt( 1.0f + pRotMatrix.c3 - pRotMatrix.a1 - pRotMatrix.b2) * 2.0f;
|
||||
x = (pRotMatrix.c1 + pRotMatrix.a3) / s;
|
||||
y = (pRotMatrix.b3 + pRotMatrix.c2) / s;
|
||||
z = 0.25f * s;
|
||||
w = (pRotMatrix.a2 - pRotMatrix.b1) / s;
|
||||
}
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
// Returns a matrix representation of the quaternion
|
||||
inline aiMatrix3x3 aiQuaternion::GetMatrix() const
|
||||
{
|
||||
aiMatrix3x3 resMatrix;
|
||||
resMatrix.a1 = 1.0f - 2.0f * (y * y + z * z);
|
||||
resMatrix.a2 = 2.0f * (x * y + z * w);
|
||||
resMatrix.a3 = 2.0f * (x * z - y * w);
|
||||
resMatrix.b1 = 2.0f * (x * y - z * w);
|
||||
resMatrix.b2 = 1.0f - 2.0f * (x * x + z * z);
|
||||
resMatrix.b3 = 2.0f * (y * z + x * w);
|
||||
resMatrix.c1 = 2.0f * (x * z + y * w);
|
||||
resMatrix.c2 = 2.0f * (y * z - x * w);
|
||||
resMatrix.c3 = 1.0f - 2.0f * (x * x + y * y);
|
||||
|
||||
return resMatrix;
|
||||
}
|
||||
|
||||
} // end extern "C"
|
||||
#endif // __cplusplus
|
||||
|
||||
#endif // AI_QUATERNION_H_INC
|
||||
147
include/aiScene.h
Normal file
147
include/aiScene.h
Normal file
@@ -0,0 +1,147 @@
|
||||
/** @file Defines the data structures in which the imported scene is returned. */
|
||||
#ifndef AI_SCENE_H_INC
|
||||
#define AI_SCENE_H_INC
|
||||
|
||||
#include "aiTypes.h"
|
||||
#include "aiMesh.h"
|
||||
#include "aiMaterial.h"
|
||||
#include "aiAnim.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
/** A node in the imported hierarchy.
|
||||
*
|
||||
* Each node has name, a parent node (except for the root node),
|
||||
* a transformation relative to its parent and possibly several child nodes.
|
||||
* Simple file formats don't support hierarchical structures, for these formats
|
||||
* the imported scene does consist of only a single root node with no childs.
|
||||
*/
|
||||
// ---------------------------------------------------------------------------
|
||||
struct aiNode
|
||||
{
|
||||
/** The name of the node.
|
||||
*
|
||||
* The name might be empty (length of zero) but all nodes which
|
||||
* need to be accessed afterwards by bones or anims are usually named.
|
||||
*/
|
||||
aiString mName;
|
||||
|
||||
/** The transformation relative to the node's parent. */
|
||||
aiMatrix4x4 mTransformation;
|
||||
|
||||
/** Parent node. NULL if this node is the root node. */
|
||||
aiNode* mParent;
|
||||
|
||||
/** The number of child nodes of this node. */
|
||||
unsigned int mNumChildren;
|
||||
/** The child nodes of this node. NULL if mNumChildren is 0. */
|
||||
|
||||
aiNode** mChildren;
|
||||
|
||||
/** The number of meshes of this node. */
|
||||
unsigned int mNumMeshes;
|
||||
|
||||
/** The meshes of this node. Each entry is an index into the mesh */
|
||||
unsigned int* mMeshes;
|
||||
|
||||
#ifdef __cplusplus
|
||||
/** Constructor */
|
||||
aiNode()
|
||||
{
|
||||
mParent = NULL;
|
||||
mNumChildren = 0; mChildren = NULL;
|
||||
mNumMeshes = 0; mMeshes = NULL;
|
||||
}
|
||||
|
||||
/** Destructor */
|
||||
~aiNode()
|
||||
{
|
||||
for( unsigned int a = 0; a < mNumChildren; a++)
|
||||
delete mChildren[a];
|
||||
delete [] mChildren;
|
||||
delete [] mMeshes;
|
||||
}
|
||||
#endif // __cplusplus
|
||||
};
|
||||
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
/** The root structure of the imported data.
|
||||
*
|
||||
* Everything that was imported from the given file can be accessed from here.
|
||||
*/
|
||||
// ---------------------------------------------------------------------------
|
||||
struct aiScene
|
||||
{
|
||||
/** The root node of the hierarchy.
|
||||
*
|
||||
* There will always be at least the root node if the import
|
||||
* was successful. Presence of further nodes depends on the
|
||||
* format and content of the imported file.
|
||||
*/
|
||||
aiNode* mRootNode;
|
||||
|
||||
/** The number of meshes in the scene. */
|
||||
unsigned int mNumMeshes;
|
||||
|
||||
/** The array of meshes.
|
||||
*
|
||||
* Use the indices given in the aiNode structure to access
|
||||
* this array. The array is mNumMeshes in size.
|
||||
*/
|
||||
aiMesh** mMeshes;
|
||||
|
||||
/** The number of materials in the scene. */
|
||||
unsigned int mNumMaterials;
|
||||
|
||||
/** The array of materials.
|
||||
*
|
||||
* Use the index given in each aiMesh structure to access this
|
||||
* array. The array is mNumMaterials in size.
|
||||
*/
|
||||
aiMaterial** mMaterials;
|
||||
|
||||
/** The number of animations in the scene. */
|
||||
unsigned int mNumAnimations;
|
||||
|
||||
/** The array of animations.
|
||||
*
|
||||
* All animations imported from the given file are listed here.
|
||||
* The array is mNumAnimations in size.
|
||||
*/
|
||||
aiAnimation** mAnimations;
|
||||
|
||||
#ifdef __cplusplus
|
||||
aiScene()
|
||||
{
|
||||
mRootNode = NULL;
|
||||
mNumMeshes = 0; mMeshes = NULL;
|
||||
mNumMaterials = 0; mMaterials = NULL;
|
||||
mNumAnimations = 0; mAnimations = NULL;
|
||||
}
|
||||
|
||||
~aiScene()
|
||||
{
|
||||
delete mRootNode;
|
||||
for( unsigned int a = 0; a < mNumMeshes; a++)
|
||||
delete mMeshes[a];
|
||||
delete [] mMeshes;
|
||||
for( unsigned int a = 0; a < mNumMaterials; a++)
|
||||
delete mMaterials[a];
|
||||
delete [] mMaterials;
|
||||
for( unsigned int a = 0; a < mNumAnimations; a++)
|
||||
delete mAnimations[a];
|
||||
delete [] mAnimations;
|
||||
}
|
||||
#endif // __cplusplus
|
||||
};
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif // AI_SCENE_H_INC
|
||||
140
include/aiTypes.h
Normal file
140
include/aiTypes.h
Normal file
@@ -0,0 +1,140 @@
|
||||
#ifndef AI_TYPES_H_INC
|
||||
#define AI_TYPES_H_INC
|
||||
|
||||
#include <sys/types.h>
|
||||
#include <memory.h>
|
||||
|
||||
#if (defined _MSC_VER)
|
||||
# include "Compiler/VisualStudio/stdint.h"
|
||||
#endif // (defined _MSC_VER)
|
||||
|
||||
#include "aiVector3D.h"
|
||||
#include "aiMatrix3x3.h"
|
||||
#include "aiMatrix4x4.h"
|
||||
#include "aiVector3D.inl"
|
||||
#include "aiMatrix3x3.inl"
|
||||
#include "aiMatrix4x4.inl"
|
||||
|
||||
#ifdef __cplusplus
|
||||
#include <string>
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/** Maximum dimension for strings, ASSIMP strings are zero terminated */
|
||||
const size_t MAXLEN = 1024;
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
/** Represents a two-dimensional vector.
|
||||
*/
|
||||
// ---------------------------------------------------------------------------
|
||||
typedef struct aiVector2D
|
||||
{
|
||||
#ifdef __cplusplus
|
||||
aiVector2D () : x(0.0f), y(0.0f) {}
|
||||
aiVector2D (float _x, float _y) : x(_x), y(_y) {}
|
||||
aiVector2D (const aiVector2D& o) : x(o.x), y(o.y) {}
|
||||
|
||||
#endif // __cplusplus
|
||||
|
||||
float x, y;
|
||||
} aiVector2D_t;
|
||||
|
||||
// aiVector3D type moved to separate header due to size of operators
|
||||
|
||||
// aiQuaternion type moved to separate header due to size of operators
|
||||
|
||||
// aiMatrix4x4 type moved to separate header due to size of operators
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
/** Represents a color in Red-Green-Blue space.
|
||||
*/
|
||||
// ---------------------------------------------------------------------------
|
||||
typedef struct aiColor3D
|
||||
{
|
||||
#ifdef __cplusplus
|
||||
aiColor3D () : r(0.0f), g(0.0f), b(0.0f) {}
|
||||
aiColor3D (float _r, float _g, float _b) : r(_r), g(_g), b(_b) {}
|
||||
aiColor3D (const aiColor3D& o) : r(o.r), g(o.g), b(o.b) {}
|
||||
|
||||
#endif // __cplusplus
|
||||
|
||||
float r, g, b;
|
||||
} aiColor3D_t;
|
||||
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
/** Represents a color in Red-Green-Blue space including an
|
||||
* alpha component.
|
||||
*/
|
||||
// ---------------------------------------------------------------------------
|
||||
typedef struct aiColor4D
|
||||
{
|
||||
#ifdef __cplusplus
|
||||
aiColor4D () : r(0.0f), g(0.0f), b(0.0f), a(0.0f) {}
|
||||
aiColor4D (float _r, float _g, float _b, float _a)
|
||||
: r(_r), g(_g), b(_b), a(_a) {}
|
||||
aiColor4D (const aiColor4D& o)
|
||||
: r(o.r), g(o.g), b(o.b), a(o.a) {}
|
||||
|
||||
#endif // __cplusplus
|
||||
|
||||
float r, g, b, a;
|
||||
} aiColor4D_t;
|
||||
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
/** Represents a string, zero byte terminated
|
||||
*/
|
||||
// ---------------------------------------------------------------------------
|
||||
typedef struct aiString
|
||||
{
|
||||
#ifdef __cplusplus
|
||||
inline aiString() :
|
||||
length(0)
|
||||
{
|
||||
// empty
|
||||
}
|
||||
|
||||
inline aiString(const aiString& rOther) :
|
||||
length(rOther.length)
|
||||
{
|
||||
memcpy( data, rOther.data, rOther.length);
|
||||
this->data[this->length] = '\0';
|
||||
}
|
||||
|
||||
void Set( const std::string& pString)
|
||||
{
|
||||
if( pString.length() > MAXLEN - 1)
|
||||
return;
|
||||
length = pString.length();
|
||||
memcpy( data, pString.c_str(), length);
|
||||
data[length] = 0;
|
||||
}
|
||||
#endif // __cplusplus
|
||||
|
||||
size_t length;
|
||||
char data[MAXLEN];
|
||||
} aiString_t;
|
||||
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
/** Standard return type for all library functions.
|
||||
*
|
||||
* To check whether a function failed or not check against
|
||||
* AI_SUCCESS.
|
||||
*/
|
||||
// ---------------------------------------------------------------------------
|
||||
enum aiReturn
|
||||
{
|
||||
AI_SUCCESS = 0x0,
|
||||
AI_FAILURE = -0x1,
|
||||
AI_INVALIDFILE = -0x2,
|
||||
AI_OUTOFMEMORY = -0x3,
|
||||
AI_INVALIDARG = -0x4
|
||||
};
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
#endif
|
||||
|
||||
99
include/aiVector3D.h
Normal file
99
include/aiVector3D.h
Normal file
@@ -0,0 +1,99 @@
|
||||
/** @file 3D vector structure, including operators when compiling in C++ */
|
||||
#ifndef AI_VECTOR3D_H_INC
|
||||
#define AI_VECTOR3D_H_INC
|
||||
|
||||
#include <math.h>
|
||||
|
||||
#include "aiAssert.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
/** Represents a three-dimensional vector. */
|
||||
typedef struct aiVector3D
|
||||
{
|
||||
#ifdef __cplusplus
|
||||
aiVector3D () : x(0.0f), y(0.0f), z(0.0f) {}
|
||||
aiVector3D (float _x, float _y, float _z) : x(_x), y(_y), z(_z) {}
|
||||
aiVector3D (const aiVector3D& o) : x(o.x), y(o.y), z(o.z) {}
|
||||
|
||||
void Set( float pX, float pY, float pZ) { x = pX; y = pY; z = pZ; }
|
||||
float SquareLength() const { return x*x + y*y + z*z; }
|
||||
float Length() const { return sqrt( SquareLength()); }
|
||||
aiVector3D& Normalize() { *this /= Length(); return *this; }
|
||||
const aiVector3D& operator += (const aiVector3D& o) { x += o.x; y += o.y; z += o.z; return *this; }
|
||||
const aiVector3D& operator -= (const aiVector3D& o) { x -= o.x; y -= o.y; z -= o.z; return *this; }
|
||||
const aiVector3D& operator *= (float f) { x *= f; y *= f; z *= f; return *this; }
|
||||
const aiVector3D& operator /= (float f) { x /= f; y /= f; z /= f; return *this; }
|
||||
|
||||
inline float operator[](unsigned int i) const {return *(&x + i);}
|
||||
inline float& operator[](unsigned int i) {return *(&x + i);}
|
||||
#endif // __cplusplus
|
||||
|
||||
float x, y, z;
|
||||
} aiVector3D_t;
|
||||
|
||||
#ifdef __cplusplus
|
||||
} // end extern "C"
|
||||
|
||||
// symmetric addition
|
||||
inline aiVector3D operator + (const aiVector3D& v1, const aiVector3D& v2)
|
||||
{
|
||||
return aiVector3D( v1.x + v2.x, v1.y + v2.y, v1.z + v2.z);
|
||||
}
|
||||
|
||||
// symmetric subtraction
|
||||
inline aiVector3D operator - (const aiVector3D& v1, const aiVector3D& v2)
|
||||
{
|
||||
return aiVector3D( v1.x - v2.x, v1.y - v2.y, v1.z - v2.z);
|
||||
}
|
||||
|
||||
// scalar product
|
||||
inline float operator * (const aiVector3D& v1, const aiVector3D& v2)
|
||||
{
|
||||
return v1.x*v2.x + v1.y*v2.y + v1.z*v2.z;
|
||||
}
|
||||
|
||||
// scalar multiplication
|
||||
inline aiVector3D operator * ( float f, const aiVector3D& v)
|
||||
{
|
||||
return aiVector3D( f*v.x, f*v.y, f*v.z);
|
||||
}
|
||||
|
||||
// and the other way around
|
||||
inline aiVector3D operator * ( const aiVector3D& v, float f)
|
||||
{
|
||||
return aiVector3D( f*v.x, f*v.y, f*v.z);
|
||||
}
|
||||
|
||||
// scalar division
|
||||
inline aiVector3D operator / ( const aiVector3D& v, float f)
|
||||
{
|
||||
//ai_assert(0.0f != f);
|
||||
return v * (1/f);
|
||||
}
|
||||
|
||||
// vector division
|
||||
inline aiVector3D operator / ( const aiVector3D& v, const aiVector3D& v2)
|
||||
{
|
||||
//ai_assert(0.0f != v2.x && 0.0f != v2.y && 0.0f != v2.z);
|
||||
return aiVector3D(v.x / v2.x,v.y / v2.y,v.z / v2.z);
|
||||
}
|
||||
|
||||
// cross product
|
||||
inline aiVector3D operator ^ ( const aiVector3D& v1, const aiVector3D& v2)
|
||||
{
|
||||
return aiVector3D( v1.y*v2.z - v1.z*v2.y, v1.z*v2.x - v1.x*v2.z, v1.x*v2.y - v1.y*v2.x);
|
||||
}
|
||||
|
||||
// vector inversion
|
||||
inline aiVector3D operator - ( const aiVector3D& v)
|
||||
{
|
||||
return aiVector3D( -v.x, -v.y, -v.z);
|
||||
}
|
||||
|
||||
#endif // __cplusplus
|
||||
|
||||
#endif // AI_VECTOR3D_H_INC
|
||||
33
include/aiVector3D.inl
Normal file
33
include/aiVector3D.inl
Normal file
@@ -0,0 +1,33 @@
|
||||
/** @file Inline implementation of vector3D operators */
|
||||
#ifndef AI_VECTOR3D_INL_INC
|
||||
#define AI_VECTOR3D_INL_INC
|
||||
|
||||
#include "aiVector3D.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
#include "aiMatrix3x3.h"
|
||||
#include "aiMatrix4x4.h"
|
||||
|
||||
/** Transformation of a vector by a 3x3 matrix */
|
||||
inline aiVector3D operator * (const aiMatrix3x3& pMatrix, const aiVector3D& pVector)
|
||||
{
|
||||
aiVector3D res;
|
||||
res.x = pMatrix.a1 * pVector.x + pMatrix.a2 * pVector.y + pMatrix.a3 * pVector.z;
|
||||
res.y = pMatrix.b1 * pVector.x + pMatrix.b2 * pVector.y + pMatrix.b3 * pVector.z;
|
||||
res.z = pMatrix.c1 * pVector.x + pMatrix.c2 * pVector.y + pMatrix.c3 * pVector.z;
|
||||
return res;
|
||||
}
|
||||
|
||||
/** Transformation of a vector by a 4x4 matrix */
|
||||
inline aiVector3D operator * (const aiMatrix4x4& pMatrix, const aiVector3D& pVector)
|
||||
{
|
||||
aiVector3D res;
|
||||
res.x = pMatrix.a1 * pVector.x + pMatrix.a2 * pVector.y + pMatrix.a3 * pVector.z + pMatrix.a4;
|
||||
res.y = pMatrix.b1 * pVector.x + pMatrix.b2 * pVector.y + pMatrix.b3 * pVector.z + pMatrix.b4;
|
||||
res.z = pMatrix.c1 * pVector.x + pMatrix.c2 * pVector.y + pMatrix.c3 * pVector.z + pMatrix.c4;
|
||||
return res;
|
||||
}
|
||||
|
||||
|
||||
#endif // __cplusplus
|
||||
#endif // AI_VECTOR3D_INL_INC
|
||||
77
include/assimp.h
Normal file
77
include/assimp.h
Normal file
@@ -0,0 +1,77 @@
|
||||
/** @file Defines the C-API to the Asset Import Library. */
|
||||
#ifndef AI_ASSIMP_H_INC
|
||||
#define AI_ASSIMP_H_INC
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
struct aiScene;
|
||||
struct aiFileIO;
|
||||
//enum aiOrigin;
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
/** Reads the given file and returns its content.
|
||||
*
|
||||
* If the call succeeds, the imported data is returned in an aiScene structure.
|
||||
* The data is intended to be read-only, it stays property of the ASSIMP
|
||||
* library and will be stable until aiReleaseImport() is called. After you're
|
||||
* done with it, call aiReleaseImport() to free the resources associated with
|
||||
* this file. If the import fails, NULL is returned instead. Call
|
||||
* aiGetErrorString() to retrieve a human-readable error text.
|
||||
* @param pFile Path and filename of the file to be imported,
|
||||
* expected to be a null-terminated c-string.
|
||||
* @param pFlags Optional post processing steps to be executed after
|
||||
* a successful import. Provide a bitwise combination of the #aiPostProcessSteps
|
||||
* flags.
|
||||
* @return Pointer to the imported data or NULL if the import failed.
|
||||
*/
|
||||
// ---------------------------------------------------------------------------
|
||||
const aiScene* aiImportFile( const char* pFile, unsigned int pFlags);
|
||||
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
/** Reads the given file using user-defined I/O functions and returns
|
||||
* its content.
|
||||
*
|
||||
* If the call succeeds, the imported data is returned in an aiScene structure.
|
||||
* The data is intended to be read-only, it stays property of the ASSIMP
|
||||
* library and will be stable until aiReleaseImport() is called. After you're
|
||||
* done with it, call aiReleaseImport() to free the resources associated with
|
||||
* this file. If the import fails, NULL is returned instead. Call
|
||||
* aiGetErrorString() to retrieve a human-readable error text.
|
||||
* @param pFile aiFileIO structure. All functions pointers must be
|
||||
* initialized. aiFileIO::OpenFunc() and aiFileIO::CloseFunc()
|
||||
* will be used to open other files in the fs if the asset to be
|
||||
* loaded depends on them.
|
||||
* @return Pointer to the imported data or NULL if the import failed.
|
||||
*/
|
||||
// ---------------------------------------------------------------------------
|
||||
const aiScene* aiImportFileEx( const aiFileIO* pFile);
|
||||
|
||||
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
/** Releases all resources associated with the given import process.
|
||||
*
|
||||
* Call this function after you're done with the imported data.
|
||||
* @param pScene The imported data to release.
|
||||
*/
|
||||
// ---------------------------------------------------------------------------
|
||||
void aiReleaseImport( const aiScene* pScene);
|
||||
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
/** Returns the error text of the last failed import process.
|
||||
*
|
||||
* @return A textual description of the error that occured at the last
|
||||
* import process. NULL if there was no error.
|
||||
*/
|
||||
// ---------------------------------------------------------------------------
|
||||
const char* aiGetErrorString();
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif // AI_ASSIMP_H_INC
|
||||
123
include/assimp.hpp
Normal file
123
include/assimp.hpp
Normal file
@@ -0,0 +1,123 @@
|
||||
/** @file Defines the CPP-API to the Asset Import Library. */
|
||||
#ifndef AI_ASSIMP_HPP_INC
|
||||
#define AI_ASSIMP_HPP_INC
|
||||
|
||||
#ifndef __cplusplus
|
||||
#error This header requires C++ to be used.
|
||||
#endif
|
||||
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
struct aiScene;
|
||||
|
||||
namespace Assimp
|
||||
{
|
||||
|
||||
class BaseImporter;
|
||||
class BaseProcess;
|
||||
class IOStream;
|
||||
class IOSystem;
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
/** The Importer class forms an C++ interface to the functionality of the
|
||||
* Asset Import library.
|
||||
*
|
||||
* Create an object of this class and call ReadFile() to import a file.
|
||||
* If the import succeeds, the function returns a pointer to the imported data.
|
||||
* The data remains property of the object, it is intended to be accessed
|
||||
* read-only. The imported data will be destroyed along with the Importer
|
||||
* object. If the import failes, ReadFile() returns a NULL pointer. In this
|
||||
* case you can retrieve a human-readable error description be calling
|
||||
* GetErrorString().
|
||||
*
|
||||
* If you need the Importer to do custom file handling to access the files,
|
||||
* implement IOSystem and IOStream and supply an instance of your custom IOSystem
|
||||
* implementation by calling SetIOHandler() before calling ReadFile(). If you
|
||||
* do not assign a custion IO handler, a default handler using the standard C++
|
||||
* IO logic will be used.
|
||||
*/
|
||||
class Importer
|
||||
{
|
||||
public:
|
||||
|
||||
// -------------------------------------------------------------------
|
||||
/** Constructor. Creates an empty importer object.
|
||||
*
|
||||
* Call ReadFile() to start the import process.
|
||||
*/
|
||||
Importer();
|
||||
|
||||
// -------------------------------------------------------------------
|
||||
/** Destructor. The object kept ownership of the imported data,
|
||||
* which now will be destroyed along with the object.
|
||||
*/
|
||||
~Importer();
|
||||
|
||||
// -------------------------------------------------------------------
|
||||
/** Supplies a custom IO handler to the importer to open and access files.
|
||||
* If you need the importer to use custion IO logic to access the files,
|
||||
* you need to provide a custom implementation of IOSystem and IOFile
|
||||
* to the importer. Then create an instance of your custion IOSystem
|
||||
* implementation and supply it by this function.
|
||||
*
|
||||
* The Importer takes ownership of the object and will destroy it afterwards.
|
||||
* The previously assigned handler will be deleted.
|
||||
*
|
||||
* @param pIOHandler The IO handler to be used in all file accesses of the Importer.
|
||||
*/
|
||||
void SetIOHandler( IOSystem* pIOHandler);
|
||||
|
||||
// -------------------------------------------------------------------
|
||||
/** Reads the given file and returns its contents if successful.
|
||||
*
|
||||
* If the call succeeds, the contents of the file are returned as a
|
||||
* pointer to an aiScene object. The returned data is intended to be
|
||||
* read-only, the importer object keeps ownership of the data and will
|
||||
* destroy it upon destruction. If the import failes, NULL is returned.
|
||||
* A human-readable error description can be retrieved by calling
|
||||
* GetErrorString().
|
||||
* @param pFile Path and filename to the file to be imported.
|
||||
* @param pFlags Optional post processing steps to be executed after
|
||||
* a successful import. Provide a bitwise combination of the #aiPostProcessSteps
|
||||
* flags.
|
||||
* @return A pointer to the imported data, NULL if the import failed.
|
||||
*/
|
||||
const aiScene* ReadFile( const std::string& pFile, unsigned int pFlags);
|
||||
|
||||
// -------------------------------------------------------------------
|
||||
/** Returns an error description of an error that occured in ReadFile().
|
||||
*
|
||||
* Returns an empty string if no error occured.
|
||||
* @return A description of the last error, an empty string if no
|
||||
* error occured.
|
||||
*/
|
||||
inline const std::string& GetErrorString() const
|
||||
{ return mErrorString; }
|
||||
|
||||
private:
|
||||
/** Empty copy constructor. */
|
||||
Importer(const Importer &other);
|
||||
|
||||
protected:
|
||||
/** IO handler to use for all file accesses. */
|
||||
IOSystem* mIOHandler;
|
||||
|
||||
/** Format-specific importer worker objects -
|
||||
* one for each format we can read. */
|
||||
std::vector<BaseImporter*> mImporter;
|
||||
|
||||
/** Post processing steps we can apply at the imported data. */
|
||||
std::vector<BaseProcess*> mPostProcessingSteps;
|
||||
|
||||
/** The imported data, if ReadFile() was successful,
|
||||
* NULL otherwise. */
|
||||
aiScene* mScene;
|
||||
|
||||
/** The error description, if there was one. */
|
||||
std::string mErrorString;
|
||||
};
|
||||
|
||||
} // End of namespace Assimp
|
||||
|
||||
#endif // AI_ASSIMP_HPP_INC
|
||||
Reference in New Issue
Block a user