1 #ifndef __DALI_INTERNAL_SCENE_GRAPH_NODE_H__
2 #define __DALI_INTERNAL_SCENE_GRAPH_NODE_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/public-api/actors/actor-enumerations.h>
23 #include <dali/public-api/actors/draw-mode.h>
24 #include <dali/public-api/math/quaternion.h>
25 #include <dali/public-api/math/math-utils.h>
26 #include <dali/public-api/math/vector3.h>
27 #include <dali/internal/common/message.h>
28 #include <dali/internal/common/event-to-update.h>
29 #include <dali/internal/update/common/animatable-property.h>
30 #include <dali/internal/update/common/double-buffered.h>
31 #include <dali/internal/update/common/property-owner.h>
32 #include <dali/internal/update/common/property-vector3.h>
33 #include <dali/internal/update/common/scene-graph-buffers.h>
34 #include <dali/internal/update/common/inherited-property.h>
35 #include <dali/integration-api/debug.h>
36 #include <dali/internal/update/nodes/node-declarations.h>
37 #include <dali/internal/update/node-attachments/node-attachment-declarations.h>
38 #include <dali/internal/render/renderers/render-data-provider.h>
46 // value types used by messages
47 template <> struct ParameterType< ColorMode > : public BasicType< ColorMode > {};
48 template <> struct ParameterType< PositionInheritanceMode > : public BasicType< PositionInheritanceMode > {};
60 * Flag whether property has changed, during the Update phase.
62 enum NodePropertyFlags
65 TransformFlag = 0x001,
70 SortModifierFlag = 0x020,
71 ChildDeletedFlag = 0x040
74 static const int AllFlags = ( ChildDeletedFlag << 1 ) - 1; // all the flags
77 * Size is not inherited.
78 * VisibleFlag is inherited so that attachments can be synchronized with nodes after they become visible
80 static const int InheritedDirtyFlags = TransformFlag | VisibleFlag | ColorFlag | OverlayFlag;
82 // Flags which require the scene renderable lists to be updated
83 static const int RenderableUpdateFlags = TransformFlag | SortModifierFlag | ChildDeletedFlag;
86 * Node is the base class for all nodes in the Scene Graph.
87 * Each node provides a transformation which applies to the node and its children.
88 * Node data is double-buffered. This allows an update thread to modify node data, without interferring
89 * with another thread reading the values from the previous update traversal.
91 class Node : public PropertyOwner, public RenderDataProvider
96 static const PositionInheritanceMode DEFAULT_POSITION_INHERITANCE_MODE;
97 static const ColorMode DEFAULT_COLOR_MODE;
102 * Construct a new Node.
112 * When a Node is marked "active" it has been disconnected, but its properties have been modified.
113 * @note An inactive Node will be skipped during the UpdateManager ResetProperties stage.
114 * @param[in] isActive True if the Node is active.
116 void SetActive( bool isActive )
118 mIsActive = isActive;
122 * Query whether the Node is active.
123 * @return True if the Node is active.
125 bool IsActive() const
131 * Called during UpdateManager::DestroyNode shortly before Node is destroyed.
138 * Query whether the node is a layer.
139 * @return True if the node is a layer.
143 return (GetLayer() != NULL);
147 * Convert a node to a layer.
148 * @return A pointer to the layer, or NULL.
150 virtual Layer* GetLayer()
158 * Attach an object to this Node; This should only be done by UpdateManager::AttachToNode.
159 * @pre The Node does not already have an attachment.
160 * @param[in] attachment The object to attach.
162 void Attach( NodeAttachment& attachment );
165 * Query the node if it has an attachment.
166 * @return True if it has an attachment.
168 bool HasAttachment() const
174 * Retreive the object attached to this node.
175 * @return The attachment.
177 NodeAttachment& GetAttachment() const
182 // Containment methods
185 * Query whether a node is the root node. Root nodes cannot have a parent node.
186 * A node becomes a root node, when it is installed by UpdateManager.
187 * @return True if the node is a root node.
195 * Set whether a node is the root node. Root nodes cannot have a parent node.
196 * This method should only be called by UpdateManager.
197 * @pre When isRoot is true, the node must not have a parent.
198 * @param[in] isRoot Whether the node is now a root node.
200 void SetRoot(bool isRoot);
203 * Retrieve the parent of a Node.
204 * @return The parent node, or NULL if the Node has not been added to the scene-graph.
212 * Retrieve the parent of a Node.
213 * @return The parent node, or NULL if the Node has not been added to the scene-graph.
215 const Node* GetParent() const
221 * Connect a node to the scene-graph.
222 * @pre A node cannot be added to itself.
223 * @pre The parent node is connected to the scene-graph.
224 * @pre The childNode does not already have a parent.
225 * @pre The childNode is not a root node.
226 * @param[in] childNode The child to add.
227 * @param[in] index to insert at, if not supplied or -1 it will be appended
230 void ConnectChild( Node* childNode, int index = -1);
233 * Disconnect a child (& its children) from the scene-graph.
234 * @pre childNode is a child of this Node.
235 * @param[in] updateBufferIndex The current update buffer index.
236 * @param[in] childNode The node to disconnect.
237 * @param[in] connectedNodes Disconnected Node attachments should be removed from here.
238 * @param[in] disconnectedNodes Disconnected Node attachments should be added here.
240 void DisconnectChild( BufferIndex updateBufferIndex, Node& childNode, std::set<Node*>& connectedNodes, std::set<Node*>& disconnectedNodes );
243 * Retrieve the children a Node.
244 * @return The container of children.
246 const NodeContainer& GetChildren() const
252 * Retrieve the children a Node.
253 * @return The container of children.
255 NodeContainer& GetChildren()
263 * Flag that one of the node values has changed in the current frame.
264 * @param[in] flag The flag to set.
266 void SetDirtyFlag(NodePropertyFlags flag)
272 * Flag that all of the node values are dirty.
274 void SetAllDirtyFlags()
276 mDirtyFlags = AllFlags;
280 * Query whether a node is dirty.
281 * @return The dirty flags
283 int GetDirtyFlags() const;
286 * Query whether a node is clean.
287 * @return True if the node is clean.
291 return ( NothingFlag == GetDirtyFlags() );
295 * Retrieve the parent-origin of the node.
296 * @return The parent-origin.
298 const Vector3& GetParentOrigin() const
300 return mParentOrigin.mValue;
304 * Sets both the local & base parent-origins of the node.
305 * @param[in] origin The new local & base parent-origins.
307 void SetParentOrigin(const Vector3& origin)
309 mParentOrigin.mValue = origin;
310 mParentOrigin.OnSet();
314 * Retrieve the anchor-point of the node.
315 * @return The anchor-point.
317 const Vector3& GetAnchorPoint() const
319 return mAnchorPoint.mValue;
323 * Sets both the local & base anchor-points of the node.
324 * @param[in] anchor The new local & base anchor-points.
326 void SetAnchorPoint(const Vector3& anchor)
328 mAnchorPoint.mValue = anchor;
329 mAnchorPoint.OnSet();
333 * Retrieve the local position of the node, relative to its parent.
334 * @param[in] bufferIndex The buffer to read from.
335 * @return The local position.
337 const Vector3& GetPosition(BufferIndex bufferIndex) const
339 return mPosition[bufferIndex];
343 * Sets both the local & base positions of the node.
344 * @param[in] updateBufferIndex The current update buffer index.
345 * @param[in] position The new local & base position.
347 void BakePosition(BufferIndex updateBufferIndex, const Vector3& position)
349 mPosition.Bake( updateBufferIndex, position );
353 * Sets the world of the node derived from the position of all its parents.
354 * @param[in] updateBufferIndex The current update buffer index.
355 * @param[in] position The world position.
357 void SetWorldPosition( BufferIndex updateBufferIndex, const Vector3& position )
359 mWorldPosition.Set( updateBufferIndex, position );
363 * Sets the position of the node derived from the position of all its parents.
364 * This method should only be called when the parent's world position is up-to-date.
365 * With a non-central anchor-point, the local rotation and scale affects the world position.
366 * Therefore the world rotation & scale must be updated before the world position.
367 * @pre The node has a parent.
368 * @param[in] updateBufferIndex The current update buffer index.
370 void InheritWorldPosition(BufferIndex updateBufferIndex)
372 DALI_ASSERT_DEBUG(mParent != NULL);
374 switch( mPositionInheritanceMode )
376 case INHERIT_PARENT_POSITION : ///@see Dali::PositionInheritanceMode for how these modes are expected to work
378 Vector3 finalPosition(-0.5f, -0.5f, -0.5f);
380 finalPosition += mParentOrigin.mValue;
381 finalPosition *= mParent->GetSize(updateBufferIndex);
382 finalPosition += mPosition[updateBufferIndex];
383 finalPosition *= mParent->GetWorldScale(updateBufferIndex);
384 const Quaternion& parentWorldRotation = mParent->GetWorldRotation(updateBufferIndex);
385 if(!parentWorldRotation.IsIdentity())
387 finalPosition *= parentWorldRotation;
390 // check if a node needs to be offsetted locally (only applies when AnchorPoint is not central)
391 // dont use operator== as that does a slower comparison (and involves function calls)
392 Vector3 localOffset(0.5f, 0.5f, 0.5f); // AnchorPoint::CENTER
393 localOffset -= mAnchorPoint.mValue;
395 if( ( fabsf( localOffset.x ) >= Math::MACHINE_EPSILON_0 ) ||
396 ( fabsf( localOffset.y ) >= Math::MACHINE_EPSILON_0 ) ||
397 ( fabsf( localOffset.z ) >= Math::MACHINE_EPSILON_0 ) )
399 localOffset *= mSize[updateBufferIndex];
401 Vector3 scale = mWorldScale[updateBufferIndex];
402 if(GetTransmitGeometryScaling())
404 // Remove geometry scaling to get back to actor scale
405 scale /= mGeometryScale;
407 // Also pick up sign of local scale
408 if (mScale[updateBufferIndex].x < 0.0f)
412 if (mScale[updateBufferIndex].y < 0.0f)
416 if (mScale[updateBufferIndex].z < 0.0f)
421 // If the anchor-point is not central, then position is affected by the local rotation & scale
422 localOffset *= scale;
423 const Quaternion& localWorldRotation = mWorldRotation[updateBufferIndex];
424 if(!localWorldRotation.IsIdentity())
426 localOffset *= localWorldRotation;
428 finalPosition += localOffset;
431 finalPosition += mParent->GetWorldPosition(updateBufferIndex);
432 mWorldPosition.Set( updateBufferIndex, finalPosition );
435 case USE_PARENT_POSITION_PLUS_LOCAL_POSITION :
437 // copy parents position plus local transform
438 mWorldPosition.Set( updateBufferIndex, mParent->GetWorldPosition(updateBufferIndex) + mPosition[updateBufferIndex] );
441 case USE_PARENT_POSITION :
443 // copy parents position
444 mWorldPosition.Set( updateBufferIndex, mParent->GetWorldPosition(updateBufferIndex) );
447 case DONT_INHERIT_POSITION :
449 // use local position as world position
450 mWorldPosition.Set( updateBufferIndex, mPosition[updateBufferIndex] );
457 * Copies the previous inherited position, if this changed in the previous frame.
458 * This method should be called instead of InheritWorldPosition i.e. if the inherited position
459 * does not need to be recalculated in the current frame.
460 * @param[in] updateBufferIndex The current update buffer index.
462 void CopyPreviousWorldPosition( BufferIndex updateBufferIndex )
464 mWorldPosition.CopyPrevious( updateBufferIndex );
468 * Retrieve the position of the node derived from the position of all its parents.
469 * @return The world position.
471 const Vector3& GetWorldPosition( BufferIndex bufferIndex ) const
473 return mWorldPosition[bufferIndex];
477 * Set the position inheritance mode.
478 * @see Dali::Actor::PositionInheritanceMode
479 * @param[in] mode The new position inheritance mode.
481 void SetPositionInheritanceMode( PositionInheritanceMode mode )
483 mPositionInheritanceMode = mode;
485 SetDirtyFlag(TransformFlag);
489 * @return The position inheritance mode.
491 PositionInheritanceMode GetPositionInheritanceMode() const
493 return mPositionInheritanceMode;
497 * Retrieve the local rotation of the node, relative to its parent.
498 * @param[in] bufferIndex The buffer to read from.
499 * @return The local rotation.
501 const Quaternion& GetRotation(BufferIndex bufferIndex) const
503 return mRotation[bufferIndex];
507 * Sets both the local & base rotations of the node.
508 * @param[in] updateBufferIndex The current update buffer index.
509 * @param[in] rotation The new local & base rotation.
511 void BakeRotation(BufferIndex updateBufferIndex, const Quaternion& rotation)
513 mRotation.Bake( updateBufferIndex, rotation );
517 * Sets the rotation of the node derived from the rotation of all its parents.
518 * @param[in] updateBufferIndex The current update buffer index.
519 * @param[in] rotation The world rotation.
521 void SetWorldRotation( BufferIndex updateBufferIndex, const Quaternion& rotation )
523 mWorldRotation.Set( updateBufferIndex, rotation );
527 * Sets the rotation of the node derived from the rotation of all its parents.
528 * This method should only be called when the parents world rotation is up-to-date.
529 * @pre The node has a parent.
530 * @param[in] updateBufferIndex The current update buffer index.
532 void InheritWorldRotation( BufferIndex updateBufferIndex )
534 DALI_ASSERT_DEBUG(mParent != NULL);
536 const Quaternion& localRotation = mRotation[updateBufferIndex];
538 if(localRotation.IsIdentity())
540 mWorldRotation.Set( updateBufferIndex, mParent->GetWorldRotation(updateBufferIndex) );
544 Quaternion finalRotation( mParent->GetWorldRotation(updateBufferIndex) );
545 finalRotation *= localRotation;
546 mWorldRotation.Set( updateBufferIndex, finalRotation );
551 * Copies the previous inherited rotation, if this changed in the previous frame.
552 * This method should be called instead of InheritWorldRotation i.e. if the inherited rotation
553 * does not need to be recalculated in the current frame.
554 * @param[in] updateBufferIndex The current update buffer index.
556 void CopyPreviousWorldRotation( BufferIndex updateBufferIndex )
558 mWorldRotation.CopyPrevious( updateBufferIndex );
562 * Retrieve the rotation of the node derived from the rotation of all its parents.
563 * @param[in] bufferIndex The buffer to read from.
564 * @return The world rotation.
566 const Quaternion& GetWorldRotation( BufferIndex bufferIndex ) const
568 return mWorldRotation[bufferIndex];
572 * Set whether the Node inherits rotation.
573 * @param[in] inherit True if the parent rotation is inherited.
575 void SetInheritRotation(bool inherit)
577 if (inherit != mInheritRotation)
579 mInheritRotation = inherit;
581 SetDirtyFlag(TransformFlag);
586 * Query whether the node inherits rotation from its parent.
587 * @return True if the parent rotation is inherited.
589 bool IsRotationInherited() const
591 return mInheritRotation;
595 * Set the initial volume of the node. Used for calculating geometry scaling
596 * as the node size is changed when transmitGeometryScaling is set to true.
598 * This property is not animatable.
600 * @param[in] volume The initial volume of this nodes meshes & children
602 void SetInitialVolume( const Vector3& volume)
604 mInitialVolume = volume;
605 SetDirtyFlag(SizeFlag);
609 * Get the initial volume. Used for calculating geometry scaling
610 * when TransmitGeometryScaling is true (i.e., the scaling is baked
611 * into the node tranform)
613 * @return The initial volume of this node and children.
615 Vector3 GetInitialVolume()
617 return mInitialVolume;
621 * Sets whether the geometry scaling should be applied to the node
622 * (In which case, set the initial scale using SetInitialVolume()).
624 * If it is applied to the node, then the attachments are not scaled,
625 * as the scaling is then already baked into the node transform.
627 * @param[in] transmitGeometryScaling true if scaling is to be applied
630 void SetTransmitGeometryScaling(bool transmitGeometryScaling)
632 mTransmitGeometryScaling = transmitGeometryScaling;
633 SetDirtyFlag(SizeFlag);
637 * Find out whether the node allows geometry scaling to be transmitted to its children.
638 * @return true if transmitted.
640 bool GetTransmitGeometryScaling() const
642 return mTransmitGeometryScaling;
646 * Retrieve the local scale of the node, relative to its parent.
647 * @param[in] bufferIndex The buffer to read from.
648 * @return The local scale.
650 const Vector3& GetScale(BufferIndex bufferIndex) const
652 return mScale[bufferIndex];
656 * Sets the scale of the node derived from the scale of all its parents and a pre-scale
657 * @param[in] updateBufferIndex The current update buffer index.
658 * @param[in] scale The world scale.
660 void SetWorldScale(BufferIndex updateBufferIndex, const Vector3& scale)
662 mWorldScale.Set( updateBufferIndex, mGeometryScale * scale );
666 * Sets the scale of the node derived from the scale of all its parents and a pre-scale.
667 * This method should only be called when the parents world scale is up-to-date.
668 * @pre The node has a parent.
669 * @param[in] updateBufferIndex The current update buffer index.
671 void InheritWorldScale(BufferIndex updateBufferIndex)
673 DALI_ASSERT_DEBUG(mParent != NULL);
675 mWorldScale.Set( updateBufferIndex, mParent->GetWorldScale(updateBufferIndex) * mGeometryScale * mScale[updateBufferIndex] );
679 * Copies the previous inherited scale, if this changed in the previous frame.
680 * This method should be called instead of InheritWorldScale i.e. if the inherited scale
681 * does not need to be recalculated in the current frame.
682 * @param[in] updateBufferIndex The current update buffer index.
684 void CopyPreviousWorldScale( BufferIndex updateBufferIndex )
686 mWorldScale.CopyPrevious( updateBufferIndex );
690 * Retrieve the scale of the node derived from the scale of all its parents.
691 * @param[in] bufferIndex The buffer to read from.
692 * @return The world scale.
694 const Vector3& GetWorldScale( BufferIndex bufferIndex ) const
696 return mWorldScale[bufferIndex];
700 * Set whether the Node inherits scale.
701 * @param inherit True if the Node inherits scale.
703 void SetInheritScale( bool inherit )
705 if( inherit != mInheritScale )
707 mInheritScale = inherit;
709 SetDirtyFlag( TransformFlag );
714 * Query whether the Node inherits scale.
715 * @return if scale is inherited
717 bool IsScaleInherited() const
719 return mInheritScale;
723 * Sets a geometry scale, calculated when TransmitGeometryScaling is true.
724 * Must only be used from render thread.
725 * @param[in] geometryScale The geometry scale value
727 void SetGeometryScale(Vector3 geometryScale)
729 mGeometryScale = geometryScale;
731 SetDirtyFlag( TransformFlag );
735 * Retrieve the geometry scale, calculated when TransmitGeometryScaling is true.
736 * @return The geometry scale value.
738 const Vector3& GetGeometryScale() const
740 return mGeometryScale;
744 * Retrieve the visibility of the node.
745 * @param[in] bufferIndex The buffer to read from.
746 * @return True if the node is visible.
748 bool IsVisible(BufferIndex bufferIndex) const
750 return mVisible[bufferIndex];
754 * Retrieves whether a node is fully visible.
755 * A node is fully visible if is visible and all its ancestors are visible.
756 * @param[in] updateBufferIndex The current update buffer index.
757 * @return True if the node is fully visible.
759 bool IsFullyVisible( BufferIndex updateBufferIndex ) const;
762 * Retrieve the opacity of the node.
763 * @param[in] bufferIndex The buffer to read from.
764 * @return The opacity.
766 float GetOpacity(BufferIndex bufferIndex) const
768 return mColor[bufferIndex].a;
772 * Retrieve the color of the node.
773 * @param[in] bufferIndex The buffer to read from.
776 const Vector4& GetColor(BufferIndex bufferIndex) const
778 return mColor[bufferIndex];
782 * Sets the color of the node derived from the color of all its parents.
783 * @param[in] color The world color.
784 * @param[in] updateBufferIndex The current update buffer index.
786 void SetWorldColor(const Vector4& color, BufferIndex updateBufferIndex)
788 mWorldColor.Set( updateBufferIndex, color );
792 * Sets the color of the node derived from the color of all its parents.
793 * This method should only be called when the parents world color is up-to-date.
794 * @pre The node has a parent.
795 * @param[in] updateBufferIndex The current update buffer index.
797 void InheritWorldColor( BufferIndex updateBufferIndex )
799 DALI_ASSERT_DEBUG(mParent != NULL);
802 if( mColorMode == USE_OWN_MULTIPLY_PARENT_ALPHA )
804 const Vector4& ownColor = mColor[updateBufferIndex];
805 mWorldColor.Set( updateBufferIndex, ownColor.r, ownColor.g, ownColor.b, ownColor.a * mParent->GetWorldColor(updateBufferIndex).a );
807 else if( mColorMode == USE_OWN_MULTIPLY_PARENT_COLOR )
809 mWorldColor.Set( updateBufferIndex, mParent->GetWorldColor(updateBufferIndex) * mColor[updateBufferIndex] );
811 else if( mColorMode == USE_PARENT_COLOR )
813 mWorldColor.Set( updateBufferIndex, mParent->GetWorldColor(updateBufferIndex) );
815 else // USE_OWN_COLOR
817 mWorldColor.Set( updateBufferIndex, mColor[updateBufferIndex] );
822 * Copies the previous inherited scale, if this changed in the previous frame.
823 * This method should be called instead of InheritWorldScale i.e. if the inherited scale
824 * does not need to be recalculated in the current frame.
825 * @param[in] updateBufferIndex The current update buffer index.
827 void CopyPreviousWorldColor( BufferIndex updateBufferIndex )
829 mWorldColor.CopyPrevious( updateBufferIndex );
833 * Retrieve the color of the node, possibly derived from the color
834 * of all its parents, depending on the value of mColorMode.
835 * @param[in] bufferIndex The buffer to read from.
836 * @return The world color.
838 const Vector4& GetWorldColor(BufferIndex bufferIndex) const
840 return mWorldColor[bufferIndex];
844 * Set the color mode. This specifies whether the Node uses its own color,
845 * or inherits its parent color.
846 * @param[in] colorMode The new color mode.
848 void SetColorMode(ColorMode colorMode)
850 mColorMode = colorMode;
852 SetDirtyFlag(ColorFlag);
856 * Retrieve the color mode.
857 * @return The color mode.
859 ColorMode GetColorMode() const
865 * Retrieve the size of the node.
866 * @param[in] bufferIndex The buffer to read from.
869 const Vector3& GetSize(BufferIndex bufferIndex) const
871 return mSize[bufferIndex];
875 * Set the world-matrix of a node, with scale + rotation + translation.
876 * Scale and rotation are centered at the origin.
877 * Translation is applied independently of the scale or rotatation axis.
878 * @param[in] updateBufferIndex The current update buffer index.
879 * @param[in] scale The scale.
880 * @param[in] rotation The rotation.
881 * @param[in] translation The translation.
883 void SetWorldMatrix( BufferIndex updateBufferIndex, const Vector3& scale, const Quaternion& rotation, const Vector3& translation )
885 mWorldMatrix.Get( updateBufferIndex ).SetTransformComponents( scale, rotation, translation );
886 mWorldMatrix.SetDirty( updateBufferIndex );
890 * Retrieve the cached world-matrix of a node.
891 * @param[in] bufferIndex The buffer to read from.
892 * @return The world-matrix.
894 const Matrix& GetWorldMatrix( BufferIndex bufferIndex ) const
896 return mWorldMatrix[ bufferIndex ];
900 * Copy previous frames world matrix
901 * @param[in] updateBufferIndex The current update buffer index.
903 void CopyPreviousWorldMatrix( BufferIndex updateBufferIndex )
905 mWorldMatrix.CopyPrevious( updateBufferIndex );
909 * Mark the node as exclusive to a single RenderTask.
910 * @param[in] renderTask The render-task, or NULL if the Node is not exclusive to a single RenderTask.
912 void SetExclusiveRenderTask( RenderTask* renderTask )
914 mExclusiveRenderTask = renderTask;
918 * Query whether the node is exclusive to a single RenderTask.
919 * @return The render-task, or NULL if the Node is not exclusive to a single RenderTask.
921 RenderTask* GetExclusiveRenderTask() const
923 return mExclusiveRenderTask;
927 * Set how the Node and its children should be drawn; see Dali::Actor::SetDrawMode() for more details.
928 * @param[in] drawMode The new draw-mode to use.
930 void SetDrawMode( const DrawMode::Type& drawMode )
932 mDrawMode = drawMode;
936 * Returns whether node is an overlay or not.
937 * @return True if node is an overlay, false otherwise.
939 DrawMode::Type GetDrawMode() const
945 * Equality operator, checks for identity, not values.
948 bool operator==( const Node* rhs ) const
958 * Set the inhibit local transform flag.@n
959 * Setting this flag will stop the node's local transform (position, scale and orientation)
960 * being applied on top of its parents transformation.
961 * @param[in] flag When true, local transformation is inhibited when calculating the world matrix.
963 void SetInhibitLocalTransform( bool flag )
965 SetDirtyFlag( TransformFlag );
966 mInhibitLocalTransform = flag;
970 * Get the inhibit local transform flag.@n
971 * See @ref SetInhibitLocalTransform
972 * @result A flag, when true, local transformation is inhibited when calculating the world matrix.
974 bool GetInhibitLocalTransform() const
976 return mInhibitLocalTransform;
982 * Set the parent of a Node.
983 * @param[in] parentNode the new parent.
985 void SetParent(Node& parentNode);
988 * Protected constructor; See also Node::New()
992 private: // from RenderDataProvider
995 * @copydoc RenderDataProvider::GetModelMatrix
997 virtual const Matrix& GetModelMatrix( unsigned int bufferId )
999 return GetWorldMatrix( bufferId );
1003 * @copydoc RenderDataProvider::GetRenderColor
1005 virtual const Vector4& GetRenderColor( unsigned int bufferId )
1007 return GetWorldColor( bufferId );
1016 Node& operator=(const Node& rhs);
1019 * @copydoc Dali::Internal::SceneGraph::PropertyOwner::ResetDefaultProperties()
1021 virtual void ResetDefaultProperties( BufferIndex updateBufferIndex );
1024 * Recursive helper to disconnect a Node and its children.
1025 * Disconnected Nodes have no parent or children.
1026 * @param[in] updateBufferIndex The current update buffer index.
1027 * @param[in] connectedNodes Disconnected Node attachments should be removed from here.
1028 * @param[in] disconnectedNodes Disconnected Node attachments should be added here.
1030 void RecursiveDisconnectFromSceneGraph( BufferIndex updateBufferIndex, std::set<Node*>& connectedNodes, std::set<Node*>& disconnectedNodes );
1032 public: // Default properties
1034 PropertyVector3 mParentOrigin; ///< Local transform; the position is relative to this. Sets the TransformFlag dirty when changed
1035 PropertyVector3 mAnchorPoint; ///< Local transform; local center of rotation. Sets the TransformFlag dirty when changed
1037 AnimatableProperty<Vector3> mSize; ///< Size is provided for layouting
1038 AnimatableProperty<Vector3> mPosition; ///< Local transform; distance between parent-origin & anchor-point
1039 AnimatableProperty<Quaternion> mRotation; ///< Local transform; rotation relative to parent node
1040 AnimatableProperty<Vector3> mScale; ///< Local transform; scale relative to parent node
1041 AnimatableProperty<bool> mVisible; ///< Visibility can be inherited from the Node hierachy
1042 AnimatableProperty<Vector4> mColor; ///< Color can be inherited from the Node hierarchy
1044 // Inherited properties; read-only from public API
1046 InheritedProperty<Vector3> mWorldPosition; ///< Full inherited position
1047 InheritedProperty<Quaternion> mWorldRotation; ///< Full inherited rotation
1048 InheritedProperty<Vector3> mWorldScale; ///< Full inherited scale
1049 InheritedProperty<Matrix> mWorldMatrix; ///< Full inherited world matrix
1050 InheritedColor mWorldColor; ///< Full inherited color
1054 Node* mParent; ///< Pointer to parent node (a child is owned by its parent)
1055 RenderTask* mExclusiveRenderTask; ///< Nodes can be marked as exclusive to a single RenderTask
1057 NodeAttachmentOwner mAttachment; ///< Optional owned attachment
1058 NodeContainer mChildren; ///< Container of children; not owned
1060 Vector3 mGeometryScale; ///< Applied before calculating world transform.
1061 Vector3 mInitialVolume; ///< Initial volume... TODO - need a better name
1063 // flags, compressed to bitfield
1064 int mDirtyFlags:10; ///< A composite set of flags for each of the Node properties
1066 bool mIsRoot:1; ///< True if the node cannot have a parent
1067 bool mInheritRotation:1; ///< Whether the parent's rotation should be inherited.
1068 bool mInheritScale:1; ///< Whether the parent's scale should be inherited.
1069 bool mTransmitGeometryScaling:1; ///< Whether geometry scaling should be applied to world transform.
1070 bool mInhibitLocalTransform:1; ///< whether local transform should be applied.
1071 bool mIsActive:1; ///< When a Node is marked "active" it has been disconnected, and its properties have not been modified
1073 DrawMode::Type mDrawMode:2; ///< How the Node and its children should be drawn
1074 PositionInheritanceMode mPositionInheritanceMode:2;///< Determines how position is inherited, 2 bits is enough
1075 ColorMode mColorMode:2; ///< Determines whether mWorldColor is inherited, 2 bits is enough
1077 // Changes scope, should be at end of class
1078 DALI_LOG_OBJECT_STRING_DECLARATION;
1081 // Messages for Node
1083 inline void SetInheritRotationMessage( EventToUpdate& eventToUpdate, const Node& node, bool inherit )
1085 typedef MessageValue1< Node, bool > LocalType;
1087 // Reserve some memory inside the message queue
1088 unsigned int* slot = eventToUpdate.ReserveMessageSlot( sizeof( LocalType ) );
1090 // Construct message in the message queue memory; note that delete should not be called on the return value
1091 new (slot) LocalType( &node, &Node::SetInheritRotation, inherit );
1094 inline void SetInitialVolumeMessage( EventToUpdate& eventToUpdate, const Node& node, const Vector3& initialVolume )
1096 typedef MessageValue1< Node, Vector3 > LocalType;
1098 // Reserve some memory inside the message queue
1099 unsigned int* slot = eventToUpdate.ReserveMessageSlot( sizeof( LocalType ) );
1101 // Construct message in the message queue memory; note that delete should not be called on the return value
1102 new (slot) LocalType( &node, &Node::SetInitialVolume, initialVolume );
1105 inline void SetTransmitGeometryScalingMessage( EventToUpdate& eventToUpdate, const Node& node, bool transmitGeometryScaling )
1107 typedef MessageValue1< Node, bool > LocalType;
1109 // Reserve some memory inside the message queue
1110 unsigned int* slot = eventToUpdate.ReserveMessageSlot( sizeof( LocalType ) );
1112 // Construct message in the message queue memory; note that delete should not be called on the return value
1113 new (slot) LocalType( &node, &Node::SetTransmitGeometryScaling, transmitGeometryScaling );
1116 inline void SetParentOriginMessage( EventToUpdate& eventToUpdate, const Node& node, const Vector3& origin )
1118 typedef MessageValue1< Node, Vector3 > LocalType;
1120 // Reserve some memory inside the message queue
1121 unsigned int* slot = eventToUpdate.ReserveMessageSlot( sizeof( LocalType ) );
1123 // Construct message in the message queue memory; note that delete should not be called on the return value
1124 new (slot) LocalType( &node, &Node::SetParentOrigin, origin );
1127 inline void SetAnchorPointMessage( EventToUpdate& eventToUpdate, const Node& node, const Vector3& anchor )
1129 typedef MessageValue1< Node, Vector3 > LocalType;
1131 // Reserve some memory inside the message queue
1132 unsigned int* slot = eventToUpdate.ReserveMessageSlot( sizeof( LocalType ) );
1134 // Construct message in the message queue memory; note that delete should not be called on the return value
1135 new (slot) LocalType( &node, &Node::SetAnchorPoint, anchor );
1138 inline void SetPositionInheritanceModeMessage( EventToUpdate& eventToUpdate, const Node& node, PositionInheritanceMode mode )
1140 typedef MessageValue1< Node, PositionInheritanceMode > LocalType;
1142 // Reserve some memory inside the message queue
1143 unsigned int* slot = eventToUpdate.ReserveMessageSlot( sizeof( LocalType ) );
1145 // Construct message in the message queue memory; note that delete should not be called on the return value
1146 new (slot) LocalType( &node, &Node::SetPositionInheritanceMode, mode );
1149 inline void SetInheritScaleMessage( EventToUpdate& eventToUpdate, const Node& node, bool inherit )
1151 typedef MessageValue1< Node, bool > LocalType;
1153 // Reserve some memory inside the message queue
1154 unsigned int* slot = eventToUpdate.ReserveMessageSlot( sizeof( LocalType ) );
1156 // Construct message in the message queue memory; note that delete should not be called on the return value
1157 new (slot) LocalType( &node, &Node::SetInheritScale, inherit );
1160 inline void SetColorModeMessage( EventToUpdate& eventToUpdate, const Node& node, ColorMode colorMode )
1162 typedef MessageValue1< Node, ColorMode > LocalType;
1164 // Reserve some memory inside the message queue
1165 unsigned int* slot = eventToUpdate.ReserveMessageSlot( sizeof( LocalType ) );
1167 // Construct message in the message queue memory; note that delete should not be called on the return value
1168 new (slot) LocalType( &node, &Node::SetColorMode, colorMode );
1171 inline void SetDrawModeMessage( EventToUpdate& eventToUpdate, const Node& node, DrawMode::Type drawMode )
1173 typedef MessageValue1< Node, DrawMode::Type > LocalType;
1175 // Reserve some memory inside the message queue
1176 unsigned int* slot = eventToUpdate.ReserveMessageSlot( sizeof( LocalType ) );
1178 // Construct message in the message queue memory; note that delete should not be called on the return value
1179 new (slot) LocalType( &node, &Node::SetDrawMode, drawMode );
1182 } // namespace SceneGraph
1184 } // namespace Internal
1188 #endif // __DALI_INTERNAL_SCENE_GRAPH_NODE_H_