Esempio n. 1
0
        public void CalculateAndSaveDistanceMapForPosition(int positionIndex, Bone[] testBones)
        {
            //quick check that we can do this. Don't need our own distance field, just the testBones'
            if (_coloredBone == null)
            {
                return;
            }

            //calculate the relative motion for each bone. Need a transform for each testBone, that will
            //move this bone into its coordinate system
            TransformMatrix[] transforms = new TransformMatrix[testBones.Length];
            if (positionIndex != 0) //in the neutral position, we are in the correct place
            {
                for (int i = 0; i < testBones.Length; i++)
                {
                    transforms[i] = CalculateRelativeMotionFromNeutral(positionIndex, testBones[i]);
                }
            }

            double[] distances = DistanceMaps.createDistanceMap(this, testBones, transforms);
            lock (_computedDistances)
            {
                _computedDistances[positionIndex] = distances;
            }
        }
Esempio n. 2
0
 public Contour[] CalculateContourForPositionTargetingAreas(int positionIndex, double[] targetArea, double tolerance, int maxNumIterations)
 {
     if (_computedDistances[positionIndex] == null)
     {
         throw new WristException("Raw distances (_computedDistancs) must be pre-computed before calculating Contour");
     }
     Contour[] c = new Contour[targetArea.Length];
     for (int i = 0; i < targetArea.Length; i++)
     {
         c[i] = DistanceMaps.CreateContourSingleBoneSinglePositionTargetingArea(this, _computedDistances[positionIndex], targetArea[i], tolerance, maxNumIterations);
     }
     return(c);
 }
Esempio n. 3
0
        public void CalculateAndSaveColorDistanceMapForPosition(int positionIndex, double maxColorDistance)
        {
            if (_computedDistances[positionIndex] == null)
            {
                throw new WristException("Raw distances (_computedDistancs) must be pre-computed before calculating ColorDistanceMap");
            }

            int[] colorMap = DistanceMaps.createColormap(_computedDistances[positionIndex], maxColorDistance);
            lock (_computedColorMaps)
            {
                _computedColorMaps[positionIndex] = colorMap;
            }
        }
Esempio n. 4
0
        public void CalculateAndSaveContourForPosition(int positionIndex, double[] cDistances, System.Drawing.Color[] colors)
        {
            if (_computedDistances[positionIndex] == null)
            {
                throw new WristException("Raw distances (_computedDistancs) must be pre-computed before calculating Contour");
            }

            Contour contour = DistanceMaps.createContourSingleBoneSinglePosition(this, _computedDistances[positionIndex], cDistances, colors);

            lock (_computedContours)
            {
                _computedContours[positionIndex] = contour;
            }
        }
Esempio n. 5
0
        public void CalculateAndSaveDistanceMapForAnimation(int[] animationOrder, int numFramesPerStep, int absoluteFrameNumber, Bone[] testBones, Bone fixedBone)
        {
            //quick check that we can do this. Don't need our own distance field, just the testBones'
            if (_coloredBone == null)
            {
                return;
            }

            //need to calculate where we are in the whole animation scheme. What two positions are we between?
            int startPositionIndex = absoluteFrameNumber / numFramesPerStep;
            int partialFrame       = absoluteFrameNumber % numFramesPerStep;
            int startPosition      = animationOrder[startPositionIndex];

            //calculate the relative motion for each bone. Need a transform for each testBone, that will
            //move this bone into its coordinate system
            TransformMatrix[] transforms = new TransformMatrix[testBones.Length];
            if (partialFrame == 0)      //no partial frame, we are exactly where we want to be
            {
                if (startPosition != 0) //if we are at absolute neutral, no calculations needed
                {
                    //check for the non
                    for (int i = 0; i < testBones.Length; i++)
                    {
                        transforms[i] = CalculateRelativeMotionFromNeutral(startPosition, testBones[i]);
                    }
                }
            }
            else
            {
                //so we have a partial motion to deal with, first calculate the position of the current bone
                TransformMatrix tmCurrentBone = CalculateInterpolatedMotion(startPosition, animationOrder[startPositionIndex + 1], fixedBone, numFramesPerStep)[partialFrame];
                for (int i = 0; i < testBones.Length; i++)
                {
                    TransformMatrix tmTestBone = testBones[i].CalculateInterpolatedMotion(startPosition, animationOrder[startPositionIndex + 1], fixedBone, numFramesPerStep)[partialFrame];
                    transforms[i] = tmTestBone.Inverse() * tmCurrentBone;
                }
            }

            double[] distances = DistanceMaps.createDistanceMap(this, testBones, transforms);
            lock (this)
            {
                if (_animationComputedDistances == null)
                {
                    _animationComputedDistances = new double[(animationOrder.Length - 1) * numFramesPerStep + 1][];
                }
                _animationComputedDistances[absoluteFrameNumber] = distances;
            }
        }
Esempio n. 6
0
        public void CalculateAndSaveColorDistanceMapForAnimation(int absoluteFrameNumber, double maxColorDistance)
        {
            if (_animationComputedDistances[absoluteFrameNumber] == null)
            {
                throw new WristException("Raw distances (_animationComputedDistances) must be pre-computed before calculating ColorDistanceMap");
            }

            int[] colorMap = DistanceMaps.createColormap(_animationComputedDistances[absoluteFrameNumber], maxColorDistance);
            lock (this)
            {
                if (_animationComputedColorMaps == null)
                {
                    _animationComputedColorMaps = new int[_animationComputedDistances.Length][];
                }
                _animationComputedColorMaps[absoluteFrameNumber] = colorMap;
            }
        }
Esempio n. 7
0
        public void CalculateAndSaveContourForAnimation(int absoluteFrameNumber, double[] cDistances, System.Drawing.Color[] colors)
        {
            if (_animationComputedDistances[absoluteFrameNumber] == null)
            {
                throw new WristException("Raw distances (_computedDistancs) must be pre-computed before calculating Contour");
            }

            Contour contour = DistanceMaps.createContourSingleBoneSinglePosition(this, _animationComputedDistances[absoluteFrameNumber], cDistances, colors);

            lock (this)
            {
                if (_animationComputedContours == null)
                {
                    _animationComputedContours = new Contour[_animationComputedDistances.Length];
                }
                _animationComputedContours[absoluteFrameNumber] = contour;
            }
        }
Esempio n. 8
0
 public static Contour createContourSingleBoneSinglePosition(Bone referenceBone, double[] distanceMap, double[] cDistances, System.Drawing.Color[] colors)
 {
     float[,] points = referenceBone.GetVertices();
     int[,] conn     = referenceBone.GetFaceSetIndices();
     return(DistanceMaps.createContourSingleBoneSinglePosition(points, conn, distanceMap, cDistances, colors));
 }