FMath/FMVector4.h

Go to the documentation of this file.
00001 /*
00002     Copyright (C) 2005-2007 Feeling Software Inc.
00003     Portions of the code are:
00004     Copyright (C) 2005-2007 Sony Computer Entertainment America
00005     
00006     MIT License: http://www.opensource.org/licenses/mit-license.php
00007 */
00008 
00014 #ifndef _FM_VECTOR4_H_
00015 #define _FM_VECTOR4_H_
00016 
00017 class FMColor;
00018 
00025 class FCOLLADA_EXPORT
00026 ALIGN_STRUCT(16)
00027 FMVector4
00028 {
00029 public:
00030     float x;    
00031     float y;    
00032     float z;    
00033     float w;    
00036     #ifndef _DEBUG
00037     inline FMVector4() {}
00038     #else
00039     inline FMVector4() { x = 123456789.0f; y = 123456789.0f; z = 123456789.0f; w = 123456789.0f; }
00040     #endif 
00041 
00048     inline FMVector4(const float* source, uint32 startIndex = 0) { source = source + startIndex; x = *source++; y = *source++; z = *source++; w = *source; }
00049 
00056     inline FMVector4(const FMVector3& v, float _w) { x = v.x; y = v.y; z = v.z; w = _w; }
00057 
00061     inline FMVector4(const FMVector2& v1, const FMVector2& v2) { x = v1.x; y = v1.y; z = v2.x; w = v2.y; }
00062 
00068     inline FMVector4(float _x, float _y, float _z, float _w) { x = _x; y = _y; z = _z; w = _w; }
00069 
00072     FMVector4(const FMColor& c);
00073 
00080     static FMVector4 FromHSVColor(float hue, float saturation, float value);
00081 
00087     FMVector3 ToHSVColor();
00088 
00089 public:
00092     inline operator float*() { return &x; }
00093 
00096     inline operator const float*() const { return &x; }
00097 
00104     inline FMVector4& operator =(const float* v) { x = *v; y = *(v + 1); z = *(v + 2); w = *(v+3); return *this; }
00105 
00110     inline void ComponentMinimum(const FMVector4& min) { if (x < min.x) x = min.x; if (y < min.y) y = min.y; if (z < min.z) z = min.z; if (w < min.w) w = min.w; }
00111 
00116     inline void ComponentMaximum(const FMVector4& max) { if (x > max.x) x = max.x; if (y > max.y) y = max.y; if (z > max.z) z = max.z; if (w > max.w) w = max.w;}
00117 
00118 public:
00119     static const FMVector4 Zero;    
00120     static const FMVector4 One;     
00121     static const FMVector4 AlphaOne;
00122 };
00123 
00128 inline FMVector4 operator *(const FMVector4& a, float b) { return FMVector4(a.x * b, a.y * b, a.z * b, a.w * b); }
00129 
00134 inline FMVector4 operator *(float a, const FMVector4& b) { return FMVector4(a * b.x, a * b.y, a * b.z, a * b.w); }
00135 
00140 inline FMVector4 operator +(const FMVector4& a, const FMVector4& b) { return FMVector4(a.x + b.x, a.y + b.y, a.z + b.z, a.w + b.w); }
00141 
00146 inline FMVector4 operator -(const FMVector4& a, const FMVector4& b) { return FMVector4(a.x - b.x, a.y - b.y, a.z - b.z, a.w - b.w); }
00147 
00152 inline FMVector4& operator +=(FMVector4& b, const FMVector4& a) { b.x += a.x; b.y += a.y; b.z += a.z; b.w += a.w; return b; }
00153 
00158 inline FMVector4& operator -=(FMVector4& b, const FMVector4& a) { b.x -= a.x; b.y -= a.y; b.z -= a.z; b.w -= a.w; return b; }
00159 
00164 inline FMVector4& operator *=(FMVector4& b, float a) { b.x *= a; b.y *= a; b.z *= a; b.w *= a; return b; }
00165 
00170 inline FMVector4& operator /=(FMVector4& b, float a) { b.x /= a; b.y /= a; b.z /= a; b.w /= a; return b; }
00171 
00176 inline float operator *(const FMVector4& a, const FMVector4& b) { return a.x * b.x + a.y * b.y + a.z * b.z + a.w * b.w; }
00177 
00178 
00183 inline bool IsEquivalent(const FMVector4& p, const FMVector4& q) { return IsEquivalent(p.x, q.x) && IsEquivalent(p.y, q.y) && IsEquivalent(p.z, q.z) && IsEquivalent(p.w, q.w); }
00184 inline bool operator==(const FMVector4& p, const FMVector4& q) { return IsEquivalent(p.x, q.x) && IsEquivalent(p.y, q.y) && IsEquivalent(p.z, q.z) && IsEquivalent(p.w, q.w); } 
00187 typedef fm::vector<FMVector4> FMVector4List;
00188 
00189 #endif // _FM_VECTOR4_H_

Generated on Thu Feb 14 16:58:35 2008 for FCollada by  doxygen 1.4.6-NO