Blender V2.61 - r43446
|
00001 /* 00002 * ***** BEGIN GPL LICENSE BLOCK ***** 00003 * 00004 * This program is free software; you can redistribute it and/or 00005 * modify it under the terms of the GNU General Public License 00006 * as published by the Free Software Foundation; either version 2 00007 * of the License, or (at your option) any later version. 00008 * 00009 * This program is distributed in the hope that it will be useful, 00010 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00011 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00012 * GNU General Public License for more details. 00013 * 00014 * You should have received a copy of the GNU General Public License 00015 * along with this program; if not, write to the Free Software Foundation, 00016 * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 00017 * 00018 * The Original Code is Copyright (C) 2001-2002 by NaN Holding BV. 00019 * All rights reserved. 00020 * 00021 * The Original Code is: all of this file. 00022 * 00023 * Contributor(s): none yet. 00024 * 00025 * ***** END GPL LICENSE BLOCK ***** 00026 */ 00027 00033 /* 00034 00035 * Copyright (c) 2000 Gino van den Bergen <gino@acm.org> 00036 * 00037 * Permission to use, copy, modify, distribute and sell this software 00038 * and its documentation for any purpose is hereby granted without fee, 00039 * provided that the above copyright notice appear in all copies and 00040 * that both that copyright notice and this permission notice appear 00041 * in supporting documentation. Gino van den Bergen makes no 00042 * representations about the suitability of this software for any 00043 * purpose. It is provided "as is" without express or implied warranty. 00044 * 00045 */ 00046 00047 #ifndef MT_TUPLE4_H 00048 #define MT_TUPLE4_H 00049 00050 #include "MT_Stream.h" 00051 #include "MT_Scalar.h" 00052 00053 class MT_Tuple4 { 00054 public: 00055 MT_Tuple4() {} 00056 MT_Tuple4(const float *v) { setValue(v); } 00057 MT_Tuple4(const double *v) { setValue(v); } 00058 MT_Tuple4(MT_Scalar xx, MT_Scalar yy, MT_Scalar zz, MT_Scalar ww) { 00059 setValue(xx, yy, zz, ww); 00060 } 00061 00062 MT_Scalar& operator[](int i) { return m_co[i]; } 00063 const MT_Scalar& operator[](int i) const { return m_co[i]; } 00064 00065 MT_Scalar& x() { return m_co[0]; } 00066 const MT_Scalar& x() const { return m_co[0]; } 00067 00068 MT_Scalar& y() { return m_co[1]; } 00069 const MT_Scalar& y() const { return m_co[1]; } 00070 00071 MT_Scalar& z() { return m_co[2]; } 00072 const MT_Scalar& z() const { return m_co[2]; } 00073 00074 MT_Scalar& w() { return m_co[3]; } 00075 const MT_Scalar& w() const { return m_co[3]; } 00076 00077 MT_Scalar *getValue() { return m_co; } 00078 const MT_Scalar *getValue() const { return m_co; } 00079 00080 00081 void getValue(float *v) const { 00082 v[0] = float(m_co[0]); 00083 v[1] = float(m_co[1]); 00084 v[2] = float(m_co[2]); 00085 v[3] = float(m_co[3]); 00086 } 00087 00088 void getValue(double *v) const { 00089 v[0] = double(m_co[0]); 00090 v[1] = double(m_co[1]); 00091 v[2] = double(m_co[2]); 00092 v[3] = double(m_co[3]); 00093 } 00094 00095 void setValue(const float *v) { 00096 m_co[0] = MT_Scalar(v[0]); 00097 m_co[1] = MT_Scalar(v[1]); 00098 m_co[2] = MT_Scalar(v[2]); 00099 m_co[3] = MT_Scalar(v[3]); 00100 } 00101 00102 void setValue(const double *v) { 00103 m_co[0] = MT_Scalar(v[0]); 00104 m_co[1] = MT_Scalar(v[1]); 00105 m_co[2] = MT_Scalar(v[2]); 00106 m_co[3] = MT_Scalar(v[3]); 00107 } 00108 00109 void setValue(MT_Scalar xx, MT_Scalar yy, MT_Scalar zz, MT_Scalar ww) { 00110 m_co[0] = xx; m_co[1] = yy; m_co[2] = zz; m_co[3] = ww; 00111 } 00112 00113 protected: 00114 MT_Scalar m_co[4]; 00115 }; 00116 00117 inline bool operator==(const MT_Tuple4& t1, const MT_Tuple4& t2) { 00118 return t1[0] == t2[0] && t1[1] == t2[1] && t1[2] == t2[2] && t1[3] == t2[3]; 00119 } 00120 00121 inline MT_OStream& operator<<(MT_OStream& os, const MT_Tuple4& t) { 00122 return os << t[0] << ' ' << t[1] << ' ' << t[2] << ' ' << t[3]; 00123 } 00124 00125 #endif 00126