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

texTrans.cpp

Go to the documentation of this file.
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 
00020 #include <texCoordGen/texTrans.h>
00021 
00022 using namespace gutz;
00023 
00024 using namespace glift;
00025 
00026 TexTrans::TexTrans()
00027 : m_texUnit(0), m_transform( CoordTrans() )
00028 {}
00029 
00030 TexTrans::TexTrans( uint texUnit ) /// Identity transform
00031 : m_texUnit(texUnit), m_transform( CoordTrans() )
00032 {}
00033 
00034 TexTrans::TexTrans( uint texUnit, const vec2f& bias, bool relBias )
00035 : m_texUnit(texUnit), m_transform( CoordTrans(bias, relBias) )
00036 {}
00037 
00038 TexTrans::TexTrans( uint texUnit, const vec3f& bias, bool relBias )
00039 : m_texUnit(texUnit), m_transform( CoordTrans(bias, relBias) )
00040 {}
00041 
00042 TexTrans::TexTrans( uint texUnit, const mat4f& mat, bool relScale, bool relBias )
00043 : m_texUnit(texUnit), m_transform( CoordTrans(mat, relScale, relBias) )
00044 {}
00045 
00046 TexTrans::TexTrans( uint texUnit, const vec3f& scale, const vec3f& bias, bool relScale, bool relBias )
00047 : m_texUnit(texUnit), m_transform( CoordTrans(scale, bias, relScale, relBias) )
00048 {}
00049 
00050 arrayo2f TexTrans::operator()( const arrayw2f& rawTexCoord, const vec3f& primScale )
00051 {
00052    /// Note: There is a lot of type-casting and copying in this function b/c I am not
00053    ///       using arrays-of-arrays. I am intentionally trading efficiency in this function for 
00054    ///       runtime, rendering efficiency by using a contiguous memory layout all for
00055    ///       2D ararys (vertex info).
00056 
00057    int numVerts = rawTexCoord.dim(0);
00058    int coordDimen = rawTexCoord.dim(1);
00059 
00060    arrayo2f texCoords( numVerts, coordDimen, (float)0 );
00061 
00062    for(int v=0; v < numVerts; v++) {
00063       arrayo1f newCoord = m_transform.apply( rawTexCoord[v], arrayo1f(3, primScale.v() ) );
00064 
00065       for(int c=0; c < coordDimen; c++) {
00066          texCoords[v][c] = newCoord[c];
00067       }
00068    }
00069 
00070    return texCoords;
00071 }
00072 
00073 

Send questions, comments, and bug reports to:
jmk