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()
148 void SetPerspectiveProjection( const Size& size );
151 * @copydoc Dali::CameraActor::SetOrthographicProjection(const Vector2& size);
153 void SetOrthographicProjection( const Vector2& size );
156 * @copydoc Dali::CameraActor::SetOrthographicProjection(float left, float right, float top, float bottom, float near, float far);
158 void SetOrthographicProjection( float left, float right, float top, float bottom, float near, float far );
161 * Build a picking ray with this camera and given screen coordinates
162 * @param [in] screenCoordinates the ray passed through
163 * @param [in] viewport to use
164 * @param [out] rayOrigin for the picking ray
165 * @param [out] rayDirection for the picking ray
166 * @return true if the building was successful, false if its not possible (camera is not valid for hit testing)
168 bool BuildPickingRay( const Vector2& screenCoordinates, const Viewport& viewport, Vector4& rayOrigin, Vector4& rayDirection );
171 * Retrieve the view-matrix; This will only be valid when the actor is on-stage.
172 * @return The view-matrix.
174 const Matrix& GetViewMatrix() const;
177 * Retrieve the projection-matrix; This will only be valid when the actor is on-stage.
178 * @return The projection-matrix.
180 const Matrix& GetProjectionMatrix() const;
182 public: // properties
185 * copydoc Dali::Internal::ProxyObject
187 virtual unsigned int GetDefaultPropertyCount() const;
190 * copydoc Dali::Internal::ProxyObject
192 virtual bool IsDefaultPropertyAnimatable( Property::Index index ) const;
195 * copydoc Dali::Internal::ProxyObject
197 virtual Property::Type GetDefaultPropertyType( Property::Index index ) const;
200 * copydoc Dali::Internal::ProxyObject
202 virtual const std::string& GetDefaultPropertyName( Property::Index index ) const;
205 * @copydoc Dali::Internal::ProxyObject::GetDefaultPropertyIndex()
207 virtual Property::Index GetDefaultPropertyIndex(const std::string& name) const;
210 * copydoc Dali::Internal::ProxyObject
212 virtual void SetDefaultProperty( Property::Index index, const Property::Value& propertyValue );
215 * copydoc Dali::Internal::ProxyObject
217 virtual Property::Value GetDefaultProperty( Property::Index index ) const;
220 * copydoc Dali::Internal::ProxyObject
222 virtual bool IsDefaultPropertyWritable( Property::Index index ) const ;
225 * @copydoc Dali::Internal::ProxyObject::GetSceneObjectAnimatableProperty()
227 virtual const SceneGraph::PropertyBase* GetSceneObjectAnimatableProperty( Property::Index index ) const;
230 * @copydoc Dali::Internal::ProxyObject::GetSceneObjectInputProperty()
232 virtual const PropertyInputImpl* GetSceneObjectInputProperty( Property::Index index ) const;
237 * Protected constructor; see also CameraActor::New()
242 * A reference counted object may only be deleted by calling Unreference()
244 virtual ~CameraActor();
247 CameraAttachmentPtr mCameraAttachment;
248 static bool mFirstInstance ;
249 static DefaultPropertyLookup* mDefaultCameraActorPropertyLookup; ///< Default properties
252 } // namespace Internal
254 // Helpers for public-api forwarding methods
256 inline Internal::CameraActor& GetImplementation(Dali::CameraActor& camera)
258 DALI_ASSERT_ALWAYS(camera && "Camera handle is empty");
260 BaseObject& handle = camera.GetBaseObject();
262 return static_cast<Internal::CameraActor&>(handle);
265 inline const Internal::CameraActor& GetImplementation(const Dali::CameraActor& camera)
267 DALI_ASSERT_ALWAYS(camera && "Camera handle is empty");
269 const BaseObject& handle = camera.GetBaseObject();
271 return static_cast<const Internal::CameraActor&>(handle);
276 #endif // __DALI_INTERNAL_CAMERA_ACTOR_H__