Пример #1
0
        public static Switch CreateHAMSwitch(Bone bone, Bone fixedBone, int[] animationOrder, int numFrames)
        {
            Switch sw = new Switch();

            sw.reference();

            //add starting HAM (none shown), each animation does the animation and the ending frame, not the starting one :)
            Separator nullSep = new Separator();

            sw.addChild(nullSep);
            for (int i = 0; i < animationOrder.Length - 1; i++) //not the last animation, there need start and end
            {
                TransformMatrix  tmTransform = bone.CalculateRelativeMotion(animationOrder[i], animationOrder[i + 1], fixedBone);
                HelicalTransform tform       = tmTransform.ToHelical();
                if (bone.HasInertia)
                {
                    double[] cent = { bone.InertiaMatrix.GetElement(0, 3), bone.InertiaMatrix.GetElement(1, 3), bone.InertiaMatrix.GetElement(2, 3) };
                    tform.AdjustQToLocateHamNearCentroid(cent);
                }
                HamAxis axis = new HamAxis(tform.N[0], tform.N[1], tform.N[2], tform.Q[0], tform.Q[1], tform.Q[2]);
                for (int j = 0; j < numFrames - 1; j++) //do one less then num frames, no HAM shown for the final position
                {
                    sw.addChild(axis);
                }
                sw.addChild(nullSep); //add the empty at the end :)
            }
            sw.unrefNoDelete();
            return(sw);
        }
Пример #2
0
        public HelicalTransform(TransformMatrix matrix)
        {
            HelicalTransform ham = matrix.ToHelical();

            _phi   = ham.Phi;
            _n     = ham.N;
            _trans = ham._trans;
            _q     = ham._q;
        }
Пример #3
0
        public TransformMatrix[] CalculateInterpolatedMotion(int startPositionIndex, int endPositionIndex, Bone startFixedBone, Bone endFixedBone, int numSteps)
        {
            TransformMatrix[] finalTransforms = new TransformMatrix[numSteps];
            TransformMatrix   startTransform  = this.CalculateRelativeMotionFromNeutral(startPositionIndex, startFixedBone);
            TransformMatrix   endTransform    = this.CalculateRelativeMotionFromNeutral(endPositionIndex, endFixedBone);

            TransformMatrix  relMotion   = endTransform * startTransform.Inverse();
            HelicalTransform relMotionHT = relMotion.ToHelical();

            HelicalTransform[] htTransforms = relMotionHT.LinearlyInterpolateMotion(numSteps);

            for (int i = 0; i < numSteps; i++)
            {
                finalTransforms[i] = htTransforms[i].ToTransformMatrix() * startTransform;
            }

            return(finalTransforms);
        }