Particle system won't show up

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
Mux
Posts: 56
Joined: Mon Feb 26, 2007 12:25 pm
Location: Stockholm

Particle system won't show up

Post by Mux »

I'm having problem with a particle system that won't show up around a mesh which I call portal.
This is the particle system:
scene::IParticleSystemSceneNode *portalParticleSystem = device->getSceneManager()->addParticleSystemSceneNode( false,portal);
portal->setPosition(core::vector3df(0,0,0));
portal->setMaterialFlag(video::EMF_LIGHTING,false);

scene::IParticleCylinderEmitter* cylinderEmitter = portalParticleSystem->createCylinderEmitter(
core::vector3df(0,-portal->getBoundingBox().getExtent().Y/2,0), //center
//core::vector3df(0,0,0),
30.0f, //radius
core::vector3df(0,1,0), //normal
100.0f, //length
false, //outline only
core::vector3df(0.0f,0.2f,0.0f), //direction
150,2500, //min & max particle per second
video::SColor( 48, 50, 6, 65 ), video::SColor( 0, 16, 16, 128 ), //min & max start color
150, 1750, //lifetime min & max
0, //max angel degrees
core::dimension2df(5,5), core::dimension2df(5,5) //min & max start size
);

video::ITexture* tex1 = device->getVideoDriver()->getTexture("fire.bmp");
if( tex1 )
{
device->getVideoDriver()->makeColorKeyTexture( tex1, core::position2d<s32>(0,0) );
tex1->regenerateMipMapLevels();
}

portalParticleSystem->setMaterialFlag(video::EMF_ZWRITE_ENABLE, false);
portalParticleSystem->setMaterialFlag(video::EMF_LIGHTING,false);
portalParticleSystem->setMaterialTexture(0,tex1);
portalParticleSystem->setMaterialType( video::EMT_TRANSPARENT_VERTEX_ALPHA );
portalParticleSystem->setVisible( true );

portalParticleSystem->setEmitter( cylinderEmitter );
cylinderEmitter->drop();
I thought that it might be something wrong with it so I wrote a simpe test program that only displayed the portal and the particle system and that worked. I've tried to make everything else in my world invisible (walls & terrain) but I still don't see my particle system. Any ideas what I'm doing wrong?
It'll only take a minute or two to debug this code...
Seven
Posts: 1034
Joined: Mon Nov 14, 2005 2:03 pm

Re: Particle system won't show up

Post by Seven »

can you give us the console output of the small test program?
Mux
Posts: 56
Joined: Mon Feb 26, 2007 12:25 pm
Location: Stockholm

Re: Particle system won't show up

Post by Mux »

