00001 // OMICRON ENGINE HEADER FILE 00002 // 00003 // -------------------------------------------------------------------------- 00004 // Copyright (C) 2001-2002 by Bjoern Paetzel <kolrabi@gmx.de> 00005 // 00006 // This file is part of the Omicron Engine. 00007 // 00008 // The Omicron Engine is free software; you can redistribute it and/or modify 00009 // it under the terms of the GNU General Public License as published by the 00010 // Free Software Foundation; either version 2 of the License, or (at your 00011 // option) any later version. 00012 // 00013 // The Omicron Engine is distributed in the hope that it will be useful, but 00014 // WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY 00015 // or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 00016 // for more details. 00017 // 00018 // You should have received a copy of the GNU General Public License along 00019 // with The Omicron Engine; if not, write to the Free Software Foundation, 00020 // Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 00021 // 00022 // -------------------------------------------------------------------------- 00023 // Last modified: $Date: 2002/12/07 19:02:17 $ 00024 // By : $Author: kolrabi $ 00025 // $Id: particle.h,v 1.1.1.1 2002/12/07 19:02:17 kolrabi Exp $ 00026 00027 /* 00028 00029 $Log: particle.h,v $ 00030 Revision 1.1.1.1 2002/12/07 19:02:17 kolrabi 00031 initial release 00032 00033 00034 */ 00035 00043 #include "forward.h" 00044 #include "vector.h" 00045 00046 /**************************************************************************** 00047 **************************************************************************** 00048 * DEFINES ****************************************************************** 00049 **************************************************************************** 00050 ****************************************************************************/ 00051 00052 /* PARTICLE FLAGS ***********************************************************/ 00053 #define PF_ACTIVE (1<<0) 00054 #define PF_ALIGNTOMOTION (1<<1) 00055 #define PF_ALIGNEDTOMOTION (1<<2) 00056 #define PF_KEEPALIGNEDTOMOTION (1<<3) 00057 #define PF_SPEEDSCALEX (1<<4) 00058 #define PF_SPEEDSCALEY (1<<5) 00059 00060 /* EMITTER SHAPES ***********************************************************/ 00061 #define ES_POINT 0 00062 #define ES_BOX 1 00063 #define ES_SPHERE 2 00064 #define ES_EMERGE 0x4000 00065 #define ES_HOLLOW 0x8000 00066 00067 /**************************************************************************** 00068 **************************************************************************** 00069 * TYPES ******************************************************************** 00070 **************************************************************************** 00071 ****************************************************************************/ 00072 00073 #ifndef OMICRON_TYPES_PARTICLE_DEFINED 00074 #define OMICRON_TYPES_PARTICLE_DEFINED 00075 00080 typedef struct particle_s 00081 { 00082 particle_s(); 00083 00084 // current state 00085 vec3_c pos; 00086 vec3_c speed; 00087 vec3_c accel; 00088 00089 vec4_c color; 00090 vec2_c size; 00091 00092 float angle; 00093 float anglespeed; 00094 vec3_c dir; 00095 00096 float birthtime; 00097 00098 // bool alignmotiondone; 00099 bool alife; 00100 } particle_t; 00101 00109 class particle_system_c 00110 { 00111 protected: 00112 00113 /* 00114 typedef struct 00115 { 00116 brush_c volume; 00117 ulong type; 00118 } effect_volume_t; 00119 */ 00120 // array_c<effect_volume_t> 00121 00122 array_c<class particle_emitter_c> 00123 *emitters; 00124 00125 array_c<class particle_type_c> 00126 *types; 00127 00128 friend class particle_emitter_c; 00129 00130 public: 00131 00132 particle_system_c(); 00133 virtual ~particle_system_c(); 00134 00135 void 00136 update(); 00137 00138 void 00139 draw(); 00140 00141 void 00142 remove_all_emitters(); 00143 00144 void 00145 remove_all_types(); 00146 00147 slong 00148 add_emitter(class particle_emitter_c *); 00149 00150 void 00151 remove_emitter(class particle_emitter_c *); 00152 00153 slong 00154 add_type(class particle_type_c *); 00155 }; 00156 00161 class particle_emitter_c 00162 { 00163 public: 00164 00165 slong particletype; 00166 00167 float birthrate; 00168 00169 vec3_c minangles; 00170 vec3_c maxangles; 00171 00172 int shape; 00173 vec3_c scale; 00174 00175 vec3_c pos, 00176 lastpos; 00177 00178 float newparts; 00179 00180 // bool selfdestruct; 00181 00182 float duration; 00183 00184 protected: 00185 00186 float lastupdate; 00187 float starttime; 00188 float endtime; 00189 00190 particle_system_c *psystem; 00191 00192 friend class particle_system_c; 00193 00194 void 00195 update(); 00196 public: 00197 00198 particle_emitter_c(); 00199 virtual ~particle_emitter_c(); 00200 00201 void 00202 start(); 00203 }; 00204 00219 class particle_type_c 00220 { 00221 protected: 00222 00223 vertex_t *verts; 00224 ulong vertexcount; 00225 00226 particle_t *particles; 00227 ulong particlecount; 00228 00229 public: 00230 00231 // setup 00232 vec2_c anglespeed; 00233 vec2_c startangle; 00234 00235 float lifetime; 00236 00237 vec4_c begincolor, 00238 endcolor; 00239 00240 vec2_c beginsize, 00241 endsize; 00242 00243 vec3_c force; 00244 00245 float mass; 00246 00247 float sparkle; 00248 00249 // other 00250 // struct shader_s *shader; ///< particle's texture 00251 sshort texture; 00252 sshort blendtype; 00253 00254 protected: 00255 00256 particle_system_c *psystem; 00257 friend class particle_system_c; 00258 friend class particle_emitter_c; 00259 00260 void 00261 update(); 00262 00263 void 00264 draw(); 00265 00266 void 00267 new_particle(const vec3_t pos, const vec3_t speed); 00268 00269 public: 00270 // particle_t reference; ///< 00271 particle_type_c(); 00272 virtual ~particle_type_c(); 00273 00274 // TODO: 00275 // void 00276 // load(const char *fname); 00277 }; 00278 00279 #endif
1.2.18