Exemple #1
0
        public static MoCapBodyFrame Average(params MoCapBodyFrame[] values)
        {
            if (values == null || values.Length == 0)
            {
                throw new Exception("Empty values list!");
            }

            var transforms = new TransformTime[(int)MoCapKinectBone.Count][];

            for (var i = 0; i < (int)MoCapKinectBone.Count; i++)
            {
                transforms[i] = new TransformTime[values.Length];

                for (var j = 0; j < values.Length; j++)
                {
                    transforms[i][j] = values[j].SkeletonTransforms[i];
                }
            }

            var ret = new MoCapBodyFrame
            {
                SkeletonTransforms = new TransformTime[(int)MoCapKinectBone.Count]
            };

            for (var i = 0; i < (int)MoCapKinectBone.Count; i++)
            {
                ret.SkeletonTransforms[i] = TransformTime.Average(transforms[i]);
            }
            return(ret);
        }
Exemple #2
0
        public static TransformTime Average(params TransformTime[] values)
        {
            if (values == null || values.Length == 0)
            {
                throw new Exception("Empty values list!");
            }

            var positions = new List <Vector3>(values.Length);
            var rotations = new List <Quaternion>(values.Length);
            var scales    = new List <Vector3>(values.Length);
            var times     = new List <float>(values.Length);

            for (var i = 0; i < values.Length; i++)
            {
                if (values[i].Time != 0)
                {
                    positions.Add(values[i].Position);
                    rotations.Add(values[i].Rotation);
                    scales.Add(values[i].Scale);
                    times.Add(values[i].Time);
                }
            }

            var ret = new TransformTime();

            if (times.Count == 0)
            {
                ret.Position = new Vector3 {
                    X = 0, Y = 0, Z = 0
                };
                ret.Rotation = new Quaternion {
                    X = 0, Y = 0, Z = 0, W = 1
                };
                ret.Scale = new Vector3 {
                    X = 1, Y = 1, Z = 1
                };
                ret.Time = 0;
            }
            else
            {
                ret.Position = Vector3.Average(positions.ToArray());
                ret.Rotation = Quaternion.Average(rotations.ToArray());
                ret.Scale    = Vector3.Average(scales.ToArray());
                ret.Time     = MathHelper.Average(times.ToArray());
            }
            return(ret);
        }
Exemple #3
0
        public static MoCapFaceFrame Average(params MoCapFaceFrame[] values)
        {
            if (values == null || values.Length == 0)
            {
                throw new Exception("Empty values list!");
            }

            var transforms = new TransformTime[values.Length];

            for (var i = 0; i < values.Length; i++)
            {
                transforms[i] = values[i].FaceTransform;
            }

            var weights = new float[(int)MoCapKinectFacialExpression.Count][];

            for (var i = 0; i < (int)MoCapKinectFacialExpression.Count; i++)
            {
                weights[i] = new float[values.Length];

                for (var j = 0; j < values.Length; j++)
                {
                    weights[i][j] = values[j].ExpressionWeights[i];
                }
            }

            var ret = new MoCapFaceFrame
            {
                ExpressionWeights = new float[(int)MoCapKinectFacialExpression.Count]
            };

            ret.FaceTransform = TransformTime.Average(transforms);

            for (var i = 0; i < (int)MoCapKinectFacialExpression.Count; i++)
            {
                ret.ExpressionWeights[i] = MathHelper.Average(weights[i]);
            }

            return(ret);
        }