Particle Box Emitter and scaled particle system

You discovered a bug in the engine, and you are sure that it is not a problem of your code? Just post it in here. Please read the bug posting guidelines first.
Post Reply
Ein
Posts: 33
Joined: Thu Feb 12, 2009 11:39 pm
Location: UK - Matrix
Contact:

Particle Box Emitter and scaled particle system

Post by Ein »

I'm trying to get my box emitter to look like rain, but when I run it, the effect comes out well boxy >_< the effects come out like there are set in a grid. How would I go about makeing them come out not grid like and more rain like?

This is what I have at the moment, I used to example from the special FX tutorial.

Code: Select all

scene::IParticleEmitter* em = ps->createBoxEmitter(
                core::aabbox3d<f32>(-7,0,-7,7,1,7), // emitter size
                core::vector3df(0.0f,-0.06f,0.0f),   // initial direction
                10,100,                             // emit rate
                video::SColor(0,0,0,255),       // darkest color
                video::SColor(0,255,255,255),       // brightest color
                80,20000,0,                         // min and max age, angle
                core::dimension2df(10.f,10.f),         // min size
                core::dimension2df(40.f,40.f));        // max size
Any ideas?
Thanks,
Pete
Ein knowledge seeker
bitplane
Admin
Posts: 3204
Joined: Mon Mar 28, 2005 3:45 am
Location: England
Contact:

Post by bitplane »

What do you mean by "in a grid"? Do you mean they are spaced like they're in a set grid, or that they're square?
You could playing with the particle settings in irrEdit until you get the effect you want, but I think that for rain particles you'd need particles that look different depending on the angle you're viewing them from, like this
Submit bugs/patches to the tracker!
Need help right now? Visit the chat room
Ein
Posts: 33
Joined: Thu Feb 12, 2009 11:39 pm
Location: UK - Matrix
Contact:

Post by Ein »

yeah I mean that they are spaced in a grid, so they come out of the sky in the same place like this;

X00X00X00X
X00X00X00X
X00X00X00X

But what I would like is;

0X0XX0X0X
X0XXXXX00
000X0X0X0X
X0X0XX0X0

So that it is more dynamic or soemthing >_<
I'll have a mess around with irredit.

How is that effect done in that video?
Thanks,
Pete
Ein knowledge seeker
bitplane
Admin
Posts: 3204
Joined: Mon Mar 28, 2005 3:45 am
Location: England
Contact:

Post by bitplane »

Ein wrote:yeah I mean that they are spaced in a grid
Hmm, I can't reproduce that. I used your settings in the special effects example but made the particles ten times smaller, looked okay to me.
Ein wrote:How is that effect done in that video?
I made a custom particle system that works like mariokart sprites. It probably doesn't work with the latest version of Irrlicht, but you can get the code here
Submit bugs/patches to the tracker!
Need help right now? Visit the chat room
Ein
Posts: 33
Joined: Thu Feb 12, 2009 11:39 pm
Location: UK - Matrix
Contact:

Post by Ein »

Custom system sounds hard.
I know what made it go gridy was becase of this ps->setScale(core::vector3df(100,100,100));

I set the scale this size to make the effect wider.
Ein knowledge seeker
bitplane
Admin
Posts: 3204
Joined: Mon Mar 28, 2005 3:45 am
Location: England
Contact:

Post by bitplane »

Ah okay, moving to bug reports.
Submit bugs/patches to the tracker!
Need help right now? Visit the chat room
Ein
Posts: 33
Joined: Thu Feb 12, 2009 11:39 pm
Location: UK - Matrix
Contact:

Post by Ein »

ah I take it this is not meant to happen? >_<
Ein knowledge seeker
hybrid
Admin
Posts: 14143
Joined: Wed Apr 19, 2006 9:20 pm
Location: Oldenburg(Oldb), Germany
Contact:

Post by hybrid »

Maybe bitplane remebered an old distribution fmod error, which is still existing in the latest code versions. But don't know, for now it just looks unpleasant, not wrong...
Ein
Posts: 33
Joined: Thu Feb 12, 2009 11:39 pm
Location: UK - Matrix
Contact:

Post by Ein »

Any news on this?
Heres the whole code that I was working on when I got this.

Code: Select all

#include <irrlicht.h>
#include <iostream>
#include <windows.h>
using namespace irr;
using namespace core;
using namespace scene;
using namespace video;
using namespace gui;

