AnoPlib - Animlets are not Particles library
|
00001 /* ************************************************************************* 00002 @file AnoPemergency1.h 00003 @project AnoPlib 00004 @module AnoPemergency1 00005 @brief An emergency vehicle's flash light 00006 @date 23.11.2010 00007 @copyright Daniel Krajzewicz 00008 @licence GPL 00009 @author Daniel Krajzewicz 00010 @email d.krajzewicz@googlemail.com 00011 ------------------------------------------------------------------ 00012 AnoPlib - small "animlet" library, see http://sf.net/projects/anoplib 00013 Copyright (C) 2009-2010 Daniel Krajzewicz 00014 00015 This program is free software: you can redistribute it and/or modify 00016 it under the terms of the GNU General Public License as published by 00017 the Free Software Foundation, either version 3 of the License, or 00018 (at your option) any later version. 00019 00020 This program is distributed in the hope that it will be useful, 00021 but WITHOUT ANY WARRANTY; without even the implied warranty of 00022 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00023 GNU General Public License for more details. 00024 00025 You should have received a copy of the GNU General Public License 00026 along with this program. If not, see <http://www.gnu.org/licenses/>. 00027 ------------------------------------------------------------------ 00028 Remarks: 00029 ------------------------------------------------------------------ 00030 ToDo: 00031 * *********************************************************************** */ 00032 #ifndef ANOP_EMERGENCY1 00033 #define ANOP_EMERGENCY1 00034 00035 00036 /* ========================================================================= 00037 * included modules 00038 * ======================================================================= */ 00039 #include <AnoP.h> 00040 #include <AnoPhelpers.h> 00041 #include <GL/gl.h> 00042 00043 00044 /* ========================================================================= 00045 * class and struct definitions 00046 * ======================================================================= */ 00047 // @brief The animlet definition structure 00048 struct emergency1Struct { 00050 double pos[2]; 00052 int step; 00053 }; 00054 00055 00059 class AnoPemergency1 : public AnoP::AnoPsystem<emergency1Struct> { 00060 public: 00064 AnoPemergency1(unsigned int bufSize=10) : AnoP::AnoPsystem<emergency1Struct>(bufSize) { 00065 white[0] = 1; 00066 white[1] = 1; 00067 white[2] = 1; 00068 white[3] = 1; 00069 yellowbright[0] = 1; 00070 yellowbright[1] = 1; 00071 yellowbright[2] = 0; 00072 yellowbright[3] = 1; 00073 yellowdark[0] = .1; 00074 yellowdark[1] = .1; 00075 yellowdark[2] = .0; 00076 yellowdark[3] = .1; 00077 } 00078 00079 00082 void preRender() throw() { 00083 glMatrixMode(GL_PROJECTION); 00084 glLoadIdentity(); 00085 glMatrixMode(GL_MODELVIEW); 00086 glLoadIdentity(); 00087 glTranslated(-1,-1,0); 00088 glScaled(1./200, 1./200, 1.); 00089 glEnable (GL_BLEND); 00090 glBlendFunc(GL_ONE, GL_ONE); 00091 glDepthMask(GL_FALSE); 00092 } 00093 00094 00100 bool render(emergency1Struct &s, unsigned int timeDiff, void * const something) throw() { 00101 glPushMatrix(); 00102 int off = s.step; 00103 glTranslated(s.pos[0], s.pos[1], 0.); 00104 double scale = off; 00105 glScaled(50./256., 50./256., 50./256.); 00106 glColor4d(1,1,0,1); 00107 AnoPhelpers::drawOutlineCircle2(.5, .09, 36, (s.step+10)%360, (s.step+70)%360, white, yellowdark); 00108 AnoPhelpers::drawOutlineCircle2(1., .09, 36, (s.step-00)%360, (s.step+80)%360, yellowbright, yellowdark); 00109 glRotated(180.,0,0,1); 00110 AnoPhelpers::drawOutlineCircle2(.5, .09, 36, (s.step+10)%360, (s.step+70)%360, white, yellowdark); 00111 AnoPhelpers::drawOutlineCircle2(1., .09, 36, (s.step-00)%360, (s.step+80)%360, yellowbright, yellowdark); 00112 glPopMatrix(); 00113 s.step += 5; 00114 if(s.step>360) { 00115 s.step = 1; 00116 } 00117 return true; 00118 } 00119 00120 float white[4], yellowbright[4], yellowdark[4]; 00121 }; 00122 00123 #endif