<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html401/loose.dtd"> <html> <!-- Created by texi2html 1.76 --> <!-- Written by: Lionel Cons <Lionel.Cons@cern.ch> (original author) Karl Berry <karl@freefriends.org> Olaf Bachmann <obachman@mathematik.uni-kl.de> and many others. Maintained by: Many creative people <dev@texi2html.cvshome.org> Send bugs and suggestions to <users@texi2html.cvshome.org> --> <head> <title>Crystal Space 1.2.1: C.2.18.2 Rain</title> <meta name="description" content="Crystal Space 1.2.1: C.2.18.2 Rain"> <meta name="keywords" content="Crystal Space 1.2.1: C.2.18.2 Rain"> <meta name="resource-type" content="document"> <meta name="distribution" content="global"> <meta name="Generator" content="texi2html 1.76"> <meta http-equiv="Content-Type" content="text/html; charset=us-ascii"> <style type="text/css"> <!-- a.summary-letter {text-decoration: none} pre.display {font-family: serif} pre.format {font-family: serif} pre.menu-comment {font-family: serif} pre.menu-preformatted {font-family: serif} pre.smalldisplay {font-family: serif; font-size: smaller} pre.smallexample {font-size: smaller} pre.smallformat {font-family: serif; font-size: smaller} pre.smalllisp {font-size: smaller} span.sansserif {font-family:sans-serif; font-weight:normal;} ul.toc {list-style: none} --> </style> </head> <body lang="en" bgcolor="#FFFFFF" text="#000000" link="#0000FF" vlink="#800080" alink="#FF0000"> <a name="Api1_005f0-PartConv-Rain"></a> <a name="0"></a> <table cellpadding="1" cellspacing="1" border="0"> <tr><td valign="middle" align="left">[<a href="Api1_005f0-PartConv-Explo.html#0" title="Previous section in reading order"> < </a>]</td> <td valign="middle" align="left">[<a href="Api1_005f0-PartConv-Snow.html#0" title="Next section in reading order"> > </a>]</td> <td valign="middle" align="left"> </td> <td valign="middle" align="left">[<a href="Release-Notes.html#0" title="Beginning of this chapter or previous chapter"> << </a>]</td> <td valign="middle" align="left">[<a href="Api1_005f0-Particle-system-changes.html#0" title="Up section"> Up </a>]</td> <td valign="middle" align="left">[<a href="Licenses.html#0" title="Next chapter"> >> </a>]</td> <td valign="middle" align="left"> </td> <td valign="middle" align="left"> </td> <td valign="middle" align="left"> </td> <td valign="middle" align="left"> </td> <td valign="middle" align="left">[<a href="index.html#SEC_Top" title="Cover (top) of document">Top</a>]</td> <td valign="middle" align="left">[<a href="cs_toc.html#SEC_Contents" title="Table of contents">Contents</a>]</td> <td valign="middle" align="left">[<a href="cs_Index.html#0" title="Index">Index</a>]</td> <td valign="middle" align="left">[<a href="cs_abt.html#SEC_About" title="About (help)"> ? </a>]</td> </tr></table> <hr size="1"> <h4 class="subsubsection"> C.2.18.2 Rain </h4> <p>To convert the old rain particle system to new particles you can use a box emitter which is oriented at the top where the rain drops should appear and which is very thin. Here you see an example of a rain particle system in the world file: </p> <table><tr><td> </td><td><pre class="example"> <meshfact name="rainFact"> <plugin>crystalspace.mesh.loader.factory.particles</plugin> <params> <particlesize x="0.02" y="0.37" /> <minbb> <min x="-10" y="0" z="-5" /> <max x="5" y="6" z="10" /> </minbb> <sortmode>none</sortmode> <renderorientation>common</renderorientation> <commondirection x="0" y="1" z="0" /> <emitter type="box"> <emissionrate>250</emissionrate> <mass min="5" max="7.5" /> <box> <min x="-10" y="6" z="-5" /> <max x="5" y="6" z="10" /> </box> <uniformvelocity /> <initialvelocity x="0" y="-2.84" z="0" /> <initialttl min="2.5" max="2.5" /> <placement>volume</placement> </emitter> <effector type="lincolor"> <color red="0" green="0" blue="1" time="2.5" /> </effector> </params> </meshfact> ... <meshobj name="rainfall"> <priority>alpha</priority> <plugin>crystalspace.mesh.loader.particles</plugin> <ztest /> <params> <factory>rainFact</factory> <mixmode> <add /> </mixmode> <material>raindrop</material> </params> <move> <v x="-10" y="0" z="10" /> </move> </meshobj> </pre></td></tr></table> <p>Here is how this could work in code: </p> <table><tr><td> </td><td><pre class="example"> 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); </pre></td></tr></table> <hr size="1"> <p> <font size="-1"> This document was generated using <a href="http://texi2html.cvshome.org/"><em>texi2html 1.76</em></a>. </font> <br> </p> </body> </html>