mirror of https://github.com/AxioDL/zeus.git
Added COBBox and renamed SBoundingBox to CAABox
Reorganized code
This commit is contained in:
parent
3a25f59adb
commit
9d657895cb
|
@ -1,34 +1,43 @@
|
|||
include_directories(../Athena/include)
|
||||
if (NOT DEFINED ATHENA_INCLUDE_DIR)
|
||||
set(ATHENA_INCLUDE_DIR ../Athena/include)
|
||||
endif()
|
||||
include_directories(include ${ATHENA_INCLUDE_DIR})
|
||||
|
||||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -msse4.1")
|
||||
|
||||
|
||||
add_library(Math
|
||||
CVector3f.cpp
|
||||
Math.cpp
|
||||
CQuaternion.cpp
|
||||
CMatrix3f.cpp
|
||||
CProjection.cpp
|
||||
CPlane.cpp
|
||||
CTransform.cpp
|
||||
CVector2f.cpp
|
||||
CRectangle.cpp
|
||||
CVector4f.cpp
|
||||
CMatrix4f.cpp
|
||||
src/CVector3f.cpp
|
||||
src/Math.cpp
|
||||
src/CQuaternion.cpp
|
||||
src/CMatrix3f.cpp
|
||||
src/CProjection.cpp
|
||||
src/CPlane.cpp
|
||||
src/CTransform.cpp
|
||||
src/CColor.cpp
|
||||
src/CVector2f.cpp
|
||||
src/CRectangle.cpp
|
||||
src/CVector4f.cpp
|
||||
src/CMatrix4f.cpp
|
||||
src/CAABox.cpp
|
||||
|
||||
CVector3f.hpp
|
||||
Math.hpp
|
||||
CQuaternion.hpp
|
||||
CMatrix3f.hpp
|
||||
CProjection.hpp
|
||||
CAxisAngle.hpp
|
||||
CPlane.hpp
|
||||
CTransform.hpp
|
||||
CColor.hpp
|
||||
Global.hpp
|
||||
MathLib.hpp
|
||||
CVector2f.hpp
|
||||
CRectangle.hpp
|
||||
CMatrix4f.hpp
|
||||
TVectorUnion.hpp
|
||||
CVector4f.hpp
|
||||
CFrustum.hpp
|
||||
SBoundingBox.hpp)
|
||||
include/CVector3f.hpp
|
||||
include/Math.hpp
|
||||
include/CQuaternion.hpp
|
||||
include/CMatrix3f.hpp
|
||||
include/CProjection.hpp
|
||||
include/CAxisAngle.hpp
|
||||
include/CPlane.hpp
|
||||
include/CTransform.hpp
|
||||
include/CColor.hpp
|
||||
include/Global.hpp
|
||||
include/MathLib.hpp
|
||||
include/CVector2f.hpp
|
||||
include/CRectangle.hpp
|
||||
include/CMatrix4f.hpp
|
||||
include/TVectorUnion.hpp
|
||||
include/CVector4f.hpp
|
||||
include/CFrustum.hpp
|
||||
include/CAABox.hpp
|
||||
include/COBBox.hpp)
|
||||
|
||||
|
|
|
@ -1,93 +0,0 @@
|
|||
#ifndef BOUNDINGBOX_HPP
|
||||
#define BOUNDINGBOX_HPP
|
||||
|
||||
#include "CVector3f.hpp"
|
||||
#include <Athena/IStreamReader.hpp>
|
||||
|
||||
struct SBoundingBox
|
||||
{
|
||||
CVector3f m_min;
|
||||
CVector3f m_max;
|
||||
|
||||
inline SBoundingBox() {}
|
||||
|
||||
SBoundingBox(const CVector3f& min, const CVector3f& max)
|
||||
: m_min(min),
|
||||
m_max(max)
|
||||
{
|
||||
}
|
||||
|
||||
SBoundingBox(const float& minX,const float& minY,const float& minZ,
|
||||
const float& maxX,const float& maxY,const float& maxZ)
|
||||
: m_min(minX, minY, minZ),
|
||||
m_max(maxX, maxY, maxZ)
|
||||
{
|
||||
}
|
||||
|
||||
inline void readBoundingBox(Athena::io::IStreamReader& in)
|
||||
{
|
||||
m_min[0] = in.readFloat();
|
||||
m_min[1] = in.readFloat();
|
||||
m_min[2] = in.readFloat();
|
||||
m_max[0] = in.readFloat();
|
||||
m_max[1] = in.readFloat();
|
||||
m_max[2] = in.readFloat();
|
||||
}
|
||||
SBoundingBox(Athena::io::IStreamReader& in) {readBoundingBox(in);}
|
||||
|
||||
inline bool intersects(SBoundingBox& other) const
|
||||
{
|
||||
if (m_max[0] < other.m_min[0]) return false;
|
||||
if (m_min[0] > other.m_max[0]) return false;
|
||||
if (m_max[1] < other.m_min[1]) return false;
|
||||
if (m_min[1] > other.m_max[1]) return false;
|
||||
if (m_max[2] < other.m_min[2]) return false;
|
||||
if (m_min[2] > other.m_max[2]) return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
inline void splitX(SBoundingBox& posX, SBoundingBox& negX) const
|
||||
{
|
||||
float midX = (m_max.x - m_min.x) / 2.0 + m_min.x;
|
||||
posX.m_max = m_max;
|
||||
posX.m_min = m_min;
|
||||
posX.m_min.x = midX;
|
||||
negX.m_max = m_max;
|
||||
negX.m_max.x = midX;
|
||||
negX.m_min = m_min;
|
||||
}
|
||||
|
||||
inline void splitY(SBoundingBox& posY, SBoundingBox& negY) const
|
||||
{
|
||||
float midY = (m_max.y - m_min.y) / 2.0 + m_min.y;
|
||||
posY.m_max = m_max;
|
||||
posY.m_min = m_min;
|
||||
posY.m_min.y = midY;
|
||||
negY.m_max = m_max;
|
||||
negY.m_max.y = midY;
|
||||
negY.m_min = m_min;
|
||||
}
|
||||
|
||||
inline void splitZ(SBoundingBox& posZ, SBoundingBox& negZ) const
|
||||
{
|
||||
float midZ = (m_max.z - m_min.z) / 2.0 + m_min.z;
|
||||
posZ.m_max = m_max;
|
||||
posZ.m_min = m_min;
|
||||
posZ.m_min.z = midZ;
|
||||
negZ.m_max = m_max;
|
||||
negZ.m_max.z = midZ;
|
||||
negZ.m_min = m_min;
|
||||
}
|
||||
};
|
||||
|
||||
inline bool operator ==(const SBoundingBox& left, const SBoundingBox& right)
|
||||
{
|
||||
return (left.m_min == right.m_min && left.m_max == right.m_max);
|
||||
}
|
||||
inline bool operator !=(const SBoundingBox& left, const SBoundingBox& right)
|
||||
{
|
||||
return (left.m_min != right.m_min || left.m_max != right.m_max);
|
||||
|
||||
}
|
||||
|
||||
#endif // BOUNDINGBOX_HPP
|
|
@ -0,0 +1,161 @@
|
|||
#ifndef CAABOX_HPP
|
||||
#define CAABOX_HPP
|
||||
|
||||
#include "CVector3f.hpp"
|
||||
#include "CTransform.hpp"
|
||||
#include <Athena/IStreamReader.hpp>
|
||||
|
||||
inline float fsel(float a, float b, float c)
|
||||
{
|
||||
return (a >= -0.0f) ? b : c;
|
||||
}
|
||||
|
||||
class ZE_ALIGN(16) CAABox
|
||||
{
|
||||
public:
|
||||
ZE_DECLARE_ALIGNED_ALLOCATOR();
|
||||
|
||||
static const CAABox skInvertedBox;
|
||||
|
||||
CVector3f m_min;
|
||||
CVector3f m_max;
|
||||
|
||||
inline CAABox()
|
||||
: m_min(10000000000000000.f), m_max(-10000000000000000.f)
|
||||
{}
|
||||
|
||||
CAABox(const CVector3f& min, const CVector3f& max)
|
||||
: m_min(min),
|
||||
m_max(max)
|
||||
{
|
||||
}
|
||||
|
||||
CAABox(float minX,const float minY,const float& minZ,
|
||||
float maxX,const float& maxY,const float& maxZ)
|
||||
: m_min(minX, minY, minZ),
|
||||
m_max(maxX, maxY, maxZ)
|
||||
{
|
||||
}
|
||||
|
||||
inline void readBoundingBox(Athena::io::IStreamReader& in)
|
||||
{
|
||||
m_min[0] = in.readFloat();
|
||||
m_min[1] = in.readFloat();
|
||||
m_min[2] = in.readFloat();
|
||||
m_max[0] = in.readFloat();
|
||||
m_max[1] = in.readFloat();
|
||||
m_max[2] = in.readFloat();
|
||||
}
|
||||
CAABox(Athena::io::IStreamReader& in) {readBoundingBox(in);}
|
||||
|
||||
inline bool intersects(const CAABox& other) const
|
||||
{
|
||||
if (m_max[0] < other.m_min[0]) return false;
|
||||
if (m_min[0] > other.m_max[0]) return false;
|
||||
if (m_max[1] < other.m_min[1]) return false;
|
||||
if (m_min[1] > other.m_max[1]) return false;
|
||||
if (m_max[2] < other.m_min[2]) return false;
|
||||
if (m_min[2] > other.m_max[2]) return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
CVector3f center() const
|
||||
{
|
||||
return (m_min + m_max) * 0.5f;
|
||||
}
|
||||
CVector3f extents() const
|
||||
{
|
||||
return (m_max - m_min) * 0.5f;
|
||||
}
|
||||
|
||||
inline void accumulateBounds(const CVector3f& point)
|
||||
{
|
||||
if (m_min.x > point.x)
|
||||
m_min.x = point.x;
|
||||
if (m_min.y > point.y)
|
||||
m_min.y = point.y;
|
||||
if (m_min.z > point.z)
|
||||
m_min.z = point.z;
|
||||
|
||||
if (m_max.x < point.x)
|
||||
m_max.x = point.x;
|
||||
if (m_max.y < point.y)
|
||||
m_max.y = point.y;
|
||||
if (m_max.z < point.z)
|
||||
m_max.z = point.z;
|
||||
|
||||
/*
|
||||
for (unsigned i = 0; i < 3; i++)
|
||||
{
|
||||
if (m_min[i] > point[i])
|
||||
m_min[i] = point[i];
|
||||
if (m_max[i] < point[i])
|
||||
m_max[i] = point[i];
|
||||
}*/
|
||||
}
|
||||
|
||||
inline bool pointInside(const CVector3f& other) const
|
||||
{
|
||||
return (m_min.x <= other.x && other.x <= m_max.z &&
|
||||
m_min.y <= other.y && other.y <= m_max.z &&
|
||||
m_min.z <= other.z && other.z <= m_max.z);
|
||||
}
|
||||
|
||||
inline CVector3f closestPointAlongVector(const CVector3f& other)
|
||||
{
|
||||
return {fsel(other.x, m_min.x, m_max.x),
|
||||
(other.y >= -0.f) ? m_min.y : m_max.y,
|
||||
(other.z >= -0.f) ? m_min.z : m_max.z};
|
||||
}
|
||||
|
||||
inline void splitX(CAABox& posX, CAABox& negX) const
|
||||
{
|
||||
float midX = (m_max.x - m_min.x) / 2.0 + m_min.x;
|
||||
posX.m_max = m_max;
|
||||
posX.m_min = m_min;
|
||||
posX.m_min.x = midX;
|
||||
negX.m_max = m_max;
|
||||
negX.m_max.x = midX;
|
||||
negX.m_min = m_min;
|
||||
}
|
||||
|
||||
inline void splitY(CAABox& posY, CAABox& negY) const
|
||||
{
|
||||
float midY = (m_max.y - m_min.y) / 2.0 + m_min.y;
|
||||
posY.m_max = m_max;
|
||||
posY.m_min = m_min;
|
||||
posY.m_min.y = midY;
|
||||
negY.m_max = m_max;
|
||||
negY.m_max.y = midY;
|
||||
negY.m_min = m_min;
|
||||
}
|
||||
|
||||
inline void splitZ(CAABox& posZ, CAABox& negZ) const
|
||||
{
|
||||
float midZ = (m_max.z - m_min.z) / 2.0 + m_min.z;
|
||||
posZ.m_max = m_max;
|
||||
posZ.m_min = m_min;
|
||||
posZ.m_min.z = midZ;
|
||||
negZ.m_max = m_max;
|
||||
negZ.m_max.z = midZ;
|
||||
negZ.m_min = m_min;
|
||||
}
|
||||
};
|
||||
|
||||
inline bool operator ==(const CAABox& left, const CAABox& right)
|
||||
{
|
||||
return (left.m_min == right.m_min && left.m_max == right.m_max);
|
||||
}
|
||||
inline bool operator !=(const CAABox& left, const CAABox& right)
|
||||
{
|
||||
return (left.m_min != right.m_min || left.m_max != right.m_max);
|
||||
|
||||
}
|
||||
|
||||
inline CAABox operator*(const CTransform& left, const CAABox& right)
|
||||
{
|
||||
return {left * (right.m_min - right.m_max), left * (right.m_max - right.m_min)};
|
||||
|
||||
}
|
||||
|
||||
#endif // CAABOX_HPP
|
|
@ -4,6 +4,13 @@
|
|||
#include "MathLib.hpp"
|
||||
#include <iostream>
|
||||
|
||||
#if BYTE_ORDER == __ORDER_LITTLE_ENDIAN__
|
||||
#define COLOR(rgba) ( ( (rgba) & 0x000000FF ) << 24 | ( (rgba) & 0x0000FF00 ) << 8 \
|
||||
| ( (rgba) & 0x00FF0000 ) >> 8 | ( (rgba) & 0xFF000000 ) >> 24 )
|
||||
#else
|
||||
#define COLOR(rgba) rgba
|
||||
#endif
|
||||
|
||||
typedef union _RGBA32
|
||||
{
|
||||
struct
|
||||
|
@ -18,6 +25,16 @@ class ZE_ALIGN(16) CColor
|
|||
public:
|
||||
ZE_DECLARE_ALIGNED_ALLOCATOR();
|
||||
|
||||
static const CColor skRed;
|
||||
static const CColor skBlack;
|
||||
static const CColor skBlue;
|
||||
static const CColor skGreen;
|
||||
static const CColor skGrey;
|
||||
static const CColor skOrange;
|
||||
static const CColor skPurple;
|
||||
static const CColor skYellow;
|
||||
static const CColor skWhite;
|
||||
|
||||
#if __SSE__
|
||||
CColor(const __m128& mVec128) : mVec128(mVec128) {}
|
||||
#endif
|
||||
|
@ -26,6 +43,8 @@ public:
|
|||
CColor(float rgb, float a = 1.0) { splat(rgb, a); }
|
||||
CColor(float r, float g, float b, float a = 1.0f) {v[0] = r; v[1] = g; v[2] = b; v[3] = a; }
|
||||
CColor(Athena::io::IStreamReader& reader) {readRGBA(reader);}
|
||||
CColor(atUint32 rgba) { fromRGBA32(rgba); }
|
||||
CColor(const unsigned char* rgba) { fromRGBA8(rgba[0], rgba[1], rgba[2], rgba[3]); }
|
||||
|
||||
inline void readRGBA(Athena::io::IStreamReader& reader)
|
||||
{
|
|
@ -2,7 +2,7 @@
|
|||
#define CFRUSTUM_HPP
|
||||
|
||||
#include "CPlane.hpp"
|
||||
#include "SBoundingBox.hpp"
|
||||
#include "CAABox.hpp"
|
||||
|
||||
class CFrustum
|
||||
{
|
||||
|
@ -84,7 +84,7 @@ public:
|
|||
|
||||
}
|
||||
|
||||
inline bool aabbFrustumTest(const SBoundingBox& aabb) const
|
||||
inline bool aabbFrustumTest(const CAABox& aabb) const
|
||||
{
|
||||
CVector3f vmin, vmax;
|
||||
int i;
|
|
@ -12,6 +12,7 @@ public:
|
|||
explicit CMatrix4f(bool zero = false)
|
||||
{
|
||||
memset(m, 0, sizeof(m));
|
||||
|
||||
if (!zero)
|
||||
{
|
||||
m[0][0] = 1.0;
|
||||
|
@ -143,7 +144,9 @@ static inline CMatrix4f operator*(const CMatrix4f& lhs, const CMatrix4f& rhs)
|
|||
CMatrix4f ret;
|
||||
#if __SSE__
|
||||
unsigned i;
|
||||
for (i=0 ; i<4 ; ++i) {
|
||||
|
||||
for (i = 0 ; i < 4 ; ++i)
|
||||
{
|
||||
ret.vec[i].mVec128 =
|
||||
_mm_add_ps(_mm_add_ps(_mm_add_ps(
|
||||
_mm_mul_ps(lhs.vec[0].mVec128, _mm_shuffle_ps(rhs.vec[i].mVec128, rhs.vec[i].mVec128, _MM_SHUFFLE(0, 0, 0, 0))),
|
||||
|
@ -151,6 +154,7 @@ static inline CMatrix4f operator*(const CMatrix4f& lhs, const CMatrix4f& rhs)
|
|||
_mm_mul_ps(lhs.vec[2].mVec128, _mm_shuffle_ps(rhs.vec[i].mVec128, rhs.vec[i].mVec128, _MM_SHUFFLE(2, 2, 2, 2)))),
|
||||
_mm_mul_ps(lhs.vec[3].mVec128, _mm_shuffle_ps(rhs.vec[i].mVec128, rhs.vec[i].mVec128, _MM_SHUFFLE(3, 3, 3, 3))));
|
||||
}
|
||||
|
||||
#else
|
||||
ret.m[0][0] = lhs.m[0][0] * rhs.m[0][0] + lhs.m[1][0] * rhs.m[0][1] + lhs.m[2][0] * rhs.m[0][2] + lhs.m[3][0] * rhs.m[0][3];
|
||||
ret.m[1][0] = lhs.m[0][0] * rhs.m[1][0] + lhs.m[1][0] * rhs.m[1][1] + lhs.m[2][0] * rhs.m[1][2] + lhs.m[3][0] * rhs.m[1][3];
|
|
@ -0,0 +1,59 @@
|
|||
#ifndef COBBOX_HPP
|
||||
#define COBBOX_HPP
|
||||
|
||||
#include "CTransform.hpp"
|
||||
#include "CVector3f.hpp"
|
||||
#include "CAABox.hpp"
|
||||
|
||||
class COBBox
|
||||
{
|
||||
public:
|
||||
CTransform m_transform;
|
||||
CVector3f m_extents;
|
||||
|
||||
COBBox()
|
||||
{}
|
||||
|
||||
COBBox(const CAABox& aabb)
|
||||
{ createFromAABox(aabb); }
|
||||
|
||||
CAABox calculateAABox(const CTransform& transform = CTransform())
|
||||
{
|
||||
CAABox ret = CAABox::skInvertedBox;
|
||||
|
||||
CTransform trans = transform * m_transform;
|
||||
static const CVector3f basis[8] ={
|
||||
{ 1.0, 1.0, 1.0},
|
||||
{ 1.0, 1.0, -1.0},
|
||||
{ 1.0, -1.0, 1.0},
|
||||
{ 1.0, -1.0, -1.0},
|
||||
{-1.0, -1.0, -1.0},
|
||||
{-1.0, -1.0, 1.0},
|
||||
{-1.0, 1.0, -1.0},
|
||||
{-1.0, 1.0, 1.0}
|
||||
};
|
||||
|
||||
for (int i = 0; i < 8; i++)
|
||||
{
|
||||
CVector3f p = (m_extents * basis[i]);
|
||||
ret.accumulateBounds(trans * p);
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
void createFromAABox(const CAABox& box)
|
||||
{
|
||||
m_extents = box.extents();
|
||||
m_transform.m_origin = box.center();
|
||||
}
|
||||
|
||||
static inline COBBox fromAABox(const CAABox& box)
|
||||
{
|
||||
COBBox ret;
|
||||
ret.createFromAABox(box);
|
||||
return box;
|
||||
}
|
||||
};
|
||||
|
||||
#endif
|
|
@ -4,6 +4,7 @@
|
|||
#include "Global.hpp"
|
||||
#include "CAxisAngle.hpp"
|
||||
#include "CVector3f.hpp"
|
||||
#include "CVector4f.hpp"
|
||||
#include <math.h>
|
||||
#include <Athena/IStreamReader.hpp>
|
||||
|
||||
|
@ -12,13 +13,23 @@ class ZE_ALIGN(16) CQuaternion
|
|||
public:
|
||||
ZE_DECLARE_ALIGNED_ALLOCATOR();
|
||||
|
||||
CQuaternion();
|
||||
CQuaternion(float r, float x, float y, float z);
|
||||
CQuaternion(float x, float y, float z);
|
||||
CQuaternion(const CVector3f& vec);
|
||||
CQuaternion(float r, const CVector3f& vec);
|
||||
CQuaternion(Athena::io::IStreamReader& input);
|
||||
~CQuaternion();
|
||||
CQuaternion() : r(1.0f) {}
|
||||
CQuaternion(float r, float x, float y, float z) : r(r), v(x, y, z){}
|
||||
CQuaternion(float x, float y, float z) { fromVector3f(CVector3f(x, y, z)); }
|
||||
CQuaternion(float r, const CVector3f& vec) : r(r), v(vec){}
|
||||
CQuaternion(Athena::io::IStreamReader& input) { r = input.readFloat(); v = CVector3f(input);}
|
||||
CQuaternion(const CVector3f& vec) { fromVector3f(vec); }
|
||||
CQuaternion(const CVector4f& vec)
|
||||
: r(vec.w)
|
||||
{
|
||||
#if __SSE__
|
||||
v.mVec128 = vec.mVec128; v.v[3] = 0;
|
||||
#else
|
||||
v.x = vec.x; v.y = vec.y; v.z = vec.z;
|
||||
#endif
|
||||
}
|
||||
|
||||
virtual ~CQuaternion() {}
|
||||
|
||||
void fromVector3f(const CVector3f& vec);
|
||||
|
|
@ -24,6 +24,12 @@ public:
|
|||
return CTransform(inv, inv * -m_origin);
|
||||
}
|
||||
|
||||
inline void translate(const CVector3f& position)
|
||||
{
|
||||
m_basis = CMatrix3f::skIdentityMatrix3f;
|
||||
m_origin = position;
|
||||
}
|
||||
|
||||
inline CVector3f operator*(const CVector3f& other) const
|
||||
{return m_origin + m_basis * other;}
|
||||
|
|
@ -29,6 +29,8 @@ namespace Math
|
|||
|
||||
extern const CVector3f kUpVec;
|
||||
CTransform lookAt(const CVector3f& pos, const CVector3f& lookPos, const CVector3f& up=kUpVec);
|
||||
inline CVector3f baryToWorld(const CVector3f& p0, const CVector3f& p1, const CVector3f& p2, const CVector3f& bary)
|
||||
{ return bary.x * p0 + bary.y * p1 + bary.z * p2; }
|
||||
}
|
||||
|
||||
#endif // MATH_HPP
|
|
@ -12,7 +12,8 @@
|
|||
#include "CVector4f.hpp"
|
||||
#include "CRectangle.hpp"
|
||||
#include "CPlane.hpp"
|
||||
#include "SBoundingBox.hpp"
|
||||
#include "CAABox.hpp"
|
||||
#include "COBBox.hpp"
|
||||
#include "CFrustum.hpp"
|
||||
#include "CColor.hpp"
|
||||
#include "Global.hpp"
|
37
main.cpp
37
main.cpp
|
@ -1,37 +0,0 @@
|
|||
#include <iostream>
|
||||
#include "CVector3d.hpp"
|
||||
#include "CQuaternion.hpp"
|
||||
#include "Math.hpp"
|
||||
#include <math.h>
|
||||
#include <iomanip>
|
||||
#include <immintrin.h>
|
||||
|
||||
#if !__SSE__
|
||||
#error "SSE instruction set not enabled"
|
||||
#endif
|
||||
|
||||
class Test
|
||||
{
|
||||
char t;
|
||||
__m128 v;
|
||||
};
|
||||
|
||||
int main()
|
||||
{
|
||||
CQuaternion slerp1 = CQuaternion::fromAxisAngle(CVector3f(1.0, .5, 0.0), Math::degToRad(45.f));
|
||||
# if 1
|
||||
CQuaternion slerp2 = CQuaternion::fromAxisAngle(CVector3f(0.5, 256.0, 4096.0), Math::degToRad(90.f));
|
||||
CQuaternion slerpQuat = CQuaternion::slerp(slerp1, slerp2, 0.5);
|
||||
|
||||
std::cout << Math::radToDeg(slerpQuat.r) << " " << slerpQuat.v.x << " " << slerpQuat.v.y << " " << slerpQuat.v.z << std::endl;
|
||||
|
||||
CQuaternion quat = CQuaternion::fromAxisAngle(CVector3f(1.0, .5, 0.0), Math::degToRad(45.f));
|
||||
quat.invert();
|
||||
CAxisAngle axisAngle = quat.toAxisAngle();
|
||||
std::cout << axisAngle.axis.x << " " << axisAngle.axis.y << " " << axisAngle.axis.z << " " << Math::radToDeg(axisAngle.angle) << "d" << std::endl;
|
||||
|
||||
std::cout << sizeof (Test) << std::endl;
|
||||
#endif
|
||||
return 0;
|
||||
}
|
||||
|
|
@ -0,0 +1,2 @@
|
|||
#include "CAABox.hpp"
|
||||
const CAABox CAABox::skInvertedBox = CAABox();
|
|
@ -0,0 +1,11 @@
|
|||
#include "CColor.hpp"
|
||||
|
||||
const CColor CColor::skRed (COLOR(0xFF0000FF));
|
||||
const CColor CColor::skBlack (COLOR(0x000000FF));
|
||||
const CColor CColor::skBlue (COLOR(0x0000FFFF));
|
||||
const CColor CColor::skGreen (COLOR(0x00FF00FF));
|
||||
const CColor CColor::skGrey (COLOR(0x808080FF));
|
||||
const CColor CColor::skOrange(COLOR(0xFF7000FF));
|
||||
const CColor CColor::skPurple(COLOR(0xA000FFFF));
|
||||
const CColor CColor::skYellow(COLOR(0xFFFF00FF));
|
||||
const CColor CColor::skWhite (COLOR(0xFFFFFFFF));
|
|
@ -1,41 +1,6 @@
|
|||
#include "CQuaternion.hpp"
|
||||
#include <math.h>
|
||||
|
||||
CQuaternion::CQuaternion()
|
||||
: r(1.0f)
|
||||
{
|
||||
}
|
||||
|
||||
CQuaternion::CQuaternion(float r, float x, float y, float z)
|
||||
: r(r), v(x, y, z)
|
||||
{
|
||||
}
|
||||
|
||||
CQuaternion::CQuaternion(float x, float y, float z)
|
||||
{
|
||||
fromVector3f(CVector3f(x, y, z));
|
||||
}
|
||||
|
||||
CQuaternion::CQuaternion(const CVector3f& vec)
|
||||
{
|
||||
fromVector3f(vec);
|
||||
}
|
||||
|
||||
CQuaternion::CQuaternion(float r, const CVector3f& vec)
|
||||
: r(r), v(vec)
|
||||
{
|
||||
}
|
||||
|
||||
CQuaternion::CQuaternion(Athena::io::IStreamReader& input)
|
||||
{
|
||||
r = input.readFloat();
|
||||
v = CVector3f(input);
|
||||
}
|
||||
|
||||
CQuaternion::~CQuaternion()
|
||||
{
|
||||
}
|
||||
|
||||
void CQuaternion::fromVector3f(const CVector3f& vec)
|
||||
{
|
||||
float cosX = cosf(0.5 * vec.x);
|
Loading…
Reference in New Issue