src/tron/gLogo.cpp

Go to the documentation of this file.
00001 /*
00002 
00003 *************************************************************************
00004 
00005 ArmageTron -- Just another Tron Lightcycle Game in 3D.
00006 Copyright (C) 2000  Manuel Moos (manuel@moosnet.de)
00007 
00008 **************************************************************************
00009 
00010 This program is free software; you can redistribute it and/or
00011 modify it under the terms of the GNU General Public License
00012 as published by the Free Software Foundation; either version 2
00013 of the License, or (at your option) any later version.
00014 
00015 This program is distributed in the hope that it will be useful,
00016 but WITHOUT ANY WARRANTY; without even the implied warranty of
00017 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00018 GNU General Public License for more details.
00019 
00020 You should have received a copy of the GNU General Public License
00021 along with this program; if not, write to the Free Software
00022 Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
00023   
00024 ***************************************************************************
00025 
00026 */
00027 
00028 #include "gLogo.h"
00029 
00030 #include "gStuff.h"
00031 #include "rTexture.h"
00032 #include "rRender.h"
00033 #include "rScreen.h"
00034 #include "eCoord.h"
00035 #include "uMenu.h"
00036 #include "tSysTime.h"
00037 
00038 /*
00039 #include "nConfig.h"
00040 static tString lala_logoTexture("Anonymous/original/textures/KGN_logo.png");
00041 static nSettingItem<tString> lalala_logoTexture("TEXTURE_LOGO", lala_logoTexture);
00042 rFileTexture sg_LogoTexture(rTextureGroups::TEX_FONT, lala_logoTexture, 0,0,1);
00043 */
00044 
00045 static rFileTexture sg_LogoTexture(rTextureGroups::TEX_FONT, "textures/KGN_logo.png",0,0,1);
00046 static rISurfaceTexture* sg_LogoMPTitle = NULL;
00047 
00048 static gLogo logo;
00049 
00050 static bool sg_Displayed = true;
00051 static bool sg_Spinning  = false;
00052 static bool sg_Big       = true;
00053 
00054 static eCoord sg_SpinStatus(1,0);    // current spinning position
00055 static REAL   sg_SizeStatus(1);    // 1 -> big      , 0 -> small
00056 static REAL   sg_DisplayStatus(-1); // 1 -> displayed, 0->invisible
00057 
00058 void gLogo::SetDisplayed(bool d, bool immediately)
00059 {
00060     if (sg_Displayed == false && d == true && sg_DisplayStatus < .01)
00061         sg_SpinStatus = eCoord(0, 1);
00062 
00063     sg_Displayed = d;
00064     if (immediately)
00065         sg_DisplayStatus = d ? 1 : 0;
00066 }
00067 
00068 void gLogo::SetSpinning(bool s)
00069 {
00070     sg_Spinning = s;
00071     if (!s)
00072         sg_SpinStatus = eCoord(1, 0);
00073 }
00074 void gLogo::SetBig(bool b, bool immediately)
00075 {
00076     sg_Big = b;
00077     if (immediately)
00078         sg_SizeStatus = b ? 1 : 0;
00079 
00080 }
00081 
00082 /*
00083 static tString sg_title("Anonymous/original/textures/title.jpg");
00084 static nSettingItem<tString> gg_title("TEXTURE_TITLE", sg_title);
00085 
00086 static tString sg_mp_title("Anonymous/original/moviepack/title.jpg");
00087 static nSettingItem<tString> gg_mp_title("TEXTURE_MP_TITLE", sg_mp_title);
00088 */
00089 
00090 void gLogo::Display()
00091 {
00092 #ifndef DEDICATED
00093     if (!sr_glOut)
00094         return;
00095 
00096     if (sg_MoviePack() && !sg_LogoMPTitle)
00097     {
00098         sg_LogoMPTitle = tNEW(rFileTexture)(rTextureGroups::TEX_FONT, "moviepack/title.jpg",0,0,1);
00099         // sg_LogoMPTitle = tNEW(rFileTexture)(rTextureGroups::TEX_FONT, sg_mp_title, 0,0,1);
00100         sg_DisplayStatus = 1;
00101     }
00102 
00103     renderer->SetFlag(rRenderer::DEPTH_TEST, false);
00104 
00105     static REAL lasttime = 0;
00106     REAL time = tSysTimeFloat();
00107     REAL dt = time - lasttime;
00108     lasttime = time;
00109 
00110     if (!sg_Displayed && sg_DisplayStatus < .00001)
00111         return;
00112 
00113     if (sg_LogoMPTitle)
00114     {
00115         // update state variables
00116         if (sg_Displayed && sg_Big)
00117         {
00118             sg_DisplayStatus += dt;
00119             if (sg_DisplayStatus > 1)
00120                 sg_DisplayStatus = 1;
00121         }
00122         else
00123         {
00124             sg_DisplayStatus -= dt;
00125             if (sg_DisplayStatus < 0)
00126                 sg_DisplayStatus = 0;
00127         }
00128 
00129         sg_LogoMPTitle->Select();
00130 
00131         if (sg_DisplayStatus <= .01 || !sg_LogoMPTitle->Loaded())
00132             return;
00133 
00134         Color(1,1,1, sg_DisplayStatus);
00135 
00136         BeginQuads();
00137         TexCoord(0,0);
00138         Vertex(-1, 1);
00139 
00140         TexCoord(0,1);
00141         Vertex(-1, -1);
00142 
00143         TexCoord(1,1);
00144         Vertex(1, -1);
00145 
00146         TexCoord(1,0);
00147         Vertex(1, 1);
00148 
00149         RenderEnd();
00150     }
00151     else
00152     {
00153 #ifndef KRAWALL
00154         sg_LogoMPTitle = tNEW(rFileTexture)(rTextureGroups::TEX_FONT, "textures/title.jpg",0,0,1);
00155         // sg_LogoMPTitle = tNEW(rFileTexture)(rTextureGroups::TEX_FONT, sg_title,0,0,1);
00156 
00157         sg_DisplayStatus = 1;
00158 
00159         // update state variables
00160         if (sg_Displayed && sg_Big)
00161         {
00162             sg_DisplayStatus += dt;
00163             if (sg_DisplayStatus > 1)
00164                 sg_DisplayStatus = 1;
00165         }
00166         else
00167         {
00168             sg_DisplayStatus -= dt;
00169             if (sg_DisplayStatus < 0)
00170                 sg_DisplayStatus = 0;
00171         }
00172 
00173         sg_LogoMPTitle->Select();
00174 
00175         if (sg_DisplayStatus <= .01 || !sg_LogoMPTitle->Loaded())
00176             return;
00177 
00178         Color(1,1,1, sg_DisplayStatus);
00179 
00180         BeginQuads();
00181         TexCoord(0,0);
00182         Vertex(-1, 1);
00183 
00184         TexCoord(0,1);
00185         Vertex(-1, -1);
00186 
00187         TexCoord(1,1);
00188         Vertex(1, -1);
00189 
00190         TexCoord(1,0);
00191         Vertex(1, 1);
00192 
00193         RenderEnd();
00194 #endif    
00195 
00196 #ifdef KRAWALL
00197         sg_LogoTexture.Select();
00198 
00199         if ( !sg_LogoTexture.Loaded() )
00200         {
00201             return;
00202         }
00203 
00204         // update state variables
00205         if (sg_Spinning)
00206         {
00207             sg_SpinStatus = sg_SpinStatus.Turn(1, dt * 2 * .2 / (sg_SizeStatus + .2));
00208             sg_SpinStatus = sg_SpinStatus * (1/sqrt(sg_SpinStatus.NormSquared()));
00209         }
00210 
00211         if (sg_Big)
00212         {
00213             sg_SizeStatus += dt;
00214             if (sg_SizeStatus > 1)
00215                 sg_SizeStatus = 1;
00216         }
00217         else
00218         {
00219             sg_SizeStatus *= (1 - 2 * dt);
00220             //      if (sg_SizeStatus < 0)
00221             //  sg_SizeStatus = 0;
00222         }
00223 
00224         if (sg_Displayed)
00225         {
00226             sg_DisplayStatus += dt;
00227             if (sg_DisplayStatus > 1)
00228                 sg_DisplayStatus = 1;
00229         }
00230         else
00231         {
00232             sg_DisplayStatus -= dt*.3;
00233             if (sg_DisplayStatus < 0)
00234                 sg_DisplayStatus = 0;
00235         }
00236 
00237         if (sg_DisplayStatus < 0)
00238             return;
00239 
00240         eCoord center(.8*(sg_SizeStatus*sg_SizeStatus-1), .8*(1-sg_SizeStatus));
00241         REAL e =.8 * (sg_SizeStatus + .1);
00242         eCoord extension(e, - .7 * e * fabs(sg_SpinStatus.x));
00243 
00244         eCoord ur = center - extension;
00245         eCoord ll = center + extension;
00246 
00247         Color(1,1,1, sg_DisplayStatus);
00248 
00249         BeginQuads();
00250         TexCoord(0,0);
00251         Vertex(ur.x, ur.y);
00252 
00253         TexCoord(0,1);
00254         Vertex(ur.x, ll.y);
00255 
00256         TexCoord(1,1);
00257         Vertex(ll.x, ll.y);
00258 
00259         TexCoord(1,0);
00260         Vertex(ll.x, ur.y);
00261 
00262         RenderEnd();
00263 #endif
00264 
00265     }
00266 
00267 #endif
00268 }
00269 
00270 gLogo::~gLogo()
00271 {
00272     if (sg_LogoMPTitle)
00273     {
00274         tDESTROY(sg_LogoMPTitle);
00275     }
00276 }

Generated on Sat Mar 15 22:56:08 2008 for Armagetron Advanced by  doxygen 1.5.4