Anonymous avatar Anonymous committed ed5793c

New particle type: blowing flowers. Also, Particle managers now clean up.

Comments (0)

Files changed (10)

Terrain/CEmitter.cpp

 #define MAX_PARTICLES       1000
 
 static UINT       cycler;
+static UINT       id_pool;
 
 /*-----------------------------------------------------------------------------
                               
 -----------------------------------------------------------------------------*/
 
+CEmitter::CEmitter ()
+{
+
+  _id = ++id_pool;
+
+}
+
 void CEmitter::Emit (UINT count)
 {
 
 
 }
 
+void CEmitter::RenderBbox ()
+{
+
+  glBindTexture (GL_TEXTURE_2D, 0);
+  _settings.volume.Render ();
+
+
+}
+
 void CEmitter::Render ()
 {
 
     glBlendFunc (GL_ONE, GL_ONE);
   else
     glBlendFunc (GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
-  glBindTexture (GL_TEXTURE_2D, 0);
+  //glBindTexture (GL_TEXTURE_2D, 0);
   //_settings.volume.Render ();
   glBindTexture (GL_TEXTURE_2D, TextureIdFromName (_settings.texture.c_str ()));
 

Terrain/CEmitter.h

 
 class CEmitter 
 {
+  UINT              _id;
   ParticleSet       _settings;
   UINT              _die;
   UINT              _last_update;
   void              Emit (UINT number);
 
 public:
+  CEmitter ();
+  UINT              Id () { return _id; };
   void              Set (ParticleSet* s);
   void              Update (float elapsed);
   void              Render ();
+  void              RenderBbox ();
   bool              Dead () { return _dead && _particle.empty (); };
 
 };
   bool        draw_sun;
 };
 
-void      EnvInit ();
-void      EnvUpdate ();
-Env*      EnvGet ();
+void          EnvInit ();
+void          EnvUpdate ();
+Env*          EnvGet ();

Terrain/Particle.cpp

                               
 -----------------------------------------------------------------------------*/
 
-void ParticleAdd (ParticleSet* p_in, GLvector position)
+UINT ParticleAdd (ParticleSet* p_in, GLvector position)
 {
   
   CEmitter*   e;
   elist.resize (elist.size () + 1);
   e = &elist[elist.size () - 1];
   e->Set (&p);
+  return e->Id ();
+
+}
+
+void ParticleDestroy (UINT id)
+{
+
+  unsigned    i;
+
+  for (i = 0; i < elist.size (); i++) {
+    if (elist[i].Id () == id) {
+      ConsoleLog ("ParticleDestroy: Removing effect #%d.", id);
+      elist.erase (elist.begin () + i);
+      return;
+    }
+  }
+  ConsoleLog ("ParticleDestroy: Effect #%d not found.", id);
 
 }
 

Terrain/Particle.h

 #include "cemitter.h"
 
-void ParticleAdd (ParticleSet* p_in, GLvector position);
+UINT ParticleAdd (ParticleSet* p_in, GLvector position);
 bool ParticleCmd (vector<string> *args);
+void ParticleDestroy (UINT id);
 void ParticleInit ();
 void ParticleLoad (const char* filename_in, struct ParticleSet* p);
 void ParticleRender ();

Terrain/Particles/groundfog.prt

     <particle.rotation>  [ 0,  0,  0 ]    </particle.rotation>
     <particle.size.min>  [ 12,  25,  0.01 ]    </particle.size.min>
     <particle.size.max>  [ 25,  12,  0.05 ]    </particle.size.max>
-    <particle.speed.min>  [ 0,  0,  -10 ]    </particle.speed.min>
-    <particle.speed.max>  [ 0,  0,  -10 ]    </particle.speed.max>
+    <particle.speed.min>  [ -2,  -2,  0 ]    </particle.speed.min>
+    <particle.speed.max>  [  2,   2,  0 ]    </particle.speed.max>
     <particle.spin>  [ 0,  0,  10 ]    </particle.spin>
     <particle.volume.min>  [ -32.0,  -32,  0.5 ]    </particle.volume.min>
     <particle.volume.max>  [  32.0,   32,  0.5 ]    </particle.volume.max>
-    <particle.wind>  204    </particle.wind>
-    <particle.z_buffer>  204    </particle.z_buffer>
+    <particle.wind>  0    </particle.wind>
+    <particle.gravity>  0    </particle.wind>
+    <particle.z_buffer>  0    </particle.z_buffer>
+
 </cvars>

Terrain/Particles/sand.prt

 <cvars>
     <particle.texture>  sand.png    </particle.texture>
-    <particle.acceleration>  [ 0,  2,  0 ]    </particle.acceleration>
+    <particle.acceleration>  [ 2,  0,  0 ]    </particle.acceleration>
     <particle.blend>  0    </particle.blend>
     <particle.emitter_lifespan>  0    </particle.emitter_lifespan>
     <particle.emit_count>  3    </particle.emit_count>

Terrain/Particles/windflower.prt

+<cvars>
+    <particle.texture>  particle_flower.png    </particle.texture>
+    <particle.acceleration>  [ 0,  0,  0.0 ]    </particle.acceleration>
+    <particle.blend>  0 </particle.blend>
+    <particle.emitter_lifespan>  0   </particle.emitter_lifespan>
+    <particle.emit_count>  1    </particle.emit_count>
+    <particle.emit_interval>  400    </particle.emit_interval>
+    <particle.fade_in>  5    </particle.fade_in>
+    <particle.fade_out>  500    </particle.fade_out>
+    <particle.interpolate>  0    </particle.interpolate>
+    <particle.lifespan>  3000    </particle.lifespan>
+    <particle.origin>  [ 0,  0,  -0.25 ]    </particle.origin>
+    <particle.panel_type>  3    </particle.panel_type>
+    <particle.rotation>  [ 0,  0,  0 ]    </particle.rotation>
+    <particle.size.min>  [ 0.07,  0.07, 0.07 ]    </particle.size.min>
+    <particle.size.max>  [ 0.17,  0.17, 0.17 ]    </particle.size.max>
+    <particle.speed.min>  [ 2,  -1,  0.05 ]    </particle.speed.min>
+    <particle.speed.max>  [ 3,   1,  0.25 ]    </particle.speed.max>
+    <particle.spin>  [ 20,  40,  0 ]    </particle.spin>
+    <particle.volume.min>  [ -2,  -2,  1.0 ]    </particle.volume.min>
+    <particle.volume.max>  [  2,   2,  1.1 ]    </particle.volume.max>
+    <particle.wind>  0    </particle.wind>
+    <particle.gravity>  0    </particle.wind>
+    <particle.z_buffer>  0    </particle.z_buffer>
+</cvars>

Terrain/Scene.cpp

 #include "cforest.h"
 #include "cg.h"
 #include "cgrass.h"
+#include "cparticlearea.h"
 #include "cterrain.h"
 #include "game.h"
 #include "ini.h"
 #define GRASS_HALF      (GRASS_GRID / 2)
 #define TERRAIN_GRID    9
 
+#define PARTICLE_GRID   3
+
 static int              cached;
 static int              texture_bytes;
 static int              texture_bytes_counter;
 
 /*                  *************************************************************/
 
-static GridManager        gm_terrain;
-static vector<CTerrain>   il_terrain;
-static GridManager        gm_forest;
-static vector<CForest>    il_forest;
-static GridManager        gm_grass;
-static vector<CGrass>     il_grass;
-static GridManager        gm_brush;
-static vector<CBrush>     il_brush;
-//static unsigned           world_seed = 2;
+static GridManager            gm_terrain;
+static vector<CTerrain>       il_terrain;
+static GridManager            gm_forest;
+static vector<CForest>        il_forest;
+static GridManager            gm_grass;
+static vector<CGrass>         il_grass;
+static GridManager            gm_brush;
+static vector<CBrush>         il_brush;
+static GridManager            gm_particle;
+static vector<CParticleArea>  il_particle;
 
 /* Module Functions *************************************************************/
 
   il_brush.resize (BRUSH_GRID * BRUSH_GRID);
   gm_brush.Init (&il_brush[0], BRUSH_GRID, BRUSH_SIZE);
 
-
 }
 
 
   il_brush.resize (BRUSH_GRID * BRUSH_GRID);
   gm_brush.Init (&il_brush[0], BRUSH_GRID, BRUSH_SIZE);
 
