<html> <head> <title>OgreColourValue.h Source File - OGRE Documentation</title> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"> <link type="text/css" rel="stylesheet" href="style.css"> </head> <body> <!-- Generated by Doxygen 1.3.6 --> <div class="qindex"><a class="qindex" href="index.html">Main Page</a> | <a class="qindex" href="namespaces.html">Namespace List</a> | <a class="qindex" href="hierarchy.html">Class Hierarchy</a> | <a class="qindex" href="classes.html">Alphabetical List</a> | <a class="qindex" href="annotated.html">Class List</a> | <a class="qindex" href="files.html">File List</a> | <a class="qindex" href="namespacemembers.html">Namespace Members</a> | <a class="qindex" href="functions.html">Class Members</a> | <a class="qindex" href="globals.html">File Members</a> | <a class="qindex" href="pages.html">Related Pages</a></div> <h1>OgreColourValue.h</h1><a href="OgreColourValue_8h.html">Go to the documentation of this file.</a><div class="fragment"><pre>00001 <span class="comment">/*</span> 00002 <span class="comment">-----------------------------------------------------------------------------</span> 00003 <span class="comment">This source file is part of OGRE</span> 00004 <span class="comment"> (Object-oriented Graphics Rendering Engine)</span> 00005 <span class="comment">For the latest info, see http://www.ogre3d.org/</span> 00006 <span class="comment"></span> 00007 <span class="comment">Copyright (c) 2000-2005 The OGRE Team</span> 00008 <span class="comment">Also see acknowledgements in Readme.html</span> 00009 <span class="comment"></span> 00010 <span class="comment">This program is free software; you can redistribute it and/or modify it under</span> 00011 <span class="comment">the terms of the GNU Lesser General Public License as published by the Free Software</span> 00012 <span class="comment">Foundation; either version 2 of the License, or (at your option) any later</span> 00013 <span class="comment">version.</span> 00014 <span class="comment"></span> 00015 <span class="comment">This program is distributed in the hope that it will be useful, but WITHOUT</span> 00016 <span class="comment">ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS</span> 00017 <span class="comment">FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.</span> 00018 <span class="comment"></span> 00019 <span class="comment">You should have received a copy of the GNU Lesser General Public License along with</span> 00020 <span class="comment">this program; if not, write to the Free Software Foundation, Inc., 59 Temple</span> 00021 <span class="comment">Place - Suite 330, Boston, MA 02111-1307, USA, or go to</span> 00022 <span class="comment">http://www.gnu.org/copyleft/lesser.txt.</span> 00023 <span class="comment">-----------------------------------------------------------------------------</span> 00024 <span class="comment">*/</span> 00025 <span class="preprocessor">#ifndef _COLOURVALUE_H__</span> 00026 <span class="preprocessor"></span><span class="preprocessor">#define _COLOURVALUE_H__</span> 00027 <span class="preprocessor"></span> 00028 <span class="preprocessor">#include "<a class="code" href="OgrePrerequisites_8h.html">OgrePrerequisites.h</a>"</span> 00029 00030 <span class="keyword">namespace </span>Ogre { 00031 <a name="l00032"></a><a class="code" href="namespaceOgre.html#a55">00032</a> <span class="keyword">typedef</span> <a class="code" href="namespaceOgre.html#a412">uint32</a> <a class="code" href="namespaceOgre.html#a55">RGBA</a>; <a name="l00033"></a><a class="code" href="namespaceOgre.html#a56">00033</a> <span class="keyword">typedef</span> <a class="code" href="namespaceOgre.html#a412">uint32</a> <a class="code" href="namespaceOgre.html#a56">ARGB</a>; <a name="l00034"></a><a class="code" href="namespaceOgre.html#a57">00034</a> <span class="keyword">typedef</span> <a class="code" href="namespaceOgre.html#a412">uint32</a> <a class="code" href="namespaceOgre.html#a57">ABGR</a>; 00035 <a name="l00047"></a><a class="code" href="classOgre_1_1ColourValue.html">00047</a> <span class="keyword">class </span><a class="code" href="OgrePlatform_8h.html#a13">_OgreExport</a> ColourValue 00048 { 00049 <span class="keyword">public</span>: <a name="l00050"></a><a class="code" href="classOgre_1_1ColourValue.html#Ogre_1_1ColourValues0">00050</a> <span class="keyword">static</span> ColourValue Black; <a name="l00051"></a><a class="code" href="classOgre_1_1ColourValue.html#Ogre_1_1ColourValues1">00051</a> <span class="keyword">static</span> ColourValue White; <a name="l00052"></a><a class="code" href="classOgre_1_1ColourValue.html#Ogre_1_1ColourValues2">00052</a> <span class="keyword">static</span> ColourValue Red; <a name="l00053"></a><a class="code" href="classOgre_1_1ColourValue.html#Ogre_1_1ColourValues3">00053</a> <span class="keyword">static</span> ColourValue Green; <a name="l00054"></a><a class="code" href="classOgre_1_1ColourValue.html#Ogre_1_1ColourValues4">00054</a> <span class="keyword">static</span> ColourValue Blue; 00055 <a name="l00056"></a><a class="code" href="classOgre_1_1ColourValue.html#Ogre_1_1ColourValuea0">00056</a> ColourValue( <span class="keywordtype">float</span> red = 1.0f, 00057 <span class="keywordtype">float</span> green = 1.0f, 00058 <span class="keywordtype">float</span> blue = 1.0f, 00059 <span class="keywordtype">float</span> alpha = 1.0f ) : r(red), g(green), b(blue), a(alpha) 00060 { } 00061 00062 <span class="keywordtype">bool</span> <a class="code" href="namespaceOgre.html#a617">operator==</a>(<span class="keyword">const</span> ColourValue& rhs) <span class="keyword">const</span>; 00063 <span class="keywordtype">bool</span> <a class="code" href="namespaceOgre.html#a618">operator!=</a>(<span class="keyword">const</span> ColourValue& rhs) <span class="keyword">const</span>; 00064 00065 <span class="keyword">union </span>{ 00066 <span class="keyword">struct </span>{ <a name="l00067"></a><a class="code" href="classOgre_1_1ColourValue.html#Ogre_1_1ColourValueo0">00067</a> <span class="keywordtype">float</span> r,g,b,a; 00068 }; <a name="l00069"></a><a class="code" href="classOgre_1_1ColourValue.html#Ogre_1_1ColourValueo4">00069</a> <span class="keywordtype">float</span> val[4]; 00070 }; 00071 00074 <a class="code" href="namespaceOgre.html#a55">RGBA</a> getAsRGBA(<span class="keywordtype">void</span>) <span class="keyword">const</span>; 00075 00078 <a class="code" href="namespaceOgre.html#a56">ARGB</a> getAsARGB(<span class="keywordtype">void</span>) <span class="keyword">const</span>; 00079 00081 <a class="code" href="namespaceOgre.html#a57">ABGR</a> getAsABGR(<span class="keywordtype">void</span>) <span class="keyword">const</span>; 00082 00083 <span class="comment">// arithmetic operations</span> <a name="l00084"></a><a class="code" href="classOgre_1_1ColourValue.html#Ogre_1_1ColourValuea6">00084</a> <span class="keyword">inline</span> ColourValue operator + ( <span class="keyword">const</span> ColourValue& rkVector )<span class="keyword"> const</span> 00085 <span class="keyword"> </span>{ 00086 ColourValue kSum; 00087 00088 kSum.<a class="code" href="classOgre_1_1ColourValue.html#Ogre_1_1ColourValueo0">r</a> = r + rkVector.<a class="code" href="classOgre_1_1ColourValue.html#Ogre_1_1ColourValueo0">r</a>; 00089 kSum.<a class="code" href="classOgre_1_1ColourValue.html#Ogre_1_1ColourValueo1">g</a> = g + rkVector.<a class="code" href="classOgre_1_1ColourValue.html#Ogre_1_1ColourValueo1">g</a>; 00090 kSum.<a class="code" href="classOgre_1_1ColourValue.html#Ogre_1_1ColourValueo2">b</a> = b + rkVector.<a class="code" href="classOgre_1_1ColourValue.html#Ogre_1_1ColourValueo2">b</a>; 00091 kSum.<a class="code" href="classOgre_1_1ColourValue.html#Ogre_1_1ColourValueo3">a</a> = a + rkVector.<a class="code" href="classOgre_1_1ColourValue.html#Ogre_1_1ColourValueo3">a</a>; 00092 00093 <span class="keywordflow">return</span> kSum; 00094 } 00095 <a name="l00096"></a><a class="code" href="classOgre_1_1ColourValue.html#Ogre_1_1ColourValuea7">00096</a> <span class="keyword">inline</span> ColourValue operator - ( <span class="keyword">const</span> ColourValue& rkVector )<span class="keyword"> const</span> 00097 <span class="keyword"> </span>{ 00098 ColourValue kDiff; 00099 00100 kDiff.<a class="code" href="classOgre_1_1ColourValue.html#Ogre_1_1ColourValueo0">r</a> = r - rkVector.<a class="code" href="classOgre_1_1ColourValue.html#Ogre_1_1ColourValueo0">r</a>; 00101 kDiff.<a class="code" href="classOgre_1_1ColourValue.html#Ogre_1_1ColourValueo1">g</a> = g - rkVector.<a class="code" href="classOgre_1_1ColourValue.html#Ogre_1_1ColourValueo1">g</a>; 00102 kDiff.<a class="code" href="classOgre_1_1ColourValue.html#Ogre_1_1ColourValueo2">b</a> = b - rkVector.<a class="code" href="classOgre_1_1ColourValue.html#Ogre_1_1ColourValueo2">b</a>; 00103 kDiff.<a class="code" href="classOgre_1_1ColourValue.html#Ogre_1_1ColourValueo3">a</a> = a - rkVector.<a class="code" href="classOgre_1_1ColourValue.html#Ogre_1_1ColourValueo3">a</a>; 00104 00105 <span class="keywordflow">return</span> kDiff; 00106 } 00107 <a name="l00108"></a><a class="code" href="classOgre_1_1ColourValue.html#Ogre_1_1ColourValuea8">00108</a> <span class="keyword">inline</span> ColourValue <a class="code" href="namespaceOgre.html#a611">operator * </a>( <span class="keywordtype">float</span> fScalar )<span class="keyword"> const</span> 00109 <span class="keyword"> </span>{ 00110 ColourValue kProd; 00111 00112 kProd.<a class="code" href="classOgre_1_1ColourValue.html#Ogre_1_1ColourValueo0">r</a> = fScalar*r; 00113 kProd.<a class="code" href="classOgre_1_1ColourValue.html#Ogre_1_1ColourValueo1">g</a> = fScalar*g; 00114 kProd.<a class="code" href="classOgre_1_1ColourValue.html#Ogre_1_1ColourValueo2">b</a> = fScalar*b; 00115 kProd.<a class="code" href="classOgre_1_1ColourValue.html#Ogre_1_1ColourValueo3">a</a> = fScalar*a; 00116 00117 <span class="keywordflow">return</span> kProd; 00118 } 00119 <a name="l00120"></a><a class="code" href="classOgre_1_1ColourValue.html#Ogre_1_1ColourValuea9">00120</a> <span class="keyword">inline</span> ColourValue <a class="code" href="namespaceOgre.html#a611">operator * </a>( <span class="keyword">const</span> ColourValue& rhs)<span class="keyword"> const</span> 00121 <span class="keyword"> </span>{ 00122 ColourValue kProd; 00123 00124 kProd.<a class="code" href="classOgre_1_1ColourValue.html#Ogre_1_1ColourValueo0">r</a> = rhs.<a class="code" href="classOgre_1_1ColourValue.html#Ogre_1_1ColourValueo0">r</a> * r; 00125 kProd.<a class="code" href="classOgre_1_1ColourValue.html#Ogre_1_1ColourValueo1">g</a> = rhs.<a class="code" href="classOgre_1_1ColourValue.html#Ogre_1_1ColourValueo1">g</a> * g; 00126 kProd.<a class="code" href="classOgre_1_1ColourValue.html#Ogre_1_1ColourValueo2">b</a> = rhs.<a class="code" href="classOgre_1_1ColourValue.html#Ogre_1_1ColourValueo2">b</a> * b; 00127 kProd.<a class="code" href="classOgre_1_1ColourValue.html#Ogre_1_1ColourValueo3">a</a> = rhs.<a class="code" href="classOgre_1_1ColourValue.html#Ogre_1_1ColourValueo3">a</a> * a; 00128 00129 <span class="keywordflow">return</span> kProd; 00130 } 00131 <a name="l00132"></a><a class="code" href="classOgre_1_1ColourValue.html#Ogre_1_1ColourValuea10">00132</a> <span class="keyword">inline</span> ColourValue <a class="code" href="namespaceOgre.html#a612">operator / </a>( <span class="keyword">const</span> ColourValue& rhs)<span class="keyword"> const</span> 00133 <span class="keyword"> </span>{ 00134 ColourValue kProd; 00135 00136 kProd.<a class="code" href="classOgre_1_1ColourValue.html#Ogre_1_1ColourValueo0">r</a> = rhs.<a class="code" href="classOgre_1_1ColourValue.html#Ogre_1_1ColourValueo0">r</a> / r; 00137 kProd.<a class="code" href="classOgre_1_1ColourValue.html#Ogre_1_1ColourValueo1">g</a> = rhs.<a class="code" href="classOgre_1_1ColourValue.html#Ogre_1_1ColourValueo1">g</a> / g; 00138 kProd.<a class="code" href="classOgre_1_1ColourValue.html#Ogre_1_1ColourValueo2">b</a> = rhs.<a class="code" href="classOgre_1_1ColourValue.html#Ogre_1_1ColourValueo2">b</a> / b; 00139 kProd.<a class="code" href="classOgre_1_1ColourValue.html#Ogre_1_1ColourValueo3">a</a> = rhs.<a class="code" href="classOgre_1_1ColourValue.html#Ogre_1_1ColourValueo3">a</a> / a; 00140 00141 <span class="keywordflow">return</span> kProd; 00142 } 00143 <a name="l00144"></a><a class="code" href="classOgre_1_1ColourValue.html#Ogre_1_1ColourValuea11">00144</a> <span class="keyword">inline</span> ColourValue <a class="code" href="namespaceOgre.html#a612">operator / </a>( <span class="keywordtype">float</span> fScalar )<span class="keyword"> const</span> 00145 <span class="keyword"> </span>{ 00146 assert( fScalar != 0.0 ); 00147 00148 ColourValue kDiv; 00149 00150 <span class="keywordtype">float</span> fInv = 1.0 / fScalar; 00151 kDiv.<a class="code" href="classOgre_1_1ColourValue.html#Ogre_1_1ColourValueo0">r</a> = r * fInv; 00152 kDiv.<a class="code" href="classOgre_1_1ColourValue.html#Ogre_1_1ColourValueo1">g</a> = g * fInv; 00153 kDiv.<a class="code" href="classOgre_1_1ColourValue.html#Ogre_1_1ColourValueo2">b</a> = b * fInv; 00154 kDiv.<a class="code" href="classOgre_1_1ColourValue.html#Ogre_1_1ColourValueo3">a</a> = a * fInv; 00155 00156 <span class="keywordflow">return</span> kDiv; 00157 } 00158 <a name="l00159"></a><a class="code" href="classOgre_1_1ColourValue.html#Ogre_1_1ColourValuen0">00159</a> <span class="keyword">inline</span> <span class="keyword">friend</span> ColourValue <a class="code" href="namespaceOgre.html#a611">operator * </a>( <span class="keywordtype">float</span> fScalar, <span class="keyword">const</span> ColourValue& rkVector ) 00160 { 00161 ColourValue kProd; 00162 00163 kProd.<a class="code" href="classOgre_1_1ColourValue.html#Ogre_1_1ColourValueo0">r</a> = fScalar * rkVector.<a class="code" href="classOgre_1_1ColourValue.html#Ogre_1_1ColourValueo0">r</a>; 00164 kProd.<a class="code" href="classOgre_1_1ColourValue.html#Ogre_1_1ColourValueo1">g</a> = fScalar * rkVector.<a class="code" href="classOgre_1_1ColourValue.html#Ogre_1_1ColourValueo1">g</a>; 00165 kProd.<a class="code" href="classOgre_1_1ColourValue.html#Ogre_1_1ColourValueo2">b</a> = fScalar * rkVector.<a class="code" href="classOgre_1_1ColourValue.html#Ogre_1_1ColourValueo2">b</a>; 00166 kProd.<a class="code" href="classOgre_1_1ColourValue.html#Ogre_1_1ColourValueo3">a</a> = fScalar * rkVector.<a class="code" href="classOgre_1_1ColourValue.html#Ogre_1_1ColourValueo3">a</a>; 00167 00168 <span class="keywordflow">return</span> kProd; 00169 } 00170 00171 <span class="comment">// arithmetic updates</span> <a name="l00172"></a><a class="code" href="classOgre_1_1ColourValue.html#Ogre_1_1ColourValuea12">00172</a> <span class="keyword">inline</span> ColourValue& operator += ( <span class="keyword">const</span> ColourValue& rkVector ) 00173 { 00174 r += rkVector.<a class="code" href="classOgre_1_1ColourValue.html#Ogre_1_1ColourValueo0">r</a>; 00175 g += rkVector.<a class="code" href="classOgre_1_1ColourValue.html#Ogre_1_1ColourValueo1">g</a>; 00176 b += rkVector.<a class="code" href="classOgre_1_1ColourValue.html#Ogre_1_1ColourValueo2">b</a>; 00177 a += rkVector.<a class="code" href="classOgre_1_1ColourValue.html#Ogre_1_1ColourValueo3">a</a>; 00178 00179 <span class="keywordflow">return</span> *<span class="keyword">this</span>; 00180 } 00181 <a name="l00182"></a><a class="code" href="classOgre_1_1ColourValue.html#Ogre_1_1ColourValuea13">00182</a> <span class="keyword">inline</span> ColourValue& operator -= ( <span class="keyword">const</span> ColourValue& rkVector ) 00183 { 00184 r -= rkVector.<a class="code" href="classOgre_1_1ColourValue.html#Ogre_1_1ColourValueo0">r</a>; 00185 g -= rkVector.<a class="code" href="classOgre_1_1ColourValue.html#Ogre_1_1ColourValueo1">g</a>; 00186 b -= rkVector.<a class="code" href="classOgre_1_1ColourValue.html#Ogre_1_1ColourValueo2">b</a>; 00187 a -= rkVector.<a class="code" href="classOgre_1_1ColourValue.html#Ogre_1_1ColourValueo3">a</a>; 00188 00189 <span class="keywordflow">return</span> *<span class="keyword">this</span>; 00190 } 00191 <a name="l00192"></a><a class="code" href="classOgre_1_1ColourValue.html#Ogre_1_1ColourValuea14">00192</a> <span class="keyword">inline</span> ColourValue& operator *= ( <span class="keywordtype">float</span> fScalar ) 00193 { 00194 r *= fScalar; 00195 g *= fScalar; 00196 b *= fScalar; 00197 a *= fScalar; 00198 <span class="keywordflow">return</span> *<span class="keyword">this</span>; 00199 } 00200 <a name="l00201"></a><a class="code" href="classOgre_1_1ColourValue.html#Ogre_1_1ColourValuea15">00201</a> <span class="keyword">inline</span> ColourValue& operator /= ( <span class="keywordtype">float</span> fScalar ) 00202 { 00203 assert( fScalar != 0.0 ); 00204 00205 <span class="keywordtype">float</span> fInv = 1.0 / fScalar; 00206 00207 r *= fInv; 00208 g *= fInv; 00209 b *= fInv; 00210 a *= fInv; 00211 00212 <span class="keywordflow">return</span> *<span class="keyword">this</span>; 00213 } 00214 00215 00216 }; 00217 00218 } <span class="comment">// namespace</span> 00219 00220 <span class="preprocessor">#endif</span> </pre></div><p> Copyright © 2000-2005 by The OGRE Team<br /> Last modified Wed Feb 23 00:19:03 2005 </p> </body> </html>