예제 #1
0
        public void Test_Sample_Linear_Primitive()
        {
            var track = new AnimationTrack ("PropetyName", InterpolationType.Linear);

            track.AddKeyframe (1, 1.0f);
            track.AddKeyframe (2, 2.0f);

            Assert.AreEqual (1.0f, track.Sample (0.0f), 0.0001f);
            Assert.AreEqual (1.0f, track.Sample (0.5f), 0.0001f);
            Assert.AreEqual (1.0f, track.Sample (1.0f), 0.0001f);
            Assert.AreEqual (1.5f, track.Sample (1.5f), 0.0001f);
            Assert.AreEqual (2.0f, track.Sample (2.0f), 0.0001f);
            Assert.AreEqual (2.0f, track.Sample (2.5f), 0.0001f);
        }
예제 #2
0
        public void Test_AddKeyframe_ValueType()
        {
            var track = new AnimationTrack ("PropetyName", InterpolationType.Step);

            track.AddKeyframe (1, new Vector3 (1, 2, 3));
            track.AddKeyframe (2, new Vector3 (4, 5, 6));
            track.AddKeyframe (3, new Vector3 (7, 8, 9));
            track.AddKeyframe (4, new Vector3 (10, 11, 12));

            Assert.AreEqual (1, track.GetKeyframe (0).Time);
            Assert.AreEqual (new Vector3(1,2,3), track.GetKeyframe (0).Value);

            Assert.AreEqual (2, track.GetKeyframe (1).Time);
            Assert.AreEqual (new Vector3 (4,5,6), track.GetKeyframe (1).Value);

            Assert.AreEqual (3, track.GetKeyframe (2).Time);
            Assert.AreEqual (new Vector3 (7,8,9), track.GetKeyframe (2).Value);

            Assert.AreEqual (4, track.GetKeyframe (3).Time);
            Assert.AreEqual (new Vector3 (10,11,12), track.GetKeyframe (3).Value);
        }
예제 #3
0
        public void Test_AddKeyframe_Primitive()
        {
            var track = new AnimationTrack ("PropetyName", InterpolationType.Step);

            // 内部でソート
            track.AddKeyframe (4, 4);
            track.AddKeyframe (3, 3);
            track.AddKeyframe (2, 2);
            track.AddKeyframe (1, 1);

            Assert.AreEqual (1, track.GetKeyframe (0).Time);
            Assert.AreEqual (1, track.GetKeyframe (0).Value);

            Assert.AreEqual (2, track.GetKeyframe (1).Time);
            Assert.AreEqual (2, track.GetKeyframe (1).Value);

            Assert.AreEqual (3, track.GetKeyframe (2).Value);
            Assert.AreEqual (3, track.GetKeyframe (2).Time);

            Assert.AreEqual (4, track.GetKeyframe (3).Value);
            Assert.AreEqual (4, track.GetKeyframe (3).Time);
        }
예제 #4
0
        public void Test_WeakReferenceTrack()
        {
            var target = new MyTarget ();
            var track = new AnimationTrack ("Speed", InterpolationType.Linear);
            track.AddKeyframe (0, 100.0f);
            track.AddKeyframe (100, 100.0f);

            var clip = new AnimationClip (100, "Clip");
            clip.AddTrack (target, track);

            var anim = new AnimationController ();
            anim.AddClip (clip);

            // ターゲットの解放
            target = null;
            GC.Collect ();

            Assert.AreEqual (1, clip.TrackCount);
            Assert.AreEqual (false, clip.GetTrack (0).Item1.IsAlive);

            // 解放済みのターゲットを含むアニメーションの実行。
            // エラーが起きてはならない
            anim.OnAnimate (0, 0);
        }
예제 #5
0
        public void Test_OnAnimate_Point_Once()
        {
            var clip = new AnimationClip (3, "TestClip");
            clip.WrapMode = WrapMode.Once;
            clip.Duration = 3;
            clip.Play ();

            var track = new AnimationTrack ("Point", InterpolationType.Step);
            track.AddKeyframe (1, new Vector3 (1, 2, 0));
            track.AddKeyframe (2, new Vector3 (2, 3, 0));

            var target = new MyTarget ();

            clip.AddTrack (target, track);

            var anim = new AnimationController ();
            anim.AddClip (clip);

            Assert.AreEqual (0f, target.Point.X, 0.0001f);
            Assert.AreEqual (0f, target.Point.Y, 0.0001f);

            anim.OnAnimate (1, 0);
            Assert.AreEqual (1.0f, target.Point.X, 0.0001f);
            Assert.AreEqual (2.0f, target.Point.Y, 0.0001f);

            anim.OnAnimate (2, 0);
            Assert.AreEqual (2.0f, target.Point.X, 0.0001f);
            Assert.AreEqual (3.0f, target.Point.Y, 0.0001f);

            anim.OnAnimate (3, 0);
            Assert.AreEqual (2.0f, target.Point.X, 0.0001f);
            Assert.AreEqual (3.0f, target.Point.Y, 0.0001f);
        }
