Esempio n. 1
0
        public MatrixIndexer(List <float[]> fFrames, BVHContent bvh)
        {
            for (int f = 0; f < fFrames.Count; f++)
            {
                indices.Add(new List <int>()); //Add new frame to collection.

                for (int b = 0; b < bvh.Skeleton.BoneCount; b++)
                {
                    #region Set indices
                    BVHNode   bone = bvh[b];
                    FrameCalc fc   = bone.calc_fc_from_frame(fFrames[f]); //get frame calc of current matrix.
                    indices[indices.Count - 1].Add(get_index(fc, b, f));  //find index of matrix and add it to frame.
                    #endregion
                }
            }

            #region Calculate matrices from frmCalcs
            matrices = new Matrix[frmCalcs.Count];

            for (int i = 0; i < matrices.Length; i++)
            {
                matrices[i] = frmCalcs[i].calc_frame();
            }
            #endregion

            frmCalcs = null;//Allows Garbage Collector to dispose
        }
Esempio n. 2
0
        private void feed_level_list(BVHNode start, List <List <BVHNode> > levels)
        {
            #region If reached a new level, create it.
            if (start.Level >= levels.Count)
            {
                levels.Add(new List <BVHNode>());
            }
            #endregion

            #region Add start bone to a collection according to its level.
            levels[start.Level].Add(start);
            #endregion

            #region Go over bone children, set their Parent value and call the function recursively.
            for (int i = 0; i < start.Children.Count; i++)
            {
                start.Children[i].Parent = start;

                feed_level_list(start.Children[i],
                                levels);
            }
            #endregion
        }
Esempio n. 3
0
        private void organize_bones_id_by_level()
        {
            List <List <BVHNode> > levels =
                new List <List <BVHNode> >();

            feed_level_list(Skeleton.Root, levels);

            int id = 0;

            #region Go over all levels.
            for (int l = 0; l < levels.Count; l++) //each level
            {
                #region Go over all bones in level.
                for (int n = 0; n < levels[l].Count; n++) //each node in level
                {
                    BVHNode node = levels[l][n];

                    #region Set bone ID.
                    node.Id = id;
                    #endregion

                    #region Add bone to BonesFromString collection.
                    BonesFromString.Add(node.Name, node);
                    #endregion

                    #region Add bone to BonesFromId collection.
                    BonesFromId.Add(node.Id, node);
                    #endregion

                    #region Raise Id count by one.
                    id++;
                    #endregion
                }
                #endregion
            }
            #endregion
        }
Esempio n. 4
0
 /// <summary>
 /// Initialize fields.
 /// </summary>
 /// <param name="node">Bone.</param>
 /// <param name="channel">Channel to update (xPosition, yRotation etc)</param>
 /// <param name="pifl">Place in frame line.</param>
 public BoneChannel(BVHNode node, string channel)
 {
     this.node    = node;
     this.channel = channel;
     pifl         = -1;
 }
Esempio n. 5
0
 /// <summary>
 ///  Initialize skeleton with given values.
 /// </summary>
 /// <param name="Root">First bone in skeleton.</param>
 /// <param name="BoneChannels">Bone channels in each frame</param>
 public Skeleton(BVHNode Root, List <BoneChannel> BoneChannels)
 {
     this.Root         = Root;
     this.BoneChannels = BoneChannels;
 }