HomeHome  CalendarCalendar  FAQFAQ  SearchSearch  MemberlistMemberlist  UsergroupsUsergroups  RegisterRegister  Log inLog in  

Share | 
 

 Would it be possible to add support for 'restarting\resetting' particle systems?

View previous topic View next topic Go down 
AuthorMessage
crushfor
Guest



PostSubject: Would it be possible to add support for 'restartingresetting' particle systems?   Thu Nov 12, 2009 7:27 pm

I often maintain a pool of previously created particle systems that have finished so that I can then restart them in a new location once a new one is required. This saves doing the memory allocations\setup and creation code many times each time a particle system is started.

By the way I really like what you've done and if and it was really easy for me to get an OpenGL ES renderer going for my iPhone project.

Cheers

-Craig
Back to top Go down
Juff
Developer


Messages : 539
Date d'inscription : 2009-07-14
Age : 34

PostSubject: Re: Would it be possible to add support for 'restarting\resetting' particle systems?   Fri Nov 13, 2009 12:56 pm

Hi,

first of all, glad to see you like the library and you built renderers for the iphone Smile

Pooling particle systems is the right way to do. I was thinking of a way to reset a particle system but it appears not that easy to do in an automatic manner as every parameters would have to be doubled to keep its original state. Im still thinking about it though.

Resetting systems in a manual way is easy to do and as you know exactly what has changed you can reset it by hand. The way I see to do it is keeping a base system that was used to build up all systems in the pool. When you need to reactivate a system, you just reset the parameters of the system you need from the values of the parameters of the base system. Most of the time it will be emptying the groups of the system and resetting the tank of the emitters.
Back to top Go down
View user profile http://spark.developpez.com
crushfor
Guest



PostSubject: Re: Would it be possible to add support for 'restarting\resetting' particle systems?   Mon Nov 16, 2009 12:20 pm

I managed to get them resetting properly but I had to make the member variable 'fraction' of emitter to public so I could reset it.

Heres my current implementation:

void ParticleSystem::start(void) {
Emitter *emitter;
int i;

// Set alive flag
m_isAlive = true;

// Empty the particle system
m_sparkParticleSystem->empty();

// Set the emitters tank values back to their initial values
for (i=0; i<m_emitters.size(); ++i) {
emitter = &m_emitters[i];
emitter->m_sparkEmitter->setTank(emitter->m_initialTank);

emitter->m_sparkEmitter->fraction = Rand::getFloat(1.0f);

}
}

The red bit is the only bit I had to hack in. If you could please add some method to reset this or something then that'll be great and I can remove my hacks Very Happy
Back to top Go down
Juff
Developer


Messages : 539
Date d'inscription : 2009-07-14
Age : 34

PostSubject: Re: Would it be possible to add support for 'restarting\resetting' particle systems?   Mon Nov 16, 2009 3:24 pm

The fraction parameter is only here to keep track of the current state of emission. It is basically the fractional part of the next particle to be emitted, when it reaches 1, a new particle is emitted. That s to keep the emission rate consistent.

You really dont have to care about it. It is set to a random value between 0 and 1 to introduce a phase shift in the emission so that for example an emitter emitting particle at a rate of 1 particle every 10 seconds will emit its first particle at a time between 0 and 10 sec.

It will always be between 0 and 1, resetting is not necessary.
Back to top Go down
View user profile http://spark.developpez.com
Sponsored content




PostSubject: Re: Would it be possible to add support for 'restarting\resetting' particle systems?   Today at 9:25 am

Back to top Go down
 
Would it be possible to add support for 'restarting\resetting' particle systems?
View previous topic View next topic Back to top 
Page 1 of 1
 Similar topics
-
» Which versions of firefox will support Selenium Rc to run?
» Update Breaking News: EA Pulls Support For Wii U and 3DS Might Develop For Nintendo Again in The Future!
» do you get moral support from your spouse/boyfriend or girlfriend.
» Does Firefox Webdriver support Auto-complete feature?
» Selenium RC & Dojo controls.

Permissions in this forum:You cannot reply to topics in this forum
 :: English Forum :: Evolution (en)-
Jump to: