Example #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);
        }
Example #2
0
        private Switch setupPosViewHAMs(PosViewReader pos, int boneIndex)
        {
            Switch s = new Switch();

            if (!pos.ShowHams)
            {
                return(s);
            }

            s.reference();
            double[][] HAMdata   = DatParser.parsePosViewHAMFile(pos.HAMFileNames[boneIndex]);
            float[][]  hamColors = PosViewSettings.PosViewColors;
            for (int i = 0; i < HAMdata.Length; i++)
            {
                Separator sepPosition = new Separator();
                s.addChild(sepPosition);
                Material color = new Material();
                color.setColor(hamColors[boneIndex][0], hamColors[boneIndex][1], hamColors[boneIndex][2]);
                color.setOverride(true);
                sepPosition.addNode(color);
                HamAxis axis = new HamAxis(HAMdata[i][1], HAMdata[i][2], HAMdata[i][3], HAMdata[i][5], HAMdata[i][6], HAMdata[i][7]);
                sepPosition.addNode(axis);

                if (_reader.HamLength > -1)
                {
                    axis.SetHamLength(_reader.HamLength);
                }
                if (_reader.HamRadius > -1)
                {
                    axis.SetHamRadius(_reader.HamRadius);
                }
            }
            s.whichChild(0); //set it to start at the first frame
            s.unrefNoDelete();
            return(s);
        }