License conversion from Flora to Apache 2.0
[platform/core/uifw/dali-core.git] / dali / public-api / geometry / mesh.h
1 #ifndef __DALI_MESH_H__
2 #define __DALI_MESH_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
22 // INTERNAL INCLUDES
23 #include <dali/public-api/actors/actor.h>
24 #include <dali/public-api/geometry/mesh-data.h>
25 #include <dali/public-api/math/rect.h>
26 #include <dali/public-api/math/vector4.h>
27 #include <dali/public-api/modeling/material.h>
28 #include <dali/public-api/modeling/bone.h>
29 #include <dali/public-api/object/base-handle.h>
30
31 namespace Dali DALI_IMPORT_API
32 {
33
34 namespace Internal DALI_INTERNAL
35 {
36 class Mesh;
37 }
38
39 /**
40  * @brief A Mesh holds a MeshData object supplied by the application writer.
41  *
42  * It is used to tell the Scene Graph if the mesh data has changed.
43  */
44 class Mesh : public BaseHandle
45 {
46 public:
47
48   /**
49    * @brief Create an initialized Mesh.
50    *
51    * @param[in] meshData The mesh data with which to initialize the handle
52    * @return A handle to a newly allocated Dali resource.
53    */
54   static Mesh New( const MeshData& meshData );
55
56   /**
57    * @brief Create an uninitialized Mesh; this can be initialized with Mesh::New().
58    *
59    * Calling member functions with an uninitialized Dali::Object is not allowed.
60    */
61   Mesh();
62
63   /**
64    * @brief Virtual destructor.
65    */
66   virtual ~Mesh();
67
68   /**
69    * @copydoc Dali::BaseHandle::operator=
70    */
71   using BaseHandle::operator=;
72
73   /**
74    * @brief Create an initialized plane aligned on the XY axis.
75    *
76    * @param[in] width   The width of the plane
77    * @param[in] height  The height of the plane
78    * @param[in] xSteps  The number of vertices along the X axis
79    * @param[in] ySteps  The number of vertices along the Y axis
80    * @param[in] textureCoordinates  UV coordinates.
81    * @return A handle to a newly allocated Dali resource.
82    */
83   static Mesh NewPlane(const float width,
84                        const float height,
85                        const int xSteps,
86                        const int ySteps,
87                        const Rect<float>& textureCoordinates = Rect<float>(0.0f, 0.0f, 1.0f, 1.0f));
88
89   /**
90    * @brief Downcast an Object handle to Mesh handle.
91    *
92    * If handle points to a Mesh object the downcast produces valid
93    * handle. If not the returned handle is left uninitialized.
94    *
95    * @param[in] handle to An object
96    * @return handle to an Mesh object or an uninitialized handle
97    */
98   static Mesh DownCast( BaseHandle handle );
99
100   /**
101    * @brief Tell Dali to update it's internal meshes from the changed mesh data.
102    *
103    * @param[in] meshData
104    */
105   void UpdateMeshData( const MeshData& meshData );
106
107 public: // Not intended for application developers
108
109   /**
110    * @brief This constructor is used by Dali New() methods.
111    *
112    * @param [in] mesh A pointer to a newly allocated Dali resource
113    */
114   explicit DALI_INTERNAL Mesh(Internal::Mesh* mesh);
115 };
116
117 } // namespace Dali
118
119 #endif // __DALI_MESH_H__