2 // Open Service Platform
3 // Copyright (c) 2012-2013 Samsung Electronics Co., Ltd.
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
9 // http://floralicense.org/license/
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.
18 * @file FUiEffects_RuntimeEffectModel.h
19 * @brief This is the header file for the EffectModel class.
22 #ifndef _FUI_EFFECTS_INTERNAL_RUNTIME_EFFECT_MODEL_H_
23 #define _FUI_EFFECTS_INTERNAL_RUNTIME_EFFECT_MODEL_H_
25 #include <unique_ptr.h>
29 #include <FUiEffectsTypes.h>
30 #include <FUiEffects_PeElementSurface.h>
31 #include "FUiEffects_RuntimeIScriptProcessing.h"
32 #include "FUiEffects_RuntimeScriptProcessing.h"
33 #include "FUiEffects_RuntimeIEffectModelListener.h"
34 #include "FUiEffects_RuntimeModel.h"
35 #include "FUiEffects_RuntimePropertyCast.h"
36 #include "FUiEffects_RuntimeRenderDataSurface.h"
37 #include "FUiEffects_RuntimeIEffectModelScript.h"
38 #include "FUiEffects_RuntimeIEffectModelManager.h"
40 namespace Tizen { namespace Ui { namespace Effects { namespace _Runtime
43 class GraphicalSurface;
48 * The map type for pointers to ElementSurface abstract class.
51 typedef std::map<long, ::Tizen::Ui::Effects::_PhysicsEngine::ElementSurface*> TypeMapElements;
54 * The map type for pointers to GraphicalSurface abstract class.
57 typedef std::map<long, GraphicalSurface*> TypeMapGSurface;
60 * The list type for pointers to model surfaces.
63 typedef std::list<ModelSurface*> TypeMSurfacesCollection;
66 * The type for denoting the time in model runtime (seconds).
69 typedef float TypeTimeEffect;
71 struct ModelSurfacesCollectionDeleter
73 void operator()(TypeMSurfacesCollection* pMSurfacesCollection);
78 * @brief This class contains the collection of model surfaces, transmits events to relevant classes.
84 : public IEffectModelScript
85 , public IEffectModelManager
89 * EffectModel class constructor
94 EffectModel(long effectID, const std::string& name, const char* pPathToScript, IEffectModelListener* pEMListener, ::Tizen::Ui::Effects::EffectType effectType, TypeTimeEffect effectDuration);
102 virtual ~EffectModel(void);
105 * Adds a pointer to model surface into model surfaces collection
109 * @remarks It is called from parser
111 void AddModelSurface(ModelSurface* pMSurface);
114 * Links classes after creating effect by parser (constructs the elements map and render data collection)
118 * @remarks It is called from up level (by parser or effects manager);
119 * after linking calls script function Initialize
121 void Construct(void);
124 * Calls script function OnEffectStart, prepares effect to starting
128 * @remarks For example, script function OnEffectStart fixes cover points for PTE effect
130 virtual int Start(const EffectsVector<float>& effectStartInfo);
133 * Stops effect performing and initializes (if not breakdown)
137 * @remarks Sends to up level about effect stop;
138 * it is called from up level in case of forced stop
140 virtual void Stop(bool isBreakdown, bool isInterruptedFromApplication);
143 * Calculating effect's elements
147 * @remarks It is called from up level by timer;
148 * calls script function OnEffectCalculate
149 * and after calls function Calculate of all model surfaces,
150 * and then, if effect is EFFECT_TYPE_INTERACTIVE,
151 * calls script function IsEffectFinished
153 virtual void Calculate(float dt);
155 virtual long GetId(void) const;
156 virtual std::string GetName(void) const;
159 * Event touch pressed handler
163 * @remarks It is called from up level by corresponding event handler,
164 * transmits event to script
166 virtual void FeedTouchPressEvent(const TouchEventScript &pos3);
169 * Event touch moved handler
173 * @remarks It is called from up level by corresponding event handler,
174 * transmits event to script
176 virtual void FeedTouchMoveEvent(const TouchEventScript &pos3);
179 * Event touch released handler
183 * @remarks It is called from up level by corresponding event handler,
184 * transmits event to script
186 virtual void FeedTouchReleaseEvent(const TouchEventScript &pos3);
189 * Event touch double pressed handler
193 * @remarks It is called from up level by corresponding event handler,
194 * transmits event to script
196 virtual void FeedTouchDoublePressEvent(const TouchEventScript &pos3);
199 * Returns time passed from the effect beginning
204 virtual float GetCalculationPeriodForTimer(void) const;
207 * Returns current effect state (see enumeration _EffectState)
212 virtual _EffectState GetState(void) const;
215 * Returns effect behaviour type (see enumeration EffectType)
220 virtual EffectType GetType(void) const;
223 * Returns the pointer to the collection of structure RenderData elements to up level (to renderer)
227 * @remarks The size of this collection is equal to quantity of graphical surfaces;
228 * this function is called once from up level for renderer
230 virtual RenderDataScene* GetRenderingData(void) const;
233 * Updates all graphical surfaces
237 * @remarks It is called for updating graphical points based on physical points
239 virtual void UpdateGraphicalSurfaces(void);
242 * Transmits event SetProperty for boolean values from script to class-inheritor of ElementSurface interface
246 * @remarks Function is inherited from IEffectModelScript class
248 virtual bool ScriptSetProperty(long objID, ElementProperty property, bool value);
251 * Transmits event SetProperty for lua_Number values (floating point or integer)
252 * from script to class-inheritor of ElementSurface interface
256 * @remarks Function is inherited from IEffectModelScript class
258 virtual bool ScriptSetProperty(long objID, ElementProperty property, LUA_NUMBER value);
261 * Transmits event SetProperty for Vec3f values from script to class-inheritor of ElementSurface interface
265 * @remarks Function is inherited from IEffectModelScript class
267 virtual bool ScriptSetProperty(long objID, ElementProperty property, const Tizen::Ui::Effects::_Utils::Vec3f &value);
270 * Transmits event SetPropertyGroup for some group of elements from script to specified model surface
275 virtual bool ScriptSetPropertyGroup(long objID, GroupElements group, ElementProperty property, LUA_NUMBER value);
278 * Transmits event GetProperty from script to class-inheritor of ElementSurface interface
282 * @remarks Function is inherited from IEffectModelScript class;
283 * if ID is equals 0, then the owner of property is EffectModel
285 virtual PropertyCast ScriptGetProperty(long objID, ElementProperty property) const;
288 * Transmits event UpdateBitmap from script to up level (to class-inheritor of IEffectModelListener interface)
292 * @remarks Function is inherited from IEffectModelScript class
294 virtual bool ScriptUpdateBitmap(long graphicalSurfaceID, long bitmapID);
297 * Transmits event GetNearestGPoint from script to corresponding graphical surface;
298 * finds the vector of vectors of nearest points to specified point of graphical surface
303 virtual PropertyCast ScriptGetNearestPointsIds(long graphicalSurfaceID, Tizen::Ui::Effects::_Utils::Vec3f &position) const;
306 * Transmits event RotateModelMatrix from script to corresponding graphical surface;
307 * rotates model matrix of corresponding graphical surface
312 virtual bool ScriptRotateSurface(long graphicalSurfaceID, float angle, _Axis axis, _Point point,
313 float ax, float ay, float az, float x0, float y0, float z0);
316 * Transmits event ScaleModelMatrix from script to corresponding graphical surface;
317 * scales model matrix of corresponding graphical surface
322 virtual bool ScriptScaleSurface(long graphicalSurfaceID, float ax, float ay, float az, _Point point,
323 float x0, float y0, float z0);
326 * Transmits event TranslateModelMatrix from script to corresponding graphical surface;
327 * translates model matrix of corresponding graphical surface
332 virtual bool ScriptMoveSurface(long graphicalSurfaceID, float x0, float y0, float z0);
335 * Transmits event ResetModelMatrix from script to corresponding graphical surface;
336 * sets identity model matrix for corresponding graphical surface
341 virtual bool ScriptResetSurfaceTransformation(long graphicalSurfaceID);
344 * Transmits event DistanceFromGround from script to corresponding model surface
349 virtual PropertyCast ScriptGetDistanceFromGround(long modelSurfaceID) const;
352 * Transmits event SetModelMatrix from script to corresponding graphical surface;
353 * sets model matrix for corresponding graphical surface
358 virtual bool ScriptSetTransformationMatrix(long graphicalSurfaceID, const Tizen::Ui::Effects::_Utils::LuaMatrix4& luaMatrix4);
361 * Adds new unit light to scene
365 * @remarks Returns true if addition was succeeded and false otherwise
367 virtual bool ScriptAddUnitLight(UnitLight& unitLight);
370 * Excludes specified unit light from scene with using unique name of it
374 * @remarks Returns true if addition was succeeded and false otherwise
376 virtual bool ScriptRemoveUnitLight(const std::string& name);
379 * Excludes all units light of specified type from scene
383 * @remarks Returns true if addition was succeeded and false otherwise
385 virtual bool ScriptRemoveAllUnitsLightType(TypeUnitLight typeUnitLight);
388 * Returns specified unit light with using unique name of it
393 virtual PropertyCast ScriptGetUnitLight(const std::string& name) const;
396 * Sets ambient colour for scene
401 virtual void ScriptSetLightAmbientColour(const Tizen::Ui::Effects::_Utils::Vec3f& ambientColour);
404 * Sets ambient colour for scene
409 virtual void ScriptSetLightAmbientColour(float red, float green, float blue);
412 * Sets light intensity for scene
417 virtual void ScriptSetLightIntensity(float intensity);
420 * Sets attenuation for units light on scene
425 virtual void ScriptSetLightAttenuation(float attenuation);
428 * Returns ambient colour of scene
433 virtual const Tizen::Ui::Effects::_Utils::Vec3f& ScriptGetLightAmbientColour(void) const;
436 * Returns light intensity of scene
441 virtual float ScriptGetLightIntensity(void) const;
444 * Returns attenuation for units light on scene
449 virtual float ScriptGetLightAttenuation(void) const;
455 * Hidden copy constructor
460 EffectModel(const EffectModel& rhs);
463 * Hidden assignment operator
468 EffectModel &operator=(const EffectModel& rhs);
471 * Finds an element in elements map by index
475 * @remarks If element with specified index not exists, the function returns false
477 bool FindElement(long objID, TypeMapElements::iterator& it) const;
480 * Finds an element in graphical surfaces map by index
484 * @remarks If graphical surface with specified index not exists, the function returns false
486 bool FindGraphicalSurface(long objID, TypeMapGSurface::iterator& it) const;
489 * Initializes some class parameters and calls function Initialize from script
494 void InitEffectModel(void);
497 * Initializes all effect parameters
501 * @remarks Effect's initialization after finishing
503 void EffectInitialize(void);
507 std::unique_ptr<IScriptProcessing> __pScript; /**< pointer to script processing (for performing some functions in scripts)*/
509 IEffectModelListener* __pEMListener; /**< pointer to effect model listener (for sending events to up level)*/
510 _EffectState __state; /**< current effect state*/
511 ::Tizen::Ui::Effects::EffectType __effectType; /**< effect behaviour type*/
512 EffectResultS __effectResult; /**< result of effect performing*/
514 std::unique_ptr<TypeMapElements> __pMapElements; /**< elements map (for quick searching the element by index)*/
515 std::unique_ptr<TypeMapGSurface> __pMapGSurface; /**< graphical surfaces map (for quick searching the graphical surface by index and access from effect model instance to graphical surface directly)*/
517 std::unique_ptr<TypeMSurfacesCollection, ModelSurfacesCollectionDeleter> __pMSurfacesCollection; /**< model surfaces collection*/
519 const long __effectID; /**< ID of effect (for sending event to up level with ID of effect which generates this event)*/
520 const std::string __name;
522 TypeTimeEffect __effectTimePassed; /**< elapsed time from effect beginning (in seconds)*/
523 TypeTimeEffect __effectDuration; /**< the effect duration (is needed for time based effect) (in seconds)*/
525 std::unique_ptr<RenderDataScene> __pRenderDataScene; /**< a pointer to render data for scene */
529 } } } } // Tizen::Ui::Effects::_Runtime
531 #endif //_FUI_EFFECTS_INTERNAL_RUNTIME_EFFECT_MODEL_H_