Ejemplo n.º 1
0
        public Animation ParseFile(string inputFileName, SceneNode root)
        {
            ICharStream       input  = new ANTLRFileStream(inputFileName);
            bvhLexer          lex    = new bvhLexer(input);
            CommonTokenStream tokens = new CommonTokenStream(lex);
            bvhParser         parser = new bvhParser(tokens);

            doc = parser.document();
            doc.Root.ComputeTransforms();

            #region MapSkelletons

            if (root != null)
            {
                MapNodes(doc.Root, root);
            }
            else
            {
                foreach (var item in scene.EnumerateNodesPosOrden())
                {
                    if (item.IsBoneRoot)
                    {
                        MapNodes(doc.Root, item);
                    }
                }
            }
            #endregion

            Animation anim = new Animation(Path.GetFileNameWithoutExtension(inputFileName));

            float[][] keys = GetAnimationKeys();

            AnimationNode[] animationNodes = CreateAnimationNodes(anim, keys);

            ReadFrames(animationNodes);

            return(anim);
        }
Ejemplo n.º 2
0
        // $ANTLR start document
        // F:\\Projects\\Igneel\\Igneel\\Importers\\BVH\\bvh.g:73:1: document returns [BvhDocument doc = new BvhDocument()] : HEIRARCHY root= heirarchy[doc] m= motion ;
        public BvhDocument document() // throws RecognitionException [1]
        {
            BvhDocument doc = new BvhDocument();

            BvhNode root = null;

            BvhMotion m = null;


            try
            {
                // F:\\Projects\\Igneel\\Igneel\\Importers\\BVH\\bvh.g:74:2: ( HEIRARCHY root= heirarchy[doc] m= motion )
                // F:\\Projects\\Igneel\\Igneel\\Importers\\BVH\\bvh.g:74:4: HEIRARCHY root= heirarchy[doc] m= motion
                {
                    Match(input, HEIRARCHY, FOLLOW_HEIRARCHY_in_document485);
                    PushFollow(FOLLOW_heirarchy_in_document496);
                    root = heirarchy(doc);
                    followingStackPointer_--;

                    doc.Root = root;
                    PushFollow(FOLLOW_motion_in_document507);
                    m = motion();
                    followingStackPointer_--;

                    doc.Motion = m;
                }
            }
            catch (RecognitionException re)
            {
                ReportError(re);
                Recover(input, re);
            }
            finally
            {
            }
            return(doc);
        }
