Ejemplo n.º 1
0
 // This function doesn't call any Unity API functions and should be safe to call from another thread
 public void parse(string bvhData)
 {
     if (respectBVHTime)
     {
         bp        = new BVHParser(bvhData);
         frameRate = 1f / bp.frameTime;
     }
     else
     {
         bp = new BVHParser(bvhData, 1f / frameRate);
     }
 }
            public BVHBone(BVHParser parser, bool rootBone)
            {
                bp = parser;
                bp.boneList.Add(this);
                channels     = new BVHChannel[6];
                channelOrder = new int[6] {
                    0, 1, 2, 5, 3, 4
                };
                children = new List <BVHBone>();

                bp.skip();
                if (rootBone)
                {
                    bp.assureExpect("ROOT");
                }
                else
                {
                    bp.assureExpect("JOINT");
                }
                bp.assure("joint name", bp.getString(out name));
                bp.skip();
                bp.assureExpect("{");
                bp.skip();
                bp.assureExpect("OFFSET");
                bp.skip();
                bp.assure("offset X", bp.getFloat(out offsetX));
                bp.skip();
                bp.assure("offset Y", bp.getFloat(out offsetY));
                bp.skip();
                bp.assure("offset Z", bp.getFloat(out offsetZ));
                bp.skip();
                bp.assureExpect("CHANNELS");

                bp.skip();
                bp.assure("channel number", bp.getInt(out channelNumber));
                bp.assure("valid channel number", channelNumber >= 1 && channelNumber <= 6);

                for (int i = 0; i < channelNumber; i++)
                {
                    bp.skip();
                    int channelId;
                    bp.assure("channel ID", bp.getChannel(out channelId));
                    channelOrder[i]             = channelId;
                    channels[channelId].enabled = true;
                }

                char peek = ' ';

                do
                {
                    float ignored;
                    bp.skip();
                    bp.assure("child joint", bp.peek(out peek));
                    switch (peek)
                    {
                    case 'J':
                        BVHBone child = new BVHBone(bp, false);
                        children.Add(child);
                        break;

                    case 'E':
                        bp.assureExpect("End Site");
                        bp.skip();
                        bp.assureExpect("{");
                        bp.skip();
                        bp.assureExpect("OFFSET");
                        bp.skip();
                        bp.assure("end site offset X", bp.getFloat(out ignored));
                        bp.skip();
                        bp.assure("end site offset Y", bp.getFloat(out ignored));
                        bp.skip();
                        bp.assure("end site offset Z", bp.getFloat(out ignored));
                        bp.skip();
                        bp.assureExpect("}");
                        break;

                    case '}':
                        bp.assureExpect("}");
                        break;

                    default:
                        bp.assure("child joint", false);
                        break;
                    }
                } while (peek != '}');
            }