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 * Set stereo bias. The frustum offset for a 3D camera
114 * @param[in] stereoBias The frustum offset for the 3D camera
116 void SetStereoBias(float stereoBias);
119 * Get stereo bias. The frustum offset for a 3D camera
120 * @return The frustum offset for the 3D camera
122 float GetStereoBias(float stereoBias) const;
125 * @copydoc Dali::Camera::SetLeftClippingPlane
127 void SetLeftClippingPlane(float leftClippingPlane);
130 * @copydoc Dali::Camera::GetLeftClippingPlane
132 float GetLeftClippingPlane() const;
135 * @copydoc Dali::Camera::SetRightClippingPlane
137 void SetRightClippingPlane(float rightClippingPlane);
140 * @copydoc Dali::Camera::GetRightClippingPlane
142 float GetRightClippingPlane() const;
145 * @copydoc Dali::Camera::SetTopClippingPlane
147 void SetTopClippingPlane(float topClippingPlane);
150 * @copydoc Dali::Camera::GetTopClippingPlane
152 float GetTopClippingPlane() const;
155 * @copydoc Dali::Camera::SetBottomClippingPlane
157 void SetBottomClippingPlane(float bottomClippingPlane);
160 * @copydoc Dali::Camera::GetBottomClippingPlane
162 float GetBottomClippingPlane() const;
165 * @copydoc Dali::Camera::SetNearClippingPlane
167 void SetNearClippingPlane(float nearClippingPlane);
170 * @copydoc Dali::Camera::GetNearClippingPlane
172 float GetNearClippingPlane() const;
175 * @copydoc Dali::Camera::SetFarClippingPlane
177 void SetFarClippingPlane(float farClippingPlane);
180 * @copydoc Dali::Camera::GetFarClippingPlane
182 float GetFarClippingPlane() const;
185 * Set the (lookAt) target for the camera
186 * @pre The Camera owned by this object must be of the type Camera::LookAtTarget
187 * @param target Position of object we want to look at
189 void SetTargetPosition(Vector3 target);
192 * Get the (lookAt) target for the camera
193 * @return the last set target
195 Vector3 GetTargetPosition();
198 * Retrieve the view-matrix.
199 * @pre The attachment is on-stage.
200 * @return The view-matrix.
202 const Matrix& GetViewMatrix() const;
205 * Retrieve the projection-matrix.
206 * @pre The attachment is on-stage.
207 * @return The projection-matrix.
209 const Matrix& GetProjectionMatrix() const;
212 * Returns the inverse view-projection matrix
213 * @pre The attachment is on-stage.
214 * @return The inverse view-projection-matrix.
216 const Matrix& GetInverseViewProjectionMatrix() const;
219 * Retrieve the view-matrix property querying interface.
220 * @pre The attachment is on-stage.
221 * @return The view-matrix property querying interface.
223 const PropertyInputImpl* GetViewMatrixProperty() const;
226 * Retrieve the projection-matrix property querying interface.
227 * @pre The attachment is on-stage.
228 * @return The projection-matrix property querying interface.
230 const PropertyInputImpl* GetProjectionMatrixProperty() const;
233 * @copydoc Dali::Internal::ProxyObject::GetSceneObjectAnimatableProperty()
235 const SceneGraph::PropertyBase* GetSceneObjectAnimatableProperty( Property::Index index ) const;
238 * @copydoc Dali::Internal::ProxyObject::GetSceneObjectInputProperty()
240 const PropertyInputImpl* GetSceneObjectInputProperty( Property::Index index ) const;
246 * First stage construction of a CameraAttachment.
247 * @param[in] stage Used to send messages to scene-graph.
249 CameraAttachment( Stage& stage );
252 * Creates the corresponding scene-graph CameraAttachment.
253 * @return A newly allocated scene object.
255 static SceneGraph::CameraAttachment* CreateSceneObject();
258 * @copydoc Dali::Internal::ActorAttachment::OnStageConnection()
260 virtual void OnStageConnection();
263 * @copydoc Dali::Internal::ActorAttachment::OnStageDisconnection()
265 virtual void OnStageDisconnection();
270 * A reference counted object may only be deleted by calling Unreference()
272 virtual ~CameraAttachment();
276 const SceneGraph::CameraAttachment* mSceneObject; ///< Not owned
278 Dali::Camera::Type mType;
279 Dali::Camera::ProjectionMode mProjectionMode;
284 float mLeftClippingPlane;
285 float mRightClippingPlane;
286 float mTopClippingPlane;
287 float mBottomClippingPlane;
288 float mNearClippingPlane;
289 float mFarClippingPlane;
290 Vector3 mTargetPosition;
293 } // namespace Internal
297 #endif // __DALI_INTERNAL_CAMERA_ATTACHMENT_H__