1 #ifndef DALI_INTERNAL_CAMERA_ACTOR_H
2 #define DALI_INTERNAL_CAMERA_ACTOR_H
5 * Copyright (c) 2018 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.
22 #include <dali/public-api/actors/camera-actor.h>
23 #include <dali/internal/event/actors/actor-impl.h>
24 #include <dali/internal/event/actors/actor-declarations.h>
38 * An actor with Camera.
40 class CameraActor : public Actor
45 * Create an initialised camera actor.
47 * Sets the default camera perspective projection for the given canvas size. @see SetPerspectiveProjection().
49 * @param[in] size The canvas size.
51 * @return A smart-pointer to a newly allocated camera actor.
53 static CameraActorPtr New( const Size& size );
56 * @copydoc Dali::CameraActor::SetTargetPosition
58 void SetTarget( const Vector3& targetPosition );
61 * @copydoc Dali::CameraActor::GetTargetPosition
63 Vector3 GetTarget() const;
66 * @copydoc Dali::CameraActor::SetType
68 void SetType( Dali::Camera::Type type );
71 * @copydoc Dali::CameraActor::GetType
73 Dali::Camera::Type GetType() const;
76 * @copydoc Dali::CameraActor::SetProjectionMode
78 void SetProjectionMode( Dali::Camera::ProjectionMode mode );
81 * @copydoc Dali::CameraActor::GetProjectionMode
83 Dali::Camera::ProjectionMode GetProjectionMode() const;
86 * @copydoc Dali::CameraActor::SetFieldOfView
88 void SetFieldOfView( float fieldOfView );
91 * @copydoc Dali::CameraActor::GetFieldOfView
93 float GetFieldOfView() const;
96 * @copydoc Dali::CameraActor::SetAspectRatio
98 void SetAspectRatio( float aspectRatio );
101 * @copydoc Dali::CameraActor::GetAspectRatio
103 float GetAspectRatio() const;
106 * @copydoc Dali::CameraActor::SetNearClippingPlane
108 void SetNearClippingPlane( float nearClippingPlane );
111 * @copydoc Dali::CameraActor::GetNearClippingPlane
113 float GetNearClippingPlane() const;
116 * @copydoc Dali::CameraActor::SetFarClippingPlane
118 void SetFarClippingPlane( float farClippingPlane );
121 * @copydoc Dali::CameraActor::GetFarClippingPlane
123 float GetFarClippingPlane() const;
126 * @param leftClippingPlane to use
128 void SetLeftClippingPlane( float leftClippingPlane );
131 * @param rightClippingPlane to use
133 void SetRightClippingPlane( float rightClippingPlane );
136 * @param topClippingPlane to use
138 void SetTopClippingPlane( float topClippingPlane );
141 * @param bottomClippingPlane to use
143 void SetBottomClippingPlane( float bottomClippingPlane );
146 * @copydoc Dali::CameraActor::SetInvertYAxis
148 void SetInvertYAxis( bool invertYAxis );
151 * @copydoc Dali::CameraActor::GetCurrentInvertYAxis
153 bool GetInvertYAxis() const;
156 * @copydoc Dali::CameraActor::SetPerspectiveProjection()
157 * @param[in] stereoBias The frustum horizontal and vertical offset for stereoscopic cameras
159 void SetPerspectiveProjection( const Size& size, const Vector2& stereoBias = Vector2::ZERO );
162 * @copydoc Dali::CameraActor::SetOrthographicProjection(const Vector2& size);
164 void SetOrthographicProjection( const Vector2& size );
167 * @copydoc Dali::CameraActor::SetOrthographicProjection(float left, float right, float top, float bottom, float near, float far);
169 void SetOrthographicProjection( float left, float right, float top, float bottom, float near, float far );
172 * Build a picking ray with this camera and given screen coordinates
173 * @param [in] screenCoordinates the ray passed through
174 * @param [in] viewport to use
175 * @param [out] rayOrigin for the picking ray
176 * @param [out] rayDirection for the picking ray
177 * @return true if the building was successful, false if its not possible (camera is not valid for hit testing)
179 bool BuildPickingRay( const Vector2& screenCoordinates, const Viewport& viewport, Vector4& rayOrigin, Vector4& rayDirection );
182 * Retrieve the view-matrix; This will only be valid when the actor is on-stage.
183 * @return The view-matrix.
185 const Matrix& GetViewMatrix() const;
188 * Retrieve the projection-matrix; This will only be valid when the actor is on-stage.
189 * @return The projection-matrix.
191 const Matrix& GetProjectionMatrix() const;
194 * Return the scene graph camera (for RenderTask)
195 * @return The scene graph camera.
197 const SceneGraph::Camera* GetCamera() const;
199 public: // properties
202 * copydoc Dali::Internal::Object::SetDefaultProperty()
204 virtual void SetDefaultProperty( Property::Index index, const Property::Value& propertyValue );
207 * copydoc Dali::Internal::Object::GetDefaultProperty()
209 virtual Property::Value GetDefaultProperty( Property::Index index ) const;
212 * copydoc Dali::Internal::Object::GetDefaultPropertyCurrentValue()
214 virtual Property::Value GetDefaultPropertyCurrentValue( Property::Index index ) const;
217 * @copydoc Dali::Internal::Object::GetSceneObjectAnimatableProperty()
219 virtual const SceneGraph::PropertyBase* GetSceneObjectAnimatableProperty( Property::Index index ) const;
222 * @copydoc Dali::Internal::Object::GetSceneObjectInputProperty()
224 virtual const PropertyInputImpl* GetSceneObjectInputProperty( Property::Index index ) const;
229 * Constructor; see also CameraActor::New()
234 * A reference counted object may only be deleted by calling Unreference()
236 virtual ~CameraActor();
240 * @copydoc Dali::Internal::Actor::OnInitialize()
242 virtual void OnInitialize();
247 const SceneGraph::Camera* mSceneObject; ///< Not owned
250 Dali::Camera::Type mType;
251 Dali::Camera::ProjectionMode mProjectionMode;
254 float mNearClippingPlane;
255 float mFarClippingPlane;
256 float mLeftClippingPlane;
257 float mRightClippingPlane;
258 float mTopClippingPlane;
259 float mBottomClippingPlane;
264 } // namespace Internal
266 // Helpers for public-api forwarding methods
268 inline Internal::CameraActor& GetImplementation(Dali::CameraActor& camera)
270 DALI_ASSERT_ALWAYS(camera && "Camera handle is empty");
272 BaseObject& handle = camera.GetBaseObject();
274 return static_cast<Internal::CameraActor&>(handle);
277 inline const Internal::CameraActor& GetImplementation(const Dali::CameraActor& camera)
279 DALI_ASSERT_ALWAYS(camera && "Camera handle is empty");
281 const BaseObject& handle = camera.GetBaseObject();
283 return static_cast<const Internal::CameraActor&>(handle);
288 #endif // DALI_INTERNAL_CAMERA_ACTOR_H