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 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
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 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 virtual ~WaterEffect();
73 * Create an initialized WaterEffect.
74 * @param [in] numberOfWaves The number of waves.
75 * @return A handle to a newly allocated Dali resource
77 static WaterEffect New( unsigned int numberOfWaves );
80 * Get the number of waves the shader supports.
81 * @return The number of waves in the shader.
83 unsigned int GetNumberOfWaves() const;
86 * Set the amplitude of a wave.
87 * @param [in] index The index of the wave to change
88 * @param [in] amplitude The new amplitude of the wave
89 * @pre index has to be between 0 and GetNumberOfWaves() - 1
91 void SetAmplitude( unsigned int index, float amplitude );
94 * Set the center point of a wave in texture coordinates.
95 * @param [in] index The index of the wave to change
96 * @param [in] center The center point of the wave
97 * @pre index has to be between 0 and GetNumberOfWaves() - 1
99 void SetCenter( unsigned int index, const Vector2& center );
102 * Set the propagation radius of a wave.
103 * @param [in] index The index of the wave to change
104 * @param [in] radius The propagation radius
105 * @pre index has to be between 0 and GetNumberOfWaves() - 1
107 void SetPropagation( unsigned int index, float radius );
110 * Get the amplitude of a wave.
111 * @param [in] index The index of the wave
112 * @return The new amplitude of the wave
113 * @pre index has to be between 0 and GetNumberOfWaves() - 1
115 float GetAmplitude( unsigned int index ) const;
118 * Get the center point of a wave in texture coordinates.
119 * @param [in] index The index of the wave
120 * @return The center point of the wave
121 * @pre index has to be between 0 and GetNumberOfWaves() - 1
123 Vector2 GetCenter( unsigned int index ) const;
126 * Get the propagation radius of a wave.
127 * @param [in] index The index of the wave
128 * @return The propagation radius
129 * @pre index has to be between 0 and GetNumberOfWaves() - 1
131 float GetPropagation( unsigned int index ) const;
134 * Get the name for the amplitude property of a wave.
135 * @param [in] index The index of the wave
136 * @return A std::string containing the property name
137 * @pre index has to be between 0 and GetNumberOfWaves() - 1
139 std::string GetAmplitudePropertyName( unsigned int index ) const;
142 * Get the name for the center property of a wave.
143 * @param [in] index The index of the wave
144 * @return A std::string containing the property name
145 * @pre index has to be between 0 and GetNumberOfWaves() - 1
147 std::string GetCenterPropertyName( unsigned int index ) const;
150 * Get the name for the propagation property.
151 * @param [in] index The index of the wave
152 * @return A std::string containing the property name
153 * @pre index has to be between 0 and GetNumberOfWaves() - 1
155 std::string GetPropagationPropertyName( unsigned int index ) const;
157 public: // Not intended for developer use
159 WaterEffect( ShaderEffect handle, Internal::WaterEffect* shaderExtension );
162 } // namespace Toolkit
166 #endif // __DALI_TOOLKIT_WATER_EFFECT_H__