Class representing a general-purpose node an articulated scene graph.
A node in the scene graph is a node in a structured tree. A node contains information about the transformation which will apply to it and all of its children. Child nodes can have transforms of their own, which are combined with their parent's transformations. This is an abstract class - concrete classes are based on this for specific purposes, e.g. SceneNode, Bone
상속: IRenderable
예제 #1
0
파일: Node.cs 프로젝트: WolfgangSt/axiom
		protected virtual void NotifyOfNewParent( Node newParent )
		{
			parent = newParent;
			isParentNotified = false;
			NeedUpdate();
		}
예제 #2
0
파일: Node.cs 프로젝트: WolfgangSt/axiom
		/// <summary>
		///    Whether the specified node is a child of this node.
		/// </summary>
		/// <param name="node"></param>
		/// <returns></returns>
		public bool HasChild( Node node )
		{
			return node.Parent == this;
		}
예제 #3
0
 public virtual void NotifyAttached(Node parent)
 {
     this.parentNode = parent;
     if ( parent != null )
     {
         tileSceneNode = (SceneNode)( parent.CreateChild( name ) );
         //mTileNode.setPosition( (Real)mTableX , 0.0, (Real)mTableZ );
         if ( renderable != null)
             if (renderable.IsLoaded)
         {
             tileSceneNode.AttachObject( (MovableObject) renderable );
         }
         tileSceneNode.NeedUpdate();
     }
 }
예제 #4
0
파일: Node.cs 프로젝트: WolfgangSt/axiom
		/// <summary>
		///		Called by children to notify their parent that they need an update.
		/// </summary>
		/// <param name="child"></param>
		public virtual void RequestUpdate( Node child )
		{
			// if we are already going to update everything, this wont matter
			if ( needChildUpdate )
				return;

			// add to the list of children that need updating
			if ( !childrenToUpdate.ContainsKey( child.name ) )
				childrenToUpdate.Add( child );

			// request to update me
			if ( parent != null && !isParentNotified )
			{
				parent.RequestUpdate( this );
				isParentNotified = true;
			}
		}
예제 #5
0
		/// <summary>
		///		Creates a new NodeAnimationTrack automatically associated with a Node. 
		/// </summary>
        /// <param name="handle">Handle to give the track, used for accessing the track later.</param>
		/// <param name="targetNode">Node object which will be affected by this track.</param>
		/// <returns></returns>
		public NodeAnimationTrack CreateNodeTrack( ushort handle, Node targetNode )
		{
			// create a new track and set it's target
			NodeAnimationTrack track = CreateNodeTrack( handle );
			track.TargetNode = targetNode;

			return track;
		}
 /// <summary>
 ///		Internal method called to notify the object that it has been attached to a node.
 /// </summary>
 /// <param name="node">Scene node to notify.</param>
 internal virtual void NotifyAttached(Node node, bool isTagPoint)
 {
     parentNode = node;
     parentIsTagPoint = isTagPoint;
 }
예제 #7
0
 public static void QueueNeedUpdate(Node node)
 {
     // Don't queue the node more than once
     if (!node.queuedForUpdate) {
         node.queuedForUpdate = true;
         queuedUpdates.Add(node);
     }
 }
 public int IndexOf(T item)
 {
     return objectList.IndexOfKey(item.Name);
 }
예제 #9
0
 protected virtual void ParentChanged(Node oldParent, Node newParent)
 {
     if(oldParent != null) {
         oldParent.RemoveChild(this);
         if (NodeDetachedEvent != null)
             NodeDetachedEvent(this);
     }
     if (newParent != null) {
         newParent.AddChild(this);
         if (NodeAttachedEvent != null)
             NodeAttachedEvent(this);
     }
 }