#ifdef _MSC_VER
#pragma comment(lib, "Irrlicht.lib")
#endif

int main()
{
    //Screen size 640, 480, 32 bit, fullscreen = false, stencilbuffer = false, vsync = true
    IrrlichtDevice *device = createDevice(EDT_OPENGL, dimension2d<s32>(640, 480), 32, false, true, false);

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

    /////////////////////////////////////////////////////////////////////////
	//        START   ----    CAMERA
    /////////////////////////////////////////////////////////////////////////
	//parent = 0, rotateSpeed AKA mouse = 0, moveSpeed = 0.1f
	scene::ICameraSceneNode * camera = smgr->addCameraSceneNodeFPS(0, 100.f, 0.1f);
	camera->setPosition(core::vector3df(40.f, 20.f, 5.f));
	device->getCursorControl()->setVisible(false);

	/////////////////////////////////////////////////////////////////////////
	//        START   ----    CAMERA
    /////////////////////////////////////////////////////////////////////////

	//Create a cube
    ISceneNode* cubey = smgr->addCubeSceneNode();

    //Add light
    smgr->setAmbientLight(video::SColorf(0.3,0.3,0.3,1));
    scene::ISceneNode* light01 = smgr->addLightSceneNode(0, core::vector3df(10,450,0), video::SColorf(0,50,150), 800.0f);

    light01 = smgr->addBillboardSceneNode(light01, core::dimension2d<f32>(500, 500));
    light01->setMaterialFlag(video::EMF_LIGHTING, false);
    light01->setMaterialType(video::EMT_TRANSPARENT_ADD_COLOR);
    light01->setMaterialTexture(0, driver->getTexture("./media/particlewhite.bmp"));


 	// First, this is the path to the texture you want to use for your sphere
	smgr->addSkyDomeSceneNode(driver->getTexture("./media/sky.jpg"),
		16,	// 16 rows from top to bottom
		16,	// rectangles each row
		1.0f,	// percent of the texture used, example 0.9f will only use the top 90% of the image file (range 0.0f-1.0f)
		2.0f);	// percent of the sphere to cover 1.0f covers the top half of the sphere, while 2.0f covers the entire sphere

    // create a particle system
    scene::IParticleSystemSceneNode* ps = smgr->addParticleSystemSceneNode(false);

    scene::IParticleEmitter* em = ps->createBoxEmitter(
        core::aabbox3d<f32>(-7,0,-7,7,1,7), // emitter size
        core::vector3df(0.0f,-0.06f,0.0f),   // initial direction
        10,100,                             // emit rate
        video::SColor(0,0,0,255),       // darkest color
        video::SColor(0,255,255,255),       // brightest color
        80,20000,0,                         // min and max age, angle
        core::dimension2df(5.f,5.f),         // min size
        core::dimension2df(20.f,20.f));        // max size

    ps->setEmitter(em); // this grabs the emitter
    em->drop(); // so we can drop it here without deleting it

    scene::IParticleAffector* paf = ps->createFadeOutParticleAffector();

    ps->addAffector(paf); // same goes for the affector
    paf->drop();

    ps->setPosition(core::vector3df(10,450,0));
    ps->setScale(core::vector3df(100,100,100));
    ps->setMaterialFlag(video::EMF_LIGHTING, false);
    ps->setMaterialFlag(video::EMF_ZWRITE_ENABLE, false);
    ps->setMaterialTexture(0, driver->getTexture("./media/rain.jpg"));
    ps->setMaterialType(video::EMT_TRANSPARENT_VERTEX_ALPHA);

    IAnimatedMesh* plane = smgr->addHillPlaneMesh("floor", // Name of mesh
        core::dimension2d<f32>(20,20), //	Size of a tile of the mesh. (10.0f, 10.0f) would be a good value to start, for example.
        core::dimension2d<u32>(40,40), 0, 0, // 	Specifies how much tiles there will be. If you specifiy for example that a tile has the size (10.0f, 10.0f) and the tileCount is (10,10), than you get a field of 100 tiles which has the dimension 100.0fx100.0f.
        core::dimension2d<f32>(0,0), //material
        core::dimension2d<f32>(10,10)); //countHills

    IAnimatedMesh* mesh = smgr->getMesh("./media/tree01.b3d");
    IAnimatedMeshSceneNode* tree = smgr->addAnimatedMeshSceneNode(mesh);
    tree->setMaterialFlag(EMF_LIGHTING, false);
    tree->setMaterialType(EMT_TRANSPARENT_ALPHA_CHANNEL);
    tree->setPosition(core::vector3df(0,8,0));

    IAnimatedMesh* mesh1 = smgr->getMesh("./media/island.obj");
    IAnimatedMeshSceneNode* island = smgr->addAnimatedMeshSceneNode(mesh1);
    island->setMaterialTexture(0, driver->getTexture("./media/sand.jpg"));
    island->setMaterialFlag(EMF_LIGHTING, false);
    island->setScale(core::vector3df(10,10,10));
    island->setPosition(core::vector3df(0,21.5,0));

    camera->setTarget(island->getAbsolutePosition());

    //IAnimatedMeshSceneNode* floor = smgr->addAnimatedMeshSceneNode(plane);
    //mesh, waveheight, wave speed, wave length
    ISceneNode* sea = smgr->addWaterSurfaceSceneNode(plane->getMesh(0), 0.5f, 350.0f, 80.0f);
    sea->setMaterialTexture(0, driver->getTexture("./media/sand.jpg"));
    sea->setMaterialTexture(1, driver->getTexture("./media/water.jpg"));
    sea->setMaterialFlag(EMF_LIGHTING, true);
    sea->setMaterialType(video::EMT_REFLECTION_2_LAYER);

    scene::ITriangleSelector* selector = smgr->createTriangleSelectorFromBoundingBox(sea);
   	scene::ISceneNodeAnimator* anim = smgr->createCollisionResponseAnimator(
		selector, camera, core::vector3df(5,5,5),
		core::vector3df(0,0,0)
    );

	camera->addAnimator(anim);
	anim->drop();

    /////////////////////////////////////////////////////////////////////////
	//                             Main loop
    /////////////////////////////////////////////////////////////////////////
    int lastFPS = -1;

	while(device->run() && !GetAsyncKeyState(VK_ESCAPE))
	if (device->isWindowActive())
	{
		driver->beginScene(true, true, video::SColor(0,200,200,200));
		smgr->drawAll();
		driver->endScene();

		int fps = driver->getFPS();

		if (lastFPS != fps)
		{
			core::stringw str = L"Petes Weather System [";
			str += driver->getName();
			str += "] FPS:";
			str += fps;
			device->setWindowCaption(str.c_str());
			lastFPS = fps;
		}

	}else{
          device->yield(); //Cause the device to temporarily pause execution and let other processes run.
	}
	
	device->drop();
	return 0;
}
I don't think you need it.
But I hope this might help something.
Pete
Ein knowledge seeker
vitek
Bug Slayer
Posts: 3919
Joined: Mon Jan 16, 2006 10:52 am
Location: Corvallis, OR

