Stage::GetCurrent().Add( root );
DALI_TEST_CHECK( bubbleMesh );
- Property::Index propertyIndex0 = bubbleMesh.GetPropertyIndex( "percentage-0" );
- Property::Index propertyIndex1 = bubbleMesh.GetPropertyIndex( "percentage-1" );
+ Property::Index propertyIndex0 = bubbleMesh.GetPropertyIndex( "uPercentage[0]" );
+ Property::Index propertyIndex1 = bubbleMesh.GetPropertyIndex( "uPercentage[1]" );
float value0, value1;
Animation animation = Animation::New( 0.5f );
animation.Play();
Wait(application, 300);
- propertyIndex0 = bubbleMesh.GetPropertyIndex( "percentage-0" );
- propertyIndex1 = bubbleMesh.GetPropertyIndex( "percentage-1" );
+ propertyIndex0 = bubbleMesh.GetPropertyIndex( "uPercentage[0]" );
+ propertyIndex1 = bubbleMesh.GetPropertyIndex( "uPercentage[1]" );
(bubbleMesh.GetProperty(propertyIndex0)).Get( value0 );
(bubbleMesh.GetProperty(propertyIndex1)).Get( value1 );
DALI_TEST_CHECK( value0 >= 0.6f );
DALI_TEST_CHECK( gl.GetUniformValue<float>( "uPercentage[0]", percentageValue ) );
DALI_TEST_EQUALS( percentageValue, 0.f, TEST_LOCATION );
- DALI_TEST_CHECK( gl.GetUniformValue<Vector4>( "uStartAndEndPos[0]", startEndPosValue ) );
+ DALI_TEST_CHECK( gl.GetUniformValue<Vector4>( "uStartEndPosition[0]", startEndPosValue ) );
DALI_TEST_EQUALS( startEndPosValue.x, 40.f, TEST_LOCATION );
DALI_TEST_EQUALS( startEndPosValue.y, 40.f, TEST_LOCATION );
DALI_TEST_CHECK( gl.GetUniformValue<float>( "uPercentage[0]", percentageValue ) );
DALI_TEST_CHECK( percentageValue < 0.5f && percentageValue >= 0.4);
- DALI_TEST_CHECK( gl.GetUniformValue<Vector4>( "uStartAndEndPos[0]", startEndPosValue ) );
+ DALI_TEST_CHECK( gl.GetUniformValue<Vector4>( "uStartEndPosition[0]", startEndPosValue ) );
DALI_TEST_EQUALS( startEndPosValue.x, 40.f, TEST_LOCATION );
DALI_TEST_EQUALS( startEndPosValue.y, 40.f, TEST_LOCATION );
DALI_TEST_CHECK( gl.GetUniformValue<float>( "uPercentage[0]", percentageValue ) );
DALI_TEST_EQUALS( percentageValue, 0.f, TEST_LOCATION );
- DALI_TEST_CHECK( gl.GetUniformValue<Vector4>( "uStartAndEndPos[0]", startEndPosValue ) );
+ DALI_TEST_CHECK( gl.GetUniformValue<Vector4>( "uStartEndPosition[0]", startEndPosValue ) );
DALI_TEST_EQUALS( startEndPosValue, Vector4::ZERO, TEST_LOCATION );
END_TEST;
}
// INTERNAL INCLUDES
-namespace
-{
-
-/**
- * Register a property and map it as uniform.
- * @param[in] handle The handle to register new property.
- * @param[in] propertyName The name of the property.
- * @param[in] unifoemName The name of the uniform.
- * @param[in] value The initial value of the property.
- * @return The index of theproperty
- */
-Dali::Property::Index RegisterUniform( Dali::Handle& handle,
- const std::string& propertyName,
- const std::string& uniformName,
- Dali::Property::Value value)
-{
- Dali::Property::Index propertyIndex = handle.RegisterProperty( propertyName, value );
- handle.AddUniformMapping( propertyIndex, uniformName );
-
- return propertyIndex;
-}
-
-}// end LOCAL_STUFF
-
namespace Dali
{
mActor.SetParentOrigin(ParentOrigin::TOP_LEFT);
// register uniforms
- mIndexGravity = RegisterUniform( mActor, "gravity", "uGravity", 50.f );
- mIndexDynamicScale = RegisterUniform( mActor, "dynamic-scale", "uDynamicScale", 1.f );
+ mIndexGravity = mActor.RegisterProperty( "uGravity", 50.f );
+ mIndexDynamicScale = mActor.RegisterProperty( "uDynamicScale", 1.f );
- mIndexInvertedMovementArea = RegisterUniform( mActor, "inverted-movement-area", "uInvertedMovementArea", Vector2(1.f,1.f) / mMovementArea );
+ mIndexInvertedMovementArea = mActor.RegisterProperty( "uInvertedMovementArea", Vector2(1.f,1.f) / mMovementArea );
srand(time(NULL));
mIndicesOffset.resize(9);
int offset = mMovementArea.Length() / 10.f;
- mIndicesOffset[0] = RegisterUniform(mActor, "offset-0", "offset[0]", Vector2(0.f,0.f));
- mIndicesOffset[1] = RegisterUniform(mActor, "offset-1", "offset[1]", Vector2(rand()%offset,rand()%offset) );
- mIndicesOffset[2] = RegisterUniform(mActor, "offset-2", "offset[2]", Vector2(rand()%offset,-rand()%offset) );
- mIndicesOffset[3] = RegisterUniform(mActor, "offset-3", "offset[3]", Vector2(-rand()%offset,rand()%offset) );
- mIndicesOffset[4] = RegisterUniform(mActor, "offset-4", "offset[4]", Vector2(-rand()%offset,-rand()%offset) );
- mIndicesOffset[5] = RegisterUniform(mActor, "offset-5", "offset[5]", Vector2(rand()%offset,0.f));
- mIndicesOffset[6] = RegisterUniform(mActor, "offset-6", "offset[6]", Vector2(-rand()%offset,0.f));
- mIndicesOffset[7] = RegisterUniform(mActor, "offset-7", "offset[7]", Vector2(0.f,rand()%offset));
- mIndicesOffset[8] = RegisterUniform(mActor, "offset-8", "offset[8]", Vector2(0.f,-rand()%offset));
+ mIndicesOffset[0] = mActor.RegisterProperty( "uOffset[0]", Vector2(0.f,0.f));
+ mIndicesOffset[1] = mActor.RegisterProperty( "uOffset[1]", Vector2(rand()%offset,rand()%offset) );
+ mIndicesOffset[2] = mActor.RegisterProperty( "uOffset[2]", Vector2(rand()%offset,-rand()%offset) );
+ mIndicesOffset[3] = mActor.RegisterProperty( "uOffset[3]", Vector2(-rand()%offset,rand()%offset) );
+ mIndicesOffset[4] = mActor.RegisterProperty( "uOffset[4]", Vector2(-rand()%offset,-rand()%offset) );
+ mIndicesOffset[5] = mActor.RegisterProperty( "uOffset[5]", Vector2(rand()%offset,0.f));
+ mIndicesOffset[6] = mActor.RegisterProperty( "uOffset[6]", Vector2(-rand()%offset,0.f));
+ mIndicesOffset[7] = mActor.RegisterProperty( "uOffset[7]", Vector2(0.f,rand()%offset));
+ mIndicesOffset[8] = mActor.RegisterProperty( "uOffset[8]", Vector2(0.f,-rand()%offset));
Vector4 zeroVector;
mIndiceStartEndPos.resize( mNumBubble );
for( unsigned int i=0; i<mNumBubble; i++ )
{
std::ostringstream ossProperty;
- ossProperty<< "start-end-position-"<< i;
-
- std::ostringstream ossUniform;
- ossUniform<< "uStartAndEndPos["<< i << "]";
- mIndiceStartEndPos[i] = RegisterUniform( mActor, ossProperty.str(), ossUniform.str(), zeroVector );
+ ossProperty<< "uStartEndPosition["<< i << "]";
+ mIndiceStartEndPos[i] = mActor.RegisterProperty( ossProperty.str(), zeroVector );
ossProperty.str("");
- ossProperty<< "percentage-"<< i;
-
- ossUniform.str("");
- ossUniform<< "uPercentage["<< i << "]";
- mIndicesPercentage[i] = RegisterUniform( mActor, ossProperty.str(), ossUniform.str(), 0.f );
+ ossProperty<< "uPercentage["<< i << "]";
+ mIndicesPercentage[i] = mActor.RegisterProperty( ossProperty.str(), 0.f );
}
}
uniform mediump float uGravity;\n
// xy: the emit position of the bubble; zw: the destination of the bubble.
// The bubble is moving from (xy) to (zw plus the y drop influenced by gravity).
- uniform vec4 uStartAndEndPos[NUMBER_OF_BUBBLE];\n
+ uniform vec4 uStartEndPosition[NUMBER_OF_BUBBLE];\n
// The undergoing percentage of the bubble movement. 0.0: start from emit position, 1.0: reach the destination
uniform float uPercentage[NUMBER_OF_BUBBLE];\n
uniform vec2 uInvertedMovementArea;\n
// The bubble number is restricted by the available uniform num.
- // To increase the displayed bubble, every uStartAndEndPos and uPercentage uniform is applied to a small bunch of bubbles (9 here)
+ // To increase the displayed bubble, every uStartEndPosition and uPercentage uniform is applied to a small bunch of bubbles (9 here)
// The offset defines the random offset between bubbles within the bunch.
- uniform vec2 offset[9];\n
+ uniform vec2 uOffset[9];\n
// This uniform is used to change the bubble size during running time
uniform float uDynamicScale;\n
varying float vPercentage;\n
int index = int(aIndex); \n
//for some i between 0 ~ NUMBER_OF_BUBBLE-1: i,i+NUMBER_OF_BUBBLE, i+NUMBER_OF_BUBBLE*2, ... (up to i+NUMBER_OF_BUBBLE*8) belongs to the same bunch.
int groupIdx = index / NUMBER_OF_BUBBLE;\n
- // The bubbles within the same bunch applies the same uniforms uStartAndEndPos[idx] & uPercentage[idx]
+ // The bubbles within the same bunch applies the same uniforms uStartEndPosition[idx] & uPercentage[idx]
int idx = index - groupIdx*NUMBER_OF_BUBBLE;\n
float percentage = uPercentage[idx];
// early out if uPercentage is (zero || one) setting position to zero (zero sized triangles)
gl_Position = vec4(0.0);\n
return;\n
}\n
- vec4 startAndEnd = uStartAndEndPos[idx];\n
+ vec4 startAndEnd = uStartEndPosition[idx];\n
// The final position is added up different offset for bubbles
- startAndEnd.zw += offset[groupIdx];\n
+ startAndEnd.zw += uOffset[groupIdx];\n
\n
// increase the bubble size from 0% to 100% during the first 1/5 of movement & apply the dynamic scale
// the new xy value containes both the new scale and new bubble position