*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
#include <dali-toolkit/internal/controls/page-turn-view/page-turn-effect.h>
#include <dali-toolkit/internal/graphics/builtin-shader-extern-gen.h>
#include <dali-toolkit/internal/controls/page-turn-view/page-turn-effect.h>
#include <dali-toolkit/internal/graphics/builtin-shader-extern-gen.h>
-const char * const PROPERTY_COMMON_PARAMETERS( "uCommonParameters" );
-const char * const PROPERTY_ORIGINAL_CENTER( "originalCenter" );
-const char * const PROPERTY_CURRENT_CENTER( "currentCenter" );
-}
+const char* const PROPERTY_COMMON_PARAMETERS("uCommonParameters");
+const char* const PROPERTY_ORIGINAL_CENTER("originalCenter");
+const char* const PROPERTY_CURRENT_CENTER("currentCenter");
+} // namespace
// calculate the curve direction and the vanishing point
// here, the vanishing point is the intersection of spine with the line passing through original center and vertical to curve direction
// calculate the curve direction and the vanishing point
// here, the vanishing point is the intersection of spine with the line passing through original center and vertical to curve direction
{
curveDirection.y = 0.01f;
}
float vanishingPointY = originalCenter.y + curveDirection.x * originalCenter.x / curveDirection.y;
{
curveDirection.y = 0.01f;
}
float vanishingPointY = originalCenter.y + curveDirection.x * originalCenter.x / curveDirection.y;
- float curveEndY, cosTheta ,sinTheta ,translateX, translateY;
+ float curveEndY, cosTheta, sinTheta, translateX, translateY;
// when the vanishing point is very far away, make it infinitely, in this case, the page bent horizontally
const float THRESHOLD(20.0);
// when the vanishing point is very far away, make it infinitely, in this case, the page bent horizontally
const float THRESHOLD(20.0);
- curveEndY = currentCenter.y - curveDirection.y * (currentCenter.x/curveDirection.x) ;
- Vector2 v1( currentCenter.x, currentCenter.y - vanishingPointY );
+ curveEndY = currentCenter.y - curveDirection.y * (currentCenter.x / curveDirection.x);
+ Vector2 v1(currentCenter.x, currentCenter.y - vanishingPointY);
- cosTheta = v1.x*v2.x + v1.y*v2.y;
- sinTheta = ( vanishingPointY > mPageHeight*0.5f ) ? sqrt(1.0-cosTheta*cosTheta) : -sqrt(1.0-cosTheta*cosTheta);
- translateX = currentCenter.x - cosTheta*originalCenter.x - sinTheta*( originalCenter.y-vanishingPointY );
- translateY = currentCenter.y + sinTheta*originalCenter.x - cosTheta*( originalCenter.y-vanishingPointY );
+ cosTheta = v1.x * v2.x + v1.y * v2.y;
+ sinTheta = (vanishingPointY > mPageHeight * 0.5f) ? sqrt(1.0 - cosTheta * cosTheta) : -sqrt(1.0 - cosTheta * cosTheta);
+ translateX = currentCenter.x - cosTheta * originalCenter.x - sinTheta * (originalCenter.y - vanishingPointY);
+ translateY = currentCenter.y + sinTheta * originalCenter.x - cosTheta * (originalCenter.y - vanishingPointY);
- float originalLength = fabs(originalCenter.x/curveDirection.x);
- float currentLength = fabs(currentCenter.x/curveDirection.x);
- float curveHeight = 0.45f*sqrt(originalLength*originalLength - currentLength*currentLength);
+ float originalLength = fabs(originalCenter.x / curveDirection.x);
+ float currentLength = fabs(currentCenter.x / curveDirection.x);
+ float curveHeight = 0.45f * sqrt(originalLength * originalLength - currentLength * currentLength);
- parameterArray[0] = cosTheta;
- parameterArray[1] = -sinTheta;
- parameterArray[2] = originalCenter.x;
- parameterArray[3] = originalCenter.y;
- parameterArray[4] = sinTheta;
- parameterArray[5] = cosTheta;
- parameterArray[6] = currentCenter.x;
- parameterArray[7] = currentCenter.y;
- parameterArray[8] = translateX;
- parameterArray[9] = translateY;
- parameterArray[10] = vanishingPointY;
- parameterArray[11] = curveEndY;
- parameterArray[12] = curveDirection.x;
- parameterArray[13] = curveDirection.y;
- parameterArray[14] = curveHeight;
- parameterArray[15] = currentLength;
+ parameterArray[0] = cosTheta;
+ parameterArray[1] = -sinTheta;
+ parameterArray[2] = originalCenter.x;
+ parameterArray[3] = originalCenter.y;
+ parameterArray[4] = sinTheta;
+ parameterArray[5] = cosTheta;
+ parameterArray[6] = currentCenter.x;
+ parameterArray[7] = currentCenter.y;
+ parameterArray[8] = translateX;
+ parameterArray[9] = translateY;
+ parameterArray[10] = vanishingPointY;
+ parameterArray[11] = curveEndY;
+ parameterArray[12] = curveDirection.x;
+ parameterArray[13] = curveDirection.y;
+ parameterArray[14] = curveHeight;
+ parameterArray[15] = currentLength;
- Constraint constraint = Constraint::New<Dali::Matrix>( actor, actor.GetPropertyIndex( PROPERTY_COMMON_PARAMETERS ) , CommonParametersConstraint( pageHeight ) );
- constraint.AddSource( LocalSource( actor.GetPropertyIndex( PROPERTY_ORIGINAL_CENTER ) ) );
- constraint.AddSource( LocalSource( actor.GetPropertyIndex( PROPERTY_CURRENT_CENTER ) ) );
+ Constraint constraint = Constraint::New<Dali::Matrix>(actor, actor.GetPropertyIndex(PROPERTY_COMMON_PARAMETERS), CommonParametersConstraint(pageHeight));
+ constraint.AddSource(LocalSource(actor.GetPropertyIndex(PROPERTY_ORIGINAL_CENTER)));
+ constraint.AddSource(LocalSource(actor.GetPropertyIndex(PROPERTY_CURRENT_CENTER)));
- customShader[ Toolkit::Visual::Shader::Property::VERTEX_SHADER ] = SHADER_PAGE_TURN_EFFECT_VERT.data();
- customShader[ Toolkit::Visual::Shader::Property::FRAGMENT_SHADER ] = SHADER_PAGE_TURN_EFFECT_FRAG.data();
- customShader[ Toolkit::Visual::Shader::Property::SUBDIVIDE_GRID_X ] = 20;
- customShader[ Toolkit::Visual::Shader::Property::SUBDIVIDE_GRID_Y ] = 20;
+ customShader[Toolkit::Visual::Shader::Property::VERTEX_SHADER] = SHADER_PAGE_TURN_EFFECT_VERT.data();
+ customShader[Toolkit::Visual::Shader::Property::FRAGMENT_SHADER] = SHADER_PAGE_TURN_EFFECT_FRAG.data();
+ customShader[Toolkit::Visual::Shader::Property::SUBDIVIDE_GRID_X] = 20;
+ customShader[Toolkit::Visual::Shader::Property::SUBDIVIDE_GRID_Y] = 20;