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 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/object/ref-object.h>
23 #include <dali/public-api/actors/camera-actor.h>
24 #include <dali/internal/event/actors/actor-impl.h>
25 #include <dali/internal/event/actors/actor-declarations.h>
26 #include <dali/internal/event/actor-attachments/actor-attachment-declarations.h>
35 * An actor with a conveniently pre-attached CameraAttachment.
37 class CameraActor : public Actor
42 * Create an initialised camera actor.
44 * Sets the default camera perspective projection for the given canvas size. @see SetPerspectiveProjection().
46 * @param[in] size The canvas size.
48 * @return A smart-pointer to a newly allocated camera actor.
50 static CameraActorPtr New( const Size& size );
53 * @copydoc Dali::Actor::OnInitialize
58 * Retrieve the camera attachment.
59 * @return The attachment.
61 CameraAttachment& GetCameraAttachment()
63 return *mCameraAttachment;
67 * @copydoc Dali::CameraActor::SetType
69 void SetType( Dali::Camera::Type type );
72 * @copydoc Dali::CameraActor::GetType
74 Dali::Camera::Type GetType() const;
77 * @copydoc Dali::CameraActor::SetProjectionMode
79 void SetProjectionMode( Dali::Camera::ProjectionMode mode );
82 * @copydoc Dali::CameraActor::GetProjectionMode
84 Dali::Camera::ProjectionMode GetProjectionMode() const;
87 * @copydoc Dali::CameraActor::SetFieldOfView
89 void SetFieldOfView( float fieldOfView );
92 * @copydoc Dali::CameraActor::GetFieldOfView
94 float GetFieldOfView( ) const;
97 * @copydoc Dali::CameraActor::SetAspectRatio
99 void SetAspectRatio( float aspectRatio );
102 * @copydoc Dali::CameraActor::GetAspectRatio
104 float GetAspectRatio( ) const;
107 * @copydoc Dali::CameraActor::SetNearClippingPlane
109 void SetNearClippingPlane( float nearClippingPlane );
112 * @copydoc Dali::CameraActor::GetNearClippingPlane
114 float GetNearClippingPlane( ) const;
117 * @copydoc Dali::CameraActor::SetFarClippingPlane
119 void SetFarClippingPlane( float farClippingPlane );
122 * @copydoc Dali::CameraActor::GetFarClippingPlane
124 float GetFarClippingPlane( ) const;
127 * @copydoc Dali::CameraActor::SetTargetPosition
129 void SetTargetPosition( const Vector3& targetPosition );
132 * @copydoc Dali::CameraActor::GetTargetPosition
134 Vector3 GetTargetPosition() const;
137 * @copydoc Dali::CameraActor::SetInvertYAxis
139 void SetInvertYAxis(bool invertYAxis);
142 * @copydoc Dali::CameraActor::GetCurrentInvertYAxis
144 bool GetInvertYAxis() const;
147 * @copydoc Dali::CameraActor::SetPerspectiveProjection()
148 * @param[in] stereoBias The frustum horizontal and vertical offset for stereoscopic cameras
150 void SetPerspectiveProjection( const Size& size, const Vector2& stereoBias = Vector2::ZERO );
153 * @copydoc Dali::CameraActor::SetOrthographicProjection(const Vector2& size);
155 void SetOrthographicProjection( const Vector2& size );
158 * @copydoc Dali::CameraActor::SetOrthographicProjection(float left, float right, float top, float bottom, float near, float far);
160 void SetOrthographicProjection( float left, float right, float top, float bottom, float near, float far );
163 * Build a picking ray with this camera and given screen coordinates
164 * @param [in] screenCoordinates the ray passed through
165 * @param [in] viewport to use
166 * @param [out] rayOrigin for the picking ray
167 * @param [out] rayDirection for the picking ray
168 * @return true if the building was successful, false if its not possible (camera is not valid for hit testing)
170 bool BuildPickingRay( const Vector2& screenCoordinates, const Viewport& viewport, Vector4& rayOrigin, Vector4& rayDirection );
173 * Retrieve the view-matrix; This will only be valid when the actor is on-stage.
174 * @return The view-matrix.
176 const Matrix& GetViewMatrix() const;
179 * Retrieve the projection-matrix; This will only be valid when the actor is on-stage.
180 * @return The projection-matrix.
182 const Matrix& GetProjectionMatrix() const;
184 public: // properties
187 * copydoc Dali::Internal::ProxyObject
189 virtual unsigned int GetDefaultPropertyCount() const;
192 * @copydoc Dali::Internal::ProxyObject::GetDefaultPropertyIndices()
194 virtual void GetDefaultPropertyIndices( Property::IndexContainer& indices ) const;
197 * copydoc Dali::Internal::ProxyObject
199 virtual bool IsDefaultPropertyAnimatable( Property::Index index ) const;
202 * @copydoc Dali::Internal::ProxyObject::IsDefaultPropertyAConstraintInput()
204 virtual bool IsDefaultPropertyAConstraintInput( Property::Index index ) const;
207 * copydoc Dali::Internal::ProxyObject
209 virtual Property::Type GetDefaultPropertyType( Property::Index index ) const;
212 * copydoc Dali::Internal::ProxyObject
214 virtual const char* GetDefaultPropertyName( Property::Index index ) const;
217 * @copydoc Dali::Internal::ProxyObject::GetDefaultPropertyIndex()
219 virtual Property::Index GetDefaultPropertyIndex(const std::string& name) const;
222 * copydoc Dali::Internal::ProxyObject
224 virtual void SetDefaultProperty( Property::Index index, const Property::Value& propertyValue );
227 * copydoc Dali::Internal::ProxyObject
229 virtual Property::Value GetDefaultProperty( Property::Index index ) const;
232 * copydoc Dali::Internal::ProxyObject
234 virtual bool IsDefaultPropertyWritable( Property::Index index ) const ;
237 * @copydoc Dali::Internal::ProxyObject::GetSceneObjectAnimatableProperty()
239 virtual const SceneGraph::PropertyBase* GetSceneObjectAnimatableProperty( Property::Index index ) const;
242 * @copydoc Dali::Internal::ProxyObject::GetSceneObjectInputProperty()
244 virtual const PropertyInputImpl* GetSceneObjectInputProperty( Property::Index index ) const;
249 * Protected constructor; see also CameraActor::New()
254 * A reference counted object may only be deleted by calling Unreference()
256 virtual ~CameraActor();
260 CameraAttachmentPtr mCameraAttachment;
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__