ParticleSystem::ParticleSystem(const FileName &fileName, TextureFactory &textureFactory, const vec3 &_position, float _rotation) { reset(); rotation = _rotation; const PropertyBag data = PropertyBag::fromFile(fileName); maxNumberOfParticles = data.getSizeT("max"); loadParticleMaterials(data, textureFactory); loadParticleTemplates(data); loadParticleEmitters(data); setPosition(_position); // allocate memory for all particle batches for(map<string, ParticleElement>::const_iterator i=templatesByName.begin(); i!=templatesByName.end(); ++i) { const ParticleElement &el = i->second; ParticleBatch &bucket = buckets[el.getMaterial()]; bucket.colors->recreate(4 * (int)maxNumberOfParticles, 0); bucket.vertices->recreate(4 * (int)maxNumberOfParticles, 0); bucket.texcoords->recreate(4 * (int)maxNumberOfParticles, 0); } }