예제 #6
0
        public void Test_OnAnimate_Float_Once()
        {
            var track = new AnimationTrack ("Speed", InterpolationType.Step);
            track.AddKeyframe (1, 1.0f);
            track.AddKeyframe (2, 2.0f);

            var clip = new AnimationClip (3, "TestClip");
            clip.WrapMode = WrapMode.Once;
            clip.Duration = 3;
            clip.Play ();

            var target = new MyTarget ();

            clip.AddTrack (target, track);

            var anim = new AnimationController ();
            anim.AddClip (clip);

            Assert.AreEqual (0.0f, target.Speed);

            anim.OnAnimate (1, 0);
            Assert.AreEqual (1.0f, target.Speed);

            anim.OnAnimate (2, 0);
            Assert.AreEqual (2.0f, target.Speed);

            anim.OnAnimate (3, 0);
            Assert.AreEqual (2.0f, target.Speed);
        }
예제 #7
0
        public static Node Create(Vector3 pos)
        {
            var cmp = new MyFireExplosion ();

            var spr = new Sprite (100, 100);
            spr.AddTexture(Resource.GetTexture ("media/FireExplosion.png"));

            var node = new Node ("FireExplosion");
            node.Attach (spr);
            node.Attach (cmp);

            node.Translation = pos - new Vector3(34, 34, 0);   // 爆発の中心を地球にあわせる

            var track = new AnimationTrack ("TextureOffset", InterpolationType.Step);
            track.AddKeyframe (0, new Vector2 (0, 0));
            track.AddKeyframe (100, new Vector2 (100, 0));
            track.AddKeyframe (200, new Vector2 (200, 0));
            track.AddKeyframe (300, new Vector2 (300, 0));
            track.AddKeyframe (400, new Vector2 (400, 0));
            track.AddKeyframe (500, new Vector2 (500, 0));
            track.AddKeyframe (600, new Vector2 (600, 0));
            track.AddKeyframe (700, new Vector2 (700, 0));
            track.AddKeyframe (800, new Vector2 (800, 0));
            track.AddKeyframe (900, new Vector2 (900, 0));
            track.AddKeyframe (1000, new Vector2 (0, 100));
            track.AddKeyframe (1100, new Vector2 (100, 100));
            track.AddKeyframe (1200, new Vector2 (200, 100));
            track.AddKeyframe (1300, new Vector2 (300, 100));
            track.AddKeyframe (1400, new Vector2 (400, 100));
            track.AddKeyframe (1500, new Vector2 (500, 100));
            track.AddKeyframe (1600, new Vector2 (600, 100));
            track.AddKeyframe (1700, new Vector2 (700, 100));
            track.AddKeyframe (1800, new Vector2 (800, 100));
            track.AddKeyframe (1900, new Vector2 (900, 100));
            track.AddKeyframe (2000, new Vector2 (0, 200));
            track.AddKeyframe (2100, new Vector2 (100, 200));
            track.AddKeyframe (2200, new Vector2 (200, 200));
            track.AddKeyframe (2300, new Vector2 (300, 200));
            track.AddKeyframe (2400, new Vector2 (400, 200));
            track.AddKeyframe (2500, new Vector2 (500, 200));
            track.AddKeyframe (2600, new Vector2 (600, 200));
            track.AddKeyframe (2700, new Vector2 (700, 200));
            track.AddKeyframe (2800, new Vector2 (800, 200));
            track.AddKeyframe (2900, new Vector2 (900, 200));

            var clip = new AnimationClip (3000, "Explosion");
            clip.AddTrack (spr, track);
            clip.WrapMode = WrapMode.Once;

            node.UserData.Add (clip.Name, clip);

            return node;
        }
