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] parentNode The node to attach a scene-object to.
55 * @return A handle to a newly allocated Dali resource.
57 static CameraAttachmentPtr New( const SceneGraph::Node& parentNode );
60 * @copydoc Dali::Camera::SetType
62 void SetType(Dali::Camera::Type type);
65 * @copydoc Dali::Camera::GetType
67 Dali::Camera::Type GetType() const;
70 * Set whether the Y Axis is inverted or not.
71 * Default camera inverts the Y axis to provide a +ve Y down LHS coordinate system
72 * Some cameras may require no inversion.
73 * @param[in] invertYAxis True if inverted, false otherwise
75 void SetInvertYAxis( bool invertYAxis );
78 * Get the setting of InvertYAxis
79 * @return True if the Y Axis is inverted.
81 bool GetInvertYAxis() const;
84 * @copydoc Dali::Camera::SetProjectionMode
86 void SetProjectionMode(Dali::Camera::ProjectionMode projectionMode);
89 * @copydoc Dali::Camera::GetProjectionMode
91 Dali::Camera::ProjectionMode GetProjectionMode() const;
94 * @copydoc Dali::Camera::SetFieldOfView
96 void SetFieldOfView(float fieldOfView);
99 * @copydoc Dali::Camera::GetFieldOfView
101 float GetFieldOfView() const;
104 * @copydoc Dali::Camera::SetAspectRatio
106 void SetAspectRatio(float aspectRatio);
109 * @copydoc Dali::Camera::GetAspectRatio
111 float GetAspectRatio() const;
114 * @copydoc Dali::Camera::SetLeftClippingPlane * Set stereo bias. The frustum offset for a 3D camera
115 * @param[in] stereoBias The frustum offset for the 3D camera
117 void SetStereoBias(float stereoBias);
120 * Get stereo bias. The frustum offset for a 3D camera
121 * @return The frustum offset for the 3D camera
123 float GetStereoBias(float stereoBias) const;
126 * @copydoc Dali::Camera::SetLeftClippingPlane
128 void SetLeftClippingPlane(float leftClippingPlane);
131 * @copydoc Dali::Camera::GetLeftClippingPlane
133 float GetLeftClippingPlane() const;
136 * @copydoc Dali::Camera::SetRightClippingPlane
138 void SetRightClippingPlane(float rightClippingPlane);
141 * @copydoc Dali::Camera::GetRightClippingPlane
143 float GetRightClippingPlane() const;
146 * @copydoc Dali::Camera::SetTopClippingPlane
148 void SetTopClippingPlane(float topClippingPlane);
151 * @copydoc Dali::Camera::GetTopClippingPlane
153 float GetTopClippingPlane() const;
156 * @copydoc Dali::Camera::SetBottomClippingPlane
158 void SetBottomClippingPlane(float bottomClippingPlane);
161 * @copydoc Dali::Camera::GetBottomClippingPlane
163 float GetBottomClippingPlane() const;
166 * @copydoc Dali::Camera::SetNearClippingPlane
168 void SetNearClippingPlane(float nearClippingPlane);
171 * @copydoc Dali::Camera::GetNearClippingPlane
173 float GetNearClippingPlane() const;
176 * @copydoc Dali::Camera::SetFarClippingPlane
178 void SetFarClippingPlane(float farClippingPlane);
181 * @copydoc Dali::Camera::GetFarClippingPlane
183 float GetFarClippingPlane() const;
186 * Set the (lookAt) target for the camera
187 * @pre The Camera owned by this object must be of the type Camera::LookAtTarget
188 * @param target Position of object we want to look at
190 void SetTargetPosition(Vector3 target);
193 * Get the (lookAt) target for the camera
194 * @return the last set target
196 Vector3 GetTargetPosition();
199 * Retrieve the view-matrix.
200 * @pre The attachment is on-stage.
201 * @return The view-matrix.
203 const Matrix& GetViewMatrix() const;
206 * Retrieve the projection-matrix.
207 * @pre The attachment is on-stage.
208 * @return The projection-matrix.
210 const Matrix& GetProjectionMatrix() const;
213 * Returns the inverse view-projection matrix
214 * @pre The attachment is on-stage.
215 * @return The inverse view-projection-matrix.
217 const Matrix& GetInverseViewProjectionMatrix() const;
220 * Retrieve the view-matrix property querying interface.
221 * @pre The attachment is on-stage.
222 * @return The view-matrix property querying interface.
224 const PropertyInputImpl* GetViewMatrixProperty() const;
227 * Retrieve the projection-matrix property querying interface.
228 * @pre The attachment is on-stage.
229 * @return The projection-matrix property querying interface.
231 const PropertyInputImpl* GetProjectionMatrixProperty() const;
234 * @copydoc Dali::Internal::ProxyObject::GetSceneObjectAnimatableProperty()
236 const SceneGraph::PropertyBase* GetSceneObjectAnimatableProperty( Property::Index index ) const;
239 * @copydoc Dali::Internal::ProxyObject::GetSceneObjectInputProperty()
241 const PropertyInputImpl* GetSceneObjectInputProperty( Property::Index index ) const;
247 * First stage construction of a CameraAttachment.
248 * @param[in] stage Used to send messages to scene-graph.
250 CameraAttachment( Stage& stage );
253 * Creates the corresponding scene-graph CameraAttachment.
254 * @return A newly allocated scene object.
256 static SceneGraph::CameraAttachment* CreateSceneObject();
259 * @copydoc Dali::Internal::ActorAttachment::OnStageConnection()
261 virtual void OnStageConnection();
264 * @copydoc Dali::Internal::ActorAttachment::OnStageDisconnection()
266 virtual void OnStageDisconnection();
271 * A reference counted object may only be deleted by calling Unreference()
273 virtual ~CameraAttachment();
277 const SceneGraph::CameraAttachment* mSceneObject; ///< Not owned
279 Dali::Camera::Type mType;
280 Dali::Camera::ProjectionMode mProjectionMode;
285 float mLeftClippingPlane;
286 float mRightClippingPlane;
287 float mTopClippingPlane;
288 float mBottomClippingPlane;
289 float mNearClippingPlane;
290 float mFarClippingPlane;
291 Vector3 mTargetPosition;
294 } // namespace Internal
298 #endif // __DALI_INTERNAL_CAMERA_ATTACHMENT_H__