1 #ifndef __DALI_INTERNAL_CAMERA_ACTOR_H__
2 #define __DALI_INTERNAL_CAMERA_ACTOR_H__
5 // Copyright (c) 2014 Samsung Electronics Co., Ltd.
7 // Licensed under the Flora License, Version 1.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://floralicense.org/license/
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/object/ref-object.h>
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>
25 #include <dali/internal/event/actor-attachments/actor-attachment-declarations.h>
34 * An actor with a conveniently pre-attached CameraAttachment.
36 class CameraActor : public Actor
41 * Create an initialised camera actor.
43 * Sets the default camera perspective projection for the given canvas size. @see SetPerspectiveProjection().
45 * @param[in] size The canvas size.
47 * @return A smart-pointer to a newly allocated camera actor.
49 static CameraActorPtr New( const Size& size );
52 * @copydoc Dali::Actor::OnInitialize
57 * Retrieve the camera attachment.
58 * @return The attachment.
60 CameraAttachment& GetCameraAttachment()
62 return *mCameraAttachment;
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 * @copydoc Dali::CameraActor::SetTargetPosition
128 void SetTargetPosition( const Vector3& targetPosition );
131 * @copydoc Dali::CameraActor::GetTargetPosition
133 Vector3 GetTargetPosition() const;
136 * @copydoc Dali::CameraActor::SetInvertYAxis
138 void SetInvertYAxis(bool invertYAxis);
141 * @copydoc Dali::CameraActor::GetCurrentInvertYAxis
143 bool GetInvertYAxis() const;
146 * @copydoc Dali::CameraActor::SetPerspectiveProjection()
147 * @param[in] stereoBias The frustum horizontal offset for stereoscopic cameras
149 void SetPerspectiveProjection( const Size& size, float stereoBias = 0.0f );
152 * @copydoc Dali::CameraActor::SetOrthographicProjection(const Vector2& size);
154 void SetOrthographicProjection( const Vector2& size );
157 * @copydoc Dali::CameraActor::SetOrthographicProjection(float left, float right, float top, float bottom, float near, float far);
159 void SetOrthographicProjection( float left, float right, float top, float bottom, float near, float far );
162 * Build a picking ray with this camera and given screen coordinates
163 * @param [in] screenCoordinates the ray passed through
164 * @param [in] viewport to use
165 * @param [out] rayOrigin for the picking ray
166 * @param [out] rayDirection for the picking ray
167 * @return true if the building was successful, false if its not possible (camera is not valid for hit testing)
169 bool BuildPickingRay( const Vector2& screenCoordinates, const Viewport& viewport, Vector4& rayOrigin, Vector4& rayDirection );
172 * Retrieve the view-matrix; This will only be valid when the actor is on-stage.
173 * @return The view-matrix.
175 const Matrix& GetViewMatrix() const;
178 * Retrieve the projection-matrix; This will only be valid when the actor is on-stage.
179 * @return The projection-matrix.
181 const Matrix& GetProjectionMatrix() const;
183 public: // properties
186 * copydoc Dali::Internal::ProxyObject
188 virtual unsigned int GetDefaultPropertyCount() const;
191 * @copydoc Dali::Internal::ProxyObject::GetDefaultPropertyIndices()
193 virtual void GetDefaultPropertyIndices( Property::IndexContainer& indices ) const;
196 * copydoc Dali::Internal::ProxyObject
198 virtual bool IsDefaultPropertyAnimatable( Property::Index index ) const;
201 * @copydoc Dali::Internal::ProxyObject::IsDefaultPropertyAConstraintInput()
203 virtual bool IsDefaultPropertyAConstraintInput( Property::Index index ) const;
206 * copydoc Dali::Internal::ProxyObject
208 virtual Property::Type GetDefaultPropertyType( Property::Index index ) const;
211 * copydoc Dali::Internal::ProxyObject
213 virtual const std::string& GetDefaultPropertyName( Property::Index index ) const;
216 * @copydoc Dali::Internal::ProxyObject::GetDefaultPropertyIndex()
218 virtual Property::Index GetDefaultPropertyIndex(const std::string& name) const;
221 * copydoc Dali::Internal::ProxyObject
223 virtual void SetDefaultProperty( Property::Index index, const Property::Value& propertyValue );
226 * copydoc Dali::Internal::ProxyObject
228 virtual Property::Value GetDefaultProperty( Property::Index index ) const;
231 * copydoc Dali::Internal::ProxyObject
233 virtual bool IsDefaultPropertyWritable( Property::Index index ) const ;
236 * @copydoc Dali::Internal::ProxyObject::GetSceneObjectAnimatableProperty()
238 virtual const SceneGraph::PropertyBase* GetSceneObjectAnimatableProperty( Property::Index index ) const;
241 * @copydoc Dali::Internal::ProxyObject::GetSceneObjectInputProperty()
243 virtual const PropertyInputImpl* GetSceneObjectInputProperty( Property::Index index ) const;
248 * Protected constructor; see also CameraActor::New()
253 * A reference counted object may only be deleted by calling Unreference()
255 virtual ~CameraActor();
258 CameraAttachmentPtr mCameraAttachment;
259 static bool mFirstInstance ;
260 static DefaultPropertyLookup* mDefaultCameraActorPropertyLookup; ///< Default properties
263 } // namespace Internal
265 // Helpers for public-api forwarding methods
267 inline Internal::CameraActor& GetImplementation(Dali::CameraActor& camera)
269 DALI_ASSERT_ALWAYS(camera && "Camera handle is empty");
271 BaseObject& handle = camera.GetBaseObject();
273 return static_cast<Internal::CameraActor&>(handle);
276 inline const Internal::CameraActor& GetImplementation(const Dali::CameraActor& camera)
278 DALI_ASSERT_ALWAYS(camera && "Camera handle is empty");
280 const BaseObject& handle = camera.GetBaseObject();
282 return static_cast<const Internal::CameraActor&>(handle);
287 #endif // __DALI_INTERNAL_CAMERA_ACTOR_H__