1 #ifndef DALI_INTERNAL_CAMERA_ACTOR_H
2 #define DALI_INTERNAL_CAMERA_ACTOR_H
5 * Copyright (c) 2019 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 * Sets the reflection plane for the camera
58 * @param[in] plane Plane parameters
60 * @note plane.xyz are normal vector of the plane.
62 void SetReflectByPlane( const Vector4& plane );
65 * @copydoc Dali::CameraActor::SetTargetPosition
67 void SetTarget( const Vector3& targetPosition );
70 * @copydoc Dali::CameraActor::GetTargetPosition
72 Vector3 GetTarget() const;
75 * @copydoc Dali::CameraActor::SetType
77 void SetType( Dali::Camera::Type type );
80 * @copydoc Dali::CameraActor::GetType
82 Dali::Camera::Type GetType() const;
85 * @copydoc Dali::CameraActor::SetProjectionMode
87 void SetProjectionMode( Dali::Camera::ProjectionMode mode );
90 * @copydoc Dali::CameraActor::GetProjectionMode
92 Dali::Camera::ProjectionMode GetProjectionMode() const;
95 * @copydoc Dali::CameraActor::SetFieldOfView
97 void SetFieldOfView( float fieldOfView );
100 * @copydoc Dali::CameraActor::GetFieldOfView
102 float GetFieldOfView() const;
105 * @copydoc Dali::CameraActor::SetAspectRatio
107 void SetAspectRatio( float aspectRatio );
110 * @copydoc Dali::CameraActor::GetAspectRatio
112 float GetAspectRatio() const;
115 * @copydoc Dali::CameraActor::SetNearClippingPlane
117 void SetNearClippingPlane( float nearClippingPlane );
120 * @copydoc Dali::CameraActor::GetNearClippingPlane
122 float GetNearClippingPlane() const;
125 * @copydoc Dali::CameraActor::SetFarClippingPlane
127 void SetFarClippingPlane( float farClippingPlane );
130 * @copydoc Dali::CameraActor::GetFarClippingPlane
132 float GetFarClippingPlane() const;
135 * @param leftClippingPlane to use
137 void SetLeftClippingPlane( float leftClippingPlane );
140 * @param rightClippingPlane to use
142 void SetRightClippingPlane( float rightClippingPlane );
145 * @param topClippingPlane to use
147 void SetTopClippingPlane( float topClippingPlane );
150 * @param bottomClippingPlane to use
152 void SetBottomClippingPlane( float bottomClippingPlane );
155 * @copydoc Dali::CameraActor::SetInvertYAxis
157 void SetInvertYAxis( bool invertYAxis );
160 * @copydoc Dali::CameraActor::GetCurrentInvertYAxis
162 bool GetInvertYAxis() const;
165 * @copydoc Dali::CameraActor::SetPerspectiveProjection()
167 void SetPerspectiveProjection( const Size& size );
170 * @copydoc Dali::CameraActor::SetOrthographicProjection(const Vector2& size);
172 void SetOrthographicProjection( const Vector2& size );
175 * @copydoc Dali::CameraActor::SetOrthographicProjection(float left, float right, float top, float bottom, float near, float far);
177 void SetOrthographicProjection( float left, float right, float top, float bottom, float near, float far );
180 * Build a picking ray with this camera and given screen coordinates
181 * @param [in] screenCoordinates the ray passed through
182 * @param [in] viewport to use
183 * @param [out] rayOrigin for the picking ray
184 * @param [out] rayDirection for the picking ray
185 * @return true if the building was successful, false if its not possible (camera is not valid for hit testing)
187 bool BuildPickingRay( const Vector2& screenCoordinates, const Viewport& viewport, Vector4& rayOrigin, Vector4& rayDirection );
190 * Retrieve the view-matrix; This will only be valid when the actor is on-stage.
191 * @return The view-matrix.
193 const Matrix& GetViewMatrix() const;
196 * Retrieve the projection-matrix; This will only be valid when the actor is on-stage.
197 * @return The projection-matrix.
199 const Matrix& GetProjectionMatrix() const;
202 * Return the scene graph camera (for RenderTask)
203 * @return The scene graph camera.
205 const SceneGraph::Camera* GetCamera() const;
207 public: // properties
210 * copydoc Dali::Internal::Object::SetDefaultProperty()
212 virtual void SetDefaultProperty( Property::Index index, const Property::Value& propertyValue );
215 * copydoc Dali::Internal::Object::GetDefaultProperty()
217 virtual Property::Value GetDefaultProperty( Property::Index index ) const;
220 * copydoc Dali::Internal::Object::GetDefaultPropertyCurrentValue()
222 virtual Property::Value GetDefaultPropertyCurrentValue( Property::Index index ) const;
225 * @copydoc Dali::Internal::Object::GetSceneObjectInputProperty()
227 virtual const PropertyInputImpl* GetSceneObjectInputProperty( Property::Index index ) const;
232 * Constructor; see also CameraActor::New()
233 * @param node the scene graph node
235 CameraActor( const SceneGraph::Node& node );
238 * A reference counted object may only be deleted by calling Unreference()
240 virtual ~CameraActor();
244 * @copydoc Dali::Internal::Actor::OnInitialize()
246 void OnInitialize() override;
249 * @copydoc Dali::Internal::Actor::OnStageConnectionInternal()
251 void OnStageConnectionInternal() override;
255 const SceneGraph::Camera* mSceneObject; ///< Not owned
259 Dali::Camera::Type mType;
260 Dali::Camera::ProjectionMode mProjectionMode;
263 float mNearClippingPlane;
264 float mFarClippingPlane;
265 float mLeftClippingPlane;
266 float mRightClippingPlane;
267 float mTopClippingPlane;
268 float mBottomClippingPlane;
273 } // namespace Internal
275 // Helpers for public-api forwarding methods
277 inline Internal::CameraActor& GetImplementation(Dali::CameraActor& camera)
279 DALI_ASSERT_ALWAYS(camera && "Camera handle is empty");
281 BaseObject& handle = camera.GetBaseObject();
283 return static_cast<Internal::CameraActor&>(handle);
286 inline const Internal::CameraActor& GetImplementation(const Dali::CameraActor& camera)
288 DALI_ASSERT_ALWAYS(camera && "Camera handle is empty");
290 const BaseObject& handle = camera.GetBaseObject();
292 return static_cast<const Internal::CameraActor&>(handle);
297 #endif // DALI_INTERNAL_CAMERA_ACTOR_H