Пример #1
0
        public void Create(TextureNode root, string[] properties, Pose basePose = null)
        {
            this.ClearPoseNodes();
            this.DifferentPropertiesCount = 0;
            List <TextureNode> nodes = new List <TextureNode>();

            nodes.Add(root);
            int baseIndex = 0;

            while (nodes.Count > 0)
            {
                PoseNode pnv = new PoseNode(nodes[0]);
                foreach (string property in properties)
                {
                    if (basePose == null)
                    {
                        pnv.SetProperty(property, nodes[0].GetProperty(property));
                    }
                    else
                    {
                        if (basePose.PoseNodes.Count > baseIndex && basePose.PoseNodes[baseIndex].Properties.ContainsKey(property))
                        {
                            float val1 = (float)nodes[0].GetProperty(property);
                            float val2 = (float)basePose.PoseNodes[baseIndex].Properties[property];
                            if (val1 != val2)
                            {
                                pnv.SetProperty(property, val1);
                            }
                        }
                        else
                        {
                            throw new IndexOutOfRangeException("base pose is not correct initialized");
                        }
                    }
                }
                if (pnv.Properties.Count > 0)
                {
                    this.PoseNodes.Add(pnv);
                    this.DifferentPropertiesCount += pnv.Properties.Count;
                }
                else
                {
                    pnv.Clear();
                }
                baseIndex++;
                foreach (TreeNode n in nodes[0].Nodes)
                {
                    nodes.Add(n as TextureNode);
                }
                nodes.RemoveAt(0);
            }
        }
Пример #2
0
 public void ComplementaryAdd(Pose pose)
 {
     foreach (PoseNode poseNode in pose.PoseNodes)
     {
         PoseNode ownNode = this.GetNode(poseNode.Node);
         if (ownNode == null)
         {
             PoseNode newNode = new PoseNode(poseNode.Node);
             foreach (string property in poseNode.Properties.Keys)
             {
                 newNode.SetProperty(property, poseNode.Properties[property]);
             }
             this.PoseNodes.Add(newNode);
         }
         else
         {
             foreach (string property in poseNode.Properties.Keys)
             {
                 if (!ownNode.Properties.ContainsKey(property))
                 {
                     ownNode.SetProperty(property, poseNode.Properties[property]);
                 }
             }
         }
     }
 }
Пример #3
0
        private static void ReadProperty(XmlTextReader reader, PoseNode poseNode)
        {
            while (reader.Read())
            {
                if (reader.NodeType == XmlNodeType.EndElement)
                {
                    if (reader.Name == "PoseNode")
                    {
                        break;
                    }
                }

                if (reader.NodeType == XmlNodeType.Element)
                {
                    if (reader.Name == "Property")
                    {
                        string pName  = reader.GetAttribute(0);
                        float  pValue = float.Parse(reader.GetAttribute(1));
                        poseNode.SetProperty(pName, pValue);
                    }
                }
            }
        }
Пример #4
0
        public void MergeAdd(PoseNode poseNode, bool deepCopy = false)
        {
            PoseNode target = poseNode;

            foreach (PoseNode node in this.PoseNodes)
            {
                if (node.Node == poseNode.Node)
                {
                    target = node;
                    break;
                }
            }

            if (target == poseNode)
            {
                if (deepCopy)
                {
                    PoseNode newNode = new PoseNode(poseNode.Node);
                    foreach (string property in poseNode.Properties.Keys)
                    {
                        newNode.SetProperty(property, poseNode.Properties[property]);
                    }
                    this.PoseNodes.Add(newNode);
                }
                else
                {
                    this.PoseNodes.Add(poseNode);
                }
            }
            else
            {
                foreach (string property in poseNode.Properties.Keys)
                {
                    target.SetProperty(property, poseNode.Properties[property]);
                }
            }
        }