Esempio n. 1
0
        public override AnimNodeData Clone()
        {
            AnimNodeBlend1DData node = new AnimNodeBlend1DData();

            node.CopyFrom(this);
            return(node);
        }
Esempio n. 2
0
        public override void CopyFrom(AnimNodeData other)
        {
            if (other.NodeType != this.NodeType)
            {
                return;
            }
            base.CopyFrom(other);
            AnimNodeBlend1DData s = other as AnimNodeBlend1DData;

            this.Thresholds = (float[])s.Thresholds.Clone();
            this.Parameter  = s.Parameter;
        }
Esempio n. 3
0
        public static AnimNodeData CreateNode(AnimNodeType nodeType)
        {
            AnimNodeData result = null;

            switch (nodeType)
            {
            case AnimNodeType.Sequence:
                result = new AnimNodeSequenceData();
                break;

            case AnimNodeType.Override:
                result = new AnimNodeOverrideData();
                break;

            case AnimNodeType.Blend1D:
                result = new AnimNodeBlend1DData();
                break;

            case AnimNodeType.Blend2D:
                result = new AnimNodeBlend2DData();
                break;

            case AnimNodeType.Additive:
                result = new AnimNodeAdditiveBlendingData();
                break;

            case AnimNodeType.BlendByIndex:
                result = new AnimNodeBlendByIndexData();
                break;

            case AnimNodeType.Root:
                result = new AnimationTreeRootData();
                break;
                //case AnimNodeType.SubTree:
                //    result = new AnimNodeSubTreeData();
                //    break;
            }
            return(result);
        }
Esempio n. 4
0
 public AnimNodeBlend1DItem(AnimNodeBlend1DData data)
     : base(data)
 {
     ValidateThresholds(data.Inputs.Length);
 }
Esempio n. 5
0
        private static void CheckAnimNodeErrors()
        {
            List <string> nameList = new List <string>(_Tree.Count);

            foreach (var item in _Tree)
            {
                if (string.IsNullOrEmpty(item.Name))
                {
                    Debug.LogError("There is an AnimNode with empty name.");
                    _ErrorFound = true;
                }
                else
                {
                    if (!nameList.Contains(item.Name))
                    {
                        int count = _Tree.Count(c => c.Name == item.Name);
                        if (count > 1)
                        {
                            Debug.LogError(string.Format("There are {0} AnimNodes with same name ({1}).", count, item.Name));
                            _ErrorFound = true;
                        }
                        nameList.Add(item.Name);
                    }
                }

                if (item.NodeType == AnimNodeType.Blend1D)
                {
                    AnimNodeBlend1DData blend1D = item as AnimNodeBlend1DData;
                    for (int i = 0; i < blend1D.Thresholds.Length - 1; i++)
                    {
                        if (blend1D.Thresholds[i] >= blend1D.Thresholds[i + 1])
                        {
                            Debug.LogError(string.Format("Thresholds of AnimNode {0} are not ascendant.", item.Name));
                            _ErrorFound = true;
                            break;
                        }
                    }

                    if (string.IsNullOrEmpty(blend1D.Parameter))
                    {
                        Debug.LogError(string.Format("Parameter of AnimNode {0} is invalid.", item.Name));
                        _ErrorFound = true;
                    }
                    else if (_Tree.Parameters.Count(c => c.Name == blend1D.Parameter) == 0)
                    {
                        Debug.LogError(string.Format("Parameter of AnimNode {0} is unasigned.", item.Name));
                        _ErrorFound = true;
                    }
                }
                else if (item.NodeType == AnimNodeType.Blend2D)
                {
                    AnimNodeBlend2DData blend2D = item as AnimNodeBlend2DData;
                    if (string.IsNullOrEmpty(blend2D.Parameter1))
                    {
                        Debug.LogError(string.Format("Parameter1 of AnimNode {0} is invalid.", item.Name));
                        _ErrorFound = true;
                    }
                    else if (_Tree.Parameters.Count(c => c.Name == blend2D.Parameter1) == 0)
                    {
                        Debug.LogError(string.Format("Parameter1 of AnimNode {0} is unasigned.", item.Name));
                        _ErrorFound = true;
                    }

                    if (string.IsNullOrEmpty(blend2D.Parameter2))
                    {
                        Debug.LogError(string.Format("Parameter2 of AnimNode {0} is invalid.", item.Name));
                        _ErrorFound = true;
                    }
                    else if (_Tree.Parameters.Count(c => c.Name == blend2D.Parameter2) == 0)
                    {
                        Debug.LogError(string.Format("Parameter2 of AnimNode {0} is unasigned.", item.Name));
                        _ErrorFound = true;
                    }
                }
                else if (item.NodeType == AnimNodeType.Override)
                {
                    AnimNodeOverrideData ov = item as AnimNodeOverrideData;
                    if (string.IsNullOrEmpty(ov.Parameter))
                    {
                        Debug.LogError(string.Format("Parameter of AnimNode {0} is invalid.", item.Name));
                        _ErrorFound = true;
                    }
                    else if (_Tree.Parameters.Count(c => c.Name == ov.Parameter) == 0)
                    {
                        Debug.LogError(string.Format("Parameter of AnimNode {0} is unasigned.", item.Name));
                        _ErrorFound = true;
                    }
                }
                else if (item.NodeType == AnimNodeType.Additive)
                {
                    AnimNodeAdditiveBlendingData additive = item as AnimNodeAdditiveBlendingData;
                    if (string.IsNullOrEmpty(additive.Parameter))
                    {
                        Debug.LogError(string.Format("Parameter of AnimNode {0} is invalid.", item.Name));
                        _ErrorFound = true;
                    }
                    else if (_Tree.Parameters.Count(c => c.Name == additive.Parameter) == 0)
                    {
                        Debug.LogError(string.Format("Parameter of AnimNode {0} is unasigned.", item.Name));
                        _ErrorFound = true;
                    }
                }
                else if (item.NodeType == AnimNodeType.BlendByIndex)
                {
                    AnimNodeBlendByIndexData byIndex = item as AnimNodeBlendByIndexData;
                    if (string.IsNullOrEmpty(byIndex.Parameter))
                    {
                        Debug.LogError(string.Format("Parameter of AnimNode {0} is invalid.", item.Name));
                        _ErrorFound = true;
                    }
                    else if (_Tree.Parameters.Count(c => c.Name == byIndex.Parameter) == 0)
                    {
                        Debug.LogError(string.Format("Parameter of AnimNode {0} is unasigned.", item.Name));
                        _ErrorFound = true;
                    }
                }
                else if (item.NodeType == AnimNodeType.Sequence)
                {
                    AnimNodeSequenceData sequence = item as AnimNodeSequenceData;
                    CheckAnimationClip(sequence);
                }
                //else if (item.NodeType == AnimNodeType.SubTree)
                //{
                //    AnimationTreeNodeViewModel at = Node.Project.GetNode(((AnimNodeSubTree)item).TreeAddress) as AnimationTreeNodeViewModel;
                //    if (at == null)
                //    {
                //        Debug.LogError(string.Format("AnimationTree address of AnimNodeSubTree {0} does not exist.", item.Name));
                //        _ErrorFound = true;
                //    }
                //}
            }
            nameList.Clear();
        }