Example #1
0
 /// <summary>
 /// Removes c from the list of immediate children of this LinkNode.
 /// If c was not a child, then no action is taken.
 /// </summary>
 /// <param name="c"></param>
 public void AbandonChild(LinkNode c)
 {
     if (this == c.Parent)
     {
         Children.Remove(c);
         c.Parent = null;
     }
 }
Example #2
0
        /// <summary>
        /// Adds c as a child of this LinkNode. The current spatial relatitionship between c and the LinkNode
        /// will be maintained. If c already had a parent, c will be removed from this other parent's list of children. 
        /// </summary>
        /// <param name="c"></param>
        public void AddAsChild(LinkNode c)
        {
            // If c was already part of a structure, have it removed first
            // This prevents loops and keeps the integrity of hte Children lists
            if (c.Parent != null)
                c.AbandonParent();

            c.Parent = this;
            Children.Add(c);
            WorldMatPrev = WorldMat;
            WorldMatRotPrev = WorldMatRot;
            WorldMatPosPrev = WorldMatPos;
        }
Example #3
0
        /// <summary>
        /// Adds c as a child of this LinkNode. The LinkNode c is first moved relative to its new parent 
        /// according to RelativeMat. If c already had a parent, c will be removed from this other parent's list of children. 
        /// </summary>
        /// <param name="c"></param>
        /// <param name="RelativeMat"></param>
        public void AddAsChild(LinkNode c, Matrix RelativeMat)
        {
            c.WorldMat = Matrix.CreateScale(c.WorldMatScale)
                //* Matrix.CreateFromQuaternion(WorldMatRot)
                            * Matrix.Transform(RelativeMat, WorldMatRot)
                            * Matrix.CreateTranslation(WorldMatPos);

            c.AdjustChidren(WorldMatPos, c.WorldMatRot / c.WorldMatRotPrev, c.WorldMatPos - c.WorldMatPosPrev);

            c.WorldMatPrev = c.WorldMat;
            c.WorldMatRotPrev = c.WorldMatRot;
            c.WorldMatPosPrev = c.WorldMatPos;

            AddAsChild(c);
        }
Example #4
0
 /// <summary>
 /// Sets p as Parent of this LinkNode. The LinkNode is first moved relative to its new parent 
 /// according to RelativeMat. If there was already a parent, this linknode is
 /// removed from that parent's list of children.
 /// </summary>
 /// <param name="p"></param>
 /// <param name="RelativeMat"></param>
 public void SetAsParent(LinkNode p, Matrix RelativeMat)
 {
     p.AddAsChild(this, RelativeMat);
 }
Example #5
0
 /// <summary>
 /// Sets p as Parent of this LinkNode. The current spatial relatitionship between p and the LinkNode
 /// will be maintained. If there was already a parent, this linknode is
 /// removed from that parent's list of children.
 /// </summary>
 /// <param name="p"></param>
 public void SetAsParent(LinkNode p)
 {
     p.AddAsChild(this);
 }