This is what the output window shows:
'ParticleTest.exe': Loaded 'F:\Programmering\Visual Studio Projects\ParticleTest\Debug\ParticleTest.exe', Symbols loaded.
'ParticleTest.exe': Loaded 'C:\WINDOWS\system32\ntdll.dll'
'ParticleTest.exe': Loaded 'C:\WINDOWS\system32\kernel32.dll'
'ParticleTest.exe': Loaded 'F:\Programmering\Visual Studio Projects\ParticleTest\Debug\Irrlicht.dll', Symbols loaded.
'ParticleTest.exe': Loaded 'C:\WINDOWS\system32\user32.dll'
'ParticleTest.exe': Loaded 'C:\WINDOWS\system32\gdi32.dll'
'ParticleTest.exe': Loaded 'C:\WINDOWS\system32\advapi32.dll'
'ParticleTest.exe': Loaded 'C:\WINDOWS\system32\rpcrt4.dll'
'ParticleTest.exe': Loaded 'C:\WINDOWS\system32\secur32.dll'
'ParticleTest.exe': Loaded 'C:\WINDOWS\system32\opengl32.dll'
'ParticleTest.exe': Loaded 'C:\WINDOWS\system32\msvcrt.dll'
'ParticleTest.exe': Loaded 'C:\WINDOWS\system32\glu32.dll'
'ParticleTest.exe': Loaded 'C:\WINDOWS\system32\ddraw.dll'
'ParticleTest.exe': Loaded 'C:\WINDOWS\system32\dciman32.dll'
'ParticleTest.exe': Loaded 'C:\WINDOWS\WinSxS\x86_Microsoft.VC90.DebugCRT_1fc8b3b9a1e18e3b_9.0.30729.6161_x-ww_ba947f24\msvcr90d.dll', Symbols loaded.
'ParticleTest.exe': Loaded 'C:\WINDOWS\system32\imm32.dll'
'ParticleTest.exe': Loaded 'C:\WINDOWS\system32\lpk.dll'
'ParticleTest.exe': Loaded 'C:\WINDOWS\system32\usp10.dll'
Irrlicht Engine version 1.7.3
IrrExtensions 13 4.2 (4 new objects).
Microsoft Windows XP Personal Service Pack 3 (Build 2600)
'ParticleTest.exe': Loaded 'C:\WINDOWS\system32\MSCTF.dll'
'ParticleTest.exe': Loaded 'C:\WINDOWS\system32\version.dll'
'ParticleTest.exe': Unloaded 'C:\WINDOWS\system32\version.dll'
'ParticleTest.exe': Loaded 'C:\WINDOWS\system32\msctfime.ime'
'ParticleTest.exe': Loaded 'C:\WINDOWS\system32\ole32.dll'
Using renderer: Direct3D 9.0
'ParticleTest.exe': Loaded 'C:\WINDOWS\system32\d3d9.dll'
'ParticleTest.exe': Loaded 'C:\WINDOWS\system32\d3d8thk.dll'
'ParticleTest.exe': Loaded 'C:\WINDOWS\system32\version.dll'
'ParticleTest.exe': Loaded 'C:\WINDOWS\system32\winmm.dll'
NVIDIA GeForce GTX 285 nv4_disp.dll 6.14.13.1407
'ParticleTest.exe': Loaded 'C:\WINDOWS\system32\D3DX9_40.dll'
Loaded header version: 4
Load vertices: 48
Load Triangles: 66
Load Groups: 4
Load Materials: 2
Loaded texture: F:/Programmering/Visual Studio Projects/Ball2/Ball2/Media/rock006.jpg
Loaded texture: F:/Programmering/Visual Studio Projects/Ball2/Ball2/Media/marb002.jpg
FPS: 24.000000
Joints: 0
Loaded mesh: F:\Programmering\Visual Studio Projects\Ball2\Ball2\Media\portal.ms3d
Loaded texture: F:/Programmering/Visual Studio Projects/Ball2/Ball2/Media/fire.bmp
Resizing window (640 480)
Resetting D3D9 device.
It'll only take a minute or two to debug this code...
hybrid
Admin
Posts: 14143
Joined: Wed Apr 19, 2006 9:20 pm
Location: Oldenburg(Oldb), Germany
Contact:

Re: Particle system won't show up

Post by hybrid »

Try to set a differetn alpha value on the particles (you have 0 at the max color), and try to enable blend mode in the material.
Mux
Posts: 56
Joined: Mon Feb 26, 2007 12:25 pm
Location: Stockholm

Re: Particle system won't show up

Post by Mux »

I tried several different values for min & max start color but I still can't see anything in my large project, in the test program however, I see the changes just fine. Which material flag do I need to set to true to enable blend mode?
It'll only take a minute or two to debug this code...
CuteAlien
Admin
Posts: 9734
Joined: Mon Mar 06, 2006 2:25 pm
Location: Tübingen, Germany
Contact:

Re: Particle system won't show up

Post by CuteAlien »

The material flag is BlendOperation and you have to set it to EBO_ADD probably.
IRC: #irrlicht on irc.libera.chat
Code snippet repository: https://github.com/mzeilfelder/irr-playground-micha
Free racer made with Irrlicht: http://www.irrgheist.com/hcraftsource.htm
Mux
Posts: 56
Joined: Mon Feb 26, 2007 12:25 pm
Location: Stockholm

Re: Particle system won't show up

Post by Mux »

Ah, that explains it. I could not see that material flag since I'm using irrlicht 1.7.3.
It'll only take a minute or two to debug this code...
Mux
Posts: 56
Joined: Mon Feb 26, 2007 12:25 pm
Location: Stockholm

Re: Particle system won't show up

Post by Mux »