예제 #8
0
        public static Node Create(Vector3 pos)
        {
            var cmp = new MyFireExplosion ();

               var spr = new Sprite (100, 100);
               spr.AddTexture (new Texture ("media/FireExplosion.png"));

               var track = new AnimationTrack ("TextureOffset", InterpolationType.Step);
               track.AddKeyframe (0, new Vector2 (0, 0));
               track.AddKeyframe (100, new Vector2 (100, 0));
               track.AddKeyframe (200, new Vector2 (200, 0));
               track.AddKeyframe (300, new Vector2 (300, 0));
               track.AddKeyframe (400, new Vector2 (400, 0));
               track.AddKeyframe (500, new Vector2 (500, 0));
               track.AddKeyframe (600, new Vector2 (600, 0));
               track.AddKeyframe (700, new Vector2 (700, 0));
               track.AddKeyframe (800, new Vector2 (800, 0));
               track.AddKeyframe (900, new Vector2 (900, 0));
               track.AddKeyframe (1000, new Vector2 (0, 100));
               track.AddKeyframe (1100, new Vector2 (100, 100));
               track.AddKeyframe (1200, new Vector2 (200, 100));
               track.AddKeyframe (1300, new Vector2 (300, 100));
               track.AddKeyframe (1400, new Vector2 (400, 100));
               track.AddKeyframe (1500, new Vector2 (500, 100));
               track.AddKeyframe (1600, new Vector2 (600, 100));
               track.AddKeyframe (1700, new Vector2 (700, 100));
               track.AddKeyframe (1800, new Vector2 (800, 100));
               track.AddKeyframe (1900, new Vector2 (900, 100));
               track.AddKeyframe (2000, new Vector2 (0, 200));
               track.AddKeyframe (2100, new Vector2 (100, 200));
               track.AddKeyframe (2200, new Vector2 (200, 200));
               track.AddKeyframe (2300, new Vector2 (300, 200));
               track.AddKeyframe (2400, new Vector2 (400, 200));
               track.AddKeyframe (2500, new Vector2 (500, 200));
               track.AddKeyframe (2600, new Vector2 (600, 200));
               track.AddKeyframe (2700, new Vector2 (700, 200));
               track.AddKeyframe (2800, new Vector2 (800, 200));
               track.AddKeyframe (2900, new Vector2 (900, 200));

               var clip = new AnimationClip (3000, "FireExplosion");
               clip.AddTrack (spr, track);
               clip.WrapMode = WrapMode.Loop;

               var anim = new AnimationController ();
               anim.AddClip (clip);

               var node = new Node ();
               node.Attach (cmp);
               node.Attach (spr);
               node.Attach (anim);

               node.Translation = pos;

               return node;
        }
예제 #9
0
        public static Node Create(Vector3 pos)
        {
            var cmp = new MyBigExplosion ();

            var spr = new Sprite (256, 128);
            //spr.AddTexture (Resource.GetTexture ("media/BigExplosion.png"));
            spr.AddTexture (new Texture ("./media/BigExplosion.png"));
            spr.SetTextureOffset (0, 0);
            spr.SetOffset (-128, -64);

            var track = new AnimationTrack ("TextureOffset", InterpolationType.Step);
            track.AddKeyframe (0, new Vector2 (0, 0));
            track.AddKeyframe (200, new Vector2 (256, 0));
            track.AddKeyframe (400, new Vector2 (512, 0));
            track.AddKeyframe (600, new Vector2 (0, 128));
            track.AddKeyframe (800, new Vector2 (256, 128));
            track.AddKeyframe (1000, new Vector2 (512, 128));
            track.AddKeyframe (1200, new Vector2 (0, 256));
            track.AddKeyframe (1400, new Vector2 (256, 256));
            track.AddKeyframe (1600, new Vector2 (512, 256));
            track.AddKeyframe (1800, new Vector2 (0, 384));
            track.AddKeyframe (2000, new Vector2 (256, 384));
            track.AddKeyframe (2200, new Vector2 (512, 384));

            cmp.clip = new AnimationClip (2400, "Fire-Animation");
            cmp.clip.AddTrack (spr, track);

            var node = new Node ();
            node.Attach (cmp);
            node.Attach (spr);

            node.Translation = pos;

            return node;
        }
예제 #10
0
        public static Node Create(Vector3 pos)
        {
            var cmp = new MyExplosion ();

            var spr = new Sprite (100, 100);
            spr.AddTexture (new Texture("media/FireExplosion.png"));
            spr.SetTextureOffset (0, 0);
            spr.SetOffset (-50, -50);

            var track = new AnimationTrack ("TextureOffset", InterpolationType.Step);
            track.AddKeyframe (0, new Vector2 (0, 0));
            track.AddKeyframe (100, new Vector2 (100 , 0));
            track.AddKeyframe (200, new Vector2 (200 , 0));
            track.AddKeyframe (300, new Vector2 (300 , 0));
            track.AddKeyframe (400, new Vector2 (400 , 0));
            track.AddKeyframe (500, new Vector2 (500 , 0));
            track.AddKeyframe (600, new Vector2 (600 , 0));
            track.AddKeyframe (700, new Vector2 (700 , 0));
            track.AddKeyframe (800, new Vector2 (800 , 0));
            track.AddKeyframe (900, new Vector2 (900 , 0));
            track.AddKeyframe (1000, new Vector2 (0, 100));
            track.AddKeyframe (1100, new Vector2 (100, 100));
            track.AddKeyframe (1200, new Vector2 (200, 100));
            track.AddKeyframe (1300, new Vector2 (300, 100));
            track.AddKeyframe (1400, new Vector2 (400, 100));
            track.AddKeyframe (1500, new Vector2 (500, 100));
            track.AddKeyframe (1600, new Vector2 (600, 100));
            track.AddKeyframe (1700, new Vector2 (700, 100));
            track.AddKeyframe (1800, new Vector2 (800, 100));
            track.AddKeyframe (1900, new Vector2 (900, 100));
            track.AddKeyframe (2000, new Vector2 (0, 200));
            track.AddKeyframe (2100, new Vector2 (100, 200));
            track.AddKeyframe (2200, new Vector2 (200, 200));
            track.AddKeyframe (2300, new Vector2 (300, 200));
            track.AddKeyframe (2400, new Vector2 (400, 200));
            track.AddKeyframe (2500, new Vector2 (500, 200));
            track.AddKeyframe (2600, new Vector2 (600, 200));
            track.AddKeyframe (2700, new Vector2 (700, 200));
            track.AddKeyframe (2800, new Vector2 (800, 200));
            track.AddKeyframe (2900, new Vector2 (900, 200));

            cmp.clip = new AnimationClip (3000, "Fire-Animation");
            cmp.clip.AddTrack (spr, track);

            var node = new Node ();
            node.Attach (cmp);
            node.Attach (spr);

            node.DrawPriority = -3;
            node.Translation = pos;

            return node;
        }
