| csRef<iMeshFactoryWrapper> mfw = engine->CreateMeshFactory (
"crystalspace.mesh.object.particles", "fire");
if (!mfw) return;
csRef<iMeshWrapper> exp = engine->CreateMeshWrapper (mfw, "custom fire",
sector, origin);
exp->SetZBufMode(CS_ZBUF_TEST);
exp->GetMeshObject()->SetMixMode (CS_FX_ADD);
exp->GetMeshObject()->SetMaterialWrapper (mat);
csRef<iParticleBuiltinEmitterFactory> emit_factory =
csLoadPluginCheck<iParticleBuiltinEmitterFactory> (
object_reg, "crystalspace.mesh.object.particles.emitter", false);
csRef<iParticleBuiltinEffectorFactory> eff_factory =
csLoadPluginCheck<iParticleBuiltinEffectorFactory> (
object_reg, "crystalspace.mesh.object.particles.effector", false);
csRef<iParticleBuiltinEmitterSphere> sphemit = emit_factory->CreateSphere ();
// Time to live depends on height of sector.
float velocity = 0.5f;
float seconds_to_live = 2.0f;
sphemit->SetRadius (.2f);
sphemit->SetParticlePlacement (CS_PARTICLE_BUILTIN_VOLUME);
sphemit->SetEmissionRate (float (num) / seconds_to_live);
sphemit->SetInitialMass (5.0f, 7.5f);
sphemit->SetUniformVelocity (true);
sphemit->SetInitialTTL (seconds_to_live, seconds_to_live);
sphemit->SetInitialVelocity (csVector3 (0, velocity, 0),
csVector3 (0));
csRef<iParticleBuiltinEffectorLinColor> lincol = eff_factory->
CreateLinColor ();
lincol->AddColor (csColor4 (0.00, 0.00, 0.00, 1), 2);
lincol->AddColor (csColor4 (1.00, 0.35, 0.00, 0), 1.5);
lincol->AddColor (csColor4 (1.00, 0.22, 0.00, .1), 1.3125);
lincol->AddColor (csColor4 (1.00, 0.12, 0.00, .3), 1.125);
lincol->AddColor (csColor4 (0.80, 0.02, 0.00, .8), 0.9375);
lincol->AddColor (csColor4 (0.60, 0.00, 0.00, .9), 0.75);
lincol->AddColor (csColor4 (0.40, 0.00, 0.00, .97), 0.5625);
lincol->AddColor (csColor4 (0.20, 0.00, 0.00, 1), 0.375);
lincol->AddColor (csColor4 (0.00, 0.00, 0.00, 1), 0.1875);
lincol->AddColor (csColor4 (0.00, 0.00, 0.00, 1), 0);
csRef<iParticleBuiltinEffectorForce> force = eff_factory->
CreateForce ();
force->SetRandomAcceleration (csVector3 (1.5f, 1.5f, 1.5f));
csRef<iParticleSystem> partstate =
scfQueryInterface<iParticleSystem> (exp->GetMeshObject ());
partstate->SetParticleSize (csVector2 (0.04f, 0.08f));
partstate->AddEmitter (sphemit);
partstate->AddEffector (lincol);
partstate->AddEffector (force);
|