1 #ifndef __DALI_TOOLKIT_SHADER_BUBBLE_EFFECT_H__
2 #define __DALI_TOOLKIT_SHADER_BUBBLE_EFFECT_H__
5 * Copyright (c) 2014 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/dali.h>
24 namespace Dali DALI_IMPORT_API
31 * BubbleEffect is a custom shader to achieve similar effect of particle system by applying on a specially created MeshActor
32 * Each bubble is rendered on a patch with two triangles; and each mesh can contain multiple such patches.
34 class BubbleEffect : public ShaderEffect
39 * Create an empty BubbleEffect handle
46 virtual ~BubbleEffect();
49 * Create an initialized BubbleEffect
50 * @param[in] numberOfBubble How many groups of uniforms are used to control the bubble movement.
51 * Note: Limited by the maximum available uniforms, this parameter cannot be bigger than 100.
52 * Ideally use one group of uniform to control one bubble.
53 * If the num of patches in the MeshActor is more than groups of uniforms,
54 * the uniform values will be shared by multiple bubbles. Allow up to 9 times.
55 * @param shapeImagePath File path of the image that will be used as a texture for each bubble.
56 * @return A handle to a newly allocated Dali resource.
58 static BubbleEffect New( unsigned int numberOfBubble, const std::string& shapeImagePath);
61 * Set the bubble movement area for the BubbleEffect
62 * @param[in] movementArea The size of bubble movement area; by default, it is the stage size
64 void SetMovementArea( const Vector2& movementArea );
67 * Set the start and end positions of the index-th bubble's movement.
68 * @param[in] index Indicate which bubble these properties are applied on.
69 * @param[in] startAndEndPosition The start and the end position of movement.
71 void SetStartAndEndPosition( unsigned int index, const Vector4& startAndEndPosition );
74 * Set the movement completed percentage of the index-th bubble.
75 * The bubble will appear at start position when percentage equals to zero,
76 * and disappear near end position (affected by gravity) when percentage equals to one.
77 * This percentage property is used to animate the bubble movement.
78 * @param[in] index Indicate which bubble this property is applied on.
79 * @param[in] percentage Set the percentage property value ( between zero and one ).
81 void SetPercentage( unsigned int index, float percentage );
84 * Set the gravity applied to the y direction, which makes the bubbles no longer moving on a straight line.
85 * @param[in] gravity The gravity on the y direction.
87 void SetGravity( float gravity );
90 * Set the width of shape image
91 * If one image has multiple shape, bubble effect will parse one shape from the image randomly.
92 * @param[in] imageWidth width of shape image
94 void SetShapeImageWidth( float imageWidth );
97 * Set the scale factor applied to the bubbles
98 * @param[in] scale The scale factor applied on all bubbles.
100 void SetDynamicScale( float scale );
103 * Increase both the bubble size and moving speed.
104 * Animate this peoperty to create special effect such as all the bubbles blow up on the screen.
105 * @param[in] magnification The manified factor applied on the bubble size and moving speed.
107 void SetMagnification( float magnification );
110 * Get the name for the idx-th percentage property.
111 * @param[in] index The percentage property index.
112 * @return std::string containing the property name.
114 std::string GetPercentagePropertyName( unsigned int index ) const;
117 * Get the name for the magnification property.
118 * @return std::string containinf the property name.
120 std::string GetMagnificationPropertyName() const;
123 * Reset the uniform values to default.
125 void ResetParameters();
127 private:// Not intended for application developers
129 BubbleEffect( ShaderEffect handle );
133 unsigned int mNumberOfBubbles;
134 Vector2 mMovementArea;
137 } // namespace Toolkit
140 #endif /* __DALI_TOOLKIT_SHADER_BUBBLE_EFFECT_H__ */