From: <and...@us...> - 2007-12-07 09:30:05
|
Revision: 493 http://python-ogre.svn.sourceforge.net/python-ogre/?rev=493&view=rev Author: andy_miller Date: 2007-12-07 01:30:09 -0800 (Fri, 07 Dec 2007) Log Message: ----------- Couple of ParticleUniverse header files needed updating towork.. Added Paths: ----------- trunk/python-ogre/code_generators/particleuniverse/ParticleUniverseDynamicAttributeFactory.h trunk/python-ogre/code_generators/particleuniverse/ParticleUniverseHook.h Added: trunk/python-ogre/code_generators/particleuniverse/ParticleUniverseDynamicAttributeFactory.h =================================================================== --- trunk/python-ogre/code_generators/particleuniverse/ParticleUniverseDynamicAttributeFactory.h (rev 0) +++ trunk/python-ogre/code_generators/particleuniverse/ParticleUniverseDynamicAttributeFactory.h 2007-12-07 09:30:09 UTC (rev 493) @@ -0,0 +1,85 @@ +/* +----------------------------------------------------------------------------- +This source file is part of the Particle Universe product. + +Copyright (c) 2006-2007 Henry van Merode + +Usage of this program is free for non-commercial use and licensed under the +the terms of the GNU Lesser General Public License. + +You should have received a copy of the GNU Lesser General Public License along with +this program; if not, write to the Free Software Foundation, Inc., 59 Temple +Place - Suite 330, Boston, MA 02111-1307, USA, or go to +http://www.gnu.org/copyleft/lesser.txt. +----------------------------------------------------------------------------- +*/ + +#ifndef __PU_DYNAMIC_ATTRIBUTE_FACTORY_H__ +#define __PU_DYNAMIC_ATTRIBUTE_FACTORY_H__ + +#include "ParticleUniverseDynamicAttribute.h" + +namespace ParticleUniverse +{ + /** This factory class is responsible for creating a DynamicAttribute object. + */ + class _ParticleUniverseExport DynamicAttributeFactory + { + public: + + DynamicAttributeFactory(void) {}; + virtual ~DynamicAttributeFactory(void) {}; + + /** + */ + template <class T> + T* createDynamicAttribute(void) + { + return new T(); + }; + + + /** + */ + DynamicAttribute* cloneDynamicAttribute(DynamicAttribute* dynamicAttribute) + { + if (dynamicAttribute) + { + switch(dynamicAttribute->getType()) + { + case DynamicAttribute::DAT_FIXED: + { + DynamicAttributeFixed* dynAttr = createDynamicAttribute<DynamicAttributeFixed>(); + dynamicAttribute->copyAttributesTo(dynAttr); + return dynAttr; + } + break; + + case DynamicAttribute::DAT_RANDOM: + { + DynamicAttributeRandom* dynAttr = createDynamicAttribute<DynamicAttributeRandom>(); + dynamicAttribute->copyAttributesTo(dynAttr); + return dynAttr; + } + break; + + case DynamicAttribute::DAT_CURVED: + { + DynamicAttributeCurved* dynAttr = createDynamicAttribute<DynamicAttributeCurved>(); + dynamicAttribute->copyAttributesTo(dynAttr); + return dynAttr; + } + break; + } + } + + return 0; + } + + /** Delete a DynamicAttribute + */ + void destroyDynamicAttribute (DynamicAttribute* dynamicAttribute){delete dynamicAttribute;}; + }; + +} +#endif Added: trunk/python-ogre/code_generators/particleuniverse/ParticleUniverseHook.h =================================================================== --- trunk/python-ogre/code_generators/particleuniverse/ParticleUniverseHook.h (rev 0) +++ trunk/python-ogre/code_generators/particleuniverse/ParticleUniverseHook.h 2007-12-07 09:30:09 UTC (rev 493) @@ -0,0 +1,126 @@ +/* +----------------------------------------------------------------------------- +This source file is part of the Particle Universe product. + +Copyright (c) 2006-2007 Henry van Merode + +Usage of this program is free for non-commercial use and licensed under the +the terms of the GNU Lesser General Public License. + +You should have received a copy of the GNU Lesser General Public License along with +this program; if not, write to the Free Software Foundation, Inc., 59 Temple +Place - Suite 330, Boston, MA 02111-1307, USA, or go to +http://www.gnu.org/copyleft/lesser.txt. +----------------------------------------------------------------------------- +*/ + +#ifndef __PU_HOOK_H__ +#define __PU_HOOK_H__ + +#include "ParticleUniversePrerequisites.h" + +namespace ParticleUniverse +{ + /** The Hook class is a template helper class that is used to call the hook functions of objects (Affectors, + Externs, ...) registered at the ParticleSystem. This prevents that the same code is duplicated + too much. + */ + template <typename T> + class _ParticleUniverseExport Hook + { + public: + /** Templated version to prepare objects. + */ + static void _prepare(std::vector<T*>* list, ParticleTechnique* technique) + { + if (list->empty()) + return; + typename T::iterator it; + typename T::iterator itEnd = list->end(); + for (it = list->begin(); it != itEnd; ++it) + { + (*it)->_prepare(technique); + } + } + + /** Templated version to notify objects that the ParticleSystem starts + */ + static void _notifyStart(std::vector<T*>* list) + { + if (list->empty()) + return; + typename T::iterator it; + typename T::iterator itEnd = list->end(); + for (it = list->begin(); it != itEnd; ++it) + { + (*it)->_notifyStart(); + } + } + + /** Templated version to notify objects that the ParticleSystem stops + */ + static void _notifyStop(std::vector<T*>* list) + { + if (list->empty()) + return; + typename T::iterator it; + typename T::iterator itEnd = list->end(); + for (it = list->begin(); it != itEnd; ++it) + { + (*it)->_notifyStop(); + } + } + + /** Templated version of _preProcessParticles. + @remarks + _preProcessParticles allows actions before the individual particles are processed. + */ + static void _preProcessParticles(std::vector<T*>* list, ParticleTechnique* technique, Ogre::Real timeElapsed) + { + if (list->empty()) + return; + typename T::iterator it; + typename T::iterator itEnd = list->end(); + for (it = list->begin(); it != itEnd; ++it) + { + (*it)->_preProcessParticles(technique, timeElapsed); + } + } + + /** Templated version to process a particle. + */ + static void _processParticle(std::vector<T*>* list, + ParticleTechnique* particleTechnique, + Particle* particle, + Ogre::Real timeElapsed, + bool firstParticle) + { + if (list->empty()) + return; + typename T::iterator it; + typename T::iterator itEnd = list->end(); + for (it = list->begin(); it != itEnd; ++it) + { + (*it)->_processParticle(particleTechnique, particle, timeElapsed, firstParticle); + } + } + + /** Templated version of _postProcessParticles. + @remarks + _postProcessParticles allows actions after the individual particles are processed. + */ + static void _postProcessParticles(std::vector<T*>* list, ParticleTechnique* technique, Ogre::Real timeElapsed) + { + if (list->empty()) + return; + typename T::iterator it; + typename T::iterator itEnd = list->end(); + for (it = list->begin(); it != itEnd; ++it) + { + (*it)->_postProcessParticles(technique, timeElapsed); + } + } + }; + +} +#endif This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |