HomeHome  CalendarCalendar  FAQFAQ  SearchSearch  MemberlistMemberlist  UsergroupsUsergroups  RegisterRegister  Log inLog in  

Share | 
 

 Implementing rain example with irrlicht

View previous topic View next topic Go down 
AuthorMessage
badday_7bf



Messages : 1
Date d'inscription : 2012-01-06

PostSubject: Implementing rain example with irrlicht   Fri Jan 06, 2012 11:34 am

Hi,

first of all thanks do the developers of Spark, it´s really useful Smile

To my current problem:

I´m trying to implement the rain example with irrlicht, but currenty I can´t see any effect of it, it´s totally invisible. Here is what I do:


Setting up the hole thing
Code:

          //Inits Particle Engine
   Vector3D gravity = Vector3D(0.0f,-2.0f,0.0f);

   // Renderers

   float sizeRatio = 1.2;

   IRR::IRRPointRenderer* basicRenderer = IRR::IRRPointRenderer::create(Main->GetDevice());

   // point renderer
   IRR::IRRPointRenderer* dropRenderer = IRR::IRRPointRenderer::create(Main->GetDevice());
   dropRenderer->setType(POINT_CIRCLE);
   dropRenderer->setSize(2.0f * sizeRatio);
   dropRenderer->setBlending(SPK::BLENDING_ADD);

   // line renderer
   IRR::IRRLineRenderer* rainRenderer = IRR::IRRLineRenderer::create(Main->GetDevice());
   rainRenderer->setLength(-0.1f);
   rainRenderer->setBlending(SPK::BLENDING_ADD);

   // quad renderer
   IRR::IRRQuadRenderer* splashRenderer = IRR::IRRQuadRenderer::create(Main->GetDevice());
   splashRenderer->setScale(0.05f,0.05f);
   splashRenderer->setTexturingMode(TEXTURE_2D);
   splashRenderer->setTexture(GetDriver()->getTexture("./res/waterdrops.bmp"));
   splashRenderer->setBlending(SPK::BLENDING_ADD);
   splashRenderer->enableRenderingHint(DEPTH_WRITE,false);
   
   // Models
   // rain model
   Model* rainModel = Model::create(FLAG_GREEN | FLAG_RED | FLAG_BLUE | FLAG_ALPHA | FLAG_MASS,
      0,
      FLAG_MASS);

   rainModel->setParam(PARAM_ALPHA,0.2f);
   rainModel->setImmortal(true);

   // drop model
   Model* dropModel = Model::create(FLAG_GREEN | FLAG_RED | FLAG_BLUE | FLAG_ALPHA | FLAG_MASS,
      0,
      FLAG_MASS);

   dropModel->setParam(PARAM_ALPHA,0.6f);

   // splash model
   Model* splashModel = Model::create(FLAG_GREEN | FLAG_RED | FLAG_BLUE | FLAG_ALPHA | FLAG_SIZE | FLAG_ANGLE,
      FLAG_SIZE | FLAG_ALPHA,
      FLAG_SIZE | FLAG_ANGLE);

   splashModel->setParam(PARAM_ANGLE,0.0f,2.0f * PI);
   splashModel->setParam(PARAM_ALPHA,1.0f,0.0f);

   // rain emitter
   //AABox* rainZone = AABox::create(Vector3D(2048.0f,100.0f,2048.0f));
   Ring* rainZone = Ring::create(Vector3D(0.0f,5.0f,0.0f));
   SphericEmitter* rainEmitter = SphericEmitter::create(Vector3D(0.0f,-1.0f,0.0f),0.0f,0.03f * PI);
   rainEmitter->setZone(rainZone);

   // drop emitter
   dropEmitter = SphericEmitter::create(Vector3D(0.0f,1.0f,0.0f),0.0f,0.2f * PI);

   // Groups
   // rain group
   Group* rainGroup = Group::create(rainModel,8000);
   //rainGroup->setCustomUpdate(&killRain); //not yet used
   rainGroup->setRenderer(rainRenderer);
   rainGroup->addEmitter(rainEmitter);
   rainGroup->setFriction(0.7f);
   rainGroup->setGravity(gravity);

   // drop group
   Group* dropGroup = Group::create(dropModel,16000);
   dropGroup->setRenderer(dropRenderer);
   dropGroup->setFriction(0.7f);
   dropGroup->setGravity(gravity);

   // splash group
   Group* splashGroup = Group::create(splashModel,2400);
   splashGroup->setRenderer(splashRenderer);

   // System
   particleSystem = SPK::IRR::IRRSystem::create(GetSmgr()->getRootSceneNode(), GetSmgr(), false);
   particleSystem->addGroup(splashGroup);
   particleSystem->addGroup(dropGroup);
   particleSystem->addGroup(rainGroup);
   


   

   SPKFactory::getInstance().traceAll();

And in the loop:
Code:
particleSystem->setTransformPosition(SPK::Vector3D(cam->getAbsolutePosition().X, cam->getAbsolutePosition().Y, cam->getAbsolutePosition().Z));
particleSystem->updateTransform();
particleSystem->update((float)GetDriver()->getFPS() * 0.01);

As you see it´s almost the same code used in the example, just changed for using irrlicht-renderers and systems.

Do you have any clue what I´m doing wrong?


Thanks,

badday
Back to top Go down
View user profile
Juff
Developer


Messages : 539
Date d'inscription : 2009-07-14
Age : 34

PostSubject: Re: Implementing rain example with irrlicht   Wed Jan 25, 2012 8:30 am

Sorry for the late reply.

I ll check that (to see if I can reproduce the issue) and get back to you.
Back to top Go down
View user profile http://spark.developpez.com
qidaozhilong2



Messages : 11
Date d'inscription : 2012-03-31

PostSubject: Re: Implementing rain example with irrlicht   Sat Apr 07, 2012 1:20 am

Question +1

I've also ported the Rain demo using Irrlicht as a renderer on my Android Phone.
Actually, I can see the effect, but the effect is not good(only some white line and splash effect can see)
I think the SPARK particle system is OK since i can see the rain effect.
Maybe the renderer part of Irrlicht-related has some problems.

PS, what i do is just 'COPY-PASTE' code from the related example.
Back to top Go down
View user profile
Sponsored content




PostSubject: Re: Implementing rain example with irrlicht   Today at 3:38 am

Back to top Go down
 
Implementing rain example with irrlicht
View previous topic View next topic Back to top 
Page 1 of 1
 Similar topics
-
» Notting Hill Carnival Ignores Rain

Permissions in this forum:You cannot reply to topics in this forum
 :: English Forum :: Questions (en)-
Jump to: