1 #ifndef __DALI_TOOLKIT_WATER_EFFECT_H__
2 #define __DALI_TOOLKIT_WATER_EFFECT_H__
5 // Copyright (c) 2014 Samsung Electronics Co., Ltd.
7 // Licensed under the Flora License, Version 1.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://floralicense.org/license/
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.
21 #include <dali/dali.h>
23 namespace Dali DALI_IMPORT_API
29 namespace Internal DALI_INTERNAL
33 * WaterEffect implementation class
37 } // namespace Internal
40 * WaterEffect is a custom shader effect to achieve water like effects on Image actors
44 * WaterEffect waterEffect = WaterEffect::New( numberOfDrops );
46 * actor.SetShaderEffect( waterEffect );
48 * // Set initial values
49 * waterEffect.SetCenter( 1, centerPosition );
50 * waterEffect.SetPropagation( 1, INITIAL_RADIUS );
52 * // Animate the wave propagation
53 * std::string propertyName = waterEffect.GetPropagationPropertyName( 1 );
54 * animation.AnimateTo( Property(waterEffect, propertyName), FINAL_RADIUS );
56 class WaterEffect : public ShaderEffect
61 * Create an uninitialized WaterEffect; this can be initialized with WaterEffect::New()
62 * Calling member functions with an uninitialized Dali::Object is not allowed.
69 virtual ~WaterEffect();
72 * Create an initialized WaterEffect.
73 * @param [in] numberOfWaves The number of waves.
74 * @return A handle to a newly allocated Dali resource
76 static WaterEffect New( unsigned int numberOfWaves );
79 * Get the number of waves the shader supports.
80 * @return The number of waves in the shader.
82 unsigned int GetNumberOfWaves() const;
85 * Set the amplitude of a wave.
86 * @param [in] index The index of the wave to change
87 * @param [in] amplitude The new amplitude of the wave
88 * @pre index has to be between 0 and GetNumberOfWaves() - 1
90 void SetAmplitude( unsigned int index, float amplitude );
93 * Set the center point of a wave in texture coordinates.
94 * @param [in] index The index of the wave to change
95 * @param [in] center The center point of the wave
96 * @pre index has to be between 0 and GetNumberOfWaves() - 1
98 void SetCenter( unsigned int index, const Vector2& center );
101 * Set the propagation radius of a wave.
102 * @param [in] index The index of the wave to change
103 * @param [in] radius The propagation radius
104 * @pre index has to be between 0 and GetNumberOfWaves() - 1
106 void SetPropagation( unsigned int index, float radius );
109 * Get the amplitude of a wave.
110 * @param [in] index The index of the wave
111 * @return The new amplitude of the wave
112 * @pre index has to be between 0 and GetNumberOfWaves() - 1
114 float GetAmplitude( unsigned int index ) const;
117 * Get the center point of a wave in texture coordinates.
118 * @param [in] index The index of the wave
119 * @return The center point of the wave
120 * @pre index has to be between 0 and GetNumberOfWaves() - 1
122 Vector2 GetCenter( unsigned int index ) const;
125 * Get the propagation radius of a wave.
126 * @param [in] index The index of the wave
127 * @return The propagation radius
128 * @pre index has to be between 0 and GetNumberOfWaves() - 1
130 float GetPropagation( unsigned int index ) const;
133 * Get the name for the amplitude property of a wave.
134 * @param [in] index The index of the wave
135 * @return A std::string containing the property name
136 * @pre index has to be between 0 and GetNumberOfWaves() - 1
138 std::string GetAmplitudePropertyName( unsigned int index ) const;
141 * Get the name for the center property of a wave.
142 * @param [in] index The index of the wave
143 * @return A std::string containing the property name
144 * @pre index has to be between 0 and GetNumberOfWaves() - 1
146 std::string GetCenterPropertyName( unsigned int index ) const;
149 * Get the name for the propagation property.
150 * @param [in] index The index of the wave
151 * @return A std::string containing the property name
152 * @pre index has to be between 0 and GetNumberOfWaves() - 1
154 std::string GetPropagationPropertyName( unsigned int index ) const;
156 public: // Not intended for developer use
158 WaterEffect( ShaderEffect handle, Internal::WaterEffect* shaderExtension );
161 } // namespace Toolkit
165 #endif // __DALI_TOOLKIT_WATER_EFFECT_H__