namespace
{
// Bouncing effect is presented by stacked three layers with same color and opacity
- const size_t NUM_LAYERS( 3 );
const Vector3 LAYER_HEIGHTS( 1.f, 27.f/42.f, 13.f/42.f);
- // use the actor color to paint every layer
- const char* MESH_FRAGMENT_SHADER =
- "void main()\n"
- "{\n"
- " gl_FragColor = uColor;\n"
- "}\n";
-
- // Constraint to move the vertices vertically
- struct VertexPositionConstraint
- {
- VertexPositionConstraint( float initialY, float range )
- : mInitialY( initialY ),
- mRange( range )
- {
- }
-
- void operator()( Vector3& current, const PropertyInputContainer& inputs )
- {
- current.y = mInitialY + mRange * fabsf( inputs[0]->GetFloat() );
- }
+ #define MAKE_SHADER(A)#A
+
+ // Modify the vertex position according to the bounce coefficient;
+ const char* MESH_VERTEX_SHADER = MAKE_SHADER(
+ attribute mediump vec3 aPosition1;\n
+ attribute mediump vec3 aPosition2;\n
+ uniform mediump mat4 uMvpMatrix;\n
+ uniform mediump vec3 uSize;
+ uniform mediump float uBounceCoefficient;\n
+ \n
+ void main()\n
+ {\n
+ gl_Position = uMvpMatrix * vec4(mix( aPosition1, aPosition2, abs(uBounceCoefficient) )*uSize, 1.0);\n
+ }
+ );
- float mInitialY;
- float mRange;
- };
+ // use the actor color to paint every layer
+ const char* MESH_FRAGMENT_SHADER = MAKE_SHADER(
+ uniform lowp vec4 uColor;\n
+ void main()\n
+ {\n
+ gl_FragColor = uColor;\n
-}\n;
++}\n
+ );
} // namespace Anon