//Property names
const char * const PRIMITIVE_SHAPE( "shape" );
-const char * const SHAPE_COLOR( "shapeColor" );
+const char * const SHAPE_COLOR( "mixColor" );
const char * const SLICES( "slices" );
const char * const STACKS( "stacks" );
const char * const SCALE_TOP_RADIUS( "scaleTopRadius" );
const float DEFAULT_SCALE_RADIUS = 1.0; ///< For cylinders
const float DEFAULT_BEVEL_PERCENTAGE = 0.0; ///< For bevelled cubes
const float DEFAULT_BEVEL_SMOOTHNESS = 0.0; ///< For bevelled cubes
-const Vector4 DEFAULT_COLOR = Vector4( 0.5, 0.5, 0.5, 0.0 ); ///< Grey, for all.
+const Vector4 DEFAULT_COLOR = Vector4( 0.5, 0.5, 0.5, 1.0 ); ///< Grey, for all.
//Property limits
const int MIN_SLICES = 3; ///< Minimum number of slices for spheres and conics
//Shader properties
const char * const OBJECT_MATRIX_UNIFORM_NAME( "uObjectMatrix" );
-const char * const COLOR_UNIFORM_NAME( "uColor" );
+const char * const COLOR_UNIFORM_NAME( "mixColor" );
const char * const OBJECT_DIMENSIONS_UNIFORM_NAME( "uObjectDimensions" );
const char * const STAGE_OFFSET_UNIFORM_NAME( "uStageOffset" );
precision mediump float;\n
varying mediump vec3 vIllumination;\n
uniform lowp vec4 uColor;\n
+ uniform lowp vec4 mixColor;\n
void main()\n
{\n
- gl_FragColor = vec4( vIllumination.rgb * uColor.rgb, uColor.a );\n
+ vec4 baseColor = mixColor * uColor;\n
+ gl_FragColor = vec4( vIllumination.rgb * baseColor.rgb, baseColor.a );\n
}\n
);
//Read in other potential properties.
- Property::Value* color = propertyMap.Find( Toolkit::PrimitiveVisual::Property::COLOR, SHAPE_COLOR );
+ Property::Value* color = propertyMap.Find( Toolkit::PrimitiveVisual::Property::MIX_COLOR, SHAPE_COLOR );
if( color && !color->Get( mColor ) )
{
DALI_LOG_ERROR( "Invalid type for color in PrimitiveVisual.\n" );
void PrimitiveVisual::DoSetOnStage( Actor& actor )
{
InitializeRenderer();
+
+ actor.AddRenderer( mImpl->mRenderer );
}
void PrimitiveVisual::DoCreatePropertyMap( Property::Map& map ) const
map.Clear();
map.Insert( Toolkit::Visual::Property::TYPE, Toolkit::Visual::PRIMITIVE );
map.Insert( Toolkit::PrimitiveVisual::Property::SHAPE, mPrimitiveType );
- map.Insert( Toolkit::PrimitiveVisual::Property::COLOR, mColor );
+ map.Insert( Toolkit::PrimitiveVisual::Property::MIX_COLOR, mColor );
map.Insert( Toolkit::PrimitiveVisual::Property::SLICES, mSlices );
map.Insert( Toolkit::PrimitiveVisual::Property::STACKS, mStacks );
map.Insert( Toolkit::PrimitiveVisual::Property::SCALE_TOP_RADIUS, mScaleTopRadius );
mShader.RegisterProperty( STAGE_OFFSET_UNIFORM_NAME, Vector2( width, height ) / 2.0f );
mShader.RegisterProperty( LIGHT_POSITION_UNIFORM_NAME, mLightPosition );
mShader.RegisterProperty( OBJECT_MATRIX_UNIFORM_NAME, scaleMatrix );
- mShader.RegisterProperty( Toolkit::PrimitiveVisual::Property::COLOR, COLOR_UNIFORM_NAME, mColor );
+ mShader.RegisterProperty( Toolkit::PrimitiveVisual::Property::MIX_COLOR, COLOR_UNIFORM_NAME, mColor );
mShader.RegisterProperty( OBJECT_DIMENSIONS_UNIFORM_NAME, mObjectDimensions );
}
void PrimitiveVisual::CreateBevelledCube( Vector<Vertex>& vertices, Vector<unsigned short>& indices,
Vector3 dimensions, float bevelPercentage, float bevelSmoothness )
{
- dimensions.Normalize();
+ float maxDimension = std::max( std::max( dimensions.x, dimensions.y ), dimensions.z );
+ dimensions = dimensions / maxDimension;
if( bevelPercentage <= MIN_BEVEL_PERCENTAGE ) //No bevel, form a cube.
{