Program that converts geometric and animation 3D scene data, from a COLLADA "*.dae" file to a binary file, with a custom format.
#ifndef MATH_VEC4_H_
#define MATH_VEC4_H_
#include "./vec3.h"
namespace math
{
struct VEC4
{
float x, y, z, w;
VEC3& xyz() const { return *((VEC3*)&x); }
VEC4() {}
VEC4(float s) : x(s), y(s), z(s), w(s) {}
VEC4(float x, float y, float z, float w) : x(x), y(y), z(z), w(w) {}
VEC4(const VEC3 &xyz) : x(xyz.x), y(xyz.y), z(xyz.z), w(0) {}
VEC4(const VEC3 &xyz, float w) : x(xyz.x), y(xyz.y), z(xyz.z), w(w) {}
VEC4(const VEC2 &xy, const VEC2 &zw) : x(xy.x), y(xy.y), z(zw.x), w(zw.y) {}
inline bool operator == (const VEC4 &v) const { return x == v.x && y == v.y && z == v.z && w == v.w; }
inline bool operator != (const VEC4 &v) const { return !(*this == v); }
VEC4 operator + (const VEC4 &v) const { return VEC4(x + v.x, y + v.y, z + v.z, w + v.w); }
VEC4 operator - (const VEC4 &v) const { return VEC4(x - v.x, y - v.y, z - v.z, w - v.w); }
VEC4 operator * (const VEC4 &v) const { return VEC4(x*v.x, y*v.y, z*v.z, w*v.w); }
VEC4& operator *= (const VEC4 &v) { x*=v.x; y*=v.y; z*=v.z; w*=v.w; return *this; }
VEC4 lerp(const VEC4 &v, const float t) const {
if (t <= 0.0f) return *this;
if (t >= 1.0f) return v;
return *this + (v - *this) * t;
}
};
}
#endif