Page 1 of 1

Changing position of snowing

Posted: Tue Jan 31, 2006 6:22 pm
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.

Posted: Tue Jan 31, 2006 7:58 pm
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.

Posted: Wed Feb 01, 2006 7:43 pm
by Isgalvotas
Ahhh I missed that parameter in function...my bad. :evil: Thanks a lot for help!

Nice code,
Isgalvotas.