Ejemplo n.º 1
0
        public BVHClip(Vector3 position,
                       float walkingSpeed,
                       float scale, BVHActionPlayer player,
                       bool grounded, float elastic,
                       params ActionCollection[] actions)
            : base(position, scale, player, grounded, elastic)
        {
            this.Player       = ((BVHActionPlayer)base.Drawable);
            this.Actions      = new ActionCollection(actions);
            this.WalkingSpeed = walkingSpeed;

            this.Player.OnActionComplete += new ActionComplete(player_OnActionComplete);
        }
Ejemplo n.º 2
0
        public WalkingClip(
            Vector3 position,
            float walkingSpeed,
            float scale, BVHActionPlayer player,
            bool grounded, float elastic, IFocusable target, float wantedDistance,
            params ActionCollection[] actions)
            : base(position, scale, player, grounded, elastic)
        {
            this.Player       = ((BVHActionPlayer)base.Drawable);
            this.Actions      = new ActionCollection(actions);
            this.WalkingSpeed = walkingSpeed;

            this.Target         = target;
            this.WantedDistance = wantedDistance;
        }
Ejemplo n.º 3
0
        protected override void LoadContent()
        {
            // Create a new SpriteBatch, which can be used to draw textures.
            spriteBatch = new SpriteBatch(GraphicsDevice);
            S.init(graphics, Content);
            S.Proj = Matrix.CreatePerspectiveFieldOfView(1, S.gd.Viewport.AspectRatio, 0.1f, 1000f);
            Dictionary <string, BVHContent> bla = S.bvhDic;

            //  graphics.PreferredBackBufferWidth = 1200;
            // graphics.PreferredBackBufferHeight = 900;
            //  graphics.ApplyChanges();

            graphics.PreferredBackBufferWidth  = 1024;
            graphics.PreferredBackBufferHeight = 768;
            graphics.ApplyChanges();

            int oiaseg = 5;
            int wut    = oiaseg + 9;

            ac = new ActionCollection(
                Content.Load <ActionCollection>
                    ("xml/stand"),
                Content.Load <ActionCollection>
                    ("xml/walk"),
                Content.Load <ActionCollection>
                    ("xml/punch"),
                Content.Load <ActionCollection>
                    ("xml/jump"),
                Content.Load <ActionCollection>
                    ("xml/leap"),
                Content.Load <ActionCollection>
                    ("xml/land"),
                Content.Load <ActionCollection>
                    ("xml/sitting"));



            playerb = new BVHPlayer("07_05", Color.Red);
            player  = new BVHActionPlayer(ac.other[0], Color.Blue);

            axis = new Axis(S.gd, 500, S.View, S.Proj);
            #region Unused math functions for terrain
            //z = (sin(x)*cos(z)-sin(x)*sin(z))/(x^2+z^2+1)
            //MathFunc mf2 = new MathFunc(new Func<float, float, float>((x, z) =>
            //    {
            //        x *= 0.05f;
            //        z *= 0.05f;
            //        float one = (float)(Math.Sin(x + S.rnd.NextDouble()) * Math.Cos(z + S.rnd.NextDouble()));
            //        float two = (float)(Math.Sin(x + S.rnd.NextDouble()) * Math.Sin(z + S.rnd.NextDouble()));
            //        float divide = (float)(Math.Pow(Math.Abs(Math.Sin(x)), 2) + Math.Pow(Math.Abs(Math.Sin(z)), 2)) + 1;
            //        return (one - two) / divide * 20;
            //    }));
            //MathFunc mfc = new MathFunc(new Func<float, float, float>((x, z) =>
            //{
            //    x *= 0.05f;
            //    z *= 0.05f;
            //    float one = (float)(Math.Sin(x) * Math.Cos(z));
            //    float two = (float)(Math.Sin(x) * Math.Sin(z));
            //    float divide = (float)(Math.Pow(Math.Abs(Math.Sin(x)), 2) + Math.Pow(Math.Abs(Math.Sin(z)), 2)) + 1;
            //    return (one - two) / divide * 10;
            //}));
            //MathFunc kk = new MathFunc(new Func<float, float, float>((x, z) =>
            //  {
            //      return 120;
            //  }));

            #endregion

            #region INIT terrain
            MapFunc map = new MapFunc(Content.Load <Texture2D>("ding"), 0, 150, true);
            //  MapFunc map = new MapFunc(Content.Load<Texture2D>("kkk"), 0, 150, true);

            S.terrain = new AnimatedTerrain(256, 256);

            S.terrain.apply_height_func_over_rect(map, new Rectangle(0, 0, 256, 256));

            /*        S.terrain.apply_height_func_over_rect(
             *          new MathFunc(
             *              new Func<float, float, float>(
             *                  (x, z) =>
             *                  {
             *                      return (float)Math.Sin((double)(new Vector3(x, 0, z) - S.terrain.Size / 2).Length());
             *                  })), new Rectangle(0, 0, 128, 128));*/

            S.terrain.recalculate_normals();
            //  S.terrain.make_it_circle();
            S.terrain.apply_color_texs(Content.Load <Texture2D>("lavab1"),
                                       Content.Load <Texture2D>("lavab2"),
                                       Content.Load <Texture2D>("lavab3"),
                                       Content.Load <Texture2D>("lavab2"));
            S.terrain.apply_height_func_over_delta(
                new MapFunc(
                    Content.Load <Texture2D>("water"), 0, 10, true), -0.5f);
            //S.terrain.update_vertices_colors((int)(map.HighestPoint * 0.8f), 0.9f);
            S.terrain.make_it_circle();
            S.terrain.init_buffers();
            #endregion

            /* sea = new Sea(S.cm.Load<Texture2D>("lava1"),
             *  S.cm.Load<Texture2D>("lava2"),
             *  S.cm.Load<Texture2D>("lava3"),
             *  S.cm.Load<Texture2D>("lava2")); */

            /*     sea = new Sea(S.cm.Load<Texture2D>("sea1"),
             * S.cm.Load<Texture2D>("sea2"),
             * S.cm.Load<Texture2D>("sea3"),
             * S.cm.Load<Texture2D>("sea2"));*/

            intro = Content.Load <Texture2D>("intro");

            gc = new BVHClip(
                Vector3.UnitY * 180,
                0.4f,
                0.2f, player,
                false, 0.17f, ac);

            gcb = new GroundedClip(
                Vector3.UnitY * 180 + Vector3.UnitX * 10,
                0.2f, playerb,
                false, 0f);

            wc = new WalkingClip(gc.Position + Vector3.UnitX * 10,
                                 gc.WalkingSpeed * 0.7f,
                                 gc.Scale,
                                 new BVHActionPlayer(ac.other[0], Color.Gray),
                                 true, 0, gc,
                                 5,
                                 ac);

            S.camera = new Camera3D(gc);

            trees.Add(new DrawableModel(Content.Load <Model>("lowpolypalmii")));
            trees.Add(new DrawableModel(Content.Load <Model>("tree stomp sculpture")));
            //  trees.Add(new DrawableModel(Content.Load<Model>("lowpolytree1")));
            // trees.Add(new DrawableModel(Content.Load<Model>("palm.fbx")));

            for (int t = 0; t < trees.Count; t++)
            {
                for (int i = 0; i < 20; i++)
                {
                    Vector3 pos = Vector3.Transform(Vector3.UnitX, Matrix.CreateRotationY(
                                                        (float)S.rnd.NextDouble() * MathHelper.TwoPi)) * (float)S.rnd.NextDouble() * S.terrain.Width / 2;
                    pos.Y = S.terrain.get_y(pos.X, pos.Z, true);

                    GroundedClip a = new GroundedClip(pos, 1, trees[t], true, 0);
                    a.RotationY = (float)S.rnd.NextDouble() * MathHelper.TwoPi;
                    a.Scale     = 1 + (float)S.rnd.NextDouble() * 5f;
                    bc.Add(a);
                    Game1.Draw3DEvent += a.Draw;
                    Game1.UpdateEvent += a.Update;
                }
            }
        }