The easiest way is to use engine->CreateMeshWrapper(). This is
actually documented in the manual. Check the using cs/engine/meshobj
section where it is explained how you can in general create a mesh
from a factory.

Greetings,

On 2/18/06, Vincent Knecht <[EMAIL PROTECTED]> wrote:
> Hi !
>
>   I'm trying to create particle systems from code, using a factory from a
> file... I've tried many combinations, but I'm lost.
> How to do that ?
>
> The following code fails on getting iParticleState:
>
>   csRef<iMeshFactoryWrapper> factoryw = loader->LoadMeshObjectFactory (
>         "/xd/models/thrusterparticles");
>   if (!factoryw)
>     return ReportError ("Unable to load thrusterparticles!");
>
>   // Initialize the emitter mesh object(s) used for thruster(s).
>   emitters.Empty ();
>   size_t i = 0;
>   csString pattern;
>   keybase = cfgkey + "ThrusterUnit.";
>   while (config->SubsectionExists (pattern.Format (keybase + "%d.", i)))
>   {
>     ThrustersInfos* infos = new ThrustersInfos (); // a csObject
>     /* that doesn't work neither
>     csString meshname;
>     infos->meshw = engine->CreateMeshWrapper (factoryw,
>           meshname.Format ("ThrusterEmitter%d", i),
>           pccamera->GetCamera ()->GetSector (),
>           csVector3 (0.0f, 0.0f, 0.0f));
>     */
>     infos->meshw = factoryw->CreateMeshWrapper ();
>     if (!infos->meshw)
>       return ReportError ("Unable to create particle meshwrapper!");
>     ///engine->AddMeshAndChildren (infos->meshw);
>     //infos->SetName (meshname.GetData ());
>     // is messing with iMeshObject really needed ?
>     csRef<iMeshObject> meshobject =
>           factoryw->GetMeshObjectFactory ()->NewInstance ();
>     infos->meshw->SetMeshObject (meshobject);
>     engine->AddMeshAndChildren (infos->meshw);
>
>     infos->state = SCF_QUERY_INTERFACE (infos->meshw->GetMeshObject (),
>           iParticleState);
>     if (!infos->state)
>       return ReportError ("Unable to get iParticleState!");
> [...]
>
> just in case:
> ===== /xd/models/thrusterparticles ===================
> <!-- <library> -->
>   <meshfact name="thrusterFACT">
>     <plugin>crystalspace.mesh.loader.factory.particles</plugin>
>     <params>
>       <emitter type="sphere">
>         <time>300</time>
>         <innerradius>0.01</innerradius>
>         <outerradius>0.03</outerradius>
>         <force type="linear">
>           <direction x="0.5" y="1" z="0"/>
>           <amount>10</amount>
>           <range>3.0</range>
>           <falloff>linear</falloff>
>         </force>
>       </emitter>
>       <dampener>0.1</dampener>
>       <mass>5</mass>
>       <massvariation>2.5</massvariation>
>       <pps>50</pps>
>       <initial>0</initial>
>       <gravity x="0" y="-1" z="0"/>
>       <diffusion>0.1</diffusion>
>       <radius>0.1</radius>
>       <ttl>5</ttl>
>       <zsort>yes</zsort>
>       <timevariation>0.5</timevariation>
>       <colormethod type="linear">
>         <gradient>
>           <color red="0" green="0" blue="1"/>
>           <color red="0" green="0.5" blue="1"/>
>           <color red="1" green="1" blue="1"/>
>         </gradient>
>       </colormethod>
>     </params>
>   </meshfact>
> <!-- </library> -->
> ==================================
>
> TIA
>
>
> -------------------------------------------------------
> This SF.net email is sponsored by: Splunk Inc. Do you grep through log files
> for problems?  Stop!  Download the new AJAX search engine that makes
> searching your log files as easy as surfing the  web.  DOWNLOAD SPLUNK!
> http://sel.as-us.falkag.net/sel?cmd=lnk&kid=103432&bid=230486&dat=121642
> _______________________________________________
> Crystal-main mailing list
> [email protected]
> https://lists.sourceforge.net/lists/listinfo/crystal-main
> Unsubscribe: mailto:[EMAIL PROTECTED]
>


--
Project Manager of Crystal Space (http://www.crystalspace3d.org)
and CEL (http://cel.crystalspace3d.org)
Support Crystal Space. Donate at
https://sourceforge.net/donate/index.php?group_id=649


-------------------------------------------------------
This SF.net email is sponsored by: Splunk Inc. Do you grep through log files
for problems?  Stop!  Download the new AJAX search engine that makes
searching your log files as easy as surfing the  web.  DOWNLOAD SPLUNK!
http://sel.as-us.falkag.net/sel?cmd=lnk&kid3432&bid#0486&dat1642
_______________________________________________
Crystal-main mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/crystal-main
Unsubscribe: mailto:[EMAIL PROTECTED]

Reply via email to