Normal-less objects now have their normals calculated so that they can be displayed...
[platform/core/uifw/dali-toolkit.git] / docs / content / shared-javascript-and-cpp-documentation / control-renderers.md
index 8f77b8d..1e79656 100644 (file)
@@ -14,6 +14,8 @@ DALi provides the following renderers:
  + [Gradient](@ref gradient-renderer)
  + [Image](@ref image-renderers)
  + [Border](@ref border-renderer)
+ + [Mesh](@ref mesh-renderer)
+ + [Primitive](@ref primitive-renderer)
  
 Controls can provide properties that allow users to specify the renderer type.
 Setting renderer properties are done via a property map.
@@ -30,11 +32,11 @@ Renders a solid color to the control's quad.
 
 ### Properties Supported
 
-**RendererType:** "color"
+**RendererType:** "COLOR"
 
 | Property Name | Type    | Required | Description               |
 |---------------|:-------:|:--------:|---------------------------|
-| blendColor    | VECTOR4 | Yes      | The solid color required. |
+| mixColor      | VECTOR4 | Yes      | The solid color required. |
 
 ### Usage
 
@@ -43,8 +45,8 @@ Renders a solid color to the control's quad.
 Dali::Toolkit::Control control = Dali::Toolkit::Control::New();
 
 Dali::Property::Map map;
-map[ "rendererType" ] = "color";
-map[ "blendColor" ] = Color::RED;
+map[ "rendererType" ] = "COLOR";
+map[ "mixColor" ] = Color::RED;
 
 control.SetProperty( Dali::Toolkit::Control::Property::BACKGROUND, map );
 ~~~
@@ -55,8 +57,8 @@ var control = new dali.Control( "Control" );
 
 control.background =
 {
-  rendererType : "color",
-  blendColor : dali.COLOR_RED
+  rendererType : "COLOR",
+  mixColor : dali.COLOR_RED
 };
 ~~~
 ___________________________________________________________________________________________________
@@ -73,18 +75,18 @@ Both Linear and Radial gradients are supported.
 
 ### Properties Supported
 
-**RendererType:** "gradient"
+**RendererType:** "GRADIENT"
 
-| Property Name                                                | Type             | Required   | Description                                                             |
-|--------------------------------------------------------------|:----------------:|:----------:|-------------------------------------------------------------------------|
-| startPosition                                                | VECTOR2          | For Linear | The start position of the linear gradient.                              |
-| endPosition                                                  | VECTOR2          | For Linear | The end position of the linear gradient.                                |
-| center                                                       | VECTOR2          | For Radial | The center point of the gradient.                                       |
-| radius                                                       | FLOAT            | For Radial | The size of the radius.                                                 |
-| stopOffset                                                   | ARRAY of FLOAT   | No         | All the stop offsets. If not supplied default is 0.0 and 1.0            |
-| stopColor                                                    | ARRAY of VECTOR4 | Yes        | The color at those stop offsets. At least 2 required to show a gradient |
-| [gradientUnits](@ref gradient-renderer-units)                | STRING           | No         | *objectBoundingBox* or *userSpace*. Default: *objectBoundingBox*.       |
-| [gradientSpreadMethod](@ref gradient-renderer-spread-method) | STRING           | No         | *pad*, *repeat* or *reflect*. Default: *pad*                            |
+| Property Name                                        | Type             | Required   | Description                                                              |
+|------------------------------------------------------|:----------------:|:----------:|--------------------------------------------------------------------------|
+| startPosition                                        | VECTOR2          | For Linear | The start position of the linear gradient.                               |
+| endPosition                                          | VECTOR2          | For Linear | The end position of the linear gradient.                                 |
+| center                                               | VECTOR2          | For Radial | The center point of the gradient.                                        |
+| radius                                               | FLOAT            | For Radial | The size of the radius.                                                  |
+| stopOffset                                           | ARRAY of FLOAT   | No         | All the stop offsets. If not supplied default is 0.0 and 1.0.            |
+| stopColor                                            | ARRAY of VECTOR4 | Yes        | The color at those stop offsets. At least 2 required to show a gradient. |
+| [units](@ref gradient-renderer-units)                | STRING           | No         | *OBJECT_BOUNDING_BOX* or *USER_SPACE*. Default: *OBJECT_BOUNDING_BOX*.   |
+| [spreadMethod](@ref gradient-renderer-spread-method) | STRING           | No         | *PAD*, *REFLECT* or *REPEAT*. Default: *PAD*.                            |
 
 If the *stopOffset* and *stopColor* arrays do not have the same number of elements, then the minimum of the two is used as the stop points.
 