Post by vitek »

Yeah, I'm pretty sure everyone understands the problem. You create a particle emitter tha emits particles in a small box...

Code: Select all

 core::aabbox3d<f32>(-7,0,-7,7,1,7), // emitter size
and then you scale the particle system to make the box bigger....

Code: Select all

  ps->setScale(core::vector3df(100,100,100);
So the emitter creates particles randomly distributed over the area you specify (a box that is 14x1x14). When rendering the particles, their positions are offset by the scale factor so the particle positions are remapped to a larger area (1400x100x1400). The easy workaround is to change the scale back to (1, 1, 1) and set the emitter box size to (1400, 100, 1400) if that is what you really want.

Of course this is indeed a bug, but pushing to get it fixed isn't very productive, especially when there is a workaround available.

Travis
Ein
Posts: 33
Joined: Thu Feb 12, 2009 11:39 pm
Location: UK - Matrix
Contact:

Post by Ein »

ah I was unaware that there was a work around >_<

I'm not botherd if the bug gets fixed (which now that I understand what I am doing I realise that this is just me not understanding the code) I know there are better things todo, I was just makeing sure that I provided all the information that I could to help the bug fix when it happend ^_^. And wondering if anything has happend to it.

Thank you for explaining it to me.
Ein knowledge seeker
vitek
Bug Slayer
Posts: 3919
Joined: Mon Jan 16, 2006 10:52 am
Location: Corvallis, OR

Post by vitek »

No problem. I thought that you understood why there was the weirdness.

Travis
Post Reply