Further work on the IRR, AC, LWS loaders. Further work on the - still unfinished - OptimizeGraph step. SceneCombiner works now properly in all cases I tested yet.

Added missing 'typename' in Colladaparser.h
First implementation of spherical and cylindrical mapping, already in use for IRR and LWO models. For the latter the coordinate system is not yet correct.
Moved vec2d to a separate header and added operators similar to vec3.
Added plane and ray helper classes. Just the data is wrapped, no operators required for the moment.

git-svn-id: https://assimp.svn.sourceforge.net/svnroot/assimp/trunk@249 67173fc5-114c-0410-ac8e-9d2fd5bffc1f
This commit is contained in:
aramis_acg
2008-11-26 13:17:39 +00:00
parent 9ca66fb999
commit fd9e6edc19
45 changed files with 2657 additions and 869 deletions

View File

@@ -0,0 +1,36 @@
#ifndef BOOST_MATH_COMMON_FACTOR_RT_HPP
#define BOOST_MATH_COMMON_FACTOR_RT_HPP
namespace boost {
namespace math {
// TODO: use binary GCD for unsigned integers ....
template < typename IntegerType >
IntegerType gcd( IntegerType const &a, IntegerType const &b )
{
while ( true )
{
if ( a == zero )
return b;
b %= a;
if ( b == zero )
return a;
a %= b;
}
}
template < typename IntegerType >
IntegerType lcm( IntegerType const &a, IntegerType const &b )
{
IntegerType t = gcd (a,b);
if (!t)return t;
return a / t * b;
}
}}
#endif

View File

@@ -51,8 +51,8 @@ public:
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.
/** 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",
@@ -60,8 +60,8 @@ public:
*
* @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.
* @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,
@@ -72,6 +72,20 @@ public:
* @param pFile The file instance previously created by Open().
*/
virtual void Close( IOStream* pFile) = 0;
// -------------------------------------------------------------------
/** Compares two paths and check whether the point to identical files.
*
* The dummy implementation of this virtual performs a
* case-insensitive comparison of the path strings.
* @param one First file
* @param second Second file
* @return true if the paths point to the same file. The file needn't
* be existing, however.
*/
virtual bool ComparePaths (const std::string& one,
const std::string& second);
};
// ----------------------------------------------------------------------------
@@ -87,6 +101,7 @@ inline IOSystem::~IOSystem()
}
// ----------------------------------------------------------------------------
} //!ns Assimp
#endif //AI_IOSYSTEM_H_INC

View File

@@ -191,6 +191,7 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
// Use our own definition of PI here
#define AI_MATH_PI (3.1415926538)
#define AI_MATH_TWO_PI (AI_MATH_PI * 2.0)
#define AI_MATH_HALF_PI (AI_MATH_PI * 0.5)
// macrod to convert from radians to degrees and the reverse
#define AI_DEG_TO_RAD(x) (x*0.0174532925f)

View File

@@ -119,6 +119,7 @@ struct aiMatrix4x4
* \param z Rotation angle for the z-axis, in radians
*/
inline void FromEulerAngles(float x, float y, float z);
inline void FromEulerAngles(const aiVector3D& blubb);
/** \brief Returns a rotation matrix for a rotation around the x axis

View File

@@ -87,15 +87,12 @@ inline aiMatrix4x4& aiMatrix4x4::Inverse()
float det = Determinant();
if(det == 0.0f)
{
const float nan = std::numeric_limits<float>::quiet_NaN();
*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());
nan,nan,nan,nan,
nan,nan,nan,nan,
nan,nan,nan,nan,
nan,nan,nan,nan);
return *this;
}
@@ -129,7 +126,6 @@ inline float* aiMatrix4x4::operator[](unsigned int p_iIndex)
return &this->a1 + p_iIndex * 4;
}
// ---------------------------------------------------------------------------
inline const float* aiMatrix4x4::operator[](unsigned int p_iIndex) const
{
@@ -208,6 +204,11 @@ inline void aiMatrix4x4::DecomposeNoScaling (aiQuaternion& rotation,
rotation = aiQuaternion((aiMatrix3x3)_this);
}
// ---------------------------------------------------------------------------
inline void aiMatrix4x4::FromEulerAngles(const aiVector3D& blubb)
{
FromEulerAngles(blubb.x,blubb.y,blubb.z);
}
// ---------------------------------------------------------------------------
inline void aiMatrix4x4::FromEulerAngles(float x, float y, float z)
{
aiMatrix4x4& _this = *this;

View File

@@ -49,6 +49,7 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
// include math helper classes
#include "aiVector3D.h"
#include "aiVector2D.h"
#include "aiMatrix3x3.h"
#include "aiMatrix4x4.h"
@@ -66,22 +67,6 @@ const size_t MAXLEN = 1024;
#include "./Compiler/pushpack1.h"
// ---------------------------------------------------------------------------
/** Represents a two-dimensional vector.
*/
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
//! X and y coordinates
float x, y;
} PACK_STRUCT;
// ---------------------------------------------------------------------------
/** Represents a plane in a three-dimensional, euclidean space
@@ -94,13 +79,32 @@ struct aiPlane
: a(_a), b(_b), c(_c), d(_d) {}
aiPlane (const aiPlane& o) : a(o.a), b(o.b), c(o.c), d(o.d) {}
#endif // !__cplusplus
//! Plane equation
float a,b,c,d;
} PACK_STRUCT;
// ---------------------------------------------------------------------------
/** Represents a ray
*/
struct aiRay
{
#ifdef __cplusplus
aiRay () {}
aiRay (const aiVector3D& _pos, const aiVector3D& _dir)
: pos(_pos), dir(_dir) {}
aiRay (const aiRay& o) : pos (o.pos), dir (o.dir) {}
#endif // !__cplusplus
//! Position and direction of the ray
aiVector3D pos, dir;
} PACK_STRUCT;
// 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

