1 #ifndef PARTICLES_PARTICLE_VIEW_H_
2 #define PARTICLES_PARTICLE_VIEW_H_
4 * Copyright (c) 2021 Samsung Electronics Co., Ltd.
6 * Licensed under the Apache License, Version 2.0 (the "License");
7 * you may not use this file except in compliance with the License.
8 * You may obtain a copy of the License at
10 * http://www.apache.org/licenses/LICENSE-2.0
12 * Unless required by applicable law or agreed to in writing, software
13 * distributed under the License is distributed on an "AS IS" BASIS,
14 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 * See the License for the specific language governing permissions and
16 * limitations under the License.
22 #include "dali/public-api/actors/camera-actor.h"
23 #include "dali/public-api/animation/animation.h"
24 #include "dali/public-api/object/weak-handle.h"
25 #include "dali/public-api/rendering/shader.h"
26 #include "particle-field.h"
34 class ParticleView : public Dali::ConnectionTracker
37 ParticleView(const ParticleField& field, Dali::Actor world, Dali::CameraActor camera, Dali::Geometry particleGeom = Dali::Geometry());
40 void SetColorRange(const ColorRange& range);
42 void SetPopulation(float percentage);
43 void SetFocalLength(float f);
44 void SetAperture(float a);
45 void SetAlphaTestRefValue(float rv);
46 void SetFadeRange(float near, float far);
47 void SetAngularVelocity(float v);
48 void SetLinearVelocity(float v);
50 ///@brief Starts a scatter & regroup animation, cancelling any previously played animation
51 /// of the same kind. Bigger particles, and those further away from the Z axis are affected
53 ///@param radius the normalised radius, within which particles are affected.
54 ///@param amount the amount of displacement applied to particles at the peak of the animation.
55 ///@param durationOut the duration of scattering, in seconds.
56 ///@param durationIn the duration of regrouping, in seconds.
57 void Scatter(float radius, float amount, float durationOut, float durationIn);
59 void SetScatterRay(Dali::Vector3 rayDir);
61 ///@brief Starts an animation to change the opacity of the particles to @a target.
62 ///@param duration Number of seconds to complete transition in.
63 ///@param target Target opacity in the 0..1.f range.
64 void Fade(float duration, float target, Dali::AlphaFunction alphaFn = Dali::AlphaFunction::DEFAULT, std::function<void(Dali::Animation&)> onFinished = nullptr);
66 ///@brief Starts an animation to change the opacity of the particles to @a target.
67 ///@param duration Number of seconds to complete transition in.
68 ///@param target Target opacity in the 0..1.f range.
69 ///@param from The value to set the opacity to prior to the animation.
70 void Fade(float duration, float target, float from, Dali::AlphaFunction alphaFn = Dali::AlphaFunction::DEFAULT, std::function<void(Dali::Animation&)> onFinished = nullptr);
75 Dali::Property::Index mPropRadius;
76 Dali::Property::Index mPropAmount;
77 Dali::Property::Index mPropRay;
79 Dali::Animation mAnim;
82 Dali::WeakHandle<Dali::Actor> mWorld;
83 Dali::Vector3 mParticleBoxSize;
85 Dali::Shader mParticleShader;
86 Dali::Property::Index mPropPopulation;
87 Dali::Property::Index mPropFocalLength;
88 Dali::Property::Index mPropAperture;
89 Dali::Property::Index mPropAlphaTestRefValue;
90 Dali::Property::Index mPropFadeRange;
92 ScatterProps mScatterProps[6];
93 int mActiveScatter = 0;
95 Dali::Actor mMasterParticles;
96 Dali::Property::Index mPropSecondaryColor;
98 Dali::Actor mSlaveParticles;
100 Dali::Animation mAngularAnim;
101 Dali::Animation mLinearAnim;
102 Dali::Animation mFadeAnim;
105 #endif //PARTICLES_PARTICLE_VIEW_H_