Use This Rain Effects

Post those lines of code you feel like sharing or find what you require for your project here; or simply use them as tutorials.
Post Reply
Radnussrini
Posts: 14
Joined: Tue Oct 10, 2006 5:58 am

Use This Rain Effects

Post by Radnussrini »

/* Rain Effects by Srini*/

#include <irrlicht.h>

using namespace irr;
using namespace core;
using namespace scene;
using namespace video;
using namespace io;
using namespace gui;


#pragma comment(lib, "irrlicht.lib")

scene::ICameraSceneNode* camera = 0;

int main()
{

IrrlichtDevice *device = createDevice(video::EDT_DIRECT3D9,
core::dimension2d<s32>(640,480),
32, false, true );

video::IVideoDriver* driver = device->getVideoDriver();
scene::ISceneManager* smgr = device->getSceneManager();


scene::ISceneNode* node = 0;

scene::IAnimatedMesh* mesh = smgr->addHillPlaneMesh("Hill",
core::dimension2d<f32>(20,20),
core::dimension2d<s32>(20,20), 0, 20,
core::dimension2d<f32>(2,2),
core::dimension2d<f32>(1,1));




scene::IParticleSystemSceneNode* ps = 0;
ps = smgr->addParticleSystemSceneNode(false);
ps->setPosition(core::vector3df(-160,170,80));
ps->setScale(core::vector3df(1,1,1));

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

scene::IParticleEmitter* em = ps->createBoxEmitter(
core::aabbox3d<f32>(-270,-200,-270,270,300,300),
core::vector3df(0.00f,0.00f,0.0f),
400,800,
video::SColor(0,255,255,255), video::SColor(0,255,255,255),
8000,10000);

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

scene::IParticleAffector* paf =
ps->createGravityAffector(core::vector3df(0.00f,0.00f, 0.0f), 1000);

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

ps->setMaterialFlag(video::EMF_LIGHTING, false);
ps->setMaterialType(EMT_TRANSPARENT_ADD_COLOR);
ps->setMaterialTexture(0, driver->getTexture("Raindrop.bmp"));
ps->setMaterialType(video::EMT_TRANSPARENT_VERTEX_ALPHA);





scene::ISceneNode* skyboxNode = smgr->addSkyBoxSceneNode(
driver->getTexture("irrlicht2_uzerp.bmp"),
driver->getTexture("irrlicht2_up.bmp"),
driver->getTexture("irrlicht2_lf.bmp"),
driver->getTexture("irrlicht2_rt.bmp"),
driver->getTexture("irrlicht2_ft.bmp"),
driver->getTexture("irrlicht2_bk.bmp"));

device->getCursorControl()->setVisible(false);

camera=smgr->addCameraSceneNode(0, vector3df(-50, 100, -100),vector3df(0, 0, 250));

ps->setParent(camera);
int lastFPS = -1;

core::vector3df Pos = camera->getPosition();
while(device->run())
{
driver->beginScene(true, true, 0);

smgr->drawAll();

driver->endScene();

core::stringw str = L"Rain Effects By Srini";
str += driver->getName();

}

device->drop();

return 0;
}
drac_gd
Posts: 132
Joined: Sun Apr 09, 2006 8:43 pm

Post by drac_gd »

cool and thanks.. um where can I get Raindrop.bmp
Midnight
Posts: 1772
Joined: Fri Jul 02, 2004 2:37 pm
Location: Wonderland

Post by Midnight »

try making one?

or search google but don't assume the material isn't copyright protected as always just cause it's available it doesn't mean free.

or you could search the lisence of the images... free image galleries are nice for that kinda stuff always check the lisence or request permission but the easiest way is to make it yourself.
wowdevver24
Posts: 26
Joined: Mon Jan 04, 2010 8:02 pm

Post by wowdevver24 »

