void SphereEmitter::Emit(const float gameTime, const unsigned int availableIndiceCount, physx::PxParticleCreationData& creationData) { unsigned int emissionCount(GetEmissionCount(gameTime, availableIndiceCount)); //If we have creation data and indices can be used if(emissionCount > 0) { //reset forces forces.clear(); positions.clear(); RandomNumberGenerator* random = RandomNumberGenerator::GetInstance(); //Generate initial force and update available indices for (unsigned int i = 0; i < emissionCount; i++) { float ranSpeed = random->GenerateRandom(minSpeed, maxSpeed); physx::PxVec3 ranDirection = physx::PxVec3( random->GenerateRandom(minimumDirection.x, maximumDirection.x), random->GenerateRandom(minimumDirection.y, maximumDirection.y), random->GenerateRandom(minimumDirection.z, maximumDirection.z)); if(EmitFromShell) positions.push_back(position + (ranDirection * Radius)); else positions.push_back(position + (ranDirection * random->GenerateRandom(0.0f, Radius))); if(TowardsSphereCenter) forces.push_back(-ranDirection * ranSpeed); else forces.push_back(ranDirection * ranSpeed); } //set creation data parameters creationData.numParticles = emissionCount; creationData.positionBuffer = physx::PxStrideIterator<physx::PxVec3>(&positions[0]); creationData.velocityBuffer = physx::PxStrideIterator<physx::PxVec3>(&forces[0]); } }