|
@@ -209,6 +209,9 @@ ParticleSystemManager ps_manager;
|
|
|
|
|
|
|
|
PT(ParticleSystem) particle_system = new ParticleSystem(PARTICLE_SYSTEM_POOL_SIZE);
|
|
PT(ParticleSystem) particle_system = new ParticleSystem(PARTICLE_SYSTEM_POOL_SIZE);
|
|
|
|
|
|
|
|
|
|
+static int particles_added = 0;
|
|
|
|
|
+
|
|
|
|
|
+/*
|
|
|
#if defined POINT_PARTICLES
|
|
#if defined POINT_PARTICLES
|
|
|
PT(PointParticleFactory) pf = new PointParticleFactory;
|
|
PT(PointParticleFactory) pf = new PointParticleFactory;
|
|
|
#elif defined ZSPIN_PARTICLES
|
|
#elif defined ZSPIN_PARTICLES
|
|
@@ -216,6 +219,14 @@ PT(ParticleSystem) particle_system = new ParticleSystem(PARTICLE_SYSTEM_POOL_SIZ
|
|
|
#elif defined ORIENTED_PARTICLES
|
|
#elif defined ORIENTED_PARTICLES
|
|
|
PT(OrientedParticleFactory) pf = new OrientedParticleFactory;
|
|
PT(OrientedParticleFactory) pf = new OrientedParticleFactory;
|
|
|
#endif
|
|
#endif
|
|
|
|
|
+*/
|
|
|
|
|
+#if defined POINT_PARTICLES
|
|
|
|
|
+ PT(BaseParticleFactory) pf = new PointParticleFactory;
|
|
|
|
|
+#elif defined ZSPIN_PARTICLES
|
|
|
|
|
+ PT(BaseParticleFactory) pf = new ZSpinParticleFactory;
|
|
|
|
|
+#elif defined ORIENTED_PARTICLES
|
|
|
|
|
+ PT(BaseParticleFactory) pf = new OrientedParticleFactory;
|
|
|
|
|
+#endif
|
|
|
|
|
|
|
|
#if defined GEOM_PARTICLE_RENDERER
|
|
#if defined GEOM_PARTICLE_RENDERER
|
|
|
PT(GeomParticleRenderer) pr = new GeomParticleRenderer;
|
|
PT(GeomParticleRenderer) pr = new GeomParticleRenderer;
|
|
@@ -271,11 +282,10 @@ event_csn_update(CPT_Event) {
|
|
|
|
|
|
|
|
static void
|
|
static void
|
|
|
event_add_particles(CPT_Event) {
|
|
event_add_particles(CPT_Event) {
|
|
|
- static initialized = 0;
|
|
|
|
|
|
|
|
|
|
// guard against additional "P" presses (bad things happen)
|
|
// guard against additional "P" presses (bad things happen)
|
|
|
- if(initialized) return;
|
|
|
|
|
- initialized = 1;
|
|
|
|
|
|
|
+ if(particles_added) return;
|
|
|
|
|
+ particles_added = 1;
|
|
|
|
|
|
|
|
// renderer setup
|
|
// renderer setup
|
|
|
#ifdef PARTICLE_RENDERER_ALPHA_MODE
|
|
#ifdef PARTICLE_RENDERER_ALPHA_MODE
|
|
@@ -364,6 +374,7 @@ event_add_particles(CPT_Event) {
|
|
|
#endif
|
|
#endif
|
|
|
|
|
|
|
|
// factory setup
|
|
// factory setup
|
|
|
|
|
+
|
|
|
#ifdef PARTICLE_FACTORY_LIFESPAN_BASE
|
|
#ifdef PARTICLE_FACTORY_LIFESPAN_BASE
|
|
|
pf->set_lifespan_base(PARTICLE_FACTORY_LIFESPAN_BASE);
|
|
pf->set_lifespan_base(PARTICLE_FACTORY_LIFESPAN_BASE);
|
|
|
#endif
|
|
#endif
|
|
@@ -560,17 +571,52 @@ event_more_particles(CPT_Event) {
|
|
|
0,
|
|
0,
|
|
|
};
|
|
};
|
|
|
|
|
|
|
|
|
|
+ if(!particles_added) return;
|
|
|
|
|
+
|
|
|
if (0 == sizes[index]) index = 0;
|
|
if (0 == sizes[index]) index = 0;
|
|
|
set_pool_size(sizes[index]);
|
|
set_pool_size(sizes[index]);
|
|
|
index++;
|
|
index++;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+static void
|
|
|
|
|
+event_switch_particle_factory_type(CPT_Event) {
|
|
|
|
|
+ static int index = 0;
|
|
|
|
|
+
|
|
|
|
|
+ if(!particles_added) return;
|
|
|
|
|
+
|
|
|
|
|
+ cout << "Switching to a";
|
|
|
|
|
+
|
|
|
|
|
+ switch (index) {
|
|
|
|
|
+ case 0:
|
|
|
|
|
+ cout << " point";
|
|
|
|
|
+ pf = new PointParticleFactory;
|
|
|
|
|
+ particle_system->set_factory(pf);
|
|
|
|
|
+ break;
|
|
|
|
|
+ case 1:
|
|
|
|
|
+ cout << " z-spin";
|
|
|
|
|
+ pf = new ZSpinParticleFactory;
|
|
|
|
|
+ particle_system->set_factory(pf);
|
|
|
|
|
+ break;
|
|
|
|
|
+ case 2:
|
|
|
|
|
+ cout << "n oriented";
|
|
|
|
|
+ pf = new OrientedParticleFactory;
|
|
|
|
|
+ particle_system->set_factory(pf);
|
|
|
|
|
+ break;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ cout << " particle factory" << endl;
|
|
|
|
|
+
|
|
|
|
|
+ index++;
|
|
|
|
|
+ if (index > 2) index = 0;
|
|
|
|
|
+}
|
|
|
|
|
+
|
|
|
void demo_keys(EventHandler&) {
|
|
void demo_keys(EventHandler&) {
|
|
|
new RenderRelation( lights, dlight );
|
|
new RenderRelation( lights, dlight );
|
|
|
have_dlight = true;
|
|
have_dlight = true;
|
|
|
|
|
|
|
|
event_handler.add_hook("p", event_add_particles);
|
|
event_handler.add_hook("p", event_add_particles);
|
|
|
event_handler.add_hook("m", event_more_particles);
|
|
event_handler.add_hook("m", event_more_particles);
|
|
|
|
|
+ event_handler.add_hook(",", event_switch_particle_factory_type);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
int main(int argc, char *argv[]) {
|
|
int main(int argc, char *argv[]) {
|