@@ -94,10 +96,10 @@ Defines the coordinate system for the attributes:
  + Start (x1, y1) and End (x2 and y2) points of a line if using a linear gradient.
  + Center point (cx, cy) and radius (r) of a circle if using a radial gradient.
  
-| Value             | Description                                                                                                                                    |
-|-------------------|------------------------------------------------------------------------------------------------------------------------------------------------|
-| objectBoundingBox | *Default*. Uses the normals for the start, end & center points, i.e. top-left is (-0.5, -0.5) and bottom-right it (0.5, 0.5).                  |
-| userSpace         | Uses the user coordinates for the start, end & center points, i.e. in a 200 by 200 control, top-left is (0, 0) and bottom-right is (200, 200). |
+| Value               | Description                                                                                                                                    |
+|---------------------|------------------------------------------------------------------------------------------------------------------------------------------------|
+| OBJECT_BOUNDING_BOX | *Default*. Uses the normals for the start, end & center points, i.e. top-left is (-0.5, -0.5) and bottom-right is (0.5, 0.5).                  |
+| USER_SPACE          | Uses the user coordinates for the start, end & center points, i.e. in a 200 by 200 control, top-left is (0, 0) and bottom-right is (200, 200). |
 
 ### Spread Method {#gradient-renderer-spread-method}
 
@@ -105,9 +107,9 @@ Indicates what happens if the gradient starts or ends inside the bounds of the t
 
 | Value   | Description                                                                                          |
 |---------|------------------------------------------------------------------------------------------------------|
-| pad     | *Default*. Uses the terminal colors of the gradient to fill the remainder of the quad.               |
-| reflect | Reflect the gradient pattern start-to-end, end-to-start, start-to-end etc. until the quad is filled. |
-| repeat  | Repeat the gradient pattern start-to-end, start-to-end, start-to-end until the quad is filled.       |
+| PAD     | *Default*. Uses the terminal colors of the gradient to fill the remainder of the quad.               |
+| REFLECT | Reflect the gradient pattern start-to-end, end-to-start, start-to-end etc. until the quad is filled. |
+| REPEAT  | Repeat the gradient pattern start-to-end, start-to-end, start-to-end etc. until the quad is filled.  |
 
 ### Usage
 
@@ -117,7 +119,7 @@ Indicates what happens if the gradient starts or ends inside the bounds of the t
 Dali::Toolkit::Control control = Dali::Toolkit::Control::New();
 
 Dali::Property::Map map;
-map[ "rendererType" ] = "gradient";
+map[ "rendererType" ] = "GRADIENT";
 map[ "startPosition" ] = Vector2( 0.5f, 0.5f );
 map[ "endPosition" ] = Vector2( -0.5f, -0.5f );
 