예제 #11
0
        public static Node Create(Vector3 pos)
        {
            var cmp = new MyCharacter ();

            // Body
            var spr1 = new Sprite (24, 32);
            spr1.AddTexture (new Texture ("media/Character-Gelato.png"));

            var col1 = new CollisionObject ();
            col1.Shape = new BoxShape (spr1.Width / 2, spr1.Height / 2, 1);
            col1.Offset = new Vector3 (spr1.Width / 2, spr1.Height / 2, 1);
            col1.IgnoreWith = (int)MyGroup.Character;

            // Foot
            var spr2 = new Sprite (24, 4);
            spr2.AddTexture (new Texture ("media/image128x128(Red).png"));

            var col2 = new CollisionObject ();
            col2.Shape = new BoxShape (2,2, 2);
            spr2.Offset = new Vector2 (0, spr1.Height + 2);
            col2.Offset = new Vector3 (spr1.Width / 2, spr1.Height + 2 + 4/2, 1);
            col2.IgnoreWith = (int)MyGroup.Character;

            var node = new Node ("MyCharacter");
            node.Attach (cmp);
            node.Attach (spr1);
            node.Attach (col1);
            node.Attach (spr2);
            node.Attach (col2);

            node.Translation = pos;
            node.DrawPriority = -1;
            node.GroupID = (int)MyGroup.Character;

            // アニメーションの設定
            var track1 = new AnimationTrack ("TextureOffset", InterpolationType.Step);
            track1.AddKeyframe (0, new Vector2 (0, 64));
            track1.AddKeyframe (300, new Vector2 (24, 64));
            track1.AddKeyframe (600, new Vector2 (48, 64));
            var clip1 = new AnimationClip (900, "MyCharacter.Down");
            clip1.AddTrack (spr1, track1);

            var track2 = new AnimationTrack ("TextureOffset", InterpolationType.Step);
            track2.AddKeyframe (0, new Vector2 (0, 0));
            track2.AddKeyframe (300, new Vector2 (24, 0));
            track2.AddKeyframe (600, new Vector2 (48, 0));
            var clip2 = new AnimationClip (900, "MyCharacter.Up");
            clip2.AddTrack (spr1, track2);

            var track3 = new AnimationTrack ("TextureOffset", InterpolationType.Step);
            track3.AddKeyframe (0, new Vector2 (0, 32));
            track3.AddKeyframe (300, new Vector2 (24, 32));
            track3.AddKeyframe (600, new Vector2 (48, 32));
            var clip3 = new AnimationClip (900, "MyCharacter.Right");
            clip3.AddTrack (spr1, track3);

            var track4 = new AnimationTrack ("TextureOffset", InterpolationType.Step);
            track4.AddKeyframe (0, new Vector2 (0, 96));
            track4.AddKeyframe (300, new Vector2 (24, 96));
            track4.AddKeyframe (600, new Vector2 (48, 96));
            var clip4 = new AnimationClip (900, "MyCharacter.Left");
            clip4.AddTrack (spr1, track4);

            node.UserData.Add (clip1.Name, clip1);
            node.UserData.Add (clip2.Name, clip2);
            node.UserData.Add (clip3.Name, clip3);
            node.UserData.Add (clip4.Name, clip4);

            // ステート管理
            cmp.sm.Configure (State.Down)
                    .Ignore (Trigger.Down)
                    .Permit (Trigger.Up, State.Up)
                    .Permit (Trigger.Right, State.Right)
                    .Permit (Trigger.Left, State.Left)
                    .OnExit (x => clip1.Stop ())
                    .OnEntry (x => clip1.Play ());

            cmp.sm.Configure (State.Up)
                    .Permit (Trigger.Down, State.Down)
                    .Ignore (Trigger.Up)
                    .Permit (Trigger.Right, State.Right)
                    .Permit (Trigger.Left, State.Left)
                    .OnExit (x => clip2.Stop ())
                    .OnEntry (x => clip2.Play ());

            cmp.sm.Configure (State.Right)
                    .Permit (Trigger.Down, State.Down)
                    .Permit (Trigger.Up, State.Up)
                    .Ignore (Trigger.Right)
                    .Permit (Trigger.Left, State.Left)
                    .OnExit (x => clip3.Stop ())
                    .OnEntry (x => clip3.Play ());

            cmp.sm.Configure (State.Left)
                    .Permit (Trigger.Down, State.Down)
                    .Permit (Trigger.Up, State.Up)
                    .Permit (Trigger.Right, State.Right)
                    .Ignore (Trigger.Left)
                    .OnExit (x => clip4.Stop ())
                    .OnEntry (x => clip4.Play ());

            return node;
        }
