コード例 #1
0
ファイル: BVHContentString.cs プロジェクト: itamarom/Stickit
        ///// <summary>
        ///// init the data
        ///// </summary>
        //public BVHNodeString()
        //{
        //    this.Channels = this.Offset = this.Name = string.Empty;

        //    this.Children = new List<BVHNodeString>();

        //}

        ///// <summary>
        ///// init data
        ///// </summary>
        ///// <param name="Name">bone name</param>
        ///// <param name="Offset">bone offset</param>
        ///// <param name="Channels">bone channels</param>
        //public BVHNodeString(string Name, string Offset, string Channels)
        //{
        //    this.Name = Name;
        //    this.Offset = Offset;
        //    this.Channels = Channels;

        //    this.Children = new List<BVHNodeString>();
        //}

        #endregion

        /// <summary>
        /// init data
        /// </summary>
        /// <param name="Name">bone name</param>
        /// <param name="brackets">brackets content</param>
        public BVHNodeString(string Name, string brackets)
        {
            this.Name = Name;

            int offsetIndex   = brackets.IndexOf("OFFSET");
            int channelsIndex = brackets.IndexOf("CHANNELS");

            this.Offset = brackets.Substring(offsetIndex,
                                             brackets.IndexOf(NewLine, offsetIndex) - offsetIndex);

            this.Channels = brackets.Substring(channelsIndex,
                                               brackets.IndexOf(NewLine, channelsIndex) - channelsIndex);


            Children = new List <BVHNodeString>();

            ///////////////////////////////////////////////////////////////////

            int where = brackets.IndexOf("JOINT");

            if (where != -1)
            {
                while (where != -1)
                {
                    int nameStart = brackets.IndexOf(' ', where) + 1;

                    string subname = brackets.Substring(nameStart,
                                                        brackets.IndexOf('{', where) - nameStart);

                    int subbrackStart = brackets.IndexOf('{', where);
                    int subbrackEnd   = StringProccesing.GetIndexOfClosing(
                        brackets, subbrackStart);

                    string subbrackets = brackets.Substring(subbrackStart, subbrackEnd - subbrackStart);

                    Children.Add(new BVHNodeString(subname, subbrackets));

                    brackets = brackets.Remove(where,
                                               subbrackEnd - where);

                    where = brackets.IndexOf("JOINT");
                }
            }
            else
            {
                int indexOfBrackets = brackets.IndexOf('{',
                                                       brackets.IndexOf("End Site"));

                int endOfEndSize = StringProccesing.GetIndexOfClosing(
                    brackets, '{', '}', indexOfBrackets);

                EndSiteOffset = brackets.Substring(indexOfBrackets, endOfEndSize - indexOfBrackets);
            }

            // if (brackets.IndexOf(
        }