Use Window instead of Stage
[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   /**
36    * Creates an instance of LookCamera
37    */
38   LookCamera();
39
40   /**
41    * Destroys an instance of LookCamera
42    */
43   ~LookCamera();
44
45   /**
46    * Initialise with given position, fovY, near, far
47    * @param[in] window The window the camera is for
48    * @param[in] position Position of the camera
49    * @param[in] fovY Field of view in degrees
50    * @param[in] near Near plane
51    * @param[in] far Far Plane
52    */
53   void Initialise( Dali::Window window, const Dali::Vector3& position, float fov, float near, float far );
54
55   /**
56    * Retrieves actor associated with camera object
57    * @return Returns camera actor
58    */
59   Dali::CameraActor GetCameraActor();
60
61 private:
62
63   /**
64    * Sets up a perspective camera using Dali default camera
65    */
66   void InitialiseDefaultCamera();
67
68   /**
69    * Creates 'interceptor' actor. Interceptor actor is always parallel
70    * to the camera and positioned little bit in front of it in order to
71    * intercept user input.
72    */
73   void CreateInterceptorActor();
74
75   /**
76    * Handles onTouch signal on the 'interceptor' actor
77    * @param[in] actor Actor receiving signal
78    * @param[in] touch Touch data
79    */
80   bool OnTouch( Dali::Actor actor, const Dali::TouchData& touch );
81
82   /**
83    * Handles camera tick() update
84    * @return true if continue running timer, false otherwise
85    */
86   bool OnTick();
87
88 private:
89
90   Dali::Window mWindow; /// The window the camera belongs to
91
92   Dali::CameraActor mCameraActor; /// Camera actor
93   Dali::Actor mInterceptorActor; /// Actor intercepting user input
94
95   Dali::Timer mTimer; /// Per-frame timer
96
97   Dali::Vector2 mScreenLookDelta; /// Look delta vector in screen space
98   Dali::Vector2 mOldTouchLookPosition; /// Previous look vector in screen space
99
100   Dali::Vector2 mCameraYawPitch; /// Camera yaw-pitch angles
101
102   float mFovY; /// Camera field-of-view
103   float mNear; /// Near plane
104   float mFar; /// Far plane
105
106   Dali::Vector3 mCameraPosition; /// Current camera position ( shadowing the actor position )
107 };
108
109 #endif