| csRef<iMeshFactoryWrapper> mfw = engine->CreateMeshFactory (
"crystalspace.mesh.object.particles", "rain");
if (!mfw) return;
csRef<iMeshWrapper> exp = engine->CreateMeshWrapper (mfw, "custom rain",
sector, csVector3 (0, 0, 0));
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<iParticleBuiltinEmitterBox> boxemit = emit_factory->CreateBox ();
boxemit->SetBox (bbox);
boxemit->SetParticlePlacement (CS_PARTICLE_BUILTIN_VOLUME);
boxemit->SetEmissionRate (num / 2.5f);
boxemit->SetInitialMass (5.0f, 7.5f);
boxemit->SetUniformVelocity (true);
boxemit->SetInitialTTL (2.5f, 2.5f);
boxemit->SetInitialVelocity (csVector3 (0, -2.84f, 0), csVector3 (0));
csRef<iParticleBuiltinEffectorLinColor> lincol = eff_factory->
CreateLinColor ();
lincol->AddColor (csColor4 (.25,.25,.25,1), 2.5f);
csRef<iParticleSystem> partstate =
scfQueryInterface<iParticleSystem> (exp->GetMeshObject ());
partstate->SetMinBoundingBox (bbox);
partstate->SetParticleSize (csVector2 (0.3f/50.0f, 0.3f));
partstate->SetParticleRenderOrientation (CS_PARTICLE_ORIENT_COMMON);
partstate->SetCommonDirection (csVector3 (0, 1, 0));
partstate->AddEmitter (boxemit);
partstate->AddEffector (lincol);
|