Instead of having engine objects interact directly with the concrecte classes, the particle system now uses interfaces to seperate the functionality that different objects need and the concrete implementations of this functionality.

So instead of using the class ParticleSystemData, you use the interface for the class IParticleSystemData and ask the datablock to create the concrete instance of the ParticleSystem. Like so:

This way, you can hand the emitter any class that inherits the IParticleSystemData interface and it will work with that class.

Interfaces for special functionality

Since everything is interfaces now, it's possible that the interface is too general for what you're trying to achieve. You might need to access the colours or the sizes of the particlerenderer or something similar. How do you handle this case?

In the file particleSystemInterfaces.h you can find a couple of additional interfaces, currently these are:

  • IColoredParticleRenderer
  • ISizedParticleRenderer

These are interfaces that you can implement if you are able to provide e.g. colours or sizes for the particles. An example of this can be found in the debris.cpp file:

ISizedParticleRenderer* sizedRenderer = dynamic_cast<ISizedParticleRenderer*>(mEmitterList[0]->getRenderer());
   if( mEmitterList[0] )
      sizeList[0] = mSize * 0.5;
      sizeList[1] = mSize;
      sizeList[2] = mSize * 1.5;
      sizedRenderer->setSizes( sizeList );

This way, you can let the debris impact the rendering of the particles if possible, if not you just carry on as usual. If you have a renderer that renders particles as e.g. other particle emitters, then it might not make sense to talk about the colour or size of the subsystem, so instead of having to implement some unused functionality just for the sake of a single class, you let the single class handle the case where that functionality doesn't apply.

Unless otherwise stated, the content of this page is licensed under Creative Commons Attribution-ShareAlike 3.0 License