예제 #12
0
        public void Test_Sample_Linear_ValueType()
        {
            var track = new AnimationTrack ("PropetyName", InterpolationType.Linear);

            track.AddKeyframe (1, new Vector3 (1, 2, 0));
            track.AddKeyframe (2, new Vector3 (2, 3, 0));

            Assert.AreEqual (1.0f, track.Sample (0.0f).X, 0.0001f);
            Assert.AreEqual (1.0f, track.Sample (0.5f).X, 0.0001f);
            Assert.AreEqual (1.0f, track.Sample (1.0f).X, 0.0001f);
            Assert.AreEqual (1.5f, track.Sample (1.5f).X, 0.0001f);
            Assert.AreEqual (2.0f, track.Sample (2.0f).X, 0.0001f);
            Assert.AreEqual (2.0f, track.Sample (2.5f).X, 0.0001f);

            Assert.AreEqual (2.0f, track.Sample (0.0f).Y, 0.0001f);
            Assert.AreEqual (2.0f, track.Sample (0.5f).Y, 0.0001f);
            Assert.AreEqual (2.0f, track.Sample (1.0f).Y, 0.0001f);
            Assert.AreEqual (2.5f, track.Sample (1.5f).Y, 0.0001f);
            Assert.AreEqual (3.0f, track.Sample (2.0f).Y, 0.0001f);
            Assert.AreEqual (3.0f, track.Sample (2.5f).Y, 0.0001f);
        }
예제 #13
0
        public void Test_Sample_ValueType_Float2Int()
        {
            var track = new AnimationTrack ("PropetyName", InterpolationType.Linear);

            track.AddKeyframe (1, new MyStruct (1, 0));     // Int
            track.AddKeyframe (100, new MyStruct (100, 0)); // Int

            Assert.AreEqual (1, track.Sample (1).X);         // Int
            Assert.AreEqual (50, track.Sample (50).X);       // Int
            Assert.AreEqual (100, track.Sample (100).X);     // Int
        }
예제 #14
0
        public void Test_Sample_ValueType_Convert_Float2Int()
        {
            var track = new AnimationTrack ("PropetyName", InterpolationType.Linear);

            track.AddKeyframe (1, 1);                         // Int
            track.AddKeyframe (100, 100);                     // Int

            Assert.AreEqual (1, track.Sample (1), 0.0001f);      // Int
            Assert.AreEqual (50, track.Sample (50), 0.0001f);    // Int
            Assert.AreEqual (100, track.Sample (100), 0.0001f);  // Int
        }
