Upgrade the particle system in the engine

Announce new projects or updates of Irrlicht Engine related tools, games, and applications.
Also check the Wiki
Post Reply
Yokom
Posts: 30
Joined: Sat Oct 09, 2004 10:50 pm

Upgrade the particle system in the engine

Post by Yokom »

I have just hit what seems to be a major limitation in the irrlicht engine. Particle affectors and Particle control. Ive been running around these boards soaking up help now im going to start to help out a bit.

Here is my plan a joint effort to add more affectors to the particle system for effects. Here is some things i want to be able to do with particles and just cant as far as i can tell.

Scale taper;; I want to be able to taper the scale of the particles down as they get distant from the emitter. This is different then the fade out affector. I want then to scale down to a small cone like affect. Im going to look into adding this to the engine.

Source rotate:: I have a particle node that disappears when you rotate around it. Im not sure what the problem is with it but its attached to the back of a space ship and when you yaw the ship around the 2d node goes flat. I can hope someone can help on this since it should be same code as the particles use to face the camera.
brcolow
Posts: 56
Joined: Mon Jul 19, 2004 6:15 am
Location: Arizona

Post by brcolow »

Sounds like a great idea. If you need any testing, let me know. Also, I remember something like this being discussed at www.irrlichtnx.mmdevel.de you may want to check there for some information :)
G'Day.
Yokom
Posts: 30
Joined: Sat Oct 09, 2004 10:50 pm

Post by Yokom »

im not sure about that NX project. Its not Niko's project right? Whats the skinny on that.

Anyway I am almost there on a taperaffector class for particles. It will allow you to call a class affector that will resize the particle array with two floats.

one will be taperfactor and the other is taperscale, it will reduce each particle size by a the factor and each particle will reduce after that by an accumalative scale by taperscale.

So if you play with the numbers right you can make a cone affect or and inverted cone. And there add some variance in degrees to get a more stable affect.

I will wait untill further testing but it will be good for things like gunshot flare and in my app engine trails.
Yokom
Posts: 30
Joined: Sat Oct 09, 2004 10:50 pm

Post by Yokom »

well ive gotten the engine to compile with the new mod but it crashes when my program tries to call it, ya ok whats new im in the middle of debbuging it atm but ill post where i am at atm incase there are some clever suggestions.

its giving me runtime check failure 0. the esp register is getting lost. This is the line im using to call it. It works on the fadeoutaffector that i used as a mold for the framework for this affector.

scene::IParticleAffector* paf2 = MySpaceShip.EngPartNode->createTaperAffector(1.0f,0.001f)

create files
CParticleTaperAffector.h
CParticleTaperAffector.cpp

edit IParticleSystemSceneNode.h
after the lines for the gravity affector
______________________________________________________________
virtual IParticleAffector* createTaperAffector(
f32 taperfactor, f32 taperscale) =0;
______________________________________________________________

edit CParticleSystemSceneNode.h
after the lines for the gravity affector
______________________________________________________________
virtual IParticleAffector* createTaperAffector(
f32 taperfactor = 1, f32 taperscale = .001);
______________________________________________________________

edit CParticleSystemSceneNode.cpp
add the include at the top
______________________________________________________________

#include "CParticleTaperAffector.h"
______________________________________________________________
under the gravity affector lines add
______________________________________________________________
IParticleAffector* CParticleSystemSceneNode::createTaperAffector(
f32 taperfactor, f32 taperscale)
{
return new CparticleTaperAffector(taperfactor, taperscale);
}
______________________________________________________________

the CParticleTaperAffector.cpp
// Copyright (C) 2002-2004 Nikolaus Gebhardt
// This file is part of the "Irrlicht Engine".
// For conditions of distribution and use, see copyright notice in Irrlicht.h
// Added BY Amen-RA, and Yokom 11/13/2004

#include "CParticleTaperAffector.h"
#include "os.h"
namespace irr{namespace scene{
//! Constructor
CParticleTaperAffector::CParticleTaperAffector(
f32 taperfactor, f32 taperscale)
{
taperFactor=taperfactor;
taperScale=taperscale;
f32 imadummy = 0;
}

//! Affects an array of particles.
void CParticleTaperAffector::affect(u32 now, SParticle* particlearray, u32 count)
{

imadummy = taperFactor;
for (u32 i=0; i<count; ++i)
if (imadummy > 0) imadummy -= taperScale;
if (particlearray.pos.X > 0 ){
particlearray.pos.X *= imadummy;
}
if (particlearray.pos.Y > 0 ){
particlearray.pos.Y *= imadummy;
}
}

} // end namespace scene
} // end namespace irr
the CParticleTaperAffector.h file
// This file is part of the "Irrlicht Engine".
// For conditions of distribution and use, see copyright notice in Irrlicht.h
// Added By Amen-Ra, and Yokom 11/13/2004
#ifndef __C_PARTICLE_TAPER_H_INCLUDED__
#define __C_PARTICLE_TAPER_H_INCLUDED__
#include "IParticleAffector.h"
namespace irr{namespace scene{
class CParticleTaperAffector : public IParticleAffector{
public: CParticleTaperAffector(f32 taperfactor,f32 taperscale);
//! Affects a particle.
virtual void affect(u32 now, SParticle* particlearray, u32 count);
private:
f32 taperFactor;
f32 taperScale;
};
} // end namespace scene
} // end namespace irr
#endif
Yokom
Posts: 30
Joined: Sat Oct 09, 2004 10:50 pm

Post by Yokom »

Well none of that worked as i didnt really understand the particle process the irrlicht way of doing it. So not much of that code up there works.

The data struct SParticle didnt have a spot to retain a size varible for each particle. It turns out there isnt a method that sets the size of the particle in the point emitter or box emitter when they generate the particle.

This means i have to add a size to the data struct and a method to set a size to a particle once it has been created as the system pushes particles through the array.

It is almost done but isnt working very well do to the particle system using a bounding box that it sets of a single size varible.

So not done yet
Yokom
Posts: 30
Joined: Sat Oct 09, 2004 10:50 pm

Post by Yokom »

OMG IT WORKS

after hours of working to overhaul the particle system it works. i can taper off particles in the array and have cone affects.

Due to alot of code in the engine being overhauled I sent it to the big guys for review before i post it here. If i dont hear back from him in a few days Ill submit it to a few vets with the engine for review.

Arries this will be great for you ship exhaust system that you have been working on ill send you a pm.

Yokom
with a ton of help from AmenRA
Post Reply