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
36 * Creates an instance of LookCamera
41 * Destroys an instance of LookCamera
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
53 void Initialise( Dali::Window window, const Dali::Vector3& position, float fov, float near, float far );
56 * Retrieves actor associated with camera object
57 * @return Returns camera actor
59 Dali::CameraActor GetCameraActor();
64 * Sets up a perspective camera using Dali default camera
66 void InitialiseDefaultCamera();
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.
73 void CreateInterceptorActor();
76 * Handles onTouch signal on the 'interceptor' actor
77 * @param[in] actor Actor receiving signal
78 * @param[in] touch Touch data
80 bool OnTouch( Dali::Actor actor, const Dali::TouchData& touch );
83 * Handles camera tick() update
84 * @return true if continue running timer, false otherwise
90 Dali::Window mWindow; /// The window the camera belongs to
92 Dali::CameraActor mCameraActor; /// Camera actor
93 Dali::Actor mInterceptorActor; /// Actor intercepting user input
95 Dali::Timer mTimer; /// Per-frame timer
97 Dali::Vector2 mScreenLookDelta; /// Look delta vector in screen space
98 Dali::Vector2 mOldTouchLookPosition; /// Previous look vector in screen space
100 Dali::Vector2 mCameraYawPitch; /// Camera yaw-pitch angles
102 float mFovY; /// Camera field-of-view
103 float mNear; /// Near plane
104 float mFar; /// Far plane
106 Dali::Vector3 mCameraPosition; /// Current camera position ( shadowing the actor position )