48ObjectParticleSystemInternal::ObjectParticleSystemInternal(
const string&
id,
Model* model,
const Vector3& scale,
bool autoEmit,
bool contributesShadows,
bool receivesShadows, int32_t maxCount,
ParticleEmitter* emitter)
59 for (
auto i = 0; i <
objects.size(); i++) {
95 for (
auto i = 0; i <
objects.size(); i++) {
103 for (
auto i = 0; i <
objects.size(); i++) {
123 auto particlesToSpawn = 0;
127 particlesToSpawn =
static_cast< int32_t
>(particlesToSpawnWithFraction);
138 if (particlesToSpawn == 0)
return 0;
140 auto particlesSpawned = 0;
141 for (
auto i = 0; i <
particles.size(); i++) {
143 if (particle.active ==
true)
continue;
148 object->setTranslation(particle.position);
150 object->setEnabled(
true);
156 if (particlesSpawned == particlesToSpawn)
break;
159 return particlesSpawned;
178 for (
auto i = 0; i <
particles.size(); i++) {
180 if (particle.active ==
false)
185 particle.lifeTimeCurrent += timeDelta;
186 if (particle.lifeTimeCurrent >= particle.lifeTimeMax) {
187 particle.active =
false;
188 object->setEnabled(
false);
193 if (particle.mass > Math::EPSILON)
194 particle.velocity.sub(
Vector3(0.0f, 0.5f * Math::g *
static_cast<float>(timeDelta) / 1000.0f, 0.0f));
199 particle.position.add(velocityForTime.
set(particle.velocity).
scale(
static_cast<float>(timeDelta) / 1000.0f));
204 point = localTransformationsMatrix.multiply(particle.position);
209 object->setTranslation(point);
216 auto& objBbMinXYZ =
object->getBoundingBoxTransformed()->getMin().
getArray();
217 auto& objBbMaxXYZ =
object->getBoundingBoxTransformed()->getMax().getArray();
218 if (objBbMinXYZ[0] < bbMinXYZ[0]) bbMinXYZ[0] = objBbMinXYZ[0];
219 if (objBbMinXYZ[1] < bbMinXYZ[1]) bbMinXYZ[1] = objBbMinXYZ[1];
220 if (objBbMinXYZ[2] < bbMinXYZ[2]) bbMinXYZ[2] = objBbMinXYZ[2];
221 if (objBbMaxXYZ[0] > bbMaxXYZ[0]) bbMaxXYZ[0] = objBbMaxXYZ[0];
222 if (objBbMaxXYZ[1] > bbMaxXYZ[1]) bbMaxXYZ[1] = objBbMaxXYZ[1];
223 if (objBbMaxXYZ[2] > bbMaxXYZ[2]) bbMaxXYZ[2] = objBbMaxXYZ[2];
233 for (
auto i = 0; i <
objects.size(); i++) {
Object 3D to be used with engine class.
int64_t getDeltaTime()
Gets the time passed between last and current frame.
Color 4 base definition class.
void set(const array< float, 4 > &color)
Set up color.
Representation of a 3d model.
Axis aligned bounding box used for frustum, this is not directly connectable with physics engine.
void fromBoundingVolumeWithTransformations(BoundingBox *original, const Transformations &transformations)
Create bounding volume from given original(of same type) with applied transformations.
void update()
Updates this bounding box.
Particle system which displays objects as particles.
void updateParticles() override
Updates the particle entity.
BoundingBox boundingBoxTransformed
Transformations inverseTransformation
void setEngine(Engine *engine)
virtual ~ObjectParticleSystemInternal()
Destructor.
void update() override
Update transformations.
vector< Particle > particles
const string & getId() override
ParticleEmitter * emitter
void fromTransformations(const Transformations &transformations) override
Set up this transformations from given transformations.
vector< Object3D * > objects
void setRenderer(Renderer *renderer)
vector< Object3D * > enabledObjects
Transformations localTransformations
float particlesToSpawnRemainder
void updateInternal()
Update internal.
int32_t emitParticles() override
Adds particles to this particle entity at given position.
void getTranslation(Vector3 &translation) const
Get translation.
Vector3 multiply(const Vector3 &v) const
Multiplies a vector3 with this matrix into destination vector.
Vector3 & set(float x, float y, float z)
Set up vector.
Vector3 & add(const Vector3 &v)
Adds a vector.
Vector3 & scale(float scale)
Scale this vector.
array< float, 3 > & getArray() const
Particle emitter interface.
virtual int32_t getCount() const =0
virtual const Vector3 & getCenter() const =0
virtual void emit(Particle *particle)=0
Emits particles.