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_RuntimeGraphicalSurfaceNurbs.h
19 * @brief This is the header file for the GraphicalSurfaceNurbs class.
22 #ifndef _FUI_EFFECTS_INTERNAL_RUNTIME_GRAPHICAL_SURFACE_NURBS_H_
23 #define _FUI_EFFECTS_INTERNAL_RUNTIME_GRAPHICAL_SURFACE_NURBS_H_
25 #include <FUiEffects_PePointSurfaceNURBS.h>
26 #include "FUiEffects_RuntimeGraphicalSurface.h"
28 namespace Tizen { namespace Ui { namespace Effects { namespace _Runtime
32 * Weight assignment for every control point of NURBS
37 struct _DataPointWeight
39 float weight; /**< the weight of control point (physical point of effect model) in NURBS algorithm (influence of it on corresponding graphical point) */
40 const Tizen::Ui::Effects::_Utils::Vec3f* pPoint; /**< the pointer to physical point (control point in accordance NURBS theory)*/
44 * The vector type for storing knots for NURBS algorithm.
49 typedef std::vector<float> TypeKnots;
52 * The vector type for storing PointSurfaceNURBS pointers.
57 typedef std::vector<Tizen::Ui::Effects::_PhysicsEngine::PointSurfaceNurbs*> TypePSurfaceNURBSCollection;
60 * The vector type for storing NURBS coefficients.
65 typedef std::vector<_DataPointWeight> TypeNURBSCoeffsCollection;
68 * The vector type for storing a coordinates of graphical surface corners (as rectangle).
73 typedef std::vector<Tizen::Ui::Effects::_Utils::Vec3f*> TypeCornerGrapSurPointsCollection;
76 * The vector type for storing a coordinates of "physical" surface corners (as rectangle).
81 typedef std::vector<const Tizen::Ui::Effects::_Utils::Vec3f*> TypeCornerPhysSurPointsCollection;
84 * The type for storing vector of vectors of ID (is needed for finding nearest points algorithm).
89 typedef EffectsVector<EffectsVector<long> > TypeNearestPointsCollection;
92 * @class GraphicalSurfaceNurbs
93 * @brief This class specifies graphical surface as mesh of Graphical Points,
94 * which are controlled by NURBS algorithm
99 class GraphicalSurfaceNurbs
100 : public GraphicalSurface
104 * GraphicalSurfaceNurbs class constructor
109 GraphicalSurfaceNurbs(long objID,
117 std::unique_ptr<TypeKnots> pKnotsX_,
118 std::unique_ptr<TypeKnots> pKnotsY_,
119 float transparency_);
122 * GraphicalSurfaceNurbs class destructor
127 virtual ~GraphicalSurfaceNurbs(void);
130 * Empty function for this class (should be implemented because it is abstract in base class)
135 virtual void Calculate(float timeStep);
138 * Provides reading access to GraphicalSurfaceNurbs's properties values from user's scripts
143 virtual PropertyCast GetProperty(ElementProperty propName) const;
146 * Provides writing access to GraphicalSurfaceNurbs's properties values of
147 * boolean type from user's scripts
152 virtual bool SetProperty(ElementProperty propName, bool propValue);
155 * Provides writing access to GraphicalSurfaceNurbs's properties values of
156 * lua_Number type (floating point or integer) from user's scripts
161 virtual bool SetProperty(ElementProperty propName, LUA_NUMBER propValue);
164 * Provides writing access to GraphicalSurfaceNurbs's properties values of
165 * Vec3f type from user's scripts
170 virtual bool SetProperty(ElementProperty propName, const Tizen::Ui::Effects::_Utils::Vec3f &propValue);
173 * Initializes GraphicalSurfaceNurbs's internal parameters and resets accumulated parameters to zero
178 virtual void Initialize(void);
181 * Synchronizes the render data (vertexes and normals) and physical (PointSurfaceNURBS) points;
182 * recalculates the normals for vertexes
186 * @remarks Must be called after CalcIndices and CalcNURBSCoeffs functions
188 virtual void Update(void);
191 * It is performed after building objects for creating links between them; prepares class instance to work
195 * @remarks Specifies connections with pointSurfaceNURBS objects,
196 * performs indexes, NURBS coefficients, texture coordinates calculation,
197 * constructs render data collection
199 virtual void Construct(TypeElemSurfaceCollection* pElemSurfaceCollection, RenderDataSurfaceCollection* pRenderDataSurfaceCollection);
207 virtual ESurface GetType(void) const;
210 * Returns the vector of vectors of nearest points to specified point of graphical surface
215 virtual PropertyCast GetNearestPointsIds(Tizen::Ui::Effects::_Utils::Vec3f &position) const;
218 * Rotates model matrix by Angle around Axis or (ax, ay, az) in case Axis=AXIS_ARBITRARY
222 * @param [in] Point: Base point for rotation (the coordinates of this point are not changed)
223 * @param [in] ax, ay, az: The coordinates of axis around which rotation is performed (in case Axis=AXIS_ARBITRARY)
224 * @param [in] x0, y0, z0: Base point coordinates in case point=POINT_ARBITRARY
226 virtual bool RotateSurface(float angle, _Axis axis, _Point point,
227 float ax, float ay, float az, float x0, float y0, float z0);
230 * Scales model matrix by multipliers ax, ay, az on the relevant axes
231 * with base Point or (x0, y0, z0) in case Point = POINT_ARBITRARY
235 * @remarks Note that the base point coordinates do not change
237 virtual bool ScaleSurface(float ax, float ay, float az, _Point point,
238 float x0, float y0, float z0);
244 * Hidden copy constructor
249 GraphicalSurfaceNurbs(const GraphicalSurfaceNurbs& rhs);
252 * Hidden assignment operator
257 GraphicalSurfaceNurbs &operator=(const GraphicalSurfaceNurbs& rhs);
260 * Basis function of rational B-spline (NURBS) to the relevant direction
265 float NurbsSingleBasisFunction(long i, long order, float u, const TypeKnots& knots) const;
268 * Denominator in formula for NURBS coefficients calculation (see NURBS theory)
273 float SummaryForNurbs(float u, float w) const;
276 * NURBS coefficients calculation
280 * @remarks Is performed once in construct function
282 void CalculationNurbsCoefficients(void);
285 * Applying the threshold to NURBS coefficients:
286 * if the absolute value of some coefficient less or equals to threshold,
287 * then this coefficient is not involved in calculation (is needed for optimization)
291 * @remarks Is performed once in construct function after calculation NURBS coefficients
293 void WeightsApplyThreshold(float threshold);
296 * Calculation of triangle indices (is needed for rendering surface)
300 * @remarks Is performed once in construct function
302 void CalcIndices(void);
305 * Calculations of normals for vertexes (is needed for surface lighting)
309 * @remarks Is performed in update function after points position recalculation
311 void CalcNormals(void);
314 * Calculations of textures coordinates (is needed for surface lighting)
318 * @remarks Is performed once in construct function after update
320 void CalcTexCoords(void);
323 * Calculates the point pointOnModel base on value of _Point enumeration.
327 * @remarks If _Point is POINT_ARBITRARY then PointOnModel = (x0, y0, z0)
329 bool DefinePointOnModel(_Point point, Tizen::Ui::Effects::_Utils::Vec3f &pointOnModel,
330 float x0, float y0, float z0) const;
333 int __dimGraphX; /**< number of graphical points on X-direction*/
334 int __dimGraphY; /**< number of graphical points on Y-direction*/
336 int __dimCtrlX; /**< number of control points on X-direction*/
337 int __dimCtrlY; /**< number of control points on Y-direction*/
339 int __orderX; /**< surface order on X-direction*/
340 int __orderY; /**< surface order on Y-direction*/
342 //pointers to knots vectors (see NURBS theory)
343 //the size of these vectors is equal to the sum of order and control points quantity for corresponding direction
344 std::unique_ptr<TypeKnots> __pKnotsX;
345 std::unique_ptr<TypeKnots> __pKnotsY;
347 std::unique_ptr<TypeNURBSCoeffsCollection> __pNURBSCoeffsCollection; /**< collection of NURBS coefficients (see NURBS theory) */
349 std::unique_ptr<TypePSurfaceNURBSCollection> __pPSurfaceNURBSCollection; /**< pointers collection on control points (PointSurfaceNURBS objects) */
351 std::unique_ptr<TypeCornerGrapSurPointsCollection> __pCornerPointsGraphSurface; /**< pointers to four corner points of graphical surface */
352 std::unique_ptr<TypeCornerPhysSurPointsCollection> __pCornerPointsPhysicalSurface; /**< pointers to four corner points of "physical" surface */
354 //pointers collection for returning into scripts;
355 //[0][0] is a nearest point to specified point,
356 //[1][...] -- first zone,
357 //[2][...] -- second zone, etc.
358 std::unique_ptr<TypeNearestPointsCollection> __pNearestPointsCollection;
360 }; // GraphicalSurfaceNurbs
362 } } } } // Tizen::Ui::Effects::_Runtime
364 #endif //_FUI_EFFECTS_INTERNAL_RUNTIME_GRAPHICAL_SURFACE_NURBS_H_