Main Page   Namespace List   Class Hierarchy   Alphabetical List   Compound List   File List   Namespace Members   Compound Members   File Members   Related Pages  

SkyBox.cpp

Go to the documentation of this file.
00001 
00002 /*
00003     TEDDY - General graphics application library
00004     Copyright (C) 1999-2002  Timo Suoranta
00005     tksuoran@cc.helsinki.fi
00006 
00007     This library is free software; you can redistribute it and/or
00008     modify it under the terms of the GNU Lesser General Public
00009     License as published by the Free Software Foundation; either
00010     version 2.1 of the License, or (at your option) any later version.
00011 
00012     This library is distributed in the hope that it will be useful,
00013     but WITHOUT ANY WARRANTY; without even the implied warranty of
00014     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00015     Lesser General Public License for more details.
00016 
00017     You should have received a copy of the GNU Lesser General Public
00018     License along with this library; if not, write to the Free Software
00019     Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
00020     
00021     $Id: SkyBox.cpp,v 1.4 2002/01/11 14:35:03 tksuoran Exp $
00022 */
00023 
00024 
00025 #if 0
00026 
00027 #include "Teddy/Scenes/SkyBox.h"
00028 #include "Teddy/Graphics/View.h"
00029 #include "Teddy/Materials/Material.h"
00030 #include "Teddy/Models/Line.h"
00031 #include "Teddy/PhysicalComponents/Projection.h"
00032 using namespace Teddy::Materials;
00033 using namespace Teddy::Graphics;
00034 using namespace Teddy::PhysicalComponents;
00035 
00036 
00037 namespace Teddy  {
00038 namespace Models {
00039 
00040 
00042 SkyBox::SkyBox()
00043 :
00044 Model( "skybox" )
00045 {
00046     Material *mat;
00047 
00048     mat = new Material( "Skybox material",
00049         RENDER_MODE_LINE,
00050         RENDER_LIGHTING_COLOR,
00051         RENDER_OPTION_DIFFUSE_M
00052     );
00053     mat->setDiffuse( Color(0,0,1,1) );
00054     this->setMaterial( mat );
00055 
00056     // front = new Material( "SkyBox Front", new Texture("simple_sunset_FR.raw") );
00057     // back  = new Material( "SkyBox Back",  new Texture("simple_sunset_BK.raw") );
00058     // left  = new Material( "SkyBox Left",  new Texture("simple_sunset_LF.raw") );
00059     // right = new Material( "SkyBox Right", new Texture("simple_sunset_RT.raw") );
00060     // up    = new Material( "SkyBox Up",    new Texture("simple_sunset_UP.raw") );
00061     // down  = new Material( "SkyBox DOwn",  new Texture("simple_sunset_DN.raw") );
00062 };
00063 
00064 
00066 /*virtual*/ void SkyBox::drawElements( Projection *p ){
00067     View *view = p->getView();
00068 
00069     double a = 4.0;
00070     //glColor4f( 0.5f, 0.5f, 0.55f, 1.0f );
00071     //for texture use only -> material
00072     //glTexEnvi( GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE );
00073     //glHint( GL_PERSPECTIVE_CORRECTION_HINT, GL_NICEST );
00074 #   define tmin (0.0 + 0.5/256.0)  // this will remove (most of) visible edges 
00075 #   define tmax (1.0 - 0.5/256.0)  // in skybox
00076     //front->glApply();
00077     view->beginQuads();
00078     view->vertex_v3ft2f(  a,  a, -a, tmin, tmin );
00079     view->vertex_v3ft2f( -a,  a, -a, tmax, tmin );
00080     view->vertex_v3ft2f( -a, -a, -a, tmax, tmax );
00081     view->vertex_v3ft2f(  a, -a, -a, tmin, tmax );
00082     //back->glApply();
00083     view->vertex_v3ft2f( -a,  a,  a, tmin, tmin );
00084     view->vertex_v3ft2f(  a,  a,  a, tmax, tmin );
00085     view->vertex_v3ft2f(  a, -a,  a, tmin, tmin );
00086     view->vertex_v3ft2f( -a, -a,  a, tmin, tmax );
00087     //right->glApply();
00088     view->vertex_v3ft2f( -a,  a, -a, tmin, tmin );
00089     view->vertex_v3ft2f( -a,  a,  a, tmax, tmin );
00090     view->vertex_v3ft2f( -a, -a,  a, tmax, tmax );
00091     view->vertex_v3ft2f( -a, -a, -a, tmin, tmax );
00092     //left->glApply();
00093     view->vertex_v3ft2f(  a,  a,  a, tmin, tmin );
00094     view->vertex_v3ft2f(  a,  a, -a, tmax, tmin );
00095     view->vertex_v3ft2f(  a, -a, -a, tmax, tmax );
00096     view->vertex_v3ft2f(  a, -a,  a, tmin, tmax );
00097     //up->glApply();
00098     view->vertex_v3ft2f( -a,  a,  a, tmax, tmin );
00099     view->vertex_v3ft2f( -a,  a, -a, tmax, tmax );
00100     view->vertex_v3ft2f(  a,  a, -a, tmin, tmax );
00101     view->vertex_v3ft2f(  a,  a,  a, tmin, tmin );
00102     //down->glApply();
00103     view->vertex_v3ft2f( -a, -a,  a, tmax, tmin );
00104     view->vertex_v3ft2f( -a, -a, -a, tmax, tmax );
00105     view->vertex_v3ft2f(  a, -a, -a, tmin, tmax );
00106     view->vertex_v3ft2f(  a, -a,  a, tmin, tmin );
00107     view->end();
00108 }
00109 
00110 
00111 };  //  namespace Models
00112 };  //  namespace Teddy
00113 
00114 
00115 #endif
00116