ApplyIK() public method

Checks for empty position in the skeleton, fills the from the last skeleton. Root and all of roots children MUST have set possition!
public ApplyIK ( BipedSkeleton &skeleton ) : void
skeleton BipedSkeleton The skeleton to be checked
return void
Ejemplo n.º 1
0
        /// <summary>
        /// Build a skeleton according to the markers
        /// </summary>
        /// <param name="markerData">A list of markers </param>
        /// <returns>A complete skeleton</returns>
        public BipedSkeleton SolveSkeleton(List <LabeledMarker> markerData)
        {
            if (skeleton == null ||
                skeletonBuffer == null ||
                mp == null ||
                joints == null ||
                ikApplier == null)
            {
                skeleton       = new BipedSkeleton();
                skeletonBuffer = new BipedSkeleton();
                MarkersNames markersMap;
                mp        = new MarkersPreprocessor(markerData, out markersMap, bodyPrefix: MarkerPrefix);;
                joints    = new JointLocalization(markersMap);
                ikApplier = new IKApplier(skeleton);
            }
            Dictionary <string, OpenTK.Vector3> markers;

            mp.ProcessMarkers(markerData, out markers, MarkerPrefix);
            var temp = skeleton;

            skeleton       = skeletonBuffer;
            skeletonBuffer = temp;
            joints.GetJointLocation(markers, ref skeleton);
            ikApplier.Interpolation = Interpolation;
            if (SolveWithIK)
            {
                ikApplier.ApplyIK(ref skeleton);
            }
            return(skeleton);
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Build a skeleton according to the markers
        /// </summary>
        /// <param name="markerData">A list of markers </param>
        /// <returns>A complete skeleton</returns>
        public BipedSkeleton SolveSkeleton(List <Marker> markerData)
        {
            if (skeleton == null ||
                skeletonBuffer == null ||
                mp == null ||
                joints == null ||
                ikApplier == null)
            {
                skeleton       = new BipedSkeleton();
                skeletonBuffer = new BipedSkeleton();
                MarkersNames markersMap;
                mp        = new MarkersPreprocessor(markerData, out markersMap, bodyPrefix: MarkerPrefix);
                joints    = new JointLocalization(markersMap);
                ikApplier = new IKApplier(skeleton);

                // Set segment tracking markers for virtual marker construction
                st = new ŚegmentTracking(skeleton, markersMap, markerData);
            }

            var temp = skeleton;

            skeleton       = skeletonBuffer;
            skeletonBuffer = temp;

            Dictionary <string, OpenTK.Vector3> markers;

            mp.UpdateMarkerList(markerData, out markers);
            mp.ProcessMarkers(out markers);

            joints.BodyData.Height = bodyHeight;
            joints.BodyData.Mass   = bodyMass;
            joints.GetJointLocations(markers, ref skeleton);

            // Try to reconstruct virtual markers
            if (UseTrackingMarkers)
            {
                if (st.ProcessMarkers(skeleton, markerData, ref markers, MarkerPrefix))
                {
                    mp.ProcessMarkers(out markers);
                    joints.GetJointLocations(markers, ref skeleton);
                }
            }

            ikApplier.Interpolation = Interpolation;
            if (SolveWithIK)
            {
                ikApplier.ApplyIK(ref skeleton);
            }

            return(skeleton);
        }