WIP organization of library
This commit is contained in:
@@ -22,58 +22,58 @@ class KRMat4;
|
||||
|
||||
class KRAABB {
|
||||
public:
|
||||
KRAABB(const Vector3 &minPoint, const Vector3 &maxPoint);
|
||||
KRAABB(const Vector3 &corner1, const Vector3 &corner2, const KRMat4 &modelMatrix);
|
||||
KRAABB();
|
||||
~KRAABB();
|
||||
KRAABB(const Vector3 &minPoint, const Vector3 &maxPoint);
|
||||
KRAABB(const Vector3 &corner1, const Vector3 &corner2, const KRMat4 &modelMatrix);
|
||||
KRAABB();
|
||||
~KRAABB();
|
||||
|
||||
void scale(const Vector3 &s);
|
||||
void scale(float s);
|
||||
void scale(const Vector3 &s);
|
||||
void scale(float s);
|
||||
|
||||
Vector3 center() const;
|
||||
Vector3 size() const;
|
||||
float volume() const;
|
||||
bool intersects(const KRAABB& b) const;
|
||||
bool contains(const KRAABB &b) const;
|
||||
bool contains(const Vector3 &v) const;
|
||||
Vector3 center() const;
|
||||
Vector3 size() const;
|
||||
float volume() const;
|
||||
bool intersects(const KRAABB& b) const;
|
||||
bool contains(const KRAABB &b) const;
|
||||
bool contains(const Vector3 &v) const;
|
||||
|
||||
bool intersectsLine(const Vector3 &v1, const Vector3 &v2) const;
|
||||
bool intersectsRay(const Vector3 &v1, const Vector3 &dir) const;
|
||||
bool intersectsSphere(const Vector3 ¢er, float radius) const;
|
||||
void encapsulate(const KRAABB & b);
|
||||
bool intersectsLine(const Vector3 &v1, const Vector3 &v2) const;
|
||||
bool intersectsRay(const Vector3 &v1, const Vector3 &dir) const;
|
||||
bool intersectsSphere(const Vector3 ¢er, float radius) const;
|
||||
void encapsulate(const KRAABB & b);
|
||||
|
||||
KRAABB& operator =(const KRAABB& b);
|
||||
bool operator ==(const KRAABB& b) const;
|
||||
bool operator !=(const KRAABB& b) const;
|
||||
KRAABB& operator =(const KRAABB& b);
|
||||
bool operator ==(const KRAABB& b) const;
|
||||
bool operator !=(const KRAABB& b) const;
|
||||
|
||||
// Comparison operators are implemented to allow insertion into sorted containers such as std::set
|
||||
bool operator >(const KRAABB& b) const;
|
||||
bool operator <(const KRAABB& b) const;
|
||||
// Comparison operators are implemented to allow insertion into sorted containers such as std::set
|
||||
bool operator >(const KRAABB& b) const;
|
||||
bool operator <(const KRAABB& b) const;
|
||||
|
||||
Vector3 min;
|
||||
Vector3 max;
|
||||
Vector3 min;
|
||||
Vector3 max;
|
||||
|
||||
static KRAABB Infinite();
|
||||
static KRAABB Zero();
|
||||
static KRAABB Infinite();
|
||||
static KRAABB Zero();
|
||||
|
||||
float longest_radius() const;
|
||||
Vector3 nearestPoint(const Vector3 & v) const;
|
||||
float longest_radius() const;
|
||||
Vector3 nearestPoint(const Vector3 & v) const;
|
||||
};
|
||||
|
||||
} // namespace kraken
|
||||
|
||||
namespace std {
|
||||
template<>
|
||||
struct hash<kraken::KRAABB> {
|
||||
public:
|
||||
size_t operator()(const kraken::KRAABB &s) const
|
||||
{
|
||||
size_t h1 = hash<kraken::Vector3>()(s.min);
|
||||
size_t h2 = hash<kraken::Vector3>()(s.max);
|
||||
return h1 ^ ( h2 << 1 );
|
||||
}
|
||||
};
|
||||
}
|
||||
template<>
|
||||
struct hash<kraken::KRAABB> {
|
||||
public:
|
||||
size_t operator()(const kraken::KRAABB &s) const
|
||||
{
|
||||
size_t h1 = hash<kraken::Vector3>()(s.min);
|
||||
size_t h2 = hash<kraken::Vector3>()(s.max);
|
||||
return h1 ^ ( h2 << 1 );
|
||||
}
|
||||
};
|
||||
} // namespace std
|
||||
|
||||
|
||||
#endif /* defined(KRAABB_H) */
|
||||
|
||||
@@ -33,83 +33,83 @@
|
||||
#include "Vector3.h"
|
||||
#include "Vector4.h"
|
||||
|
||||
#ifndef KRMAT4_H
|
||||
#define KRMAT4_H
|
||||
#ifndef KRAKEN_MATRIX4_H
|
||||
#define KRAKEN_MATRIX4_H
|
||||
|
||||
namespace kraken {
|
||||
|
||||
typedef enum {
|
||||
X_AXIS,
|
||||
Y_AXIS,
|
||||
Z_AXIS
|
||||
X_AXIS,
|
||||
Y_AXIS,
|
||||
Z_AXIS
|
||||
} AXIS;
|
||||
|
||||
class KRQuaternion;
|
||||
|
||||
class KRMat4 {
|
||||
public:
|
||||
public:
|
||||
|
||||
float c[16]; // Matrix components, in column-major order
|
||||
float c[16]; // Matrix components, in column-major order
|
||||
|
||||
// Default constructor - Creates an identity matrix
|
||||
KRMat4();
|
||||
// Default constructor - Creates an identity matrix
|
||||
KRMat4();
|
||||
|
||||
KRMat4(float *pMat);
|
||||
KRMat4(float *pMat);
|
||||
|
||||
KRMat4(const Vector3 &axis_x, const Vector3 &axis_y, const Vector3 &axis_z, const Vector3 &trans);
|
||||
KRMat4(const Vector3 &axis_x, const Vector3 &axis_y, const Vector3 &axis_z, const Vector3 &trans);
|
||||
|
||||
// Destructor
|
||||
~KRMat4();
|
||||
// Destructor
|
||||
~KRMat4();
|
||||
|
||||
// Copy constructor
|
||||
KRMat4(const KRMat4 &m);
|
||||
// Copy constructor
|
||||
KRMat4(const KRMat4 &m);
|
||||
|
||||
// Overload assignment operator
|
||||
KRMat4& operator=(const KRMat4 &m);
|
||||
// Overload assignment operator
|
||||
KRMat4& operator=(const KRMat4 &m);
|
||||
|
||||
// Overload comparison operator
|
||||
bool operator==(const KRMat4 &m) const;
|
||||
// Overload comparison operator
|
||||
bool operator==(const KRMat4 &m) const;
|
||||
|
||||
// Overload compound multiply operator
|
||||
KRMat4& operator*=(const KRMat4 &m);
|
||||
// Overload compound multiply operator
|
||||
KRMat4& operator*=(const KRMat4 &m);
|
||||
|
||||
float& operator[](unsigned i);
|
||||
float operator[](unsigned i) const;
|
||||
float& operator[](unsigned i);
|
||||
float operator[](unsigned i) const;
|
||||
|
||||
// Overload multiply operator
|
||||
//KRMat4& operator*(const KRMat4 &m);
|
||||
KRMat4 operator*(const KRMat4 &m) const;
|
||||
// Overload multiply operator
|
||||
//KRMat4& operator*(const KRMat4 &m);
|
||||
KRMat4 operator*(const KRMat4 &m) const;
|
||||
|
||||
float *getPointer();
|
||||
float *getPointer();
|
||||
|
||||
void perspective(float fov, float aspect, float nearz, float farz);
|
||||
void ortho(float left, float right, float top, float bottom, float nearz, float farz);
|
||||
void translate(float x, float y, float z);
|
||||
void translate(const Vector3 &v);
|
||||
void scale(float x, float y, float z);
|
||||
void scale(const Vector3 &v);
|
||||
void scale(float s);
|
||||
void rotate(float angle, AXIS axis);
|
||||
void rotate(const KRQuaternion &q);
|
||||
void bias();
|
||||
bool invert();
|
||||
void transpose();
|
||||
void perspective(float fov, float aspect, float nearz, float farz);
|
||||
void ortho(float left, float right, float top, float bottom, float nearz, float farz);
|
||||
void translate(float x, float y, float z);
|
||||
void translate(const Vector3 &v);
|
||||
void scale(float x, float y, float z);
|
||||
void scale(const Vector3 &v);
|
||||
void scale(float s);
|
||||
void rotate(float angle, AXIS axis);
|
||||
void rotate(const KRQuaternion &q);
|
||||
void bias();
|
||||
bool invert();
|
||||
void transpose();
|
||||
|
||||
static Vector3 DotNoTranslate(const KRMat4 &m, const Vector3 &v); // Dot product without including translation; useful for transforming normals and tangents
|
||||
static KRMat4 Invert(const KRMat4 &m);
|
||||
static KRMat4 Transpose(const KRMat4 &m);
|
||||
static Vector3 Dot(const KRMat4 &m, const Vector3 &v);
|
||||
static Vector4 Dot4(const KRMat4 &m, const Vector4 &v);
|
||||
static float DotW(const KRMat4 &m, const Vector3 &v);
|
||||
static Vector3 DotWDiv(const KRMat4 &m, const Vector3 &v);
|
||||
static Vector3 DotNoTranslate(const KRMat4 &m, const Vector3 &v); // Dot product without including translation; useful for transforming normals and tangents
|
||||
static KRMat4 Invert(const KRMat4 &m);
|
||||
static KRMat4 Transpose(const KRMat4 &m);
|
||||
static Vector3 Dot(const KRMat4 &m, const Vector3 &v);
|
||||
static Vector4 Dot4(const KRMat4 &m, const Vector4 &v);
|
||||
static float DotW(const KRMat4 &m, const Vector3 &v);
|
||||
static Vector3 DotWDiv(const KRMat4 &m, const Vector3 &v);
|
||||
|
||||
static KRMat4 LookAt(const Vector3 &cameraPos, const Vector3 &lookAtPos, const Vector3 &upDirection);
|
||||
static KRMat4 LookAt(const Vector3 &cameraPos, const Vector3 &lookAtPos, const Vector3 &upDirection);
|
||||
|
||||
static KRMat4 Translation(const Vector3 &v);
|
||||
static KRMat4 Rotation(const Vector3 &v);
|
||||
static KRMat4 Scaling(const Vector3 &v);
|
||||
static KRMat4 Translation(const Vector3 &v);
|
||||
static KRMat4 Rotation(const Vector3 &v);
|
||||
static KRMat4 Scaling(const Vector3 &v);
|
||||
};
|
||||
|
||||
} // namespace kraken
|
||||
|
||||
#endif // KRMAT4_H
|
||||
#endif // KRAKEN_MATRIX4_H
|
||||
|
||||
@@ -38,51 +38,51 @@ namespace kraken {
|
||||
|
||||
class KRQuaternion {
|
||||
public:
|
||||
KRQuaternion();
|
||||
KRQuaternion(float w, float x, float y, float z);
|
||||
KRQuaternion(const KRQuaternion& p);
|
||||
KRQuaternion(const Vector3 &euler);
|
||||
KRQuaternion(const Vector3 &from_vector, const Vector3 &to_vector);
|
||||
~KRQuaternion();
|
||||
KRQuaternion();
|
||||
KRQuaternion(float w, float x, float y, float z);
|
||||
KRQuaternion(const KRQuaternion& p);
|
||||
KRQuaternion(const Vector3 &euler);
|
||||
KRQuaternion(const Vector3 &from_vector, const Vector3 &to_vector);
|
||||
~KRQuaternion();
|
||||
|
||||
KRQuaternion& operator =( const KRQuaternion& p );
|
||||
KRQuaternion operator +(const KRQuaternion &v) const;
|
||||
KRQuaternion operator -(const KRQuaternion &v) const;
|
||||
KRQuaternion operator +() const;
|
||||
KRQuaternion operator -() const;
|
||||
KRQuaternion& operator =( const KRQuaternion& p );
|
||||
KRQuaternion operator +(const KRQuaternion &v) const;
|
||||
KRQuaternion operator -(const KRQuaternion &v) const;
|
||||
KRQuaternion operator +() const;
|
||||
KRQuaternion operator -() const;
|
||||
|
||||
KRQuaternion operator *(const KRQuaternion &v);
|
||||
KRQuaternion operator *(float num) const;
|
||||
KRQuaternion operator /(float num) const;
|
||||
KRQuaternion operator *(const KRQuaternion &v);
|
||||
KRQuaternion operator *(float num) const;
|
||||
KRQuaternion operator /(float num) const;
|
||||
|
||||
KRQuaternion& operator +=(const KRQuaternion& v);
|
||||
KRQuaternion& operator -=(const KRQuaternion& v);
|
||||
KRQuaternion& operator *=(const KRQuaternion& v);
|
||||
KRQuaternion& operator *=(const float& v);
|
||||
KRQuaternion& operator /=(const float& v);
|
||||
KRQuaternion& operator +=(const KRQuaternion& v);
|
||||
KRQuaternion& operator -=(const KRQuaternion& v);
|
||||
KRQuaternion& operator *=(const KRQuaternion& v);
|
||||
KRQuaternion& operator *=(const float& v);
|
||||
KRQuaternion& operator /=(const float& v);
|
||||
|
||||
friend bool operator ==(KRQuaternion &v1, KRQuaternion &v2);
|
||||
friend bool operator !=(KRQuaternion &v1, KRQuaternion &v2);
|
||||
float& operator [](unsigned i);
|
||||
float operator [](unsigned i) const;
|
||||
friend bool operator ==(KRQuaternion &v1, KRQuaternion &v2);
|
||||
friend bool operator !=(KRQuaternion &v1, KRQuaternion &v2);
|
||||
float& operator [](unsigned i);
|
||||
float operator [](unsigned i) const;
|
||||
|
||||
void setEulerXYZ(const Vector3 &euler);
|
||||
void setEulerZYX(const Vector3 &euler);
|
||||
Vector3 eulerXYZ() const;
|
||||
KRMat4 rotationMatrix() const;
|
||||
void setEulerXYZ(const Vector3 &euler);
|
||||
void setEulerZYX(const Vector3 &euler);
|
||||
Vector3 eulerXYZ() const;
|
||||
KRMat4 rotationMatrix() const;
|
||||
|
||||
void normalize();
|
||||
static KRQuaternion Normalize(const KRQuaternion &v1);
|
||||
void normalize();
|
||||
static KRQuaternion Normalize(const KRQuaternion &v1);
|
||||
|
||||
void conjugate();
|
||||
static KRQuaternion Conjugate(const KRQuaternion &v1);
|
||||
void conjugate();
|
||||
static KRQuaternion Conjugate(const KRQuaternion &v1);
|
||||
|
||||
static KRQuaternion FromAngleAxis(const Vector3 &axis, float angle);
|
||||
static KRQuaternion Lerp(const KRQuaternion &a, const KRQuaternion &b, float t);
|
||||
static KRQuaternion Slerp(const KRQuaternion &a, const KRQuaternion &b, float t);
|
||||
static float Dot(const KRQuaternion &v1, const KRQuaternion &v2);
|
||||
static KRQuaternion FromAngleAxis(const Vector3 &axis, float angle);
|
||||
static KRQuaternion Lerp(const KRQuaternion &a, const KRQuaternion &b, float t);
|
||||
static KRQuaternion Slerp(const KRQuaternion &a, const KRQuaternion &b, float t);
|
||||
static float Dot(const KRQuaternion &v1, const KRQuaternion &v2);
|
||||
private:
|
||||
float m_val[4];
|
||||
float m_val[4];
|
||||
};
|
||||
|
||||
} // namespace kraken
|
||||
|
||||
@@ -39,25 +39,25 @@ namespace kraken {
|
||||
class KRTriangle3
|
||||
{
|
||||
public:
|
||||
Vector3 vert[3];
|
||||
Vector3 vert[3];
|
||||
|
||||
KRTriangle3(const KRTriangle3 &tri);
|
||||
KRTriangle3(const Vector3 &v1, const Vector3 &v2, const Vector3 &v3);
|
||||
~KRTriangle3();
|
||||
KRTriangle3(const KRTriangle3 &tri);
|
||||
KRTriangle3(const Vector3 &v1, const Vector3 &v2, const Vector3 &v3);
|
||||
~KRTriangle3();
|
||||
|
||||
Vector3 calculateNormal() const;
|
||||
Vector3 calculateNormal() const;
|
||||
|
||||
bool operator ==(const KRTriangle3& b) const;
|
||||
bool operator !=(const KRTriangle3& b) const;
|
||||
KRTriangle3& operator =(const KRTriangle3& b);
|
||||
Vector3& operator[](unsigned int i);
|
||||
Vector3 operator[](unsigned int i) const;
|
||||
bool operator ==(const KRTriangle3& b) const;
|
||||
bool operator !=(const KRTriangle3& b) const;
|
||||
KRTriangle3& operator =(const KRTriangle3& b);
|
||||
Vector3& operator[](unsigned int i);
|
||||
Vector3 operator[](unsigned int i) const;
|
||||
|
||||
bool rayCast(const Vector3 &start, const Vector3 &dir, Vector3 &hit_point) const;
|
||||
bool sphereCast(const Vector3 &start, const Vector3 &dir, float radius, Vector3 &hit_point, float &hit_distance) const;
|
||||
bool rayCast(const Vector3 &start, const Vector3 &dir, Vector3 &hit_point) const;
|
||||
bool sphereCast(const Vector3 &start, const Vector3 &dir, float radius, Vector3 &hit_point, float &hit_distance) const;
|
||||
|
||||
bool containsPoint(const Vector3 &p) const;
|
||||
Vector3 closestPointOnTriangle(const Vector3 &p) const;
|
||||
bool containsPoint(const Vector3 &p) const;
|
||||
Vector3 closestPointOnTriangle(const Vector3 &p) const;
|
||||
};
|
||||
|
||||
} // namespace kraken
|
||||
|
||||
@@ -34,7 +34,7 @@
|
||||
|
||||
namespace kraken {
|
||||
|
||||
float SmoothStep(float a, float b, float t);
|
||||
float SmoothStep(float a, float b, float t);
|
||||
|
||||
}; // namespace kraken
|
||||
|
||||
|
||||
@@ -39,62 +39,62 @@ namespace kraken {
|
||||
class Vector2 {
|
||||
|
||||
public:
|
||||
union {
|
||||
struct {
|
||||
float x, y;
|
||||
};
|
||||
float c[2];
|
||||
union {
|
||||
struct {
|
||||
float x, y;
|
||||
};
|
||||
float c[2];
|
||||
};
|
||||
|
||||
Vector2();
|
||||
Vector2(float X, float Y);
|
||||
Vector2(float v);
|
||||
Vector2(float *v);
|
||||
Vector2(const Vector2 &v);
|
||||
~Vector2();
|
||||
Vector2();
|
||||
Vector2(float X, float Y);
|
||||
Vector2(float v);
|
||||
Vector2(float *v);
|
||||
Vector2(const Vector2 &v);
|
||||
~Vector2();
|
||||
|
||||
// Vector2 swizzle getters
|
||||
Vector2 yx() const;
|
||||
// Vector2 swizzle getters
|
||||
Vector2 yx() const;
|
||||
|
||||
// Vector2 swizzle setters
|
||||
void yx(const Vector2 &v);
|
||||
// Vector2 swizzle setters
|
||||
void yx(const Vector2 &v);
|
||||
|
||||
Vector2& operator =(const Vector2& b);
|
||||
Vector2 operator +(const Vector2& b) const;
|
||||
Vector2 operator -(const Vector2& b) const;
|
||||
Vector2 operator +() const;
|
||||
Vector2 operator -() const;
|
||||
Vector2 operator *(const float v) const;
|
||||
Vector2 operator /(const float v) const;
|
||||
Vector2& operator =(const Vector2& b);
|
||||
Vector2 operator +(const Vector2& b) const;
|
||||
Vector2 operator -(const Vector2& b) const;
|
||||
Vector2 operator +() const;
|
||||
Vector2 operator -() const;
|
||||
Vector2 operator *(const float v) const;
|
||||
Vector2 operator /(const float v) const;
|
||||
|
||||
Vector2& operator +=(const Vector2& b);
|
||||
Vector2& operator -=(const Vector2& b);
|
||||
Vector2& operator *=(const float v);
|
||||
Vector2& operator /=(const float v);
|
||||
Vector2& operator +=(const Vector2& b);
|
||||
Vector2& operator -=(const Vector2& b);
|
||||
Vector2& operator *=(const float v);
|
||||
Vector2& operator /=(const float v);
|
||||
|
||||
// Comparison operators are implemented to allow insertion into sorted containers such as std::set
|
||||
bool operator >(const Vector2& b) const;
|
||||
bool operator <(const Vector2& b) const;
|
||||
// Comparison operators are implemented to allow insertion into sorted containers such as std::set
|
||||
bool operator >(const Vector2& b) const;
|
||||
bool operator <(const Vector2& b) const;
|
||||
|
||||
bool operator ==(const Vector2& b) const;
|
||||
bool operator !=(const Vector2& b) const;
|
||||
bool operator ==(const Vector2& b) const;
|
||||
bool operator !=(const Vector2& b) const;
|
||||
|
||||
float& operator[](unsigned i);
|
||||
float operator[](unsigned i) const;
|
||||
float& operator[](unsigned i);
|
||||
float operator[](unsigned i) const;
|
||||
|
||||
float sqrMagnitude() const;
|
||||
float magnitude() const;
|
||||
float sqrMagnitude() const;
|
||||
float magnitude() const;
|
||||
|
||||
void normalize();
|
||||
static Vector2 Normalize(const Vector2 &v);
|
||||
void normalize();
|
||||
static Vector2 Normalize(const Vector2 &v);
|
||||
|
||||
static float Cross(const Vector2 &v1, const Vector2 &v2);
|
||||
static float Cross(const Vector2 &v1, const Vector2 &v2);
|
||||
|
||||
static float Dot(const Vector2 &v1, const Vector2 &v2);
|
||||
static Vector2 Min();
|
||||
static Vector2 Max();
|
||||
static Vector2 Zero();
|
||||
static Vector2 One();
|
||||
static float Dot(const Vector2 &v1, const Vector2 &v2);
|
||||
static Vector2 Min();
|
||||
static Vector2 Max();
|
||||
static Vector2 Zero();
|
||||
static Vector2 One();
|
||||
};
|
||||
|
||||
} // namespace kraken
|
||||
@@ -110,7 +110,6 @@ namespace std {
|
||||
return h1 ^ (h2 << 1);
|
||||
}
|
||||
};
|
||||
}
|
||||
} // namespace std
|
||||
|
||||
#endif // KRAKEN_VECTOR2_H
|
||||
|
||||
|
||||
@@ -42,89 +42,89 @@ namespace kraken {
|
||||
class Vector3 {
|
||||
|
||||
public:
|
||||
union {
|
||||
struct {
|
||||
float x, y, z;
|
||||
};
|
||||
float c[3];
|
||||
union {
|
||||
struct {
|
||||
float x, y, z;
|
||||
};
|
||||
float c[3];
|
||||
};
|
||||
|
||||
Vector3();
|
||||
Vector3(float X, float Y, float Z);
|
||||
Vector3(float v);
|
||||
Vector3(float *v);
|
||||
Vector3(double *v);
|
||||
Vector3(const Vector3 &v);
|
||||
Vector3(const Vector4 &v);
|
||||
~Vector3();
|
||||
Vector3();
|
||||
Vector3(float X, float Y, float Z);
|
||||
Vector3(float v);
|
||||
Vector3(float *v);
|
||||
Vector3(double *v);
|
||||
Vector3(const Vector3 &v);
|
||||
Vector3(const Vector4 &v);
|
||||
~Vector3();
|
||||
|
||||
// Vector2 swizzle getters
|
||||
Vector2 xx() const;
|
||||
Vector2 xy() const;
|
||||
Vector2 xz() const;
|
||||
Vector2 yx() const;
|
||||
Vector2 yy() const;
|
||||
Vector2 yz() const;
|
||||
Vector2 zx() const;
|
||||
Vector2 zy() const;
|
||||
Vector2 zz() const;
|
||||
// Vector2 swizzle getters
|
||||
Vector2 xx() const;
|
||||
Vector2 xy() const;
|
||||
Vector2 xz() const;
|
||||
Vector2 yx() const;
|
||||
Vector2 yy() const;
|
||||
Vector2 yz() const;
|
||||
Vector2 zx() const;
|
||||
Vector2 zy() const;
|
||||
Vector2 zz() const;
|
||||
|
||||
// Vector2 swizzle setters
|
||||
void xy(const Vector2 &v);
|
||||
void xz(const Vector2 &v);
|
||||
void yx(const Vector2 &v);
|
||||
void yz(const Vector2 &v);
|
||||
void zx(const Vector2 &v);
|
||||
void zy(const Vector2 &v);
|
||||
// Vector2 swizzle setters
|
||||
void xy(const Vector2 &v);
|
||||
void xz(const Vector2 &v);
|
||||
void yx(const Vector2 &v);
|
||||
void yz(const Vector2 &v);
|
||||
void zx(const Vector2 &v);
|
||||
void zy(const Vector2 &v);
|
||||
|
||||
Vector3& operator =(const Vector3& b);
|
||||
Vector3& operator =(const Vector4& b);
|
||||
Vector3 operator +(const Vector3& b) const;
|
||||
Vector3 operator -(const Vector3& b) const;
|
||||
Vector3 operator +() const;
|
||||
Vector3 operator -() const;
|
||||
Vector3 operator *(const float v) const;
|
||||
Vector3 operator /(const float v) const;
|
||||
Vector3& operator =(const Vector3& b);
|
||||
Vector3& operator =(const Vector4& b);
|
||||
Vector3 operator +(const Vector3& b) const;
|
||||
Vector3 operator -(const Vector3& b) const;
|
||||
Vector3 operator +() const;
|
||||
Vector3 operator -() const;
|
||||
Vector3 operator *(const float v) const;
|
||||
Vector3 operator /(const float v) const;
|
||||
|
||||
Vector3& operator +=(const Vector3& b);
|
||||
Vector3& operator -=(const Vector3& b);
|
||||
Vector3& operator *=(const float v);
|
||||
Vector3& operator /=(const float v);
|
||||
Vector3& operator +=(const Vector3& b);
|
||||
Vector3& operator -=(const Vector3& b);
|
||||
Vector3& operator *=(const float v);
|
||||
Vector3& operator /=(const float v);
|
||||
|
||||
bool operator ==(const Vector3& b) const;
|
||||
bool operator !=(const Vector3& b) const;
|
||||
bool operator ==(const Vector3& b) const;
|
||||
bool operator !=(const Vector3& b) const;
|
||||
|
||||
// Comparison operators are implemented to allow insertion into sorted containers such as std::set
|
||||
bool operator >(const Vector3& b) const;
|
||||
bool operator <(const Vector3& b) const;
|
||||
// Comparison operators are implemented to allow insertion into sorted containers such as std::set
|
||||
bool operator >(const Vector3& b) const;
|
||||
bool operator <(const Vector3& b) const;
|
||||
|
||||
float& operator[](unsigned i);
|
||||
float operator[](unsigned i) const;
|
||||
float& operator[](unsigned i);
|
||||
float operator[](unsigned i) const;
|
||||
|
||||
float sqrMagnitude() const; // calculate the square of the magnitude (useful for comparison of magnitudes without the cost of a sqrt() function)
|
||||
float magnitude() const;
|
||||
float sqrMagnitude() const; // calculate the square of the magnitude (useful for comparison of magnitudes without the cost of a sqrt() function)
|
||||
float magnitude() const;
|
||||
|
||||
void scale(const Vector3 &v);
|
||||
void normalize();
|
||||
static Vector3 Normalize(const Vector3 &v);
|
||||
void scale(const Vector3 &v);
|
||||
void normalize();
|
||||
static Vector3 Normalize(const Vector3 &v);
|
||||
|
||||
static Vector3 Cross(const Vector3 &v1, const Vector3 &v2);
|
||||
static Vector3 Cross(const Vector3 &v1, const Vector3 &v2);
|
||||
|
||||
static float Dot(const Vector3 &v1, const Vector3 &v2);
|
||||
static Vector3 Min();
|
||||
static Vector3 Max();
|
||||
static const Vector3 &Zero();
|
||||
static Vector3 One();
|
||||
static Vector3 Forward();
|
||||
static Vector3 Backward();
|
||||
static Vector3 Up();
|
||||
static Vector3 Down();
|
||||
static Vector3 Left();
|
||||
static Vector3 Right();
|
||||
static Vector3 Scale(const Vector3 &v1, const Vector3 &v2);
|
||||
static Vector3 Lerp(const Vector3 &v1, const Vector3 &v2, float d);
|
||||
static Vector3 Slerp(const Vector3 &v1, const Vector3 &v2, float d);
|
||||
static void OrthoNormalize(Vector3 &normal, Vector3 &tangent); // Gram-Schmidt Orthonormalization
|
||||
static float Dot(const Vector3 &v1, const Vector3 &v2);
|
||||
static Vector3 Min();
|
||||
static Vector3 Max();
|
||||
static const Vector3 &Zero();
|
||||
static Vector3 One();
|
||||
static Vector3 Forward();
|
||||
static Vector3 Backward();
|
||||
static Vector3 Up();
|
||||
static Vector3 Down();
|
||||
static Vector3 Left();
|
||||
static Vector3 Right();
|
||||
static Vector3 Scale(const Vector3 &v1, const Vector3 &v2);
|
||||
static Vector3 Lerp(const Vector3 &v1, const Vector3 &v2, float d);
|
||||
static Vector3 Slerp(const Vector3 &v1, const Vector3 &v2, float d);
|
||||
static void OrthoNormalize(Vector3 &normal, Vector3 &tangent); // Gram-Schmidt Orthonormalization
|
||||
};
|
||||
|
||||
} // namespace kraken
|
||||
@@ -141,6 +141,6 @@ namespace std {
|
||||
return h1 ^ (h2 << 1) ^ (h3 << 2);
|
||||
}
|
||||
};
|
||||
}
|
||||
} // namespace std
|
||||
|
||||
#endif // KRAKEN_VECTOR3_H
|
||||
|
||||
@@ -41,65 +41,65 @@ class Vector3;
|
||||
class Vector4 {
|
||||
|
||||
public:
|
||||
union {
|
||||
struct {
|
||||
float x, y, z, w;
|
||||
};
|
||||
float c[4];
|
||||
union {
|
||||
struct {
|
||||
float x, y, z, w;
|
||||
};
|
||||
float c[4];
|
||||
};
|
||||
|
||||
Vector4();
|
||||
Vector4(float X, float Y, float Z, float W);
|
||||
Vector4(float v);
|
||||
Vector4(float *v);
|
||||
Vector4(const Vector4 &v);
|
||||
Vector4(const Vector3 &v, float W);
|
||||
~Vector4();
|
||||
Vector4();
|
||||
Vector4(float X, float Y, float Z, float W);
|
||||
Vector4(float v);
|
||||
Vector4(float *v);
|
||||
Vector4(const Vector4 &v);
|
||||
Vector4(const Vector3 &v, float W);
|
||||
~Vector4();
|
||||
|
||||
|
||||
Vector4& operator =(const Vector4& b);
|
||||
Vector4 operator +(const Vector4& b) const;
|
||||
Vector4 operator -(const Vector4& b) const;
|
||||
Vector4 operator +() const;
|
||||
Vector4 operator -() const;
|
||||
Vector4 operator *(const float v) const;
|
||||
Vector4 operator /(const float v) const;
|
||||
Vector4& operator =(const Vector4& b);
|
||||
Vector4 operator +(const Vector4& b) const;
|
||||
Vector4 operator -(const Vector4& b) const;
|
||||
Vector4 operator +() const;
|
||||
Vector4 operator -() const;
|
||||
Vector4 operator *(const float v) const;
|
||||
Vector4 operator /(const float v) const;
|
||||
|
||||
Vector4& operator +=(const Vector4& b);
|
||||
Vector4& operator -=(const Vector4& b);
|
||||
Vector4& operator *=(const float v);
|
||||
Vector4& operator /=(const float v);
|
||||
Vector4& operator +=(const Vector4& b);
|
||||
Vector4& operator -=(const Vector4& b);
|
||||
Vector4& operator *=(const float v);
|
||||
Vector4& operator /=(const float v);
|
||||
|
||||
bool operator ==(const Vector4& b) const;
|
||||
bool operator !=(const Vector4& b) const;
|
||||
bool operator ==(const Vector4& b) const;
|
||||
bool operator !=(const Vector4& b) const;
|
||||
|
||||
// Comparison operators are implemented to allow insertion into sorted containers such as std::set
|
||||
bool operator >(const Vector4& b) const;
|
||||
bool operator <(const Vector4& b) const;
|
||||
// Comparison operators are implemented to allow insertion into sorted containers such as std::set
|
||||
bool operator >(const Vector4& b) const;
|
||||
bool operator <(const Vector4& b) const;
|
||||
|
||||
float& operator[](unsigned i);
|
||||
float operator[](unsigned i) const;
|
||||
float& operator[](unsigned i);
|
||||
float operator[](unsigned i) const;
|
||||
|
||||
float sqrMagnitude() const; // calculate the square of the magnitude (useful for comparison of magnitudes without the cost of a sqrt() function)
|
||||
float magnitude() const;
|
||||
float sqrMagnitude() const; // calculate the square of the magnitude (useful for comparison of magnitudes without the cost of a sqrt() function)
|
||||
float magnitude() const;
|
||||
|
||||
void normalize();
|
||||
static Vector4 Normalize(const Vector4 &v);
|
||||
void normalize();
|
||||
static Vector4 Normalize(const Vector4 &v);
|
||||
|
||||
static float Dot(const Vector4 &v1, const Vector4 &v2);
|
||||
static Vector4 Min();
|
||||
static Vector4 Max();
|
||||
static const Vector4 &Zero();
|
||||
static Vector4 One();
|
||||
static Vector4 Forward();
|
||||
static Vector4 Backward();
|
||||
static Vector4 Up();
|
||||
static Vector4 Down();
|
||||
static Vector4 Left();
|
||||
static Vector4 Right();
|
||||
static Vector4 Lerp(const Vector4 &v1, const Vector4 &v2, float d);
|
||||
static Vector4 Slerp(const Vector4 &v1, const Vector4 &v2, float d);
|
||||
static void OrthoNormalize(Vector4 &normal, Vector4 &tangent); // Gram-Schmidt Orthonormalization
|
||||
static float Dot(const Vector4 &v1, const Vector4 &v2);
|
||||
static Vector4 Min();
|
||||
static Vector4 Max();
|
||||
static const Vector4 &Zero();
|
||||
static Vector4 One();
|
||||
static Vector4 Forward();
|
||||
static Vector4 Backward();
|
||||
static Vector4 Up();
|
||||
static Vector4 Down();
|
||||
static Vector4 Left();
|
||||
static Vector4 Right();
|
||||
static Vector4 Lerp(const Vector4 &v1, const Vector4 &v2, float d);
|
||||
static Vector4 Slerp(const Vector4 &v1, const Vector4 &v2, float d);
|
||||
static void OrthoNormalize(Vector4 &normal, Vector4 &tangent); // Gram-Schmidt Orthonormalization
|
||||
};
|
||||
|
||||
} // namespace kraken
|
||||
@@ -117,6 +117,6 @@ namespace std {
|
||||
return h1 ^ (h2 << 1) ^ (h3 << 2) ^ (h4 << 3);
|
||||
}
|
||||
};
|
||||
}
|
||||
} // namespace std
|
||||
|
||||
#endif // KRAKEN_VECTOR4_H
|
||||
|
||||
Reference in New Issue
Block a user