14 using std::make_unique;
15 using std::unique_ptr;
26 BoundingBoxParticleEmitter::BoundingBoxParticleEmitter(int32_t count, int64_t lifeTime, int64_t lifeTimeRnd,
float mass,
float massRnd,
OrientedBoundingBox* obb,
const Vector3& velocity,
const Vector3& velocityRnd,
const Color4& colorStart,
const Color4& colorEnd)
33 this->obb = unique_ptr<OrientedBoundingBox>(
obb);
51 const auto& obbHalfExtension =
worldObb->getHalfExtension();
54 particle->
position.
add(tmpAxis.
set(obbAxes[0]).
scale((
static_cast<float>(Math::random()) * obbHalfExtension[0] * 2.0f) - obbHalfExtension[0]));
55 particle->
position.
add(tmpAxis.
set(obbAxes[1]).
scale((
static_cast<float>(Math::random()) * obbHalfExtension[1] * 2.0f) - obbHalfExtension[1]));
56 particle->
position.
add(tmpAxis.
set(obbAxes[2]).
scale((
static_cast<float>(Math::random()) * obbHalfExtension[2] * 2.0f) - obbHalfExtension[2]));
81 array<Vector3, 3> worldAxes;
82 array<Vector3, 3> worldAxesUnnormalized;
86 worldCenter = transformMatrix.multiply(
obb->getCenter());
88 worldAxesUnnormalized[0] = transformMatrix.multiplyNoTranslation(
obb->getAxes()[0]);
89 worldAxesUnnormalized[1] = transformMatrix.multiplyNoTranslation(
obb->getAxes()[1]);
90 worldAxesUnnormalized[2] = transformMatrix.multiplyNoTranslation(
obb->getAxes()[2]);
93 worldAxesUnnormalized[0].computeLength(),
94 worldAxesUnnormalized[1].computeLength(),
95 worldAxesUnnormalized[2].computeLength()
102 worldHalfExtension.
set(
obb->getHalfExtension());
103 worldHalfExtension.
scale(worldScale);
104 worldObb = make_unique<OrientedBoundingBox>(worldCenter, worldAxes[0], worldAxes[1], worldAxes[2], worldHalfExtension);
Color 4 definition class.
void set(float r, float g, float b, float a)
Sets this color by its components.
Bounding volume interface.
Oriented bounding box physics primitive.
Bounding box particle emitter.
unique_ptr< OrientedBoundingBox > obb
void setTransform(const Transform &transform) override
Update transform with given transform.
unique_ptr< OrientedBoundingBox > worldObb
void emit(Particle *particle) override
Emits particles.
virtual ~BoundingBoxParticleEmitter()
Destructor.
Vector3 class representing vector3 mathematical structure and operations with x, y,...
Vector3 & add(float scalar)
Adds a scalar.
Vector3 & scale(float scalar)
Scales by scalar.
Vector3 & set(float x, float y, float z)
Sets this vector3 by its components.
Vector3 & normalize()
Normalizes this vector3.