1 #ifndef __DALI_TOOLKIT_WATER_EFFECT_H__
2 #define __DALI_TOOLKIT_WATER_EFFECT_H__
5 * Copyright (c) 2015 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/shader-effects/shader-effect.h>
30 namespace Internal DALI_INTERNAL
34 * WaterEffect implementation class
38 } // namespace Internal
41 * WaterEffect is a custom shader effect to achieve water like effects on Image actors
45 * WaterEffect waterEffect = WaterEffect::New( numberOfDrops );
47 * actor.SetShaderEffect( waterEffect );
49 * // Set initial values
50 * waterEffect.SetCenter( 1, centerPosition );
51 * waterEffect.SetPropagation( 1, INITIAL_RADIUS );
53 * // Animate the wave propagation
54 * std::string propertyName = waterEffect.GetPropagationPropertyName( 1 );
55 * animation.AnimateTo( Property(waterEffect, propertyName), FINAL_RADIUS );
57 class DALI_IMPORT_API WaterEffect : public ShaderEffect
62 * Create an uninitialized WaterEffect; this can be initialized with WaterEffect::New()
63 * Calling member functions with an uninitialized Dali::Object is not allowed.
70 * This is non-virtual since derived Handle types must not contain data or virtual methods.
75 * Create an initialized WaterEffect.
76 * @param [in] numberOfWaves The number of waves.
77 * @return A handle to a newly allocated Dali resource
79 static WaterEffect New( unsigned int numberOfWaves );
82 * Get the number of waves the shader supports.
83 * @return The number of waves in the shader.
85 unsigned int GetNumberOfWaves() const;
88 * Set the amplitude of a wave.
89 * @param [in] index The index of the wave to change
90 * @param [in] amplitude The new amplitude of the wave
91 * @pre index has to be between 0 and GetNumberOfWaves() - 1
93 void SetAmplitude( unsigned int index, float amplitude );
96 * Set the center point of a wave in texture coordinates.
97 * @param [in] index The index of the wave to change
98 * @param [in] center The center point of the wave
99 * @pre index has to be between 0 and GetNumberOfWaves() - 1
101 void SetCenter( unsigned int index, const Vector2& center );
104 * Set the propagation radius of a wave.
105 * @param [in] index The index of the wave to change
106 * @param [in] radius The propagation radius
107 * @pre index has to be between 0 and GetNumberOfWaves() - 1
109 void SetPropagation( unsigned int index, float radius );
112 * Get the amplitude of a wave.
113 * @param [in] index The index of the wave
114 * @return The new amplitude of the wave
115 * @pre index has to be between 0 and GetNumberOfWaves() - 1
117 float GetAmplitude( unsigned int index ) const;
120 * Get the center point of a wave in texture coordinates.
121 * @param [in] index The index of the wave
122 * @return The center point of the wave
123 * @pre index has to be between 0 and GetNumberOfWaves() - 1
125 Vector2 GetCenter( unsigned int index ) const;
128 * Get the propagation radius of a wave.
129 * @param [in] index The index of the wave
130 * @return The propagation radius
131 * @pre index has to be between 0 and GetNumberOfWaves() - 1
133 float GetPropagation( unsigned int index ) const;
136 * Get the name for the amplitude property of a wave.
137 * @param [in] index The index of the wave
138 * @return A std::string containing the property name
139 * @pre index has to be between 0 and GetNumberOfWaves() - 1
141 std::string GetAmplitudePropertyName( unsigned int index ) const;
144 * Get the name for the center property of a wave.
145 * @param [in] index The index of the wave
146 * @return A std::string containing the property name
147 * @pre index has to be between 0 and GetNumberOfWaves() - 1
149 std::string GetCenterPropertyName( unsigned int index ) const;
152 * Get the name for the propagation property.
153 * @param [in] index The index of the wave
154 * @return A std::string containing the property name
155 * @pre index has to be between 0 and GetNumberOfWaves() - 1
157 std::string GetPropagationPropertyName( unsigned int index ) const;
159 public: // Not intended for developer use
161 DALI_INTERNAL WaterEffect( ShaderEffect handle, Internal::WaterEffect* shaderExtension );
164 } // namespace Toolkit
168 #endif // __DALI_TOOLKIT_WATER_EFFECT_H__