include/particles.h

Go to the documentation of this file.
00001 /***************************************************************************
00002  *            particle.h
00003  *
00004  *  Sun Apr  3 10:56:03 2005
00005  *  Copyright  2005  Joe Venzon
00006  *  joe@venzon.net
00007  ****************************************************************************/
00008 
00009 /*
00010  *  This program is free software; you can redistribute it and/or modify
00011  *  it under the terms of the GNU General Public License as published by
00012  *  the Free Software Foundation; either version 2 of the License, or
00013  *  (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 Library 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
00023  */
00024  
00025 #ifndef _PARTICLE_H
00026 
00027 #include <stdio.h>                      // Header File For Standard Input/Output
00028 #include <GL/gl.h>
00029 #include <GL/glu.h>
00030 #include <SDL/SDL.h>
00031 #ifdef __APPLE__
00032 #include <SDL_image/SDL_image.h>
00033 #else
00034 #include <SDL/SDL_image.h>
00035 #endif
00036 #include <string>
00037 #include <iostream>
00038 #include <fstream>
00039 #include <cmath>
00040 #include <cassert>
00041 
00042 using namespace std;
00043 
00044 #include "quat.h"
00045 #include "textures.h"
00046 #include "globals.h"
00047 
00048 #define MAX_PARTICLES 20
00049 #define PARTICLE_TEXTURES 6
00050 #define NUM_ROTATIONS 5
00051 
00052 struct SINGLE_PARTICLE
00053 {
00054         float transparency;
00055         float longevity;
00056         VERTEX start_position;
00057         float speed;
00058         VERTEX direction;
00059         float rotation;
00060         float size;
00061         int texture;
00062         
00063         float timestamp;
00064         bool active;
00065 };
00066 
00067 class PARTICLE
00068 {
00069 public:
00070         PARTICLE();
00071         ~PARTICLE();
00072         void Load();
00073         void Update(float timefactor, float fps);
00074         void Draw();
00075         void SetParams(float transmin, float transmax, float longmin, float longmax,
00076                                         float speedmin, float speedmax, VERTEX direction,
00077                                         float sizemin, float sizemax);
00078         void AddParticle(VERTEX pos);
00079         void ProbAddParticle(VERTEX pos, float probability);
00080         float ParticleHeight();
00081         void ClipParticles(VERTEX * rect); //stop particles from drifting up into the car's
00082                                                                                 //undercarriage
00083         void Clear();
00084 
00085         void SetWind(VERTEX newwind) {wind = newwind;}
00086         
00087 private:
00088         int slotguess;
00089         GLuint drawlist;
00090         TEXTURE_HANDLE texture[PARTICLE_TEXTURES];
00091 
00092         VERTEX wind;
00093 
00094         double curtime;
00095 
00096         float pheight;
00097 
00098         bool inrange(float x1, float x2, float val);
00099         bool inrect (VERTEX * rect, VERTEX p);
00100         bool overlap (VERTEX * rect1, VERTEX * rect2);
00101 
00102         struct SINGLE_PARTICLE particle[MAX_PARTICLES];
00103         struct SINGLE_PARTICLE params[2];
00104         
00105         int curtex;
00106         
00107         float randf(float min, float max);
00108         void DrawParticle(struct SINGLE_PARTICLE & p);
00109         void init_draw();
00110         
00111         bool loaded;
00112 };
00113 
00114 #define _PARTICLE_H
00115 #endif /* _PARTICLE_H */

Generated on Thu Oct 19 04:05:47 2006 by  doxygen 1.4.6