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 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/internal/event/actor-attachments/actor-attachment-impl.h>
23 #include <dali/internal/event/actor-attachments/actor-attachment-declarations.h>
24 #include <dali/internal/update/common/animatable-property.h>
25 #include <dali/internal/update/common/inherited-property.h>
26 #include <dali/public-api/actors/camera-actor.h>
27 #include <dali/public-api/math/rect.h>
42 class CameraAttachment;
47 * An attachment for managing the properties of a camera in the scene
49 class CameraAttachment : public ActorAttachment
53 * Create an initialised CameraAttachment.
54 * @param[in] eventThreadServices to use
55 * @param[in] parentNode The node to attach a scene-object to.
56 * @return A handle to a newly allocated Dali resource.
58 static CameraAttachmentPtr New( EventThreadServices& eventThreadServices, const SceneGraph::Node& parentNode );
61 * @copydoc Dali::Camera::SetType
63 void SetType(Dali::Camera::Type type);
66 * @copydoc Dali::Camera::GetType
68 Dali::Camera::Type GetType() const;
71 * Set whether the Y Axis is inverted or not.
72 * Default camera inverts the Y axis to provide a +ve Y down LHS coordinate system
73 * Some cameras may require no inversion.
74 * @param[in] invertYAxis True if inverted, false otherwise
76 void SetInvertYAxis( bool invertYAxis );
79 * Get the setting of InvertYAxis
80 * @return True if the Y Axis is inverted.
82 bool GetInvertYAxis() const;
85 * @copydoc Dali::Camera::SetProjectionMode
87 void SetProjectionMode(Dali::Camera::ProjectionMode projectionMode);
90 * @copydoc Dali::Camera::GetProjectionMode
92 Dali::Camera::ProjectionMode GetProjectionMode() const;
95 * @copydoc Dali::Camera::SetFieldOfView
97 void SetFieldOfView(float fieldOfView);
100 * @copydoc Dali::Camera::GetFieldOfView
102 float GetFieldOfView() const;
105 * @copydoc Dali::Camera::SetAspectRatio
107 void SetAspectRatio(float aspectRatio);
110 * @copydoc Dali::Camera::GetAspectRatio
112 float GetAspectRatio() const;
115 * @copydoc Dali::Camera::SetLeftClippingPlane * Set stereo bias. The frustum offset for a 3D camera
116 * @param[in] stereoBias The frustum offset for the 3D camera
118 void SetStereoBias(const Vector2& stereoBias);
121 * Get stereo bias. The frustum offset for a 3D camera
122 * @return The frustum offset for the 3D camera
124 Vector2 GetStereoBias() const;
127 * @copydoc Dali::Camera::SetLeftClippingPlane
129 void SetLeftClippingPlane(float leftClippingPlane);
132 * @copydoc Dali::Camera::GetLeftClippingPlane
134 float GetLeftClippingPlane() const;
137 * @copydoc Dali::Camera::SetRightClippingPlane
139 void SetRightClippingPlane(float rightClippingPlane);
142 * @copydoc Dali::Camera::GetRightClippingPlane
144 float GetRightClippingPlane() const;
147 * @copydoc Dali::Camera::SetTopClippingPlane
149 void SetTopClippingPlane(float topClippingPlane);
152 * @copydoc Dali::Camera::GetTopClippingPlane
154 float GetTopClippingPlane() const;
157 * @copydoc Dali::Camera::SetBottomClippingPlane
159 void SetBottomClippingPlane(float bottomClippingPlane);
162 * @copydoc Dali::Camera::GetBottomClippingPlane
164 float GetBottomClippingPlane() const;
167 * @copydoc Dali::Camera::SetNearClippingPlane
169 void SetNearClippingPlane(float nearClippingPlane);
172 * @copydoc Dali::Camera::GetNearClippingPlane
174 float GetNearClippingPlane() const;
177 * @copydoc Dali::Camera::SetFarClippingPlane
179 void SetFarClippingPlane(float farClippingPlane);
182 * @copydoc Dali::Camera::GetFarClippingPlane
184 float GetFarClippingPlane() const;
187 * Set the (lookAt) target for the camera
188 * @pre The Camera owned by this object must be of the type Camera::LookAtTarget
189 * @param target Position of object we want to look at
191 void SetTargetPosition(Vector3 target);
194 * Get the (lookAt) target for the camera
195 * @return the last set target
197 Vector3 GetTargetPosition();
200 * Retrieve the view-matrix.
201 * @pre The attachment is on-stage.
202 * @return The view-matrix.
204 const Matrix& GetViewMatrix() const;
207 * Retrieve the projection-matrix.
208 * @pre The attachment is on-stage.
209 * @return The projection-matrix.
211 const Matrix& GetProjectionMatrix() const;
214 * Returns the inverse view-projection matrix
215 * @pre The attachment is on-stage.
216 * @return The inverse view-projection-matrix.
218 const Matrix& GetInverseViewProjectionMatrix() const;
221 * Retrieve the view-matrix property querying interface.
222 * @pre The attachment is on-stage.
223 * @return The view-matrix property querying interface.
225 const PropertyInputImpl* GetViewMatrixProperty() const;
228 * Retrieve the projection-matrix property querying interface.
229 * @pre The attachment is on-stage.
230 * @return The projection-matrix property querying interface.
232 const PropertyInputImpl* GetProjectionMatrixProperty() const;
235 * @copydoc Dali::Internal::Object::GetSceneObjectAnimatableProperty()
237 const SceneGraph::PropertyBase* GetSceneObjectAnimatableProperty( Property::Index index ) const;
240 * @copydoc Dali::Internal::Object::GetSceneObjectInputProperty()
242 const PropertyInputImpl* GetSceneObjectInputProperty( Property::Index index ) const;
248 * First stage construction of a CameraAttachment.
249 * @param[in] eventThreadServices Used for messaging to and reading from scene-graph.
251 CameraAttachment( EventThreadServices& eventThreadServices );
254 * Creates the corresponding scene-graph CameraAttachment.
255 * @return A newly allocated scene object.
257 static SceneGraph::CameraAttachment* CreateSceneObject();
260 * @copydoc Dali::Internal::ActorAttachment::OnStageConnection()
262 virtual void OnStageConnection();
265 * @copydoc Dali::Internal::ActorAttachment::OnStageDisconnection()
267 virtual void OnStageDisconnection();
272 * A reference counted object may only be deleted by calling Unreference()
274 virtual ~CameraAttachment();
278 const SceneGraph::CameraAttachment* mSceneObject; ///< Not owned
280 Dali::Camera::Type mType;
281 Dali::Camera::ProjectionMode mProjectionMode;
285 float mLeftClippingPlane;
286 float mRightClippingPlane;
287 float mTopClippingPlane;
288 float mBottomClippingPlane;
289 float mNearClippingPlane;
290 float mFarClippingPlane;
292 Vector3 mTargetPosition;
295 } // namespace Internal
299 #endif // __DALI_INTERNAL_CAMERA_ATTACHMENT_H__