1 #ifndef DALI_TOOLKIT_INTERNAL_BUBBLE_ACTOR_H
2 #define DALI_TOOLKIT_INTERNAL_BUBBLE_ACTOR_H
5 * Copyright (c) 2016 Samsung Electronics Co., Ltd.
7 * Licensed under the Apache License, Version 2.0 (the "License");
8 * you may not use this file except in compliance with the License.
9 * You may obtain a copy of the License at
11 * http://www.apache.org/licenses/LICENSE-2.0
13 * Unless required by applicable law or agreed to in writing, software
14 * distributed under the License is distributed on an "AS IS" BASIS,
15 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16 * See the License for the specific language governing permissions and
17 * limitations under the License.
22 #include <dali/public-api/actors/actor.h>
23 #include <dali/public-api/common/vector-wrapper.h>
24 #include <dali/public-api/object/property-map.h>
25 #include <dali/public-api/rendering/renderer.h>
37 * BubbleActor is a group of bubbles.Each bubble can be moved separately.
38 * Its custom shader achieves similar effect of particle system by applying on a specially created mesh
39 * Each bubble is rendered on a patch with two triangles; and each mesh can contain multiple such patches, thus a group.
41 class BubbleActor : public RefObject
47 * @param[in] numberOfBubble How many groups of uniforms are used to control the bubble movement.
48 * Note: Limited by the maximum available uniforms, this parameter cannot be bigger than 100.
49 * Ideally use one group of uniform to control one bubble.
50 * If the num of patches in the MeshActor is more than groups of uniforms,
51 * the uniform values will be shared by multiple bubbles. Allow up to 9 times.
52 * @param[in] movementArea The size of the bubble moving area, usually the same size as the background.
53 * @return A newly allocated object.
55 BubbleActor( unsigned int numberOfBubble,
56 const Vector2& movementArea);
64 * Prepare for the rendering: create and add renderer, and register properties
65 * @param[in] geometry The geometry to be used by the renderer
66 * @param[in] textureSet The texture set to be used by the renderer
67 * @param[in] textureSet The shader set to be used by the renderer
69 void MakeRenderable( Geometry geometry, TextureSet textureSet, Shader shader );
72 * Return the mesh actor which is used to display the bubbles
77 * Sets the geometry to be used by the renderer
78 * @param[in] geometry The geometry to be used by the renderer
80 void SetGeometry( Geometry geometry );
83 * Set the bubble movement area for the BubbleEffect
84 * @param[in] movementArea The size of bubble movement area; by default, it is the stage size
86 void SetMovementArea( const Vector2& movementArea );
89 * Set the start and end positions of the index-th bubble's movement.
90 * @param[in] index Indicate which bubble these properties are applied on.
91 * @param[in] startAndEndPosition The start and the end position of movement.
93 void SetStartAndEndPosition( unsigned int index, const Vector4& startAndEndPosition );
96 * Set the movement completed percentage of the index-th bubble.
97 * The bubble will appear at start position when percentage equals to zero,
98 * and disappear near end position (affected by gravity) when percentage equals to one.
99 * This percentage property is used to animate the bubble movement.
100 * @param[in] index Indicate which bubble this property is applied on.
101 * @param[in] percentage Set the percentage property value ( between zero and one ).
103 void SetPercentage( unsigned int index, float percentage );
106 * Set the gravity applied to the y direction, which makes the bubbles no longer moving on a straight line.
107 * @param[in] gravity The gravity on the y direction.
109 void SetGravity( float gravity );
112 * Set the scale factor applied to the bubbles
113 * @param[in] scale The scale factor applied on all bubbles.
115 void SetDynamicScale( float scale );
118 * Get the idx-th percentage property.
119 * @param[in] idx The percentage property index.
120 * @return the idx-th percentage property.
122 Property GetPercentageProperty( unsigned int idx );
125 * Reset the uniform values to default.
127 void ResetProperties();
134 Vector2 mMovementArea; ///< The size of the bubble moving area, usually the same size as the background.
136 //properties mapped as uniforms
137 std::vector<Property::Index> mIndicesOffset; ///< Indices of the properties mapping to uniform array 'uOffset'
138 std::vector<Property::Index> mIndiceStartEndPos; ///< Indices of the properties mapping to uniform array 'uStartAndEndPos'
139 std::vector<Property::Index> mIndicesPercentage; ///< Indices of the properties mapping to uniform array 'uPercentage'
140 Property::Index mIndexGravity; ///< Index of the property mapping to uniform 'uGravity'
141 Property::Index mIndexDynamicScale; ///< Index of the property mapping to uniform 'uDynamicScale'
142 Property::Index mIndexInvertedMovementArea; ///< Index of the property mapping to uniform 'uInvertedMovementArea'
144 unsigned int mNumBubble; ///< How many groups of uniforms are used to control the bubble movement.
145 unsigned int mRandomSeed; ///< Seed to generate random number.
148 } // namespace Internal
150 } // namespace Toolkit
154 #endif // DALI_TOOLKIT_INTERNAL_BUBBLE_ACTOR_H