License conversion from Flora to Apache 2.0
[platform/core/uifw/dali-core.git] / dali / public-api / dynamics / dynamics-shape.h
1 #ifndef __DALI_DYNAMICS_SHAPE_H__
2 #define __DALI_DYNAMICS_SHAPE_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 // EXTERNAL INCLUDES
22 #include <string>
23
24 // BASE CLASS INCLUDES
25 #include <dali/public-api/object/base-handle.h>
26
27 namespace Dali DALI_IMPORT_API
28 {
29
30 namespace Internal DALI_INTERNAL
31 {
32 class DynamicsShape;
33 } // namespace Internal
34
35 class Mesh;
36 class DynamicsWorld;
37
38 /**
39  * @brief Defines the shape of an object in the simulation.
40  */
41 class DynamicsShape : public BaseHandle
42 {
43 public:
44   /**
45    * @brief The types of shape available.
46    */
47   enum ShapeType
48   {
49     CAPSULE = 0,        ///< A capsule (a cylinder capped with half spheres) defined by the radius of the caps and its height (the height is to the center of the caps)
50     CONE,               ///< A cone defined by the radius of its base and its height
51     CUBE,               ///< A cube defined by width,height and depth
52     CYLINDER,           ///< A cylinder defined by the radius of its ends and its height
53     MESH,               ///< A shape defined by a triangular mesh
54     SPHERE,             ///< A sphere defined by its radius
55   }; // enum ShapeType
56
57 public:
58   /**
59    * @brief Creates a capsule. (A cylinder capped with half spheres)
60    *
61    * @param[in] radius The radius of the capsule.
62    * @param[in] length The length of the capsule.
63    * @return a handle to the new shape.
64    */
65   static DynamicsShape NewCapsule(const float radius, const float length);
66
67   /**
68    * @brief Creates a cone.
69    *
70    * @param[in] radius The radius of the cone.
71    * @param[in] length The length of the cone.
72    * @return a handle to the new shape.
73    */
74   static DynamicsShape NewCone(const float radius, const float length);
75
76   /**
77    * @brief Creates a cube shape.
78    *
79    * All angles are right angles, and opposite faces are equal.
80    * @param[in] dimensions The dimensions of the cuboid ( width, height and depth ).
81    * @return A handle to the new shape
82    */
83   static DynamicsShape NewCube(const Vector3& dimensions);
84
85   /**
86    * @brief Creates a cylinder.
87    *
88    * @param[in] radius The radius of the cylinder.
89    * @param[in] length The length of the cylinder.
90    * @return A handle to the new shape
91    */
92   static DynamicsShape NewCylinder(const float radius, const float length);
93
94   /**
95    * @brief Creates a mesh.
96    *
97    * @param[in] mesh  A mesh.
98    * @return A handle to the new shape
99    */
100   static DynamicsShape NewMesh(Mesh mesh);
101
102   /**
103    * @brief Creates a sphere.
104    *
105    * @param[in] radius The radius of the sphere.
106    * @return A handle to the new shape
107    */
108   static DynamicsShape NewSphere(const float radius);
109
110 public:
111   /**
112    * @brief Constructor which creates an uninitialized DynamicsShape handle.
113    *
114    * Use one of the DynamicsShape::New methods to initialise the handle.
115    */
116   DynamicsShape();
117
118   /**
119    * @brief Virtual destructor.
120    */
121   virtual ~DynamicsShape();
122
123   /**
124    * @copydoc Dali::BaseHandle::operator=
125    */
126   using BaseHandle::operator=;
127
128 public:
129   /**
130    * @brief Get the type of shape.
131    *
132    * @return One of the ShapeType enumeration.
133    */
134   ShapeType GetType() const;
135
136   // Not intended for application developers
137 public:
138   /**
139    * @brief This constructor is used by Dali New() methods.
140    *
141    * @param [in] internal A pointer to a newly allocated Dali resource
142    */
143   explicit DALI_INTERNAL DynamicsShape(Internal::DynamicsShape* internal);
144 }; // class DynamicsShape
145
146 } // namespace Dali
147
148 #endif /* __DALI_DYNAMICS_SHAPE_H__ */