@@ -146,7 +148,7 @@ var control = new dali.Control( "Control" );
 
 control.background =
 {
-  rendererType : "gradient",
+  rendererType : "GRADIENT",
   startPosition : [ 0.5, 0.5 ],
   endPosition : [ -0.5, -0.5 ],
   stopOffset : [ 0.0, 0.3, 0.6, 0.8, 1.0 ],
@@ -166,7 +168,7 @@ control.background =
 Dali::Toolkit::Control control = Dali::Toolkit::Control::New();
 
 Dali::Property::Map map;
-map[ "rendererType" ] = "gradient";
+map[ "rendererType" ] = "GRADIENT";
 map[ "center" ] = Vector2( 0.5f, 0.5f );
 map[ "radius" ] = 1.414f;
 
@@ -195,7 +197,7 @@ var control = new dali.Control( "Control" );
 
 control.background =
 {
-  rendererType : "gradient",
+  rendererType : "GRADIENT",
   center : [ 0.5, 0.5 ],
   radius : 1.414,
   stopOffset : [ 0.0, 0.3, 0.6, 0.8, 1.0 ],
@@ -231,15 +233,15 @@ Renders a raster image ( jpg, png etc.) into the control's quad.
 
 #### Properties Supported
 
-**RendererType:** "image"
+**RendererType:** "IMAGE"
 
-| Property Name      | Type     | Required | Description                                                                                                                                     |
-|--------------------|:--------:|:--------:|-------------------------------------------------------------------------------------------------------------------------------------------------|
-| url           | STRING   | Yes      | The URL of the image.                                                                                                                           |
-| [fittingMode](@ref resourceimagescaling-fittingmode) | STRING   | No       | *SHRINK_TO_FIT*, *SCALE_TO_FILL*, *FIT_WIDTH* or *FIT_HEIGHT*. Default: *SHRINK_TO_FIT*.                         |
-| [samplingMode](@ref resourceimagescaling-scaling)    | STRING   | No       | *BOX*, *NEAREST*, *LINEAR*, *BOX_THEN_NEAREST*, *BOX_THEN_LINEAR*, *NO_FILTERr* or *DONT_CARE*. Default: *BOX*. |
-| desiredWidth  | INT      | No       | The desired image width. Will use actual image width if not specified.                                                                          |
-| desiredHeight | INT      | No       | The desired image height. Will use actual image height if not specified.                                                                        |
+| Property Name                                        | Type     | Required | Description                                                                                                    |
+|------------------------------------------------------|:--------:|:--------:|----------------------------------------------------------------------------------------------------------------|
+| url                                                  | STRING   | Yes      | The URL of the image.                                                                                          |
+| [fittingMode](@ref resourceimagescaling-fittingmode) | STRING   | No       | *SHRINK_TO_FIT*, *SCALE_TO_FILL*, *FIT_WIDTH* or *FIT_HEIGHT*. Default: *SHRINK_TO_FIT*.                       |
+| [samplingMode](@ref resourceimagescaling-scaling)    | STRING   | No       | *BOX*, *NEAREST*, *LINEAR*, *BOX_THEN_NEAREST*, *BOX_THEN_LINEAR*, *NO_FILTER* or *DONT_CARE*. Default: *BOX*. |
+| desiredWidth                                         | INT      | No       | The desired image width. Will use actual image width if not specified.                                         |
+| desiredHeight                                        | INT      | No       | The desired image height. Will use actual image height if not specified.                                       |
 
 #### Usage
 
@@ -248,7 +250,7 @@ Renders a raster image ( jpg, png etc.) into the control's quad.
 Dali::Toolkit::Control control = Dali::Toolkit::Control::New();
 
 Dali::Property::Map map;
-map[ "rendererType" ] = "image";
+map[ "rendererType" ] = "IMAGE";
 map[ "url" ] = "path-to-image.jpg";
 
 control.SetProperty( Dali::Toolkit::Control::Property::BACKGROUND, map );
@@ -260,7 +262,7 @@ var control = new dali.Control( "Control" );
 
 control.background =
 {
-  rendererType : "image",
+  rendererType : "IMAGE",
   url : "path-to-image.jpg"
 };
 ~~~
@@ -275,7 +277,7 @@ Renders an n-patch or a 9-patch image into the control's quad.
 
 #### Properties Supported
 
-**RendererType:** "image"
+**RendererType:** "IMAGE"
 
 | Property Name | Type    | Required | Description                      |
 |---------------|:-------:|:--------:|----------------------------------|
@@ -290,7 +292,7 @@ Dali::Toolkit::Control control = Dali::Toolkit::Control::New();
 
 Dali::Property::Map map;
 
-map[ "rendererType" ] = "image";
+map[ "rendererType" ] = "IMAGE";
 map[ "url" ] = "path-to-image.9.png";
 
 control.SetProperty( Dali::Toolkit::Control::Property::BACKGROUND, map );
@@ -302,7 +304,7 @@ var control = new dali.Control( "Control" );
 
 control.background =
 {
-  rendererType : "image",
+  rendererType : "IMAGE",
   url : "path-to-image.9.png"
 };
 ~~~
@@ -346,7 +348,7 @@ Renders a svg image into the control's quad.
  
 #### Properties Supported
 
-**RendererType:** "image"
+**RendererType:** "IMAGE"
 
 | Property Name | Type    | Required | Description                      |
 |---------------|:-------:|:--------:|----------------------------------|
@@ -360,7 +362,7 @@ Dali::Toolkit::Control control = Dali::Toolkit::Control::New();
 
 Dali::Property::Map map;
 
-map[ "rendererType" ] = "image";
+map[ "rendererType" ] = "IMAGE";
 map[ "url" ] = "path-to-image.svg";
 
 control.SetSize( 200.f, 200.f );
@@ -373,7 +375,7 @@ var control = new dali.Control( "Control" );
 
 control.background =
 {
-  rendererType : "image",
+  rendererType : "IMAGE",
   url : "path-to-image.svg"
 };
 ~~~
@@ -388,7 +390,7 @@ Renders a solid color as an internal border to the control's quad.
 
 ### Properties Supported
 
-**RendererType:** "border"
+**RendererType:** "BORDER"
 
 | Property Name | Type    | Required | Description                                      |
 |---------------|:-------:|:--------:|--------------------------------------------------|
@@ -404,7 +406,7 @@ Dali::Toolkit::Control control = Dali::Toolkit::Control::New();
 
 Dali::Property::Map map;
 
-map[ "rendererType" ] = "border";
+map[ "rendererType" ] = "BORDER";
 map[ "borderColor"  ] = Color::BLUE;
 map[ "borderSize"   ] = 5.0f;
 
@@ -417,12 +419,190 @@ var control = new dali.Control( "Control" );
 
 control.background =
 {
-  rendererType : "border",
+  rendererType : "BORDER",
   borderColor : dali.COLOR_BLUE,
   borderSize = 5
 };
 ~~~
 
+___________________________________________________________________________________________________
+
+## Mesh Renderer {#mesh-renderer}
+
+Renders a mesh using a .obj file, optionally with textures provided by a mtl file. Scaled to fit the control.
+
+![ ](../assets/img/renderers/mesh-renderer.png)
+![ ](renderers/mesh-renderer.png)
+
+### Properties Supported
+
+**RendererType** "MESH"
+
+| Property Name                                | Type    | Required           | Description                                                                                |
+|----------------------------------------------|:-------:|:------------------:|--------------------------------------------------------------------------------------------|
+| objectUrl                                    | STRING  | Yes                | The location of the ".obj" file.                                                           |
+| materialUrl                                  | STRING  | No                 | The location of the ".mtl" file. Leave blank for a textureless object.                     |
+| texturesPath                                 | STRING  | If using material  | Path to the directory the textures (including gloss and normal) are stored in.             |
+| [shaderType](@ref mesh-renderer-shader-type) | STRING  | No                 | Sets the type of shader to be used with the mesh.                                          |
+| useMipmapping                                | BOOLEAN | No                 | Flag for whether to use mipmaps for textures or not. Default true.                         |
+| useSoftNormals                               | BOOLEAN | No                 | Flag for whether to average normals at each point to smooth textures or not. Default true. |
+
+### Shader Type {#mesh-renderer-shader-type}
+
+When specifying the shader type, if anything the shader requires is missing, a simpler type that can be handled with what has been supplied will be used instead.
+**Possible values:**
+| String Value    | Description                                    |
+|-----------------|------------------------------------------------|
+| TEXTURELESS     | *Simplest*. A flat color with shading is used. |
+| DIFFUSE_TEXTURE | Textured.                                      |
+| ALL_TEXTURES    | Has a gloss, normal map and texture map.       |
+
+### Usage
+
+~~~{.cpp}
+// C++
+Dali::Toolkit::Control control = Dali::Toolkit::Control::New();
+
+Dali::Property::Map map;
+
+map[ "rendererType" ] = "MESH";
+map[ "objectUrl"    ] = "home/models/Dino.obj";
+map[ "materialUrl"  ] = "home/models/Dino.mtl";
+map[ "texturesPath" ] = "home/images/";
+
+control.SetProperty( Dali::Toolkit::Control::Property::BACKGROUND, map );
+~~~
+
+___________________________________________________________________________________________________
+
+## Primitive Renderer {#primitive-renderer}
+
+Renders a simple 3D shape, such as a cube or sphere. Scaled to fit the control.
+
+![ ](../assets/img/renderers/cube.png)
+![ ](renderers/cube.png)
+
+### Properties Supported
+
+**RendererType** "PRIMITIVE"
+
+| Property Name                         | Type    | Description                                                                     | Default Value        | Range                          |
+|---------------------------------------|:-------:|---------------------------------------------------------------------------------|:--------------------:|:------------------------------:|
+| [shape](@ref shape-details)           | STRING  | The specific shape to render.                                                   | "SPHERE"             | [See list](@ref shape-details) |
+| shapeColor                            | VECTOR4 | The color of the shape.                                                         | (0.5, 0.5, 0.5, 1.0) | 0.0 - 1.0 for each             |
+| [slices](@ref slices-details)         | INT     | The number of slices as you go around the shape.                                | 128                  | 1 - 255                        |
+| [stacks](@ref stacks-details)         | INT     | The number of stacks as you go down the shape.                                  | 128                  | 1 - 255                        |
+| scaleTopRadius                        | FLOAT   | The scale of the radius of the top circle of a conical frustrum.                | 1.0                  | ≥ 0.0                          |
+| scaleBottomRadius                     | FLOAT   | The scale of the radius of the bottom circle of a conical frustrum.             | 1.5                  | ≥ 0.0                          |
+| scaleHeight                           | FLOAT   | The scale of the height of a conic.                                             | 3.0                  | > 0.0                          |
+| scaleRadius                           | FLOAT   | The scale of the radius of a cylinder.                                          | 1.0                  | > 0.0                          |
+| scaleDimensions                       | VECTOR3 | The dimensions of a cuboid. Scales in the same fashion as a 9-patch image.      | (1.0, 1.0, 1.0)      | > 0.0 for each                 |
+| [bevelPercentage](@ref bevel-details) | FLOAT   | Determines how bevelled the cuboid should be, based off the smallest dimension. | 0.0 (no bevel)       | 0.0 - 1.0                      |
+| bevelSmoothness                       | FLOAT   | Defines how smooth the bevelled edges should be.                                | 0.0 (sharp edges)    | 0.0 - 1.0                      |
+| uLightPosition                        | VECTOR3 | The position, in stage space, of the point light that applies lighting to the model. This is based off the stage's dimensions, so using the width and height of the stage halved will correspond to the center, and using all zeroes will place the light at the upper left back corner. Note that this corresponds to a shader property, so it can be registered and set in the actor as well. | (Offset outwards from the center of the screen.) | Unlimited |
+
+### Shapes {#shape-details}
+
+There are six shapes that can be chosen, some of which are simplified specialisations of another.
+
+| Value            | Description                                                                       | Parameters                                                    |
+|------------------|-----------------------------------------------------------------------------------|---------------------------------------------------------------|
+| SPHERE           | *Default*.                                                                        | color, slices, stacks                                         |
+| CONICAL_FRUSTRUM | The area bound between two circles, i.e. a cone with the tip removed.             | color, scaleTopRadius, scaleBottomRadius, scaleHeight, slices |
+| CONE             | Equivalent to a conical frustrum with top radius of zero.                         | color, scaleBottomRadius, scaleHeight, slices                 |
+| CYLINDER         | Equivalent to a conical frustrum with equal radii for the top and bottom circles. | color, scaleRadius, scaleHeight, slices                       |
+| CUBE             | Equivalent to a bevelled cube with a bevel percentage of zero.                    | color, scaleDimensions                                        |
+| OCTAHEDRON       | Equivalent to a bevelled cube with a bevel percentage of one.                     | color, scaleDimensions                                        |
+| BEVELLED_CUBE    | A cube/cuboid with all edges flattened to some degree.                            | color, scaleDimensions, bevelPercentage, bevelSmoothness      |
+
+Examples below:
+
+**sphere:**
+
+![ ](../assets/img/renderers/sphere.png)
+![ ](renderers/sphere.png)
+
+**conics:**
+
+| Frustrum | Cone | Cylinder |
+|----------|------|----------|
+| ![ ](../assets/img/renderers/conical-frustrum.png) ![ ](renderers/conical-frustrum.png) | ![ ](../assets/img/renderers/cone.png) ![ ](renderers/cone.png) | ![ ](../assets/img/renderers/cylinder.png) ![ ](renderers/cylinder.png) |
+
+### Bevel {#bevel-details}
+
+Bevel percentage ranges from 0.0 to 1.0. It affects the ratio of the outer face widths to the width of the overall cube, as shown:
+
+| 0.0 ( cube) | 0.3 | 0.7 | 1.0 (octahedron) |
+|-------------|-----|-----|------------------|
+| ![ ](../assets/img/renderers/cube.png) ![ ](renderers/cube.png) | ![ ](../assets/img/renderers/bevelled-cube-low.png) ![ ](renderers/bevelled-cube-low.png) | ![ ](../assets/img/renderers/bevelled-cube-high.png) ![ ](renderers/bevelled-cube-high.png) | ![ ](../assets/img/renderers/octahedron.png) ![ ](renderers/octahedron.png) |
+
+### Slices {#slices-details}
+
+For spheres and conical frustrums, 'slices' determines how many divisions there are as you go around the object.
+
+![ ](../assets/img/renderers/slices.png)
+![ ](renderers/slices.png)
+
+### Stacks {#stacks-details}
+
+For spheres, 'stacks' determines how many layers there are as you go down the object.
+
+![ ](../assets/img/renderers/stacks.png)
+![ ](renderers/stacks.png)
+
+### Usage
+
+**sphere**
+
+~~~{.cpp}
+// C++
+Dali::Toolkit::Control control = Dali::Toolkit::Control::New();
+
+Dali::Property::Map map;
+
+map[ "rendererType" ] = "PRIMITIVE";
+map[ "shape"        ] = "SPHERE";
+map[ "shapeColor"   ] = Vector4( 1.0, 0.5, 0.0, 1.0 );
+
+control.SetProperty( Dali::Toolkit::Control::Property::BACKGROUND, map );
+~~~
+
+**conical frustrum**
+
+~~~{.cpp}
+// C++
+Dali::Toolkit::Control control = Dali::Toolkit::Control::New();
+
+Dali::Property::Map map;
+
+map[ "rendererType"      ] = "PRIMITIVE";
+map[ "shape"             ] = "CONICAL_FRUSTRUM";
+map[ "shapeColor"        ] = Vector4( 1.0, 0.5, 0.0, 1.0 );
+map[ "scaleTopRadius"    ] = 1.0f;
+map[ "scaleBottomRadius" ] = 1.5f;
+map[ "scaleHeight"       ] = 3.0f;
+
+control.SetProperty( Dali::Toolkit::Control::Property::BACKGROUND, map );
+~~~
+
+**bevelled cube**
+
+~~~{.cpp}
+// C++
+Dali::Toolkit::Control control = Dali::Toolkit::Control::New();
+
+Dali::Property::Map map;
+
+map[ "rendererType"    ] = "PRIMITIVE";
+map[ "shape"           ] = "BEVELLED_CUBE";
+map[ "shapeColor"      ] = Vector4( 1.0, 0.5, 0.0, 1.0 );
+map[ "bevelPercentage" ] = 0.4f;
+
+control.SetProperty( Dali::Toolkit::Control::Property::BACKGROUND, map );
+~~~
+
 @class _Guide_Control_Renderers
 
 */