예제 #10
0
        /// <summary>
        /// 
        /// </summary>
        public Node()
        {
            this.name = "Unnamed_" + nextUnnamedNodeExtNum++;

            parent = null;

            // initialize objects
            orientation = initialOrientation = derivedOrientation = Quaternion.Identity;
            position = initialPosition = derivedPosition = Vector3.Zero;
            scale = initialScale = derivedScale = Vector3.UnitScale;
            cachedTransform = Matrix4.Identity;

            inheritsScale = true;

            accumAnimWeight = 0.0f;

            childNodes = new Dictionary<string, Node>();
            childrenToUpdate = new List<Node>();

            NeedUpdate();
        }
 /// <summary>
 ///		Adds a named object to the collection.
 /// </summary>
 /// <param name="name"></param>
 /// <param name="item"></param>
 public void Add(K key, T item)
 {
     base.Add(key, item);
 }
 /// <summary>
 ///		Adds an object to the collection.
 /// </summary>
 /// <param name="item"></param>
 public void Add(T item)
 {
     Add(item.Name, item);
 }
 public void Remove(T item)
 {
     objectList.Remove(item.Name);
 }
예제 #14
0
파일: Node.cs 프로젝트: WolfgangSt/axiom
		/// <summary>
		/// Internal method to remove a child of this node, keeping it in the list of child nodes by option.
		/// Useful when enumerating the list of children while removing them too.
		/// </summary>
		/// <param name="child"></param>
		/// <param name="removeFromInternalList"></param>
		protected virtual void RemoveChild( Node child, bool removeFromInternalList )
		{
			CancelUpdate( child );
			child.NotifyOfNewParent( null );

            if (removeFromInternalList)
            {
                childNodes.Remove(child.Name);
            }
		}
예제 #15
0
 public bool HasChild(Node node)
 {
     return childNodes.ContainsValue(node);
 }
예제 #16
0
		/// <summary>
		/// Removes the specified node from the scene graph and the octree, optionally keeping it in the internal node list yet. For internal use.
		/// </summary>
		/// <remarks>
		/// Removes all of the node's child subtree from the octree, but children remain linked to parents.
		/// </remarks>
		/// <param name="child"></param>
		/// <param name="removeFromInternalList"></param>
		protected override void RemoveChild( Node child, bool removeFromInternalList )
		{
			Debug.Assert( child is OctreeNode, "node is not an octree node" );

			// remove all linked nodes from octree
			RemoveNodesFromOctree( (OctreeNode)child );

			// remove child from scene graph
			base.RemoveChild( child, removeFromInternalList );
		}
예제 #17
0
 /// <summary>
 ///    Removes the specifed node as a child of this node.
 /// </summary>
 /// <param name="child"></param>
 public virtual void RemoveChild(Node child)
 {
     if (child != null) {
         CancelUpdate(child);
         child.NotifyOfNewParent(null);
     }
     childNodes.Remove(child.Name);
 }
예제 #18
0
		/// <summary>
		///		Same as the Apply method, but applies to a specified Node instead of it's associated node.
		/// </summary>
		public void ApplyToNode( Node node, float time, float weight, bool accumulate, float scale )
		{
			this.GetInterpolatedKeyFrame( time, kf );

			if ( accumulate )
			{
				// add to existing. Weights are not relative, but treated as absolute multipliers for the animation
				Vector3 translate = kf.Translate * weight * scale;
				node.Translate( translate );

				// interpolate between not rotation and full rotation, to point weight, so 0 = no rotate, and 1 = full rotation
				Quaternion rotate = Quaternion.Slerp( weight, Quaternion.Identity, kf.Rotation );
				node.Rotate( rotate );

				// TODO: not yet sure how to modify scale for cumulative animations
				Vector3 scaleVector = kf.Scale;
				// Not sure how to modify scale for cumulative anims... leave it alone
				//scaleVector = ((Vector3::UNIT_SCALE - kf.getScale()) * weight) + Vector3::UNIT_SCALE;
				if ( scale != 1.0f && scaleVector != Vector3.UnitScale )
					scaleVector = Vector3.UnitScale + ( scaleVector - Vector3.UnitScale ) * scale;
				node.ScaleBy( scaleVector );
			}
			else
			{
				// apply using weighted transform method
				node.WeightedTransform( weight, kf.Translate, kf.Rotation, kf.Scale );
			}
		}
예제 #19
0
 public void Remove(T item)
 {
     objectList.Remove(item.Name);
 }
 /// <summary>
 ///		Internal method called to notify the object that it has been attached to a node.
 /// </summary>
 /// <param name="node">Scene node to notify.</param>
 internal virtual void NotifyAttached(Node node)
 {
     NotifyAttached(node, false);
 }
