arbeit
Main Page | Namespace List | Class Hierarchy | Alphabetical List | Compound List | File List | Namespace Members | Compound Members | File Members

coordTrans.h

Go to the documentation of this file.
00001 //////////////////////////////////////////////////////////////////////
00002 // 6/26/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_COORD_TRANS_H
00020 #define GLIFT_COORD_TRANS_H
00021 
00022 #include "../core/gliftObject.h"
00023 #include "gliftDecl.h"
00024 #include <mathGutz.h>
00025 #include <arrayGutz.h>
00026 #include <vector>
00027 
00028 namespace glift {
00029 
00030    /// Typedefs
00031 class CoordTrans;
00032 typedef std::vector<CoordTrans>  VecCoordTrans;
00033 typedef std::vector<CoordTrans*> VecCoordTransP;
00034 
00035 //////////////////////////////////////////////////////////////////////////
00036 ///
00037 /// CoordTrans - Encapsulates a 4x4 matrix transform that can be specified
00038 ///                         as an absolute or relative transform.
00039 ///
00040 ///                             It is most commonly used to transform texture coordinates 
00041 ///                             of the primitive to which a shader is applied.
00042 ///
00043 /// CoordTrans
00044 ///////////////////////
00045 class _export_ CoordTrans : public GliftObject
00046 {
00047 public:
00048    CoordTrans();
00049    CoordTrans( const gutz::vec2f& bias,  bool relBias=false );
00050    CoordTrans( const gutz::vec3f& bias,  bool relBias=false );
00051    CoordTrans( const gutz::vec3f& scale, const gutz::vec3f& bias, bool relScale, bool relBias );
00052    CoordTrans( const gutz::mat4f& mat,   bool relScale=false, bool relTrans=false );
00053 
00054    /// Apply transform to 'coord'. 
00055    /// - If 'm_relScale' or 'm_relBias' are true, the appropriate transform 
00056    ///   components are first divided by the corresponding component 
00057    ///   of the 'divisor' vector.
00058    gutz::vec2f          apply( const gutz::vec2f&        coord, const gutz::vec2f&        divisor );
00059    gutz::vec3f          apply( const gutz::vec3f&        coord, const gutz::vec3f&        divisor );
00060    gutz::arrayo1f       apply( const gutz::arrayw1f& coord, const gutz::arrayw1f& divisor );
00061 
00062 private:
00063    gutz::mat4f m_mat;   /// The scale/bias transformation matrix
00064 
00065    bool  m_relScale;            /// Should scale be applied rel. to geom. or as absolute value?
00066    bool  m_relBias;             /// Should bias be applied rel. to geom. or as absolute value?
00067 
00068    void  init( const gutz::vec3f& scale, const gutz::vec3f& bias, bool relScale, bool relBias );
00069    gutz::mat4f applyDivisor( const gutz::arrayw1f& divisor );
00070 };
00071 
00072 } /// End of namespace glift
00073 
00074 #endif

Send questions, comments, and bug reports to:
jmk