Property refactor in dali-core: Core changes
[platform/core/uifw/dali-core.git] / dali / public-api / geometry / animatable-vertex.h
1 #ifndef __DALI_ANIMATABLE_VERTEX__H__
2 #define __DALI_ANIMATABLE_VERTEX__H__
3
4 /*
5  * Copyright (c) 2014 Samsung Electronics Co., Ltd.
6  *
7  * Licensed under the Apache License, Version 2.0 (the "License");
8  * you may not use this file except in compliance with the License.
9  * You may obtain a copy of the License at
10  *
11  * http://www.apache.org/licenses/LICENSE-2.0
12  *
13  * Unless required by applicable law or agreed to in writing, software
14  * distributed under the License is distributed on an "AS IS" BASIS,
15  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16  * See the License for the specific language governing permissions and
17  * limitations under the License.
18  *
19  */
20
21 // INTERNAL INCLUDES
22 #include <dali/public-api/common/dali-common.h>
23 #include <dali/public-api/object/property.h>
24 #include <dali/public-api/object/property-index-ranges.h>
25 #include <dali/public-api/math/vector2.h>
26 #include <dali/public-api/math/vector3.h>
27 #include <dali/public-api/math/vector4.h>
28
29 namespace Dali
30 {
31 class AnimatableMesh;
32
33 namespace Internal DALI_INTERNAL
34 {
35 class AnimatableMesh;
36 }
37
38 /**
39  * @brief Represents a vertex in an AnimatableMesh.
40  *
41  * It is used by AnimatableMesh to offer an array interface for
42  * setting properties:
43  *
44  * @code
45  * AnimatableMesh mesh = AnimatableMesh(numVerts, faces);
46  * mesh[vertex].SetColor(color);
47  * @endcode
48  */
49 class DALI_IMPORT_API AnimatableVertex
50 {
51 public:
52
53   /**
54    * @brief An enumeration of properties belonging to the AnimatableVertex class.
55    * Note: These are used by animatable mesh also.
56    */
57   struct Property
58   {
59     enum
60     {
61       Position      = DEFAULT_DERIVED_HANDLE_PROPERTY_START_INDEX, ///< name prefix "position-",        type VECTOR3
62       Color,                                                       ///< name prefix "color-",           type VECTOR4
63       TextureCoords,                                               ///< name prefix "texture-coords-",  type VECTOR2
64     };
65   };
66
67   /**
68    * @brief Destructor
69    */
70   ~AnimatableVertex();
71
72   /**
73    * @brief Set the position of the vertex.
74    *
75    * @param[in] position (note, -0.5 - +0.5 are inside the actor's boundaries)
76    */
77   void SetPosition(const Vector3& position);
78
79   /**
80    * @brief Set the vertex color.
81    * @param[in] color The vertex color
82    */
83   void SetColor(const Vector4& color);
84
85   /**
86    * @brief Set the texture coordinates.
87    *
88    * @param[in] textureCoords The texture coordinates
89    */
90   void SetTextureCoords(const Vector2& textureCoords);
91
92   /**
93    * @brief Get the current position of the vertex.
94    *
95    * @return position
96    */
97   Vector3 GetCurrentPosition();
98
99   /**
100    * @brief Get the current vertex color.
101    *
102    * @return The vertex color
103    */
104   Vector4 GetCurrentColor();
105
106   /**
107    * @brief Get the current texture coordinates.
108    *
109    * @return textureCoords The texture coordinates
110    */
111   Vector2 GetCurrentTextureCoords();
112
113 private:
114   // Only allow AnimatableMesh to construct this object.
115   friend class Dali::AnimatableMesh;
116
117   /**
118    * @brief Constructor.
119    *
120    * @param[in] vertex The index of the vertex in the parent mesh
121    * @param[in] mesh   The parent mesh
122    */
123   AnimatableVertex( unsigned int vertex, AnimatableMesh mesh );
124
125   /**
126    * @brief Undefined Copy Constructor
127    */
128   AnimatableVertex(const AnimatableVertex& vertex);
129
130   /**
131    * @brief Undefined Assignment Operator
132    */
133   AnimatableVertex& operator=(const AnimatableVertex& vertex);
134
135   int mVertex; ///< The index of this vertex in the parent mesh
136   Internal::AnimatableMesh& mMesh;  ///< The parent mesh
137 };
138
139
140 }//Dali
141
142 #endif