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

multiPrim.cpp

Go to the documentation of this file.
00001 /////////////////////////////////////////////////////////////////////
00002 // 6/6/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 // compositePrim.cpp: implementation of the MultiPrim class.
00021 //
00022 /////////////////////////////////////////////////////////////////////
00023 
00024 #include <drawable/multiPrim.h>
00025 #include <state/shader.h>
00026 #include <iostream>
00027 
00028 using namespace std;
00029 using namespace gutz;
00030 
00031 using namespace glift;
00032 
00033 //////////////////////////////////////////////////////////////////////
00034 /// Construction/Destruction
00035 //////////////////////////////////////////////////////////////////////
00036 
00037 MultiPrim::MultiPrim( const VecSinglePrimP& prim ) : m_prim( prim )
00038 {}
00039 
00040 void MultiPrim::init( const VecSinglePrimP& prim )
00041 {
00042    m_prim = prim;
00043 }
00044 
00045 MultiPrimTexCoord* MultiPrim::genTexCoords( const Shader* shader )
00046 {
00047    MultiPrimTexCoord* vecTexCoords = new MultiPrimTexCoord( m_prim.size() );
00048 
00049    for(uint i=0; i < m_prim.size(); i++) {
00050       MultiTexCoord* primTexCoords = shader->genTexCoords( m_prim[i]->texCoord(), m_prim[i]->scale() );
00051       (*vecTexCoords)[i] = primTexCoords;
00052    }
00053    return vecTexCoords;
00054 }
00055 
00056 /// Return true if ALL of the primitives have texture coordinates
00057 bool MultiPrim::hasTexCoords() const
00058 {
00059    bool retVal = true;
00060    for(uint i=0; i < m_prim.size(); i++) {
00061       retVal &= m_prim[i]->hasTexCoords();
00062    }
00063    return retVal;
00064 }
00065 
00066 void MultiPrim::bindTexCoords( const MultiPrimTexCoord* texCoordsPtr )
00067 {
00068    for(uint i=0; i < m_prim.size(); i++ ) {
00069       m_prim[i]->bindTexCoords( (*texCoordsPtr)[i] );
00070    }
00071 }
00072 
00073 void MultiPrim::bindTexCoords( const MultiTexCoord* texCoordsPtr )
00074 {
00075    for(uint i=0; i < m_prim.size(); i++ ) {
00076       m_prim[i]->bindTexCoords( texCoordsPtr );
00077    }
00078 }
00079 
00080 void MultiPrim::releaseTexCoords()
00081 {
00082    for(uint i=0; i < m_prim.size(); i++ ) {
00083       m_prim[i]->releaseTexCoords();
00084    }
00085 }
00086 
00087 void MultiPrim::bindIndices( const MultiPrimIndices* indices )
00088 {
00089    for(uint i=0; i < m_prim.size(); i++) {
00090       m_prim[i]->bindIndices( (*indices)[i] );
00091    }
00092 }
00093 
00094 void MultiPrim::bindIndices( const arrayw1ui* indices )
00095 {
00096    for(uint i=0; i < m_prim.size(); i++) {
00097       m_prim[i]->bindIndices( indices );
00098    }
00099 }
00100 
00101 void MultiPrim::releaseIndices()
00102 {
00103    for(uint i=0; i < m_prim.size(); i++ ) {
00104       m_prim[i]->releaseIndices();
00105    }
00106 }
00107 
00108 void MultiPrim::drawDef()
00109 {
00110    for(uint i=0; i < m_prim.size() ; i++ ) {
00111       //for(uint i=3; i < 4 ; i++ ) { /// Sparse-grid trial
00112       m_prim[i]->draw();
00113    }
00114 }
00115 
00116 

Send questions, comments, and bug reports to:
jmk