148
include/aiVector2D.h Normal file
View File

@@ -0,0 +1,148 @@
/*
---------------------------------------------------------------------------
Open Asset Import Library (ASSIMP)
---------------------------------------------------------------------------
Copyright (c) 2006-2008, ASSIMP Development Team
All rights reserved.
Redistribution and use of this software in source and binary forms,
with or without modification, are permitted provided that the following
conditions are met:
* Redistributions of source code must retain the above
copyright notice, this list of conditions and the
following disclaimer.
* 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.
* Neither the name of the ASSIMP team, nor the names of its
contributors may be used to endorse or promote products
derived from this software without specific prior
written permission of the ASSIMP Development Team.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
"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 COPYRIGHT
OWNER OR CONTRIBUTORS 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.
---------------------------------------------------------------------------
*/
/** @file 2D vector structure, including operators when compiling in C++ */
#ifndef AI_VECTOR2D_H_INC
#define AI_VECTOR2D_H_INC
#include <math.h>
#ifdef __cplusplus
extern "C" {
#endif
#include "./Compiler/pushpack1.h"
// ---------------------------------------------------------------------------
/** Represents a two-dimensional vector. */
struct aiVector2D
{
#ifdef __cplusplus
aiVector2D () : x(0.0f), y(0.0f) {}
aiVector2D (float _x, float _y) : x(_x), y(_y) {}
aiVector2D (float _xyz) : x(_xyz), y(_xyz) {}
aiVector2D (const aiVector2D& o) : x(o.x), y(o.y) {}
void Set( float pX, float pY) { x = pX; y = pY;}
float SquareLength() const { return x*x + y*y; }
float Length() const { return sqrt( SquareLength()); }
aiVector2D& Normalize() { *this /= Length(); return *this; }
const aiVector2D& operator += (const aiVector2D& o) { x += o.x; y += o.y; return *this; }
const aiVector2D& operator -= (const aiVector2D& o) { x -= o.x; y -= o.y; return *this; }
const aiVector2D& operator *= (float f) { x *= f; y *= f; return *this; }
const aiVector2D& operator /= (float f) { x /= f; y /= f; return *this; }
inline float operator[](unsigned int i) const {return *(&x + i);}
inline float& operator[](unsigned int i) {return *(&x + i);}
inline bool operator== (const aiVector2D& other) const
{return x == other.x && y == other.y;}
inline bool operator!= (const aiVector2D& other) const
{return x != other.x || y != other.y;}
inline aiVector2D& operator= (float f)
{x = y = f;return *this;}
const aiVector2D SymMul(const aiVector2D& o)
{return aiVector2D(x*o.x,y*o.y);}
#endif // __cplusplus
float x, y;
} PACK_STRUCT;
#include "./Compiler/poppack1.h"
#ifdef __cplusplus
} // end extern "C"
// symmetric addition
inline aiVector2D operator + (const aiVector2D& v1, const aiVector2D& v2)
{
return aiVector2D( v1.x + v2.x, v1.y + v2.y);
}
// symmetric subtraction
inline aiVector2D operator - (const aiVector2D& v1, const aiVector2D& v2)
{
return aiVector2D( v1.x - v2.x, v1.y - v2.y);
}
// scalar product
inline float operator * (const aiVector2D& v1, const aiVector2D& v2)
{
return v1.x*v2.x + v1.y*v2.y;
}
// scalar multiplication
inline aiVector2D operator * ( float f, const aiVector2D& v)
{
return aiVector2D( f*v.x, f*v.y);
}
// and the other way around
inline aiVector2D operator * ( const aiVector2D& v, float f)
{
return aiVector2D( f*v.x, f*v.y);
}
// scalar division
inline aiVector2D operator / ( const aiVector2D& v, float f)
{
return v * (1/f);
}
// vector division
inline aiVector2D operator / ( const aiVector2D& v, const aiVector2D& v2)
{
return aiVector2D(v.x / v2.x,v.y / v2.y);
}
// vector inversion
inline aiVector2D operator - ( const aiVector2D& v)
{
return aiVector2D( -v.x, -v.y);
}
#endif // __cplusplus
#endif // AI_VECTOR2D_H_INC