예제 #15
0
        public override object Load(LoadedAsset asset)
        {
            XmlReader xmlReader = XmlReader.Create(asset.Data);

            while (xmlReader.Read())
            {
                if (xmlReader.NodeType == XmlNodeType.Element)
                {
                    if (xmlReader.Name == ApxExporter.TOKEN_NODE)
                    {
                        node = true;
                        geom = false;
                        string name = xmlReader.GetAttribute(ApxExporter.TOKEN_NAME);
                        Node   n    = new Node(name);
                        if (lastNode != null)
                        {
                            lastNode.AddChild(n);
                        }
                        lastNode = n;
                        nodes.Add(n);
                    }
                    else if (xmlReader.Name == ApxExporter.TOKEN_GEOMETRY)
                    {
                        node = false;
                        geom = true;
                        string   name = xmlReader.GetAttribute(ApxExporter.TOKEN_NAME);
                        Geometry g    = new Geometry();
                        g.Name = name;
                        if (lastNode != null)
                        {
                            lastNode.AddChild(g);
                        }
                        geoms.Add(g);
                    }
                    else if (xmlReader.Name == ApxExporter.TOKEN_MATERIAL)
                    {
                        Material mat = new Material();
                        mats.Add(mat);
                        string bucketStr = xmlReader.GetAttribute(ApxExporter.TOKEN_MATERIAL_BUCKET);
                        RenderManager.Bucket bucket;
                        if (bucketStr != null)
                        {
                            Enum.TryParse <RenderManager.Bucket>(bucketStr, out bucket);
                        }
                        else
                        {
                            bucket = RenderManager.Bucket.Opaque;
                        }
                        Console.WriteLine("Bucket: " + bucket.ToString());
                        mat.Bucket = bucket;
                    }
                    else if (xmlReader.Name == ApxExporter.TOKEN_MATERIAL_PROPERTY)
                    {
                        Material lastMaterial = mats[mats.Count - 1];

                        string name = xmlReader.GetAttribute(ApxExporter.TOKEN_NAME);
                        string type = xmlReader.GetAttribute(ApxExporter.TOKEN_TYPE);
                        string val  = xmlReader.GetAttribute(ApxExporter.TOKEN_VALUE);

                        object value = null;
                        if (type == ApxExporter.TOKEN_TYPE_STRING)
                        {
                            value = val;
                        }
                        else if (type == ApxExporter.TOKEN_TYPE_INT)
                        {
                            value = int.Parse(val);
                        }
                        else if (type == ApxExporter.TOKEN_TYPE_BOOLEAN)
                        {
                            value = bool.Parse(val);
                        }
                        else if (type == ApxExporter.TOKEN_TYPE_FLOAT)
                        {
                            value = float.Parse(val);
                        }
                        else if (type == ApxExporter.TOKEN_TYPE_VECTOR2)
                        {
                            value = ParseVector2(val);
                        }
                        else if (type == ApxExporter.TOKEN_TYPE_VECTOR3)
                        {
                            value = ParseVector3(val);
                        }
                        else if (type == ApxExporter.TOKEN_TYPE_VECTOR4)
                        {
                            value = ParseVector4(val);
                        }
                        else if (type == ApxExporter.TOKEN_TYPE_TEXTURE)
                        {
                            string texPath      = val;
                            string parentPath   = System.IO.Directory.GetParent(asset.FilePath).ToString();
                            string finalTexPath = parentPath + "\\" + texPath;
                            if (System.IO.File.Exists(finalTexPath))
                            {
                                value = AssetManager.LoadTexture(finalTexPath);
                            }
                            else if (System.IO.File.Exists(texPath)) // absolute path
                            {
                                value = AssetManager.LoadTexture(texPath);
                            }
                            else
                            {
                                value = null;
                            }
                        }

                        lastMaterial.SetValue(name, value);
                    }
                    else if (xmlReader.Name == ApxExporter.TOKEN_TRANSLATION)
                    {
                        float x = float.Parse(xmlReader.GetAttribute("x"));
                        float y = float.Parse(xmlReader.GetAttribute("y"));
                        float z = float.Parse(xmlReader.GetAttribute("z"));

                        Vector3f   vec = new Vector3f(x, y, z);
                        GameObject go  = null;
                        if (node)
                        {
                            go = nodes[nodes.Count - 1];
                        }
                        else if (geom)
                        {
                            go = geoms[geoms.Count - 1];
                        }
                        go.SetLocalTranslation(vec);
                    }
                    else if (xmlReader.Name == ApxExporter.TOKEN_ROTATION)
                    {
                        float x = float.Parse(xmlReader.GetAttribute("x"));
                        float y = float.Parse(xmlReader.GetAttribute("y"));
                        float z = float.Parse(xmlReader.GetAttribute("z"));
                        float w = float.Parse(xmlReader.GetAttribute("w"));

                        Quaternion quat = new Quaternion(x, y, z, w);
                        GameObject go   = null;
                        if (node)
                        {
                            go = nodes[nodes.Count - 1];
                        }
                        else if (geom)
                        {
                            go = geoms[geoms.Count - 1];
                        }
                        go.SetLocalRotation(quat);
                    }
                    else if (xmlReader.Name == ApxExporter.TOKEN_SCALE)
                    {
                        float x = float.Parse(xmlReader.GetAttribute("x"));
                        float y = float.Parse(xmlReader.GetAttribute("y"));
                        float z = float.Parse(xmlReader.GetAttribute("z"));

                        Vector3f   vec = new Vector3f(x, y, z);
                        GameObject go  = null;
                        if (node)
                        {
                            go = nodes[nodes.Count - 1];
                        }
                        else if (geom)
                        {
                            go = geoms[geoms.Count - 1];
                        }
                        go.SetLocalScale(vec);
                    }
                    else if (xmlReader.Name == ApxExporter.TOKEN_MESH)
                    {
                        meshes.Add(new Mesh());
                    }
                    else if (xmlReader.Name == ApxExporter.TOKEN_VERTICES)
                    {
                        List <Vertex> newVList = new List <Vertex>();
                        vertices.Add(newVList);

                        List <Vector3f> newPList = new List <Vector3f>();
                        positions.Add(newPList);

                        List <Vector3f> newNList = new List <Vector3f>();
                        normals.Add(newNList);

                        List <Vector2f> newT0List = new List <Vector2f>();
                        texcoords0.Add(newT0List);

                        List <Vector2f> newT1List = new List <Vector2f>();
                        texcoords1.Add(newT1List);
                    }
                    else if (xmlReader.Name == ApxExporter.TOKEN_POSITION)
                    {
                        List <Vector3f> pos = positions[positions.Count - 1];

                        float x = float.Parse(xmlReader.GetAttribute("x"));
                        float y = float.Parse(xmlReader.GetAttribute("y"));
                        float z = float.Parse(xmlReader.GetAttribute("z"));

                        Vector3f position = new Vector3f(x, y, z);
                        pos.Add(position);
                    }
                    else if (xmlReader.Name == ApxExporter.TOKEN_NORMAL)
                    {
                        List <Vector3f> nor = normals[normals.Count - 1];

                        float x = float.Parse(xmlReader.GetAttribute("x"));
                        float y = float.Parse(xmlReader.GetAttribute("y"));
                        float z = float.Parse(xmlReader.GetAttribute("z"));

                        Vector3f normal = new Vector3f(x, y, z);
                        nor.Add(normal);
                    }
                    else if (xmlReader.Name == ApxExporter.TOKEN_TEXCOORD0)
                    {
                        List <Vector2f> tc0 = texcoords0[texcoords0.Count - 1];

                        float x = float.Parse(xmlReader.GetAttribute("x"));
                        float y = float.Parse(xmlReader.GetAttribute("y"));

                        Vector2f tc = new Vector2f(x, y);
                        tc0.Add(tc);
                    }
                    else if (xmlReader.Name == ApxExporter.TOKEN_TEXCOORD1)
                    {
                        List <Vector2f> tc1 = texcoords1[texcoords1.Count - 1];

                        float x = float.Parse(xmlReader.GetAttribute("x"));
                        float y = float.Parse(xmlReader.GetAttribute("y"));

                        Vector2f tc = new Vector2f(x, y);
                        tc1.Add(tc);
                    }
                    else if (xmlReader.Name == ApxExporter.TOKEN_FACES)
                    {
                        faces.Add(new List <int>());
                    }
                    else if (xmlReader.Name == ApxExporter.TOKEN_FACE)
                    {
                        List <int> fList = faces[faces.Count - 1];
                        for (int i = 0; i < 3; i++)
                        {
                            string val = xmlReader.GetAttribute("i" + i.ToString());
                            if (val != "")
                            {
                                string[] tokens = val.Split('/');
                                for (int j = 0; j < tokens.Length; j++)
                                {
                                    fList.Add(int.Parse(tokens[j]));
                                }
                            }
                        }
                    }
                    else if (xmlReader.Name == ApxExporter.TOKEN_SKELETON)
                    {
                        skeletons.Add(new Skeleton());
                        bones.Add(new List <Bone>());
                    }
                    else if (xmlReader.Name == ApxExporter.TOKEN_SKELETON_ASSIGN)
                    {
                        string assign = xmlReader.GetAttribute(ApxExporter.TOKEN_ID);
                        skeletonAssigns.Add(int.Parse(assign));
                    }
                    else if (xmlReader.Name == ApxExporter.TOKEN_BONE)
                    {
                        string      name   = xmlReader.GetAttribute(ApxExporter.TOKEN_NAME);
                        string      parent = xmlReader.GetAttribute(ApxExporter.TOKEN_PARENT);
                        Bone        bone   = new Bone(name);
                        List <Bone> lastBL = bones[bones.Count - 1];
                        if (!string.IsNullOrEmpty(parent))
                        {
                            foreach (Bone b in lastBL)
                            {
                                if (b.Name == parent)
                                {
                                    b.AddChild(bone);
                                }
                            }
                        }
                        List <Bone> skel = bones[bones.Count - 1];
                        skel.Add(bone);
                        Skeleton lastSkeleton = skeletons[skeletons.Count - 1];
                        lastSkeleton.AddBone(bone);
                    }
                    else if (xmlReader.Name == ApxExporter.TOKEN_BONE_BINDPOSITION)
                    {
                        float x = float.Parse(xmlReader.GetAttribute("x"));
                        float y = float.Parse(xmlReader.GetAttribute("y"));
                        float z = float.Parse(xmlReader.GetAttribute("z"));

                        Vector3f    vec  = new Vector3f(x, y, z);
                        List <Bone> skel = bones[bones.Count - 1];
                        if (skel.Count > 0)
                        {
                            Bone lastBone = skel[skel.Count - 1];
                            lastBone.SetBindTranslation(vec);
                        }
                    }
                    else if (xmlReader.Name == ApxExporter.TOKEN_BONE_BINDROTATION)
                    {
                        float x = float.Parse(xmlReader.GetAttribute("x"));
                        float y = float.Parse(xmlReader.GetAttribute("y"));
                        float z = float.Parse(xmlReader.GetAttribute("z"));
                        float w = float.Parse(xmlReader.GetAttribute("w"));

                        List <Bone> skel = bones[bones.Count - 1];
                        if (skel.Count > 0)
                        {
                            Bone lastBone = skel[skel.Count - 1];
                            //   lastBone.SetBindAxisAngle(new Vector3f(x, y, z), w);
                            lastBone.SetBindRotation(new Quaternion(x, y, z, w));
                        }
                    }
                    else if (xmlReader.Name == ApxExporter.TOKEN_BONE_ASSIGNS)
                    {
                        boneAssigns.Add(new List <BoneAssign>());
                    }
                    else if (xmlReader.Name == ApxExporter.TOKEN_BONE_ASSIGN)
                    {
                        int               vertIdx    = int.Parse(xmlReader.GetAttribute(ApxExporter.TOKEN_VERTEXINDEX));
                        int               boneIdx    = int.Parse(xmlReader.GetAttribute(ApxExporter.TOKEN_BONEINDEX));
                        float             boneWeight = float.Parse(xmlReader.GetAttribute(ApxExporter.TOKEN_BONEWEIGHT));
                        List <BoneAssign> ba         = boneAssigns[boneAssigns.Count - 1];
                        ba.Add(new BoneAssign(vertIdx, boneWeight, boneIdx));
                    }
                    else if (xmlReader.Name == ApxExporter.TOKEN_ANIMATIONS)
                    {
                        hasAnimations = true;
                    }
                    else if (xmlReader.Name == ApxExporter.TOKEN_ANIMATION)
                    {
                        string    name = xmlReader.GetAttribute(ApxExporter.TOKEN_NAME);
                        Animation anim = new Animation(name);
                        animations.Add(anim);
                    }
                    else if (xmlReader.Name == ApxExporter.TOKEN_ANIMATION_TRACK)
                    {
                        string bone = xmlReader.GetAttribute(ApxExporter.TOKEN_BONE);
                        Bone   b    = skeletons[skeletons.Count - 1].GetBone(bone);
                        if (b != null)
                        {
                            AnimationTrack track = new AnimationTrack(b);
                            animations[animations.Count - 1].AddTrack(track);
                        }
                    }
                    else if (xmlReader.Name == ApxExporter.TOKEN_KEYFRAME)
                    {
                        float time = float.Parse(xmlReader.GetAttribute(ApxExporter.TOKEN_TIME));

                        Keyframe       frame  = new Keyframe(time, null, null);
                        Animation      canim  = animations[animations.Count - 1];
                        AnimationTrack ctrack = canim.GetTrack(canim.GetTracks().Count - 1);
                        ctrack.AddKeyframe(frame);
                    }
                    else if (xmlReader.Name == ApxExporter.TOKEN_KEYFRAME_TRANSLATION)
                    {
                        Animation      canim     = animations[animations.Count - 1];
                        AnimationTrack ctrack    = canim.GetTrack(canim.GetTracks().Count - 1);
                        Keyframe       lastFrame = ctrack.frames[ctrack.frames.Count - 1];

                        float x = float.Parse(xmlReader.GetAttribute("x"));
                        float y = float.Parse(xmlReader.GetAttribute("y"));
                        float z = float.Parse(xmlReader.GetAttribute("z"));

                        Vector3f vec = new Vector3f(x, y, z);
                        lastFrame.SetTranslation(vec);
                    }
                    else if (xmlReader.Name == ApxExporter.TOKEN_KEYFRAME_ROTATION)
                    {
                        Animation      canim     = animations[animations.Count - 1];
                        AnimationTrack ctrack    = canim.GetTrack(canim.GetTracks().Count - 1);
                        Keyframe       lastFrame = ctrack.frames[ctrack.frames.Count - 1];

                        float x = float.Parse(xmlReader.GetAttribute("x"));
                        float y = float.Parse(xmlReader.GetAttribute("y"));
                        float z = float.Parse(xmlReader.GetAttribute("z"));
                        float w = float.Parse(xmlReader.GetAttribute("w"));

                        Quaternion rot = new Quaternion(x, y, z, w);
                        lastFrame.SetRotation(rot);
                    }
                } // start element
                else if (xmlReader.NodeType == XmlNodeType.EndElement)
                {
                    if (xmlReader.Name == ApxExporter.TOKEN_NODE)
                    {
                        if (lastNode != null)
                        {
                            if (lastNode.GetParent() != null)
                            {
                                lastNode = lastNode.GetParent();
                            }
                            else
                            {
                                lastNode = null;
                            }
                        }
                        node = false;
                    }
                    else if (xmlReader.Name == ApxExporter.TOKEN_GEOMETRY)
                    {
                        geom = false;
                    }
                    else if (xmlReader.Name == ApxExporter.TOKEN_MATERIAL)
                    {
                        if (geoms.Count > 0)
                        {
                            int      lastGeomIndex = geoms.Count - 1;
                            Geometry parent        = geoms[lastGeomIndex];
                            int      lastMatIndex  = mats.Count - 1;
                            Material m             = mats[lastMatIndex];
                            geomMats.Add(parent, m);
                        }
                    }
                    else if (xmlReader.Name == ApxExporter.TOKEN_SKELETON)
                    {
                    }
                    else if (xmlReader.Name == ApxExporter.TOKEN_MODEL)
                    {
                        // end of model, load in meshes
                        EndModel();
                    }
                } // end element
            }
            xmlReader.Close();
            Node finalNode = new Node();

            foreach (Node n in nodes)
            {
                if (n.GetParent() == null)
                {
                    finalNode.AddChild(n);
                }
            }
            this.ResetLoader();
            return(finalNode);
        }