Ejemplo n.º 3
0
        // $ANTLR end values


        // $ANTLR start heirarchy
        // F:\\Projects\\Igneel\\Igneel\\Importers\\BVH\\bvh.g:89:1: heirarchy[BvhDocument d] returns [BvhNode node = new BvhNode()] : ( ROOT | JOINT ) ID LCURLY v= offsets ch= channels ( (child= heirarchy[d] )+ | end= endsite ) RCURLY ;
        public BvhNode heirarchy(BvhDocument d) // throws RecognitionException [1]
        {
            BvhNode node = new BvhNode();

            IToken  ID1 = null;
            Vector3?v   = null;

            List <FODChannel> ch = null;

            BvhNode child = null;

            EndSite end = null;



            d.Nodes.Add(node);

            try
            {
                // F:\\Projects\\Igneel\\Igneel\\Importers\\BVH\\bvh.g:94:2: ( ( ROOT | JOINT ) ID LCURLY v= offsets ch= channels ( (child= heirarchy[d] )+ | end= endsite ) RCURLY )
                // F:\\Projects\\Igneel\\Igneel\\Importers\\BVH\\bvh.g:94:4: ( ROOT | JOINT ) ID LCURLY v= offsets ch= channels ( (child= heirarchy[d] )+ | end= endsite ) RCURLY
                {
                    // F:\\Projects\\Igneel\\Igneel\\Importers\\BVH\\bvh.g:94:4: ( ROOT | JOINT )
                    int alt2  = 2;
                    int LA2_0 = input.LA(1);

                    if ((LA2_0 == ROOT))
                    {
                        alt2 = 1;
                    }
                    else if ((LA2_0 == JOINT))
                    {
                        alt2 = 2;
                    }
                    else
                    {
                        NoViableAltException nvae_d2s0 =
                            new NoViableAltException("94:4: ( ROOT | JOINT )", 2, 0, input);

                        throw nvae_d2s0;
                    }
                    switch (alt2)
                    {
                    case 1:
                        // F:\\Projects\\Igneel\\Igneel\\Importers\\BVH\\bvh.g:94:5: ROOT
                    {
                        Match(input, ROOT, FOLLOW_ROOT_in_heirarchy611);
                        node.IsRoot = true;
                    }
                    break;

                    case 2:
                        // F:\\Projects\\Igneel\\Igneel\\Importers\\BVH\\bvh.g:94:33: JOINT
                    {
                        Match(input, JOINT, FOLLOW_JOINT_in_heirarchy616);
                    }
                    break;
                    }

                    ID1 = (IToken)input.LT(1);
                    Match(input, ID, FOLLOW_ID_in_heirarchy619);
                    node.Name = ID1.Text;
                    Match(input, LCURLY, FOLLOW_LCURLY_in_heirarchy627);
                    PushFollow(FOLLOW_offsets_in_heirarchy635);
                    v = offsets();
                    followingStackPointer_--;

                    node.Offset = (Vector3)v;
                    PushFollow(FOLLOW_channels_in_heirarchy646);
                    ch = channels();
                    followingStackPointer_--;

                    node.Channels = ch.ToArray();
                    // F:\\Projects\\Igneel\\Igneel\\Importers\\BVH\\bvh.g:98:6: ( (child= heirarchy[d] )+ | end= endsite )
                    int alt4  = 2;
                    int LA4_0 = input.LA(1);

                    if (((LA4_0 >= ROOT && LA4_0 <= JOINT)))
                    {
                        alt4 = 1;
                    }
                    else if ((LA4_0 == END_SITE))
                    {
                        alt4 = 2;
                    }
                    else
                    {
                        NoViableAltException nvae_d4s0 =
                            new NoViableAltException("98:6: ( (child= heirarchy[d] )+ | end= endsite )", 4, 0, input);

                        throw nvae_d4s0;
                    }
                    switch (alt4)
                    {
                    case 1:
                        // F:\\Projects\\Igneel\\Igneel\\Importers\\BVH\\bvh.g:98:8: (child= heirarchy[d] )+
                    {
                        // F:\\Projects\\Igneel\\Igneel\\Importers\\BVH\\bvh.g:98:8: (child= heirarchy[d] )+
                        int cnt3 = 0;
                        do
                        {
                            int alt3  = 2;
                            int LA3_0 = input.LA(1);

                            if (((LA3_0 >= ROOT && LA3_0 <= JOINT)))
                            {
                                alt3 = 1;
                            }


                            switch (alt3)
                            {
                            case 1:
                                // F:\\Projects\\Igneel\\Igneel\\Importers\\BVH\\bvh.g:98:9: child= heirarchy[d]
                            {
                                PushFollow(FOLLOW_heirarchy_in_heirarchy660);
                                child = heirarchy(d);
                                followingStackPointer_--;

                                node.Nodes.Add(child);
                            }
                            break;

                            default:
                                if (cnt3 >= 1)
                                {
                                    goto loop3;
                                }
                                EarlyExitException eee =
                                    new EarlyExitException(3, input);
                                throw eee;
                            }
                            cnt3++;
                        } while (true);

loop3:
                        ;                       // Stops C# compiler whinging that label 'loop3' has no statements
                    }
                    break;

                    case 2:
                        // F:\\Projects\\Igneel\\Igneel\\Importers\\BVH\\bvh.g:99:8: end= endsite
                    {
                        PushFollow(FOLLOW_endsite_in_heirarchy677);
                        end = endsite();
                        followingStackPointer_--;

                        node.End = end;
                    }
                    break;
                    }

                    Match(input, RCURLY, FOLLOW_RCURLY_in_heirarchy685);
                }
            }
            catch (RecognitionException re)
            {
                ReportError(re);
                Recover(input, re);
            }
            finally
            {
            }
            return(node);
        }