00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025 #ifndef _PARTICLE_H
00026
00027 #include <stdio.h>
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);
00082
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