Click here to Skip to main content
12,998,483 members (85,631 online)
Click here to Skip to main content
Articles » Multimedia » OpenGL » General » Downloads


32 bookmarked
Posted 23 Feb 2005

Quagmire Particle Engine

, 23 Feb 2005
An object oriented OpenGL particle engine, for the simple creation of advanced particle effects.
/*	Ken Mazaika
	February 23, 2005
	Quagmire Particle Engine::Fire Engine


#include "FireEngine.h"
#include <math.h>

//Allow the easy change of a flame color, through setting it in the constructor
QdFireEngine::QdFireEngine(float fRed, float fGreen, float fBlue, float fAlpha)
	m_clrParticleColor.m_fA = fAlpha;
	m_clrParticleColor.m_fB = fBlue;
	m_clrParticleColor.m_fG = fGreen;
	m_clrParticleColor.m_fR = fRed;

//This initializes the particles/reinitializes particles that faded
int QdFireEngine::particleDead(int nParticle)
	int nCount = nParticle;
	setCurrentColor(nCount, m_clrParticleColor.m_fR, m_clrParticleColor.m_fG, m_clrParticleColor.m_fB,m_clrParticleColor.m_fA);
	float fRand= (float)(rand()%500);
	fRand = fRand/50000;
	setFadeColor(nCount, 0, 0, 0,-fRand-.01f);
	setFadeLife(nCount, -fRand-.001f);

	float fX;
	float fY;

	fRand= (float)(rand()%500);
	fRand = fRand/500;

	fX = fRand-.5f;
	fRand= (float)(rand()%500);
	fRand = fRand/500;
	fY = fRand;

	fX = fX/1000;
	fY = fY/50;

	setDirection(nCount,0, fY, 0);
	setGravity(nCount, 0, 0, 0);
	fRand= (float)(rand()%400);
	fRand = fRand/500;
	setLR(nCount,fRand-.4f, -1, 0);
	setUL(nCount, fRand-.4f+0.3f, -0.7f, 0);
	setAge(nCount, 0);
	setFrame(nCount, 0);

	setLife(nCount, 1);

	return QD_SUCCESS;

//This function is called by default by init() and sets the particles with
int QdFireEngine::resetParticles()
	int nCount=0;
	//Give the random number generator a seed

	while(nCount != m_nParticles)
	return QD_SUCCESS;

By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.

If a file you wish to view isn't highlighted, and is a text file (not binary), please let us know and we'll add colourisation support for it.


This article has no explicit license attached to it but may contain usage terms in the article text or the download files themselves. If in doubt please contact the author via the discussion board below.

A list of licenses authors might use can be found here


About the Author

Ken Mazaika
United States United States
No Biography provided

You may also be interested in...

Permalink | Advertise | Privacy | Terms of Use | Mobile
Web01 | 2.8.170622.1 | Last Updated 23 Feb 2005
Article Copyright 2005 by Ken Mazaika
Everything else Copyright © CodeProject, 1999-2017
Layout: fixed | fluid