示例#1
0
        /// <summary>
        /// init data
        /// </summary>
        /// <param name="bvh">bone</param>
        /// <param name="content">content</param>
        public BVHNode(BVHNodeString bvh, BVHContent content, int ParentLevel)
        {
            #region Set fields value.
            this.Level = ++ParentLevel;
            this.Name  = StringProccesing.CleanUp(bvh.Name);
            this.Id    = content.Skeleton.BoneCount;
            #endregion

            content.Skeleton.BoneCount++;

            #region Calculate offset and channels.
            this.Offset = StringProccesing.StringToVector3(bvh.Offset.Replace("OFFSET", ""));

            this.Channels = StringToChannels(
                bvh.Channels.Remove(bvh.Channels.IndexOf("CHANNELS"),
                                    "CHANNELS".Length + 2));
            #endregion

            #region Add this bones channel to content channel collection.
            for (int i = 0; i < Channels.Length; i++)
            {
                Channels[i].pifl = content.Skeleton.BoneChannels.Count;
                content.Skeleton.BoneChannels.Add(Channels[i]);
            }
            #endregion

            #region Set EndsiteOffset if needed.
            if (bvh.EndSiteOffset != null)
            {
                EndSiteOffset = StringProccesing.StringToVector3(bvh.EndSiteOffset.Replace("OFFSET", ""));
            }
            #endregion

            #region Initialize children and add them from BVHNodeString.
            Children = new List <BVHNode>();

            for (int i = 0; i < bvh.Children.Count; i++)
            {
                Children.Add(new BVHNode(bvh.Children[i], content, Level));
            }
            #endregion

            #region If bone has children, set EndSiteOffset as Offset of first one.
            if (EndSiteOffset == null)
            {
                EndSiteOffset = Children[0].Offset;
            }
            #endregion
        }
示例#2
0
 public static Vector3 FromString(this Vector3 v, string s)
 {
     return(StringProccesing.StringToVector3(s, ','));
 }