Exemplo n.º 1
0
        private Switch setupPosViewBone(PosViewReader pos, int boneIndex)
        {
            Switch s = new Switch();

            s.reference();
            _bones[boneIndex] = new Separator();
            //create a material for that bone!
            _boneMaterials[boneIndex] = new Material();
            float[][] hamColors  = PosViewSettings.PosViewColors;
            int       colorIndex = boneIndex % hamColors.Length; //prevent index exception when we have more than 15 bones. (only 15 colors defined)

            _boneMaterials[boneIndex].setColor(hamColors[colorIndex][0], hamColors[colorIndex][1], hamColors[colorIndex][2]);
            _boneMaterials[boneIndex].setOverride(true);                  //for this material to apply to everything below it.

            _bones[boneIndex].addFile(pos.IvFileNames[boneIndex], false); //load bone file once, it will referenced multiple times
            if (pos.SetColor)                                             //only insert now if the config file says to
            {
                _bones[boneIndex].insertNode(_boneMaterials[boneIndex], 0);
            }

            Transform[] transforms = DatParser.parsePosViewRTFileToTransforms(pos.RTFileNames[boneIndex]);
            _numPositions = transforms.Length;
            for (int i = 0; i < transforms.Length; i++)
            {
                Separator sepPosition = new Separator();
                sepPosition.addNode(transforms[i]);
                sepPosition.addChild(_bones[boneIndex]);
                s.addChild(sepPosition);
            }
            s.whichChild(0); //set it to start at the first frame
            s.unrefNoDelete();
            return(s);
        }
Exemplo n.º 2
0
        private Switch setupPosViewLables(PosViewReader pos)
        {
            _labels = new Switch();
            if (!pos.HasLables)
            {
                return(_labels);
            }

            for (int i = 0; i < pos.Labels.Length; i++)
            {
                Label2D l = new Label2D();
                l.setText(pos.Labels[i]);
                l.setLocation(-0.9f, 0.9f);
                l.setFontSize(20);
                _labels.addChild(l);
            }
            return(_labels);
        }
Exemplo n.º 3
0
        private List <Switch> setupPosViewLigaments(PosViewReader pos, int numPositions)
        {
            List <Switch> ligaments = new List <Switch>();

            if (!pos.HasLigaments)
            {
                return(ligaments);
            }

            //so we actually create a switch for every ligament and ligament fiber...
            string[] ligamentNames = pos.LigamentFiberNames;

            /* we are really looping through ligaments here. Inside the loop we will
             * look for individual fibers of each ligament
             */
            foreach (string ligamentName in ligamentNames)
            {
                //first reformat the filename, so that it goes from fprint
                string ligamentPattern = Path.Combine(pos.LigamentFiberBasePath, reformatFiberPattern(ligamentName));

                //lets loop through possible fiber strings
                int fiberNumber = 1; //mike starts his counting at one
                while (File.Exists(String.Format(ligamentPattern, 1, fiberNumber)))
                {
                    Switch fiberSwitch = new Switch();
                    fiberSwitch.reference(); //prevent deletion while we work with it
                    for (int i = 0; i < numPositions; i++)
                    {
                        //since Mike uses index of 1, we need to offset the position number
                        string    fname      = String.Format(ligamentPattern, i + 1, fiberNumber);
                        Separator streamTube = new Separator();
                        streamTube.addFile(fname);
                        fiberSwitch.addChild(streamTube);
                    }
                    fiberSwitch.whichChild(0); //start at first frame
                    fiberSwitch.unrefNoDelete();
                    ligaments.Add(fiberSwitch);

                    fiberNumber++;
                }
            }

            return(ligaments);
        }
Exemplo n.º 4
0
        private void loadPosView(string posViewFilename)
        {
            _root = new Separator();
            Separator sec1 = new Separator();
            Separator sec2 = new Separator();

            _root.addNode(sec1);
            _root.addNode(sec2);
            sec1.addNode(new Camera());
            sec2.addNode(new Camera());
            _currentFrame = 0;
            try
            {
                _reader        = new PosViewReader(posViewFilename);
                _bonesSwitch   = new Switch[_reader.NumBones];
                _hamsSwitch    = new Switch[_reader.NumBones];
                _bones         = new Separator[_reader.NumBones];
                _boneMaterials = new Material[_reader.NumBones];
                //_root = new Separator();
                for (int i = 0; i < _reader.NumBones; i++)
                {
                    _bonesSwitch[i] = setupPosViewBone(_reader, i);
                    _hamsSwitch[i]  = setupPosViewHAMs(_reader, i);
                    sec1.addNode(_bonesSwitch[i]);
                    sec1.addNode(_hamsSwitch[i]);
                }
                _ligaments = setupPosViewLigaments(_reader, _numPositions); //load all of the ligaments
                foreach (Switch lig in _ligaments)
                {
                    sec1.addNode(lig); //add to scenegraph
                }
                if (_reader.HasLables)
                {
                    setupPosViewLables(_reader);
                    sec2.addNode(_labels);
                }
            }
            catch
            {
                throw;
            }
        }
Exemplo n.º 5
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);
        }