1 #ifndef __DALI_TOOLKIT_SHADER_EFFECT_MOTION_STRETCH_H__
2 #define __DALI_TOOLKIT_SHADER_EFFECT_MOTION_STRETCH_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.
24 #include <dali/dali.h>
26 namespace Dali DALI_IMPORT_API
34 * Class for motion stretch shader that works on a per object basis. Objects will stretch in the direction of motion when they move, or if the camera moves. Can be applied
35 * to ImageActor or TextActor only.
39 * // Create shader used for doing motion stretch\n
40 * MotionStretchEffect MotionStretchEffect = MotionStretchEffect::New();
42 * // set actor shader to the stretch one\n
43 * Actor Actor = Actor::New( ... );\n
44 * Actor.SetShaderEffect( MotionStretchEffect );
47 class MotionStretchEffect : public ShaderEffect
53 * Create an uninitialized MotionStretchEffect; this can be initialized with MotionStretchEffect::New()
54 * Calling member functions with an uninitialized Dali::Object is not allowed.
56 MotionStretchEffect();
61 virtual ~MotionStretchEffect();
64 * Create an initialized MotionStretchEffect
65 * @return A handle to a newly allocated Dali resource.
67 static MotionStretchEffect New();
70 * Create a MotionStretchEffect and attach it to the specified actor
71 * @return A handle to a newly allocated Dali resource.
73 static MotionStretchEffect Apply( Actor handle );
76 * Set geometry stretch factor property. This scales the amount the geometry
77 * stretches along the motion velocity vector. A smaller value means the geometry
78 * stretches less, larger it stretches more. Default 0.5.
79 * @param scalingFactor The scaling factor that extrudes the geometry forwards along the motion velocity vector.
81 void SetGeometryStretchFactor( float scalingFactor );
84 * Set speed scaling factor property. This value is used to control how much
85 * to fade the actor near the edges, based on the speed the actor is moving.
86 * When the actor is at rest this is not applied. Default 0.5.
87 * @param scalingFactor The scaling factor that controls the edge fade of the actor.
89 void SetSpeedScalingFactor( float scalingFactor );
92 * Set the displacement from the centre of the actor that the actor will start to
93 * fade towards its edges. This is used to prevent an unsightly hard edge
94 * between the stretched actor and the scene. Depends on the values of the
95 * vertices in the vertex stream. When the actor is at rest this is not applied.
96 * Default Vector2(0.25, 0.25), which is half way towards the edge for an ImageRenderer::QUAD.
97 * @param displacement The displacement from the centre of the actor that the actor will start to edge fade.
99 void SetObjectFadeStart( Vector2 displacement );
102 * Set the displacement from the centre of the actor that the actor will
103 * finish fading towards its edges. This is used to prevent an unsightly hard
104 * edge between the stretched actor and the scene. Depends on the values of
105 * the vertices in the vertex stream. When the actor is at rest this is not applied.
106 * Default 0.5, which is all the way towards the edge for an ImageRenderer::QUAD.
107 * @param displacement The displacement from the centre of the actor that the actor will finish edge fading.
109 void SetObjectFadeEnd( Vector2 displacement );
112 * Set a global scaler applied to the alpha of the actor. Used to make the
113 * stretched actor a bit more subtle and reveal a bit of the background behind
114 * it as it moves. When the actor is at rest this is not applied. Default 0.75.
115 * @param alphaScale The scaling factor which multiplies the alpha of each pixel of the actor.
117 void SetAlphaScale( float alphaScale );
121 * Get the name for the texcoord scale property. Useful for animation.
122 * @return A std::string containing the property name
124 const std::string& GetTexcoordScalePropertyName() const;
127 * Get the name for the geometry stretching property. Useful for animation.
128 * @return A std::string containing the property name
130 const std::string& GetGeometryStretchFactorPropertyName() const;
133 * Get the name for the speed scaling property. Useful for animation.
134 * @return A std::string containing the property name
136 const std::string& GetSpeedScalingFactorPropertyName() const;
139 * Get the name for the fade start X property. Useful for animation.
140 * @return A std::string containing the property name
142 const std::string& GetObjectFadeStartPropertyName() const;
145 * Get the name for the fade end X property. Useful for animation.
146 * @return A std::string containing the property name
148 const std::string& GetObjectFadeEndPropertyName() const;
151 * Get the name for the alpha scale property. Useful for animation.
152 * @return A std::string containing the property name
154 const std::string& GetAlphaScalePropertyName() const;
157 // Not intended for application developers
158 MotionStretchEffect( ShaderEffect handle );
165 #endif //#ifndef __DALI_TOOLKIT_SHADER_EFFECT_MOTION_STRETCH_H__