to make raindrop.bmp just open paint(ms or linux alternative) and set the size to 5px by 5px then select an appropriate color, I used dark blue, if you wish to modify this to be snow then obviously use grey #cccccc and make a 10x10 snowflake or series of snowflakes, also I'd suggest adding gravity, here is my code for irrlicht 1.6(obviously kudos go to the OP for their creation of the concept)

Code: Select all

#ifdef _MSC_VER
// We'll define this to stop MSVC complaining about sprintf().
#define _CRT_SECURE_NO_WARNINGS
#pragma comment(lib, "C:\\Program Files\\Microsoft Visual Studio 9.0\\VC\\lib\\irrlicht1_6\\Irrlicht.lib")
#endif

#include <irrlicht1_6/irrlicht.h>
#include <iostream>

using namespace irr;

scene::ICameraSceneNode* camera = 0;

int main()
{

IrrlichtDevice *device = createDevice(video::EDT_DIRECT3D9,core::dimension2d<u32>(640,480),32, false, true );

video::IVideoDriver* driver = device->getVideoDriver();
scene::ISceneManager* smgr = device->getSceneManager();


scene::ISceneNode* node = 0;

scene::IAnimatedMesh* mesh = smgr->addHillPlaneMesh("Hill",core::dimension2d<f32>(20,20),core::dimension2d<u32>(20,20), 0, (f32)20.0f,core::dimension2d<f32>(2,2),core::dimension2d<f32>(1.0f,1.0f));




scene::IParticleSystemSceneNode* ps = 0;
ps = smgr->addParticleSystemSceneNode(false);
ps->setPosition(core::vector3df(-160,170,80));
ps->setScale(core::vector3df(1,1,1));

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

scene::IParticleEmitter* em = ps->createBoxEmitter(core::aabbox3d<f32>(-270,-270,-270,270,300,300),core::vector3df(0.00f,0.00f,0.0f),400,800,video::SColor(0,255,255,255), video::SColor(0,255,255,255),8000,10000);

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

scene::IParticleAffector* paf = ps->createGravityAffector(core::vector3df(0.00f,-0.15f, 0.00f), 1000);

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

ps->setMaterialFlag(video::EMF_LIGHTING, false);
ps->setMaterialTexture(0, driver->getTexture("./media/raindrop.bmp"));
ps->setMaterialType(video::EMT_TRANSPARENT_ADD_COLOR);
ps->setParticleSize(core::dimension2d<f32>(0.5f,2.5f));




scene::ISceneNode* skyboxNode = smgr->addSkyBoxSceneNode(
      driver->getTexture("./media/irrlicht2_up.jpg"),
      driver->getTexture("./media/irrlicht2_dn.jpg"),
      driver->getTexture("./media/irrlicht2_lf.jpg"),
      driver->getTexture("./media/irrlicht2_rt.jpg"),
      driver->getTexture("./media/irrlicht2_ft.jpg"),
      driver->getTexture("./media/irrlicht2_bk.jpg"));
device->getCursorControl()->setVisible(false);

camera=smgr->addCameraSceneNodeFPS(0, 100.0f,1.0f);
camera->setPosition(core::vector3df(-50, 100, -100));
camera->setTarget(core::vector3df(0, 0, 250));

ps->setParent(camera);
int lastFPS = -1;

core::vector3df Pos = camera->getPosition();
while(device->run())
{
driver->beginScene(true, true, 0);

smgr->drawAll();

driver->endScene();

core::stringw str = L"Rain Effects By Srini";
str += driver->getName();

}

device->drop();

return 0;
}
now this does assume that you have a folder called media in either your debug or release folder and either irrlicht.dll in your system32 directory or your your executable directory, sorry to linux users on this part but as I'm quite sure I used DirectX as a renderer it was not as if you were not going to moan anyway, also aparently the setParticleSize is deprecated (ooh la de daa) but I'm going to use it anyway as it seems to work very nicely
Remember all information is contextual and if I do not understand the context I cannot gras the information
Post Reply