Tizen 2.1 base
[framework/osp/uifw.git] / src / ui / effects / inc / FUiEffects_RuntimeModelSurface.h
1 //
2 // Open Service Platform
3 // Copyright (c) 2012-2013 Samsung Electronics Co., Ltd.
4 //
5 // Licensed under the Flora License, Version 1.0 (the License);
6 // you may not use this file except in compliance with the License.
7 // You may obtain a copy of the License at
8 //
9 //     http://floralicense.org/license/
10 //
11 // Unless required by applicable law or agreed to in writing, software
12 // distributed under the License is distributed on an AS IS BASIS,
13 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 // See the License for the specific language governing permissions and
15 // limitations under the License.
16 //
17 /**
18  * @file        FUiEffects_RuntimeModelSurface.h
19  * @brief       This is the header file for the ModelSurface class.
20  */
21
22 #ifndef _FUI_EFFECTS_INTERNAL_RUNTIME_MODEL_SURFACE_H_
23 #define _FUI_EFFECTS_INTERNAL_RUNTIME_MODEL_SURFACE_H_
24
25 #include <list>
26 #include <FUiEffects_PeElementSurface.h>
27 #include "FUiEffects_RuntimeEffectModel.h"
28 #include "FUiEffects_RuntimeRenderDataSurface.h"
29
30 namespace Tizen { namespace Ui { namespace Effects { namespace _PhysicsEngine
31 {
32 class PointSurface;
33 class SpringSurface;
34 class RodSurface;
35 } } } } // Tizen::Ui::Effects:_PhysicsEngine
36
37 namespace Tizen { namespace Ui { namespace Effects { namespace _Runtime
38 {
39
40 class GraphicalSurface;
41
42 /**
43  * The list type for storing ElementSurface pointers.
44  *
45  * @since 2.0
46  *
47  */
48 typedef std::list<Tizen::Ui::Effects::_PhysicsEngine::ElementSurface*> TypeElemSurfaceCollection;
49
50 /**
51  * The list type for storing PointSurface pointers.
52  *
53  * @since 2.0
54  *
55  */
56 typedef std::list<Tizen::Ui::Effects::_PhysicsEngine::PointSurface*> TypePointSurfaceCollection;
57
58 /**
59  * The list type for storing SpringSurface pointers.
60  *
61  * @since 2.0
62  *
63  */
64 typedef std::list<Tizen::Ui::Effects::_PhysicsEngine::SpringSurface*> TypeSpringSurfaceCollection;
65
66 /**
67  * The list type for storing RodSurface pointers.
68  *
69  * @since 2.0
70  *
71  */
72 typedef std::list<Tizen::Ui::Effects::_PhysicsEngine::RodSurface*> TypeRodSurfaceCollection;
73
74 struct ElementsSurfaceContainerDeleter
75 {
76         void operator()(TypeElemSurfaceCollection* pElemSurfaceCollection);
77 };
78
79 /**
80  * @class       ModelSurface
81  * @brief       This class contains one 3D object
82  *
83  * @since 2.0
84  */
85 class ModelSurface
86         : public ::Tizen::Ui::Effects::_PhysicsEngine::ElementSurface
87 {
88 public:
89         /**
90          * ModelSurface class constructor
91          *
92          * @since 2.0
93          *
94          */
95         ModelSurface(long objId,
96                            unsigned short iterationCount_,
97                            unsigned short modelSpeed_,
98                            float envResistance_,
99                            const Tizen::Ui::Effects::_Utils::Vec3f &gravityAccelerationIdentity_,
100                            float gravityAccelerationValue_,
101                            float groundLevel_);
102
103         /**
104          * ModelSurface class destructor
105          *
106          * @since 2.0
107          *
108          */
109         virtual ~ModelSurface(void);
110
111         /**
112          * Sends to all element surfaces event Calculate
113          *
114          * @since 2.0
115          *
116          */
117         virtual void Calculate(float timeStep);
118
119         /**
120          * Returns specified property value of any type (see class PropertyCast)
121          *
122          * @since 2.0
123          *
124          */
125         virtual PropertyCast GetProperty(ElementProperty propName) const;
126
127         /**
128          * Sets ModelSurface's property which is specified in enumeration ElementProperty
129          * of boolean type
130          *
131          * @since 2.0
132          *
133          */
134         virtual bool SetProperty(ElementProperty propName, bool propValue);
135
136         /**
137          * Sets ModelSurface's property which is specified in enumeration ElementProperty
138          * of floating point type (float or integer)
139          *
140          * @since 2.0
141          *
142          */
143         virtual bool SetProperty(ElementProperty propName, LUA_NUMBER propValue);
144
145         /**
146          * Sets ModelSurface's property which is specified in enumeration ElementProperty
147          * of Vector3 type
148          *
149          * @since 2.0
150          *
151          */
152         virtual bool SetProperty(ElementProperty propName, const Tizen::Ui::Effects::_Utils::Vec3f &propValue);
153
154         /**
155          * Sets specified property value for group of elements
156          *
157          * @since 2.0
158          *
159          * @remarks             Returns true if setting was successful and false otherwise
160          */
161         bool SetPropertyGroup(GroupElements group, ElementProperty property, LUA_NUMBER value);
162
163         /**
164          * Sends event Initialize to all elements of the surface
165          *
166          * @since 2.0
167          *
168          */
169         virtual void Initialize(void);
170
171         /**
172          * Gets object's type
173          *
174          * @since 2.0
175          *
176          */
177         virtual ESurface GetType(void) const;
178
179         /**
180          * GraphicalSurface object assigning during register effect file procedure
181          *
182          * @since 2.0
183          *
184          */
185         void AddGraphicalSurface(std::unique_ptr<GraphicalSurface> pGraphicalSurface);
186
187         /**
188          * ElementSurface object addition during register effect file procedure
189          *
190          * @since 2.0
191          *
192          */
193         void AddElementSurface(::Tizen::Ui::Effects::_PhysicsEngine::ElementSurface* pElementSurface);
194
195         /**
196          * Constructs the elements map for fast searching object in EffectModel,
197          * constructs RenderDataSurfaceCollection object,
198          * links the ModelSurface and PointSurface instances
199          *
200          * @since 2.0
201          *
202          * @remarks             Must be called after parser performing
203          */
204         bool Construct(TypeMapElements* pMapElements, TypeMapGSurface* pMapGSurface, RenderDataSurfaceCollection* pRenderDataSurfaceCollection);
205
206         /**
207          * Transmits event UpdateGraphicalSurface from EffectModel to GraphicalSurface
208          *
209          * @since 2.0
210          *
211          * @remarks             It is called from EffectModel by timer
212          *                              for building graphical points based on physical points
213          */
214         void UpdateGraphicalSurface(void);
215
216         /**
217          * Calculates distance from this model surface to its ground level
218          *
219          * @since 2.0
220          *
221          */
222         float GetDistanceFromGround(void) const;
223
224 private:
225         /**
226          * Hidden copy constructor
227          *
228          * @since 2.0
229          *
230          */
231         ModelSurface(const ModelSurface& rhs);
232
233         /**
234          * Hidden assignment operator
235          *
236          * @since 2.0
237          *
238          */
239         ModelSurface &operator=(const ModelSurface& rhs);
240
241         /**
242          * Sets specified property value for group of elements
243          *
244          * @since 2.0
245          *
246          * @return              Returns true if setting was successful and false otherwise
247          * @remarks             Is needed for internal use only
248          */
249         template<typename T, typename TIter>
250         bool SetPropertyGroup(T* pDataPointer, ElementProperty property, LUA_NUMBER value);
251
252 private:
253
254         std::unique_ptr<TypeElemSurfaceCollection, ElementsSurfaceContainerDeleter> __pElemSurfaceCollection;   /**< collection of surface elements (3D object)*/
255
256         std::unique_ptr<GraphicalSurface> __pGraphicalSurface;                          /**< pointer to graphical surface*/
257
258         unsigned short __iterationCount;                                                                        /**< number of iterations per one calculation event (no speed change, but more stability)*/
259         unsigned short __modelSpeed;                                                                            /**< model speed as animation multiplier*/
260
261         float __envResistance;                                                                                          /**< environment resistance (for physics calculation)*/
262         Tizen::Ui::Effects::_Utils::Vec3f __gravityAccelerationIdentity;                /**< identity vector (length of vector equals 1) of gravity acceleration (for physics calculation)*/
263         float __gravityAccelerationValue;                                                                       /**< length of gravity acceleration vector (for physics calculation)*/
264         Tizen::Ui::Effects::_Utils::Vec3f __gravityAccelerationVector;          /**< gravity acceleration vector (for physics calculation)*/
265         float __groundLevel;
266
267         std::unique_ptr<TypePointSurfaceCollection> __pPointsCollection;        /**< pointers collection to model surface points*/
268         std::unique_ptr<TypeSpringSurfaceCollection> __pSpringsCollection;      /**< pointers collection to model surface springs*/
269         std::unique_ptr<TypeRodSurfaceCollection> __pRodsCollection;            /**< pointers collection to model surface rods*/
270
271 }; // ModelSurface
272
273 } } } } // Tizen::Ui::Effects::_Runtime
274
275 #endif //_FUI_EFFECTS_INTERNAL_RUNTIME_MODEL_SURFACE_H_