Dali 3D User Interface Engine
camera-attachment-impl.cpp
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2014 Samsung Electronics Co., Ltd.
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  *
16  */
17 
18 // CLASS HEADER
20 
21 // INTERNAL INCLUDES
26 
27 namespace Dali
28 {
29 
30 namespace Internal
31 {
32 
34 {
35  CameraAttachmentPtr attachment( new CameraAttachment( eventThreadServices ) );
36 
37  // Transfer object ownership of scene-object to message
39  AttachToNodeMessage( eventThreadServices.GetUpdateManager(), parentNode, sceneObject );
40 
41  // Keep raw pointer for message passing
42  attachment->mSceneObject = sceneObject;
43 
44  return attachment;
45 }
46 
48 : ActorAttachment( eventThreadServices ),
49  mSceneObject( NULL ),
50  mType( SceneGraph::CameraAttachment::DEFAULT_TYPE ),
51  mProjectionMode( SceneGraph::CameraAttachment::DEFAULT_MODE ),
52  mInvertYAxis( SceneGraph::CameraAttachment::DEFAULT_INVERT_Y_AXIS ),
53  mFieldOfView( SceneGraph::CameraAttachment::DEFAULT_FIELD_OF_VIEW ),
54  mAspectRatio( SceneGraph::CameraAttachment::DEFAULT_ASPECT_RATIO ),
55  mLeftClippingPlane( SceneGraph::CameraAttachment::DEFAULT_LEFT_CLIPPING_PLANE ),
56  mRightClippingPlane( SceneGraph::CameraAttachment::DEFAULT_RIGHT_CLIPPING_PLANE ),
57  mTopClippingPlane( SceneGraph::CameraAttachment::DEFAULT_TOP_CLIPPING_PLANE ),
58  mBottomClippingPlane( SceneGraph::CameraAttachment::DEFAULT_BOTTOM_CLIPPING_PLANE ),
59  mNearClippingPlane( SceneGraph::CameraAttachment::DEFAULT_NEAR_CLIPPING_PLANE ),
60  mFarClippingPlane( SceneGraph::CameraAttachment::DEFAULT_FAR_CLIPPING_PLANE ),
61  mStereoBias( SceneGraph::CameraAttachment::DEFAULT_STEREO_BIAS ),
62  mTargetPosition( SceneGraph::CameraAttachment::DEFAULT_TARGET_POSITION )
63 {
64 }
65 
67 {
68 }
69 
71 {
73 }
74 
76 {
77  if( type != mType )
78  {
79  mType = type;
80 
81  // sceneObject is being used in a separate thread; queue a message to set
83  }
84 }
85 
87 {
88  return mType;
89 }
90 
92 {
93  if( ! Equals(projectionMode, mProjectionMode) )
94  {
95  mProjectionMode = projectionMode;
96 
97  // sceneObject is being used in a separate thread; queue a message to set
99  }
100 }
101 
103 {
104  return mProjectionMode;
105 }
106 
107 void CameraAttachment::SetFieldOfView( float fieldOfView )
108 {
109  if( ! Equals(fieldOfView, mFieldOfView) )
110  {
111  mFieldOfView = fieldOfView;
112 
113  // sceneObject is being used in a separate thread; queue a message to set
115  }
116 }
117 
119 {
120  return mFieldOfView;
121 }
122 
123 void CameraAttachment::SetAspectRatio( float aspectRatio )
124 {
125  if( ! Equals(aspectRatio, mAspectRatio) )
126  {
127  mAspectRatio = aspectRatio;
128 
129  // sceneObject is being used in a separate thread; queue a message to set
131  }
132 }
133 
135 {
136  return mAspectRatio;
137 }
138 
140 {
141  if( ! Equals(stereoBias.x, mStereoBias.x ) || ! Equals(stereoBias.y, mStereoBias.y ) )
142  {
143  mStereoBias = stereoBias;
144 
145  // sceneObject is being used in a separate thread; queue a message to set
147  }
148 }
149 
151 {
152  return mStereoBias;
153 }
154 
155 void CameraAttachment::SetLeftClippingPlane( float leftClippingPlane )
156 {
157  if( ! Equals(leftClippingPlane, mLeftClippingPlane ) )
158  {
159  mLeftClippingPlane = leftClippingPlane;
160 
161  // sceneObject is being used in a separate thread; queue a message to set
163  }
164 }
165 
167 {
168  return mLeftClippingPlane;
169 }
170 
171 void CameraAttachment::SetRightClippingPlane( float rightClippingPlane )
172 {
173  if( ! Equals(rightClippingPlane, mRightClippingPlane ) )
174  {
175  mRightClippingPlane = rightClippingPlane;
176 
177  // sceneObject is being used in a separate thread; queue a message to set
179  }
180 }
181 
183 {
184  return mRightClippingPlane;
185 }
186 
187 void CameraAttachment::SetTopClippingPlane( float topClippingPlane )
188 {
189  if( ! Equals(topClippingPlane, mTopClippingPlane ) )
190  {
191  mTopClippingPlane = topClippingPlane;
192 
193  // sceneObject is being used in a separate thread; queue a message to set
195  }
196 }
197 
199 {
200  return mTopClippingPlane;
201 }
202 
203 void CameraAttachment::SetBottomClippingPlane( float bottomClippingPlane )
204 {
205  if( ! Equals(bottomClippingPlane, mBottomClippingPlane ) )
206  {
207  mBottomClippingPlane = bottomClippingPlane;
208 
209  // sceneObject is being used in a separate thread; queue a message to set
211  }
212 }
213 
215 {
216  return mBottomClippingPlane;
217 }
218 
219 void CameraAttachment::SetNearClippingPlane( float nearClippingPlane )
220 {
221  if( ! Equals(nearClippingPlane, mNearClippingPlane ) )
222  {
223  mNearClippingPlane = nearClippingPlane;
224 
225  // sceneObject is being used in a separate thread; queue a message to set
227  }
228 }
229 
231 {
232  return mNearClippingPlane;
233 }
234 
235 void CameraAttachment::SetFarClippingPlane( float farClippingPlane )
236 {
237  if( ! Equals( farClippingPlane, mFarClippingPlane ) )
238  {
239  mFarClippingPlane = farClippingPlane;
240 
241  // sceneObject is being used in a separate thread; queue a message to set
243  }
244 }
245 
247 {
248  return mFarClippingPlane;
249 }
250 
252 {
253  if( targetPosition != mTargetPosition )
254  {
255  mTargetPosition = targetPosition;
256 
258  }
259 }
260 
262 {
263  return mTargetPosition;
264 }
265 
266 void CameraAttachment::SetInvertYAxis( bool invertYAxis )
267 {
268  if( invertYAxis != mInvertYAxis )
269  {
270  mInvertYAxis = invertYAxis;
271 
272  // sceneObject is being used in a separate thread; queue a message to set
274  }
275 }
276 
278 {
279  return mInvertYAxis;
280 }
281 
283 {
284  const SceneGraph::CameraAttachment& sceneObject = *mSceneObject;
285 
286  return sceneObject.GetViewMatrix( GetEventThreadServices().GetEventBufferIndex() );
287 }
288 
290 {
291  const SceneGraph::CameraAttachment& sceneObject = *mSceneObject;
292 
293  return sceneObject.GetProjectionMatrix( GetEventThreadServices().GetEventBufferIndex() );
294 }
295 
297 {
298  const SceneGraph::CameraAttachment& sceneObject = *mSceneObject;
299 
300  return sceneObject.GetInverseViewProjectionMatrix( GetEventThreadServices().GetEventBufferIndex() );
301 }
302 
304 {
306 
307  const SceneGraph::CameraAttachment& sceneObject = *mSceneObject;
308 
309  return sceneObject.GetViewMatrix();
310 }
311 
313 {
315 
316  const SceneGraph::CameraAttachment& sceneObject = *mSceneObject;
317 
318  return sceneObject.GetProjectionMatrix();
319 }
320 
322 {
323  // do nothing
324 }
325 
327 {
328  // do nothing
329 }
330 
331 } // namespace Internal
332 
333 } // namespace Dali
Dali Docs Home
Read more about Dali