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_RuntimeGraphicalSurface.h
19 * @brief This is the header file for the GraphicalSurface class.
22 #ifndef _FUI_EFFECTS_INTERNAL_RUNTIME_GRAPHICAL_SURFACE_H_
23 #define _FUI_EFFECTS_INTERNAL_RUNTIME_GRAPHICAL_SURFACE_H_
25 #include <unique_ptr.h>
26 #include <FUiEffects_PeElementSurface.h>
27 #include "FUiEffects_RuntimeModelSurface.h"
28 #include "FUiEffects_RuntimeRenderDataSurface.h"
30 namespace Tizen { namespace Ui { namespace Effects { namespace _Runtime
34 * @class GraphicalSurface
35 * @brief This class is an abstract for any graphical surface
40 class GraphicalSurface
41 : public ::Tizen::Ui::Effects::_PhysicsEngine::ElementSurface
45 * GraphicalSurface class constructor
50 GraphicalSurface(long objId, long bitmapID_, float transpar_);
53 * GraphicalSurface class destructor
58 virtual ~GraphicalSurface(void);
61 * Initializes GraphicalSurface's internal parameters and resets accumulated parameters to zero
65 * @remarks Function is inherited from ElementSurface interface
67 virtual void Initialize(void);
70 * Updates graphical points based on physical points
75 virtual void Update(void) = 0;
78 * Constructs render data collection
83 virtual void Construct(TypeElemSurfaceCollection* pElemSurfaceCollection, RenderDataSurfaceCollection* pRenderDataSurfaceCollection);
86 * Constructs z-coordinate of position
87 * based on intersection point of the ray (from camera to point with coordinates (position.x, position.y)) with some triangle of the surface
91 * @remarks The algorithm consists of several steps:
92 * 1. Finds triangles from RenderData structure which are crossed by the ray (position.x, position.y)
93 * 2. Builds planes passing through 3 vertexes triangles which were found on previous step
94 * 3. Finds z-coordinate of ray with coordinates (position.x, position.y)
95 * which crosses planes which were built on previous step (for receive maximal z-coordinate)
97 virtual PropertyCast GetNearestPointsIds(Tizen::Ui::Effects::_Utils::Vec3f &position) const;
100 * Returns the ID of current bitmap for this graphical surface
105 long GetBitmapId(void) const;
108 * Sets the bitmap ID for this graphical surface
113 void SetBitmapId(long bitmapID);
116 * Provides reading access to GraphicalSurface's properties values from user's scripts
121 virtual PropertyCast GetProperty(ElementProperty propName) const;
124 * Provides writing access to GraphicalSurface's properties values of
125 * boolean type from user's scripts
130 virtual bool SetProperty(ElementProperty propName, bool PropValue);
133 * Provides writing access to GraphicalSurface's properties values of
134 * lua_Number type (double or float, or integer etc) from user's scripts
139 virtual bool SetProperty(ElementProperty propName, LUA_NUMBER propValue);
142 * Provides writing access to GraphicalSurface's properties values of
143 * Vec3f type from user's scripts
148 virtual bool SetProperty(ElementProperty propName, const Tizen::Ui::Effects::_Utils::Vec3f &propValue);
151 * Rotates model matrix by Angle around Axis or (ax, ay, az) in case Axis=AXIS_ARBITRARY
155 * @param [in] Point: Base point for rotation (the coordinates of this point are not changed)
156 * @param [in] ax, ay, az: The coordinates of axis around which rotation is performed (in case Axis=AXIS_ARBITRARY)
157 * @param [in] x0, y0, z0: Base point coordinates in case point=POINT_ARBITRARY
159 virtual bool RotateSurface(float angle, _Axis axis, _Point point,
160 float ax, float ay, float az, float x0, float y0, float z0) = 0;
163 * Scales model matrix by multipliers ax, ay, az on the relevant axes
164 * with base Point or (x0, y0, z0) in case Point = POINT_ARBITRARY
168 * @remarks Note that the base point coordinates do not change
170 virtual bool ScaleSurface(float ax, float ay, float az, _Point point,
171 float x0, float y0, float z0) = 0;
174 * Translates model matrix to position (x0, y0, z0)
179 void MoveSurface(float x0, float y0, float z0);
182 * Sets identity model matrix
187 void ResetSurfaceTransformation(void);
190 * Sets model matrix for this graphical surface
195 void SetTransformationMatrix(const Tizen::Ui::Effects::_Utils::LuaMatrix4& luaMatrix4);
199 * Rotates model matrix by Angle around Axis or (ax, ay, az) in case Axis=AXIS_ARBITRARY
203 * @remarks Differs from previous function that do not uses variable Point
204 * (it variable already taken into account in variables x0, y0, z0)
206 bool RotateSurface(float angle, _Axis axis,
207 float ax, float ay, float az, float x0, float y0, float z0);
210 * Scales model matrix by multipliers ax, ay, az on the relevant axes
211 * with base point (x0, y0, z0)
215 * @remarks Note that the base point coordinates are not changed
217 bool ScaleSurface(float ax, float ay, float az, float x0, float y0, float z0);
221 * Hidden copy constructor
226 GraphicalSurface(const GraphicalSurface& rhs);
229 * Hidden assignment operator
234 GraphicalSurface &operator=(const GraphicalSurface& rhs);
237 * Determines whether a point lies inside the triangle with vertexes which are specified by indices
241 * @param [in] pos The point Cartesian coordinates
242 * @param [in] i1, i2, i3 The triangle vertex indices
243 * (is represented in RenderData::IndicesCollection)
244 * @return Returns true if point pos lies in the triangle and false otherwise
246 bool InTriangle(const Tizen::Ui::Effects::_Utils::Vec3f& pos, short i1, short i2, short i3) const;
249 * Finds the the z-coordinate of the point pos on
250 * the plane passing through the points with indices i1, i2, i3
255 float ZInPlane(const Tizen::Ui::Effects::_Utils::Vec3f& pos, short i1, short i2, short i3) const;
259 std::unique_ptr<RenderDataSurface> _pRenderData; /**< pointer to data for rendering (for this concrete surface)*/
262 float __initTransparency; /**< initial value of surface transparency*/
263 long __initBitmapID; /**< initial value of bitmap ID*/
264 Tizen::Ui::Effects::_Utils::Mat4f __initModelMtr;
266 }; // GraphicalSurface
268 } } } } // Tizen::Ui::Effects::_Runtime
270 #endif //_FUI_EFFECTS_INTERNAL_RUNTIME_GRAPHICAL_SURFACE_H_