예제 #21
0
 public bool Contains(T item)
 {
     return(objectList.Contains(item.Name));
 }
 //-----------------------------------------------------------------------
 public override void NotifyAttached(Node parent, bool isTagPoint)
 {
     billboardSet.NotifyAttached(parent, isTagPoint);
 }
예제 #23
0
 public int IndexOf(T item)
 {
     return(objectList.IndexOfKey(item.Name));
 }
예제 #24
0
파일: Node.cs 프로젝트: WolfgangSt/axiom
		public static void QueueNeedUpdate( Node node )
		{
			if ( !_queuedForUpdate.Contains( node ) )
			{
				_queuedForUpdate.Add( node );
			}
		}
예제 #25
0
 /// <summary>
 ///		Adds an object to the collection.
 /// </summary>
 /// <param name="item"></param>
 public void Add(T item)
 {
     Add(item.Name, item);
 }
예제 #26
0
파일: Node.cs 프로젝트: WolfgangSt/axiom
		/// <summary>
		///		Called by children to notify their parent that they no longer need an update.
		/// </summary>
		/// <param name="child"></param>
		public virtual void CancelUpdate( Node child )
		{
			// remove this from the list of children to update
			childrenToUpdate.Remove( child.Name );

			// propogate this changed if we are done
			if ( childrenToUpdate.Count == 0 && parent != null && !needChildUpdate )
			{
				parent.CancelUpdate( this );
				isParentNotified = false;
			}
		}
예제 #27
0
 /// <summary>
 ///		Adds a named object to the collection.
 /// </summary>
 /// <param name="name"></param>
 /// <param name="item"></param>
 public void Add(K key, T item)
 {
     base.Add(key, item);
 }
예제 #28
0
파일: Node.cs 프로젝트: WolfgangSt/axiom
		/// <summary>
		///    Adds a node to the list of children of this node.
		/// </summary>
		public void AddChild( Node child )
		{
			string childName = child.Name;
			if ( child == this )
				throw new ArgumentException( string.Format( "Node '{0}' cannot be added as a child of itself.", childName ) );
			if ( childNodes.ContainsKey( childName ) )
				throw new ArgumentException( string.Format( "Node '{0}' already has a child node with the name '{1}'.", this.name, childName ) );

			child.RemoveFromParent();
			childNodes.Add( childName, child );

			child.NotifyOfNewParent( this );
		}
예제 #29
0
 public void DetachScriptNode(Node node)
 {
     if (!scriptNodeAttachments.ContainsKey(node))
     {
         log.Warn("Got DetachScriptNode without valid node");
         return;
     }
     long objectId = scriptNodeAttachments[node];
     DetachNode(objectId, true);
     scriptNodeAttachments.Remove(node);
     return;
 }
예제 #30
0
파일: Node.cs 프로젝트: WolfgangSt/axiom
		/// <summary>
		///    Removes the specifed node that is a child of this node.
		/// </summary>
		/// <param name="child"></param>
		public virtual void RemoveChild( Node child )
		{
			RemoveChild( child, true );
		}
예제 #31
0
		/// <summary>
		///		Internal constructor, to prevent direction instantiation.  Should be created
		///		via a call to the CreateTrack method of an Animation.
		/// </summary>
		public NodeAnimationTrack( Animation parent, Node target )
			: base( parent )
		{
			this.target = target;
		}
