mirror of
https://github.com/lubosz/overte.git
synced 2025-08-07 16:41:02 +02:00
Make able to emit from within portion of ellipsoid volume
This commit is contained in:
parent
9e2b5b75b6
commit
8634b59914
2 changed files with 22 additions and 2 deletions
|
@ -30,7 +30,7 @@
|
||||||
ZERO_EMIT_ACCELERATON = { x: 0.0, y: 0.0, z: 0.0 },
|
ZERO_EMIT_ACCELERATON = { x: 0.0, y: 0.0, z: 0.0 },
|
||||||
PI = 3.141593,
|
PI = 3.141593,
|
||||||
DEG_TO_RAD = PI / 180.0,
|
DEG_TO_RAD = PI / 180.0,
|
||||||
NUM_PARTICLE_EXAMPLES = 17;
|
NUM_PARTICLE_EXAMPLES = 18;
|
||||||
|
|
||||||
function onClickDownOnEntity(entityID) {
|
function onClickDownOnEntity(entityID) {
|
||||||
if (entityID === box || entityID === sphere || entityID === particles) {
|
if (entityID === box || entityID === sphere || entityID === particles) {
|
||||||
|
@ -171,6 +171,18 @@
|
||||||
});
|
});
|
||||||
break;
|
break;
|
||||||
case 16:
|
case 16:
|
||||||
|
print("Emit within quarter of sphere volume");
|
||||||
|
Entities.editEntity(particles, {
|
||||||
|
polarStart: 0.0,
|
||||||
|
polarFinish: PI / 2.0,
|
||||||
|
azimuthStart: 0,
|
||||||
|
azimuthFinish: PI / 2.0,
|
||||||
|
emitRadiusStart: 0.0,
|
||||||
|
alphaFinish: 1.0,
|
||||||
|
emitSpeed: 0.0
|
||||||
|
});
|
||||||
|
break;
|
||||||
|
case 17:
|
||||||
print("Stop emitting");
|
print("Stop emitting");
|
||||||
Entities.editEntity(particles, {
|
Entities.editEntity(particles, {
|
||||||
emitDimensions: pointDimensions,
|
emitDimensions: pointDimensions,
|
||||||
|
|
|
@ -693,6 +693,7 @@ void ParticleEffectEntityItem::stepSimulation(float deltaTime) {
|
||||||
// Emit around point or from ellipsoid
|
// Emit around point or from ellipsoid
|
||||||
// - Distribute directions evenly around point
|
// - Distribute directions evenly around point
|
||||||
// - Distribute points relatively evenly over ellipsoid surface
|
// - Distribute points relatively evenly over ellipsoid surface
|
||||||
|
// - Distribute points relatively evenly within ellipsoid volume
|
||||||
|
|
||||||
float elevationMinZ = sin(PI_OVER_TWO - _polarFinish);
|
float elevationMinZ = sin(PI_OVER_TWO - _polarFinish);
|
||||||
float elevationMaxZ = sin(PI_OVER_TWO - _polarStart);
|
float elevationMaxZ = sin(PI_OVER_TWO - _polarStart);
|
||||||
|
@ -715,7 +716,14 @@ void ParticleEffectEntityItem::stepSimulation(float deltaTime) {
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
// Ellipsoid
|
// Ellipsoid
|
||||||
glm::vec3 radiuses = 0.5f * _emitDimensions;
|
float radiusScale = 1.0f;
|
||||||
|
if (_emitRadiusStart < 1.0f) {
|
||||||
|
float emitRadiusStart = glm::max(_emitRadiusStart, EPSILON); // Avoid math complications at center
|
||||||
|
float randRadius = emitRadiusStart + (1.0f - emitRadiusStart) * randFloat();
|
||||||
|
radiusScale = 1.0f - std::pow(1.0f - randRadius, 3);
|
||||||
|
}
|
||||||
|
|
||||||
|
glm::vec3 radiuses = radiusScale * 0.5f * _emitDimensions;
|
||||||
float x = radiuses.x * cos(elevation) * cos(azimuth);
|
float x = radiuses.x * cos(elevation) * cos(azimuth);
|
||||||
float y = radiuses.y * cos(elevation) * sin(azimuth);
|
float y = radiuses.y * cos(elevation) * sin(azimuth);
|
||||||
float z = radiuses.z * sin(elevation);
|
float z = radiuses.z * sin(elevation);
|
||||||
|
|
Loading…
Reference in a new issue