src/tron/gParticles.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 #if 0
00029 #include "gParticles.h"
00030 #include <cmath>
00031 #include <ctime>
00032 #include <cstdlib>
00033 // #include "papi.h"
00034 
00035 #ifndef DEDICATED
00036 void gParticles::Render(const eCamera *cam) {
00037 #ifdef USE_PARTICLES
00038     // Select this particle system in the PS API
00039     pCurrentGroup(thisSystem);
00040 
00041     pDrawGroupp(GL_POINTS, true);
00042 #endif
00043 }
00044 #endif
00045 
00046 bool gParticles::Timestep(REAL currentTime) {
00047 #ifdef USE_PARTICLES
00048     REAL ticks = currentTime - lastTime;
00049 
00050     // Store the current time as the lastTime, for next time
00051     lastTime = currentTime;
00052 
00053     // Select this particle system in the PS API
00054     pCurrentGroup(thisSystem);
00055 
00056     // Set the timestep interval for the system
00057     pTimeStep( (float) ticks);
00058 
00059     // Bounce particles off a disc of radius 5.
00060     //  pBounce(-0.05, 0.35, 0, PDDisc, 0, 0, 0,  0, 0, 1,  5);
00061 
00062     // Kill particles below Z=-3.
00063     //pSink(false, PDPlane, 0, 0, 0, 0,0,1);
00064 
00065     // Move particles to their new positions.
00066     pMove();
00067 
00068     // Now we check to see if the system is over
00069     //if( pGetGroupCount() == 0 )
00070     //return true;
00071 
00072 
00073 #endif
00074     return false;
00075 }
00076 
00077 void gParticles::GiveBirth(REAL currentTime) {
00078 #ifdef USE_PARTICLES
00079     ParticleInfo newParticle;
00080 
00081     glCoord tmpFocus;
00082     glCoord tmpVec;
00083 
00084     tmpFocus = focus;
00085 
00086     float randomaxis;
00087 
00088     randomaxis = 10.0f * rand()/(RAND_MAX+1.0f);
00089     tmpFocus.x -= randomaxis/2.0f;
00090     tmpFocus.x += randomaxis;
00091 
00092     tmpFocus.y -= randomaxis/2.0f;
00093     tmpFocus.y += randomaxis;
00094 
00095     tmpVec = svector;
00096 
00097     //tmpVec.x -= randomaxis/2.0f;
00098     //tmpVec.x += randomaxis;
00099 
00100     //tmpVec.y -= randomaxis/2.0f;
00101     //tmpVec.y += randomaxis;
00102 
00103     newParticle.pos = tmpFocus;
00104     newParticle.vec = tmpVec;
00105     newParticle.life = psystem.life;
00106     newParticle.startTime = currentTime;
00107 
00108     particles.push_back(newParticle);
00109 #endif
00110 }
00111 
00112 gParticles::gParticles(const eCoord &pos,const glCoord &vec,REAL time, ParticleSystem &param) {
00113 #ifdef USE_PARTICLES
00114     // Grab the incoming data and store it
00115     startTime = time;
00116 
00117     // focus is the focus of the particle system
00118     focus.x = pos.x;
00119     focus.y = pos.y;
00120     focus.z = 0;
00121 
00122     // vector stores a vector that shows where the particle system points
00123     svector.x = vec.x;
00124     svector.y = vec.y;
00125     svector.z = vec.z;
00126 
00127     // psystem stores the parameters of the whole system
00128     psystem = param;
00129 
00130     // Initialize the system
00131     thisSystem = pGenParticleGroups(1, psystem.numParticles);
00132     // Select this particle system in the PS API
00133     pCurrentGroup(thisSystem);
00134 
00135     // Set up the state.
00136     pVelocity(svector.x, svector.y, svector.z);
00137     pColorD(1.0, PDLine, 0.8, 0.9, 1.0, 1.0, 1.0, 1.0);
00138     pSize(1.5);
00139 
00140     // Generate particles along a very small line in the nozzel.
00141     pSource(psystem.numParticles, PDSphere, focus.x, focus.y, focus.z, 20);
00142 
00143     // Gravity.
00144     pGravity(0.0, 0.0, -0.01);
00145 #endif
00146 }
00147 
00148 #endif
00149 

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