Changing position of snowing

If you are a new Irrlicht Engine user, and have a newbie-question, this is the forum for you. You may also post general programming questions here.
Post Reply
Isgalvotas
Posts: 13
Joined: Mon Oct 31, 2005 8:58 pm
Location: Lithuania
Contact:

Changing position of snowing

Post by Isgalvotas »

Hi all :)

I've a problem with changing position of snowing. I want that every while (device->run) cycle snowing position will change (in simple words just move snowing cube to another position with every redrawing of scene). Snowing position should be the same as camera position (it should make snowing effect). If someone can help me figure out how to do it, I will be happy...

Here is code of snowing effect:

Code: Select all

 ps = smgr->addParticleSystemSceneNode(false);
        //ps->setPosition(core::vector3df(3800.0f,510.0f,7400.0f)); // -160,170,80
        ps->setPosition(core::vector3df(snw_x,snw_y,snw_z));
        ps->setScale(core::vector3df(2,2,2));

        ps->setParticleSize(core::dimension2d<f32>(5.0f, 5.0f));

	    em = ps->createBoxEmitter(
		core::aabbox3d<f32>(-270,-200,-270,270,300,300),
		core::vector3df(0.01f,-0.02f,0.0f),
		400,800,
		video::SColor(0,255,255,255), video::SColor(0,255,255,255),
		1800,3000);

	    ps->setEmitter(em);
	    em->drop();

	    paf = ps->createGravityAffector(core::vector3df(-0.05f,-0.03f, 0.0f), 2000);

	    ps->addAffector(paf);
	    paf->drop();

	    ps->setMaterialFlag(video::EMF_LIGHTING, false);
	    ps->setMaterialTexture(0, driver->getTexture("./data/snowparticle.bmp"));
	    ps->setMaterialType(video::EMT_TRANSPARENT_VERTEX_ALPHA);
Nice code,
Isgalvotas.
Image
vitek
Bug Slayer
Posts: 3919
Joined: Mon Jan 16, 2006 10:52 am
Location: Corvallis, OR

Post by vitek »

Well, you could just attach the particle system scene node to the camera and be done with it...

Code: Select all

  ps = smgr->addParticleSystemSceneNode(false, camera);
You should be told that It won't work with the Maya camera because its OnPostRender does not update the cameras children. This is good because you can use the maya camera to inspect the scene for debugging.
Isgalvotas
Posts: 13
Joined: Mon Oct 31, 2005 8:58 pm
Location: Lithuania
Contact:

Post by Isgalvotas »

Ahhh I missed that parameter in function...my bad. :evil: Thanks a lot for help!

Nice code,
Isgalvotas.
Image
Post Reply