| csRef<iMeshFactoryWrapper> mfw = engine->CreateMeshFactory (
"crystalspace.mesh.object.particles", "fountain");
if (!mfw) return;
csRef<iMeshWrapper> exp = engine->CreateMeshWrapper (mfw, "custom fountain",
sector, origin);
exp->SetZBufMode(CS_ZBUF_TEST);
exp->GetMeshObject()->SetMixMode (CS_FX_ADD);
exp->GetMeshObject()->SetMaterialWrapper (mat);
csRef<iParticleBuiltinEmitterFactory> emit_factory =
csLoadPluginCheck<iParticleBuiltinEmitterFactory> (
Sys->object_reg, "crystalspace.mesh.object.particles.emitter", false);
csRef<iParticleBuiltinEffectorFactory> eff_factory =
csLoadPluginCheck<iParticleBuiltinEffectorFactory> (
Sys->object_reg, "crystalspace.mesh.object.particles.effector", false);
csRef<iParticleBuiltinEmitterCone> conemit = emit_factory->CreateCone ();
float velocity = 3.0f;
float seconds_to_live = 1.5f;
conemit->SetExtent (csVector3 (0, 0.5f, 0));
conemit->SetConeAngle (0.3f);
conemit->SetParticlePlacement (CS_PARTICLE_BUILTIN_VOLUME);
conemit->SetEmissionRate (float (num) / seconds_to_live);
conemit->SetInitialMass (8.0f, 10.0f);
conemit->SetInitialTTL (seconds_to_live, seconds_to_live);
conemit->SetInitialVelocity (csVector3 (0, velocity, 0), csVector3 (0));
csRef<iParticleBuiltinEffectorLinColor> lincol = eff_factory->
CreateLinColor ();
lincol->AddColor (csColor4 (0.25f, 0.35f, 0.55f, 1), seconds_to_live);
csRef<iParticleBuiltinEffectorForce> force = eff_factory->
CreateForce ();
force->SetAcceleration (csVector3 (0.0f, -3.0f, 0.0f));
csRef<iParticleSystem> partstate =
scfQueryInterface<iParticleSystem> (exp->GetMeshObject ());
partstate->SetParticleSize (csVector2 (0.1f, 0.1f));
partstate->AddEmitter (conemit);
partstate->AddEffector (lincol);
partstate->AddEffector (force);
|