00001 ////////////////////////////////////////////////////////////////////// 00002 // 6/28/02 Aaron Lefohn Scientific Computing and Imaging Institute 00003 // School of Computing University of Utah 00004 // 00005 // This library is free software; you can redistribute it and/or 00006 // modify it under the terms of the GNU Lesser General Public 00007 // License as published by the Free Software Foundation; either 00008 // version 2.1 of the License, or (at your option) any later version. 00009 // 00010 // This library is distributed in the hope that it will be useful, 00011 // but WITHOUT ANY WARRANTY; without even the implied warranty of 00012 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 00013 // Lesser General Public License for more details. 00014 // 00015 // You should have received a copy of the GNU Lesser General Public 00016 // License along with this library; if not, write to the Free Software 00017 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 00018 00019 #ifndef GLIFT_TEX_CONST_GEN_H 00020 #define GLIFT_TEX_CONST_GEN_H 00021 00022 #include "texCoordGen.h" 00023 #include <arrayGutz.h> 00024 #include <mathGutz.h> 00025 00026 #include <vector> 00027 00028 namespace glift { 00029 00030 class TexConst; 00031 typedef std::vector<TexConst> VecTexConst; 00032 typedef std::vector<TexConst*> VecTexConstP; 00033 typedef std::vector<VecTexConst> VecVecTexConst; 00034 typedef std::vector<VecTexConstP> VecVecTexConstP; 00035 00036 /// Define Bitwise OR-able constants to specify texture coord names 00037 #define GLIFT_NONE 0 00038 #define GLIFT_S_BIT 1 00039 #define GLIFT_T_BIT 2 00040 #define GLIFT_R_BIT 4 00041 #define GLIFT_Q_BIT 8 00042 00043 00044 ///////////////////////////////////////////////////////////////////////// 00045 /// 00046 /// TexConst : Use to specify texture coordinate floating-point constants 00047 /// 00048 /// example: /// Place 3.14516 on the 's' texture coordinate 00049 /// /// Place 2.71828 on the 'r' texture coordinate 00050 /// gutz::vec2f twoVec( 3.14516, 2.71828 ); 00051 /// TexConst const1( twoVec, 2, GLIFT_R | GLIFT_S ); 00052 /// 00053 /// - Note: The ordering of the texture coordinate specifications has no 00054 /// effect on which coordinate the scalar values of a vector will 00055 /// end up. They are placed in 'increasing' order beginning. 00056 /// 00057 /// - Note: The default constructor makes an object that does NOT perturb 00058 /// the passed-in, raw texture coords. The 'genTexCoords(..)' fcn 00059 /// will just return the input, raw coords. 00060 /// 00061 /////////////////////////////////////////////////////////////////////// 00062 00063 /// A floating-point constant that is set to a texture coordinate 00064 class _export_ TexConst : public TexCoordGen 00065 { 00066 public: 00067 TexConst(); //Calling 'genTexCoords' in this case does not alter the texCoords 00068 TexConst( float val, uint texUnit, uint coords ); 00069 TexConst( const gutz::vec2f& val, uint texUnit, uint coords ); 00070 TexConst( const gutz::vec3f& val, uint texUnit, uint coords ); 00071 00072 virtual gutz::arrayo2f operator()( const gutz::arrayw2f& rawTexCoord, const gutz::vec3f& primScale ); 00073 00074 gutz::arrayo1f value() const {return m_val;} 00075 uint texUnit() const {return m_texUnit;} 00076 int size() const {return m_size;} 00077 uint coords() const {return m_coords;} 00078 gutz::vec4<bool> usedTexCoords() const; // Return array of bools to show which texCoords are used by const 00079 00080 private: 00081 gutz::arrayo1f m_val; 00082 uint m_coords; 00083 uint m_texUnit; 00084 uint m_size; 00085 uint m_maxCoordDimen; 00086 00087 void checkCoords(); 00088 uint maxCoordDimen( uint coords );/// Find max coordDimen that is being used. 00089 virtual gutz::arrayo2f operator()() {return gutz::arrayo2f();} //Disallow default call. 00090 }; 00091 00092 } /// End of namespace glift 00093 00094 #endif