5 * Copyright (c) 2020 Samsung Electronics Co., Ltd.
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
11 * http://www.apache.org/licenses/LICENSE-2.0
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.
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>
27 * @brief The LookCamera class
29 * LookCamera handles user input to change the orientation of the default camera.
31 class LookCamera : public Dali::ConnectionTracker
35 * Creates an instance of LookCamera
40 * Destroys an instance of LookCamera
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
52 void Initialise(Dali::Window window, const Dali::Vector3& position, float fov, float near, float far);
55 * Retrieves actor associated with camera object
56 * @return Returns camera actor
58 Dali::CameraActor GetCameraActor();
62 * Sets up a perspective camera using Dali default camera
64 void InitialiseDefaultCamera();
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.
71 void CreateInterceptorActor();
74 * Handles onTouch signal on the 'interceptor' actor
75 * @param[in] actor Actor receiving signal
76 * @param[in] touch Touch data
78 bool OnTouch(Dali::Actor actor, const Dali::TouchEvent& touch);
81 * Handles camera tick() update
82 * @return true if continue running timer, false otherwise
87 Dali::Window mWindow; /// The window the camera belongs to
89 Dali::CameraActor mCameraActor; /// Camera actor
90 Dali::Actor mInterceptorActor; /// Actor intercepting user input
92 Dali::Timer mTimer; /// Per-frame timer
94 Dali::Vector2 mScreenLookDelta; /// Look delta vector in screen space
95 Dali::Vector2 mOldTouchLookPosition; /// Previous look vector in screen space
97 Dali::Vector2 mCameraYawPitch; /// Camera yaw-pitch angles
99 float mFovY; /// Camera field-of-view
100 float mNear; /// Near plane
101 float mFar; /// Far plane
103 Dali::Vector3 mCameraPosition; /// Current camera position ( shadowing the actor position )