Updated demos to use DALi clang-format
[platform/core/uifw/dali-demo.git] / examples / rendering-skybox / look-camera.h
1 #ifndef LOOK_CAMERA_H
2 #define LOOK_CAMERA_H
3
4 /*
5  * Copyright (c) 2020 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 #include <dali/public-api/actors/camera-actor.h>
22 #include <dali/public-api/adaptor-framework/timer.h>
23 #include <dali/public-api/adaptor-framework/window.h>
24 #include <dali/public-api/math/vector2.h>
25
26 /**
27  * @brief The LookCamera class
28  *
29  * LookCamera handles user input to change the orientation of the default camera.
30  */
31 class LookCamera : public Dali::ConnectionTracker
32 {
33 public:
34   /**
35    * Creates an instance of LookCamera
36    */
37   LookCamera();
38
39   /**
40    * Destroys an instance of LookCamera
41    */
42   ~LookCamera();
43
44   /**
45    * Initialise with given position, fovY, near, far
46    * @param[in] window The window the camera is for
47    * @param[in] position Position of the camera
48    * @param[in] fovY Field of view in degrees
49    * @param[in] near Near plane
50    * @param[in] far Far Plane
51    */
52   void Initialise(Dali::Window window, const Dali::Vector3& position, float fov, float near, float far);
53
54   /**
55    * Retrieves actor associated with camera object
56    * @return Returns camera actor
57    */
58   Dali::CameraActor GetCameraActor();
59
60 private:
61   /**
62    * Sets up a perspective camera using Dali default camera
63    */
64   void InitialiseDefaultCamera();
65
66   /**
67    * Creates 'interceptor' actor. Interceptor actor is always parallel
68    * to the camera and positioned little bit in front of it in order to
69    * intercept user input.
70    */
71   void CreateInterceptorActor();
72
73   /**
74    * Handles onTouch signal on the 'interceptor' actor
75    * @param[in] actor Actor receiving signal
76    * @param[in] touch Touch data
77    */
78   bool OnTouch(Dali::Actor actor, const Dali::TouchEvent& touch);
79
80   /**
81    * Handles camera tick() update
82    * @return true if continue running timer, false otherwise
83    */
84   bool OnTick();
85
86 private:
87   Dali::Window mWindow; /// The window the camera belongs to
88
89   Dali::CameraActor mCameraActor;      /// Camera actor
90   Dali::Actor       mInterceptorActor; /// Actor intercepting user input
91
92   Dali::Timer mTimer; /// Per-frame timer
93
94   Dali::Vector2 mScreenLookDelta;      /// Look delta vector in screen space
95   Dali::Vector2 mOldTouchLookPosition; /// Previous look vector in screen space
96
97   Dali::Vector2 mCameraYawPitch; /// Camera yaw-pitch angles
98
99   float mFovY; /// Camera field-of-view
100   float mNear; /// Near plane
101   float mFar;  /// Far plane
102
103   Dali::Vector3 mCameraPosition; /// Current camera position ( shadowing the actor position )
104 };
105
106 #endif