I've upgraded to Irrlicht 1.8 now and tried to enable BlendOperation on the particle system but it's still invisible.
It'll only take a minute or two to debug this code...
CuteAlien
Admin
Posts: 9734
Joined: Mon Mar 06, 2006 2:25 pm
Location: Tübingen, Germany
Contact:

Re: Particle system won't show up

Post by CuteAlien »

Sorry, didn't read the text full last time (too many messages each day...). You did already create a small text program and it worked there? Then that means the particle system works and your problem is something else. Maybe it's not in the position where you expect it? Or not really created at all or something like that. What I often do when debugging such stuff is compiling Irrlicht in debug and then set a breakpoint in render() and in OnRegisterSceneNode() of the corresponding class. If you have more than one object of that class then you can set for example set a debug-name to find the right one. In OnRegisterSceneNode() you can find out if it does register itself for rendering. And in render() you can see if it really renders (should do if it registered itself in OnRegisterSceneNode) and maybe you see what's going on (like wrong position or so).
IRC: #irrlicht on irc.libera.chat
Code snippet repository: https://github.com/mzeilfelder/irr-playground-micha
Free racer made with Irrlicht: http://www.irrgheist.com/hcraftsource.htm
Mux
Posts: 56
Joined: Mon Feb 26, 2007 12:25 pm
Location: Stockholm

Re: Particle system won't show up

Post by Mux »

Yes I did create a small program to see if it worked there (which it did) I then added terrain and my walls to that program and the particle system still worked fine. I thought about the position but since my system is a child to my portal node it should be where I expect it (I did create the particle system as a "stand alone" node and tried a couple of cooridnates for the position but it's still invisible). Thanks for the debug advice, I will try it.
It'll only take a minute or two to debug this code...
Mux
Posts: 56
Joined: Mon Feb 26, 2007 12:25 pm
Location: Stockholm

Re: Particle system won't show up

Post by Mux »

Now I'm completely mystified. I put a breakpoint in CParticleSystemSceneNode::OnRegisterSceneNode() on the row f (IsVisible && (Particles.size() != 0)) to be exact and everytime I end up there all the values of the data members of Patricles is ???, IsVisible is true. So for some reason my particle system is not created properly, the portal however (created just above the particle system) shows up just fine. I have no idea on how to solve this.
It'll only take a minute or two to debug this code...
CuteAlien
Admin
Posts: 9734
Joined: Mon Mar 06, 2006 2:25 pm
Location: Tübingen, Germany
Contact:

Re: Particle system won't show up

Post by CuteAlien »

Hard to give hints without knowing more. Lots of stuff that can go wrong. Maybe you delete the node? Or do you pass it around as reference somewhere and the reference might become invalid (for example because the object was in an array that got resized). Etc, etc... too many possibilities to know the problem without more info.
IRC: #irrlicht on irc.libera.chat
Code snippet repository: https://github.com/mzeilfelder/irr-playground-micha
Free racer made with Irrlicht: http://www.irrgheist.com/hcraftsource.htm
Mux
Posts: 56
Joined: Mon Feb 26, 2007 12:25 pm
Location: Stockholm

Re: Particle system won't show up

Post by Mux »

Now I have come a bit closer. I've tried to make my project as modular as possbile so the first thing that runs is tha main program that creates the irrlicht device and shows the title screen and main menu. When the game is started from the main menu I pass the Irrlicht device as a pointer to my game logic. I now tried to create a particle system in my main program and that seems to have worked, at least it registers as i should for rendering and render() is called as it should. So there seems to happen something strange with the Irrlicht device when I pass it as a pointer to another class.
It'll only take a minute or two to debug this code...
CuteAlien
Admin
Posts: 9734
Joined: Mon Mar 06, 2006 2:25 pm
Location: Tübingen, Germany
Contact:

Re: Particle system won't show up

Post by CuteAlien »

More likely the object of the other class itself is not ok. Passing a pointer doesn't mess up the pointer or the object. Check if you really still have the same pointer - otherwise your class object where you use the device-pointer is probably not set up correctly.
IRC: #irrlicht on irc.libera.chat
Code snippet repository: https://github.com/mzeilfelder/irr-playground-micha
Free racer made with Irrlicht: http://www.irrgheist.com/hcraftsource.htm
Post Reply