1 #ifndef __DALI_INTERNAL_CAMERA_ATTACHMENT_H__
2 #define __DALI_INTERNAL_CAMERA_ATTACHMENT_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/internal/event/actor-attachments/actor-attachment-impl.h>
22 #include <dali/internal/event/actor-attachments/actor-attachment-declarations.h>
23 #include <dali/internal/update/common/animatable-property.h>
24 #include <dali/internal/update/common/inherited-property.h>
25 #include <dali/public-api/actors/camera-actor.h>
26 #include <dali/public-api/math/rect.h>
41 class CameraAttachment;
46 * An attachment for managing the properties of a camera in the scene
48 class CameraAttachment : public ActorAttachment
52 * Create an initialised CameraAttachment.
53 * @param[in] parentNode The node to attach a scene-object to.
54 * @return A handle to a newly allocated Dali resource.
56 static CameraAttachmentPtr New( const SceneGraph::Node& parentNode );
59 * @copydoc Dali::Camera::SetType
61 void SetType(Dali::Camera::Type type);
64 * @copydoc Dali::Camera::GetType
66 Dali::Camera::Type GetType() const;
69 * Set whether the Y Axis is inverted or not.
70 * Default camera inverts the Y axis to provide a +ve Y down LHS coordinate system
71 * Some cameras may require no inversion.
72 * @param[in] invertYAxis True if inverted, false otherwise
74 void SetInvertYAxis( bool invertYAxis );
77 * Get the setting of InvertYAxis
78 * @return True if the Y Axis is inverted.
80 bool GetInvertYAxis() const;
83 * @copydoc Dali::Camera::SetProjectionMode
85 void SetProjectionMode(Dali::Camera::ProjectionMode projectionMode);
88 * @copydoc Dali::Camera::GetProjectionMode
90 Dali::Camera::ProjectionMode GetProjectionMode() const;
93 * @copydoc Dali::Camera::SetFieldOfView
95 void SetFieldOfView(float fieldOfView);
98 * @copydoc Dali::Camera::GetFieldOfView
100 float GetFieldOfView() const;
103 * @copydoc Dali::Camera::SetAspectRatio
105 void SetAspectRatio(float aspectRatio);
108 * @copydoc Dali::Camera::GetAspectRatio
110 float GetAspectRatio() const;
113 * @copydoc Dali::Camera::SetLeftClippingPlane
115 void SetLeftClippingPlane(float leftClippingPlane);
118 * @copydoc Dali::Camera::GetLeftClippingPlane
120 float GetLeftClippingPlane() const;
123 * @copydoc Dali::Camera::SetRightClippingPlane
125 void SetRightClippingPlane(float rightClippingPlane);
128 * @copydoc Dali::Camera::GetRightClippingPlane
130 float GetRightClippingPlane() const;
133 * @copydoc Dali::Camera::SetTopClippingPlane
135 void SetTopClippingPlane(float topClippingPlane);
138 * @copydoc Dali::Camera::GetTopClippingPlane
140 float GetTopClippingPlane() const;
143 * @copydoc Dali::Camera::SetBottomClippingPlane
145 void SetBottomClippingPlane(float bottomClippingPlane);
148 * @copydoc Dali::Camera::GetBottomClippingPlane
150 float GetBottomClippingPlane() const;
153 * @copydoc Dali::Camera::SetNearClippingPlane
155 void SetNearClippingPlane(float nearClippingPlane);
158 * @copydoc Dali::Camera::GetNearClippingPlane
160 float GetNearClippingPlane() const;
163 * @copydoc Dali::Camera::SetFarClippingPlane
165 void SetFarClippingPlane(float farClippingPlane);
168 * @copydoc Dali::Camera::GetFarClippingPlane
170 float GetFarClippingPlane() const;
173 * Set the (lookAt) target for the camera
174 * @pre The Camera owned by this object must be of the type Camera::LookAtTarget
175 * @param target Position of object we want to look at
177 void SetTargetPosition(Vector3 target);
180 * Get the (lookAt) target for the camera
181 * @return the last set target
183 Vector3 GetTargetPosition();
186 * Retrieve the view-matrix.
187 * @pre The attachment is on-stage.
188 * @return The view-matrix.
190 const Matrix& GetViewMatrix() const;
193 * Retrieve the projection-matrix.
194 * @pre The attachment is on-stage.
195 * @return The projection-matrix.
197 const Matrix& GetProjectionMatrix() const;
200 * Returns the inverse view-projection matrix
201 * @pre The attachment is on-stage.
202 * @return The inverse view-projection-matrix.
204 const Matrix& GetInverseViewProjectionMatrix() const;
207 * Retrieve the view-matrix property querying interface.
208 * @pre The attachment is on-stage.
209 * @return The view-matrix property querying interface.
211 const PropertyInputImpl* GetViewMatrixProperty() const;
214 * Retrieve the projection-matrix property querying interface.
215 * @pre The attachment is on-stage.
216 * @return The projection-matrix property querying interface.
218 const PropertyInputImpl* GetProjectionMatrixProperty() const;
221 * @copydoc Dali::Internal::ProxyObject::GetSceneObjectAnimatableProperty()
223 const SceneGraph::PropertyBase* GetSceneObjectAnimatableProperty( Property::Index index ) const;
226 * @copydoc Dali::Internal::ProxyObject::GetSceneObjectInputProperty()
228 const PropertyInputImpl* GetSceneObjectInputProperty( Property::Index index ) const;
234 * First stage construction of a CameraAttachment.
235 * @param[in] stage Used to send messages to scene-graph.
237 CameraAttachment( Stage& stage );
240 * Creates the corresponding scene-graph CameraAttachment.
241 * @return A newly allocated scene object.
243 static SceneGraph::CameraAttachment* CreateSceneObject();
246 * @copydoc Dali::Internal::ActorAttachment::OnStageConnection()
248 virtual void OnStageConnection();
251 * @copydoc Dali::Internal::ActorAttachment::OnStageDisconnection()
253 virtual void OnStageDisconnection();
258 * A reference counted object may only be deleted by calling Unreference()
260 virtual ~CameraAttachment();
264 const SceneGraph::CameraAttachment* mSceneObject; ///< Not owned
266 Dali::Camera::Type mType;
267 Dali::Camera::ProjectionMode mProjectionMode;
271 float mLeftClippingPlane;
272 float mRightClippingPlane;
273 float mTopClippingPlane;
274 float mBottomClippingPlane;
275 float mNearClippingPlane;
276 float mFarClippingPlane;
277 Vector3 mTargetPosition;
280 } // namespace Internal
284 #endif // __DALI_INTERNAL_CAMERA_ATTACHMENT_H__