예제 #32
0
파일: Node.cs 프로젝트: WolfgangSt/axiom
			public DebugRenderable( Node parent )
			{
				_parent = parent;

				string materialName = "Axiom/Debug/AxesMat";
				_material = (Material)MaterialManager.Instance[ materialName ];
				if ( _material == null )
				{
					_material = (Material)MaterialManager.Instance.Create( materialName, ResourceGroupManager.InternalResourceGroupName );
					Pass p = _material.GetTechnique( 0 ).GetPass( 0 );
					p.LightingEnabled = false;
					//TODO: p.PolygonModeOverrideable = false;
					p.VertexColorTracking = TrackVertexColor.Ambient;
					p.SetSceneBlending( SceneBlendType.TransparentAlpha );
					p.CullingMode = CullingMode.None;
					p.DepthWrite = false;
				}

				string meshName = "Axiom/Debug/AxesMesh";
				_mesh = MeshManager.Instance[ meshName ];
				if ( _mesh == null )
				{
					ManualObject mo = new ManualObject( "tmp" );
					mo.Begin( Material.Name, OperationType.TriangleList );
					/* 3 axes, each made up of 2 of these (base plane = XY)
					 *   .------------|\
					 *   '------------|/
					 */
					mo.EstimateVertexCount( 7 * 2 * 3 );
					mo.EstimateIndexCount( 3 * 2 * 3 );
					Quaternion[] quat = new Quaternion[ 6 ];
					ColorEx[] col = new ColorEx[ 3 ];

					// x-axis
					quat[ 0 ] = Quaternion.Identity;
					quat[ 1 ] = Quaternion.FromAxes( Vector3.UnitX, Vector3.NegativeUnitZ, Vector3.UnitY );
					col[ 0 ] = ColorEx.Red;
					col[ 0 ].a = 0.8f;
					// y-axis
					quat[ 2 ] = Quaternion.FromAxes( Vector3.UnitY, Vector3.NegativeUnitX, Vector3.UnitZ );
					quat[ 3 ] = Quaternion.FromAxes( Vector3.UnitY, Vector3.UnitZ, Vector3.UnitX );
					col[ 1 ] = ColorEx.Green;
					col[ 1 ].a = 0.8f;
					// z-axis
					quat[ 4 ] = Quaternion.FromAxes( Vector3.UnitZ, Vector3.UnitY, Vector3.NegativeUnitX );
					quat[ 5 ] = Quaternion.FromAxes( Vector3.UnitZ, Vector3.UnitX, Vector3.UnitY );
					col[ 2 ] = ColorEx.Blue;
					col[ 2 ].a = 0.8f;

					Vector3[] basepos = new Vector3[ 7 ]  
										{
											// stalk
											new Vector3(0f, 0.05f, 0f), 
											new Vector3(0f, -0.05f, 0f),
											new Vector3(0.7f, -0.05f, 0f),
											new Vector3(0.7f, 0.05f, 0f),
											// head
											new Vector3(0.7f, -0.15f, 0f),
											new Vector3(1f, 0f, 0f),
											new Vector3(0.7f, 0.15f, 0f)
										};


					// vertices
					// 6 arrows
					for ( int i = 0; i < 6; ++i )
					{
						// 7 points
						for ( int p = 0; p < 7; ++p )
						{
							Vector3 pos = quat[ i ] * basepos[ p ];
							mo.Position( pos );
							mo.Color( col[ i / 2 ] );
						}
					}

					// indices
					// 6 arrows
					for ( int i = 0; i < 6; ++i )
					{
						ushort baseIndex = (ushort)( i * 7 );
						mo.Triangle( (ushort)( baseIndex + 0 ), (ushort)( baseIndex + 1 ), (ushort)( baseIndex + 2 ) );
						mo.Triangle( (ushort)( baseIndex + 0 ), (ushort)( baseIndex + 2 ), (ushort)( baseIndex + 3 ) );
						mo.Triangle( (ushort)( baseIndex + 4 ), (ushort)( baseIndex + 5 ), (ushort)( baseIndex + 6 ) );
					}

					mo.End();

					_mesh = mo.ConvertToMesh( meshName, ResourceGroupManager.InternalResourceGroupName );
				}
			}
예제 #33
0
		public NodeAnimationTrack( Animation parent )
			: base( parent )
		{
			this.target = null;
		}
예제 #34
0
		/// <summary>
		///		Internal method called to notify the object that it has been attached to a node.
		/// </summary>
		/// <param name="node">Scene node to which we are being attached.</param>
		/// <param name="isTagPoint"></param>
		internal override void NotifyAttached( Node node, bool isTagPoint )
		{
			base.NotifyAttached( node, isTagPoint );
			// Also notify LOD entities
			foreach ( var lodEntity in this.lodEntityList )
			{
				lodEntity.NotifyAttached( node, isTagPoint );
			}
		}
 public bool Contains(T item)
 {
     return objectList.Contains(item.Name);
 }