+  il_particle.clear ();
+  il_particle.resize (PARTICLE_GRID * PARTICLE_GRID);
+  gm_particle.Init (&il_particle[0], PARTICLE_GRID, PARTICLE_AREA_SIZE);
+
 }
 
 CTerrain* SceneTerrainGet (int x, int y)
   case 3: gm_brush.Update (stop); break;
   }
   //any time left over goes to the losers...
+  gm_particle.Update (stop);
   gm_terrain.Update (stop);
   gm_grass.Update (stop);
   gm_forest.Update (stop);
   CgShaderSelect (FSHADER_NONE);
   CgShaderSelect (VSHADER_NONE);
   ParticleRender ();
+  gm_particle.Render ();
 
 }
 

Terrain/Terrain.vcxproj

     <ClCompile Include="CGrid.cpp" />
     <ClCompile Include="Console.cpp" />
     <ClCompile Include="CPage.cpp" />
+    <ClCompile Include="CParticleArea.cpp" />
     <ClCompile Include="CTerrain.cpp" />
     <ClCompile Include="CTree.cpp" />
     <ClCompile Include="Entropy.cpp" />
     <ClInclude Include="CGrid.h" />
     <ClInclude Include="Console.h" />
     <ClInclude Include="Cpage.h" />
+    <ClInclude Include="CParticleArea.h" />
     <ClInclude Include="CTerrain.h" />
     <ClInclude Include="CTree.h" />
     <ClInclude Include="Entropy.h" />
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.