Skybox rendering example
[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) 2017 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/math/vector2.h>
24
25 /**
26  * @brief The LookCamera class
27  *
28  * LookCamera handles user input to change the orientation of the default camera.
29  */
30 class LookCamera : public Dali::ConnectionTracker
31 {
32 public:
33
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] position Position of the camera.
47    * @param[in] fovY Field of view in degrees
48    * @param[in] near Near plane
49    * @param[in] far Far Plane
50    */
51   void Initialise( const Dali::Vector3& position, float fov, float near, float far );
52
53   /**
54    * Retrieves actor associated with camera object
55    * @return Returns camera actor
56    */
57   Dali::CameraActor GetCameraActor();
58
59 private:
60
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::TouchData& 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
88   Dali::CameraActor mCameraActor; /// Camera actor
89   Dali::Actor mInterceptorActor; /// Actor intercepting user input
90
91   Dali::Timer mTimer; /// Per-frame timer
92
93   Dali::Vector2 mScreenLookDelta; /// Look delta vector in screen space
94   Dali::Vector2 mOldTouchLookPosition; /// Previous look vector in screen space
95
96   Dali::Vector2 mCameraYawPitch; /// Camera yaw-pitch angles
97
98   float mFovY; /// Camera field-of-view
99   float mNear; /// Near plane
100   float mFar; /// Far plane
101
102   Dali::Vector3 mCameraPosition; /// Current camera position ( shadowing the actor position )
103 };
104
105 #endif