************************************************************************************************** ** Particles * ************************************************************************************************** * April 2011 * By Kaitlyn Callow ( KaitlynCallow.com | dacallow@learn.senecac.on.ca ) * For DPS905, Professor Chris Szalwinski **************************************************************************************************
Contents:
[A] INSTALLATION
[B] HOW TO USE
[A]
INSTALLATION
1) Add the following files to your project:
- Particle.cpp
- Particle.h
- ParticleGenerator.cpp
- ParticleGenerator.h
- ParticleVertexList.cpp
- ParticleVertexList.h
2) Append onto the bottom of your existing Effects.fx file the contents of the following file:
3) Modify iObject.h:
- Add to Class iObject...
//added for particle effects / animations virtual void update(int now) = 0;
- At the bottom of the file iObject.h add...
extern "C" iObject* CreateParticleGenerator(float _generatorlifespan, float _particlelifespan, float _particlespawnrate, float _spawnpositiondispersion, float _theta, float _startingspeed, Colour _startcolour, Colour _endcolour, float _frequencycolour, float _startsize, float _endsize, float _frequencysize, Vector _startgravity, Vector _endgravity, float _frequencygravityvertical, float _frequencygravityhorizontal, float _startalpha, float _endalpha, float _frequencyalpha, Colour* c, float* p);
4) Modify Object.h
- Add to Class Object...
void update(int now) { /* do nothing, added for particle effects & animations */ }
5) Modify Display.cpp
- Inside of method: bool Display::setup(void* hwnd)
near line 360 (beneath the comment "// setup successful") add...
ParticleVertex::device = d3dd; ParticleVertexList::connectDevice(d3dd);
6) Modify Configuration.h
- Adding into the existing typedef enum Category (line 375) a new type of:
PARTICLES
7) Modify Object.cpp
- Updating the Object::Object(category, colour, iGraphic*, int, int) method..
Change from..
// store reflectivity, shininess, and texture pointers material = new Colour[nSubsets]; shine = new float[nSubsets]; texture = new iTexture**[nSubsets]; for (int i = 0; i < nSubsets; i++) { material[i] = c[i]; if (p && p[i]) shine[i] = p[i]; else shine[i] = DEFAULT_SHININESS; if (material[i].a != 1.0f) category = TRANSLUCENT_OBJECT; texture[i] = new iTexture*[nStages]; for (int j = 0; j < nStages; j++) texture[i][j] = NULL; }
And change it to..:
// store reflectivity, shininess, and texture pointers material = new Colour[nSubsets]; shine = new float[nSubsets]; texture = new iTexture**[nSubsets]; for (int i = 0; i < nSubsets; i++) { material[i] = c[i]; if (p && p[i]) shine[i] = p[i]; else shine[i] = DEFAULT_SHININESS; if (material[i].a != 1.0f && category != PARTICLES) category = TRANSLUCENT_OBJECT; texture[i] = new iTexture*[nStages]; for (int j = 0; j < nStages; j++) texture[i][j] = NULL; }
8) Modify DeviceTexture.cpp
- Inside the method ( void DeviceTexture::create(iScene* scene, const Matrix& view, const Matrix& projection, const Vector& viewpoint) )
Near line 190...
Change from:
d3dd->BeginScene(); scene->draw(SKYBOX); scene->draw(OPAQUE_OBJECT); scene->draw(TRANSLUCENT_OBJECT); d3dd->EndScene();
And change it to..:
d3dd->BeginScene(); scene->draw(SKYBOX); scene->draw(OPAQUE_OBJECT); scene->draw(TRANSLUCENT_OBJECT); scene->draw(PARTICLES); d3dd->EndScene();
9) Modify Design.cpp
- Modify void Design::draw()
Changing from:
scene->draw(MIRROR); scene->draw(SKYBOX); scene->draw(OPAQUE_OBJECT); scene->draw(TRANSLUCENT_OBJECT); hud->draw(HUD_ALPHA);
Changing to:
scene->draw(MIRROR); scene->draw(SKYBOX); scene->draw(OPAQUE_OBJECT); scene->draw(TRANSLUCENT_OBJECT); scene->draw(PARTICLES); hud->draw(HUD_ALPHA);