Пример #1
0
        protected override void OnLoad(EventArgs e)
        {
            base.OnLoad(e);
            ScreenContext.CameraMotionProvider = new BasicCameraControllerMotionProvider(this, this);
            BasicGrid grid = new BasicGrid();

            grid.Load(RenderContext);
            WorldSpace.AddResource(grid);
            bulletPhysics = new BulletPhysics(new Vector3(0, -9.8f, 0f));
            ground        = bulletPhysics.CreatePlane(0, Matrix.Identity);
            ball_Model    = MMDModel.OpenLoad("1.pmx", RenderContext);
            ball_Model2   = MMDModel.OpenLoad("1.pmx", RenderContext);
            RigidBodyData data = ball_Model.Model.RigidBodyList.RigidBodies[0];

            ball  = bulletPhysics.CreateSphere(data.Size.X, Matrix.Translation(-15, 12f, 0), 1f, 1f, 0f);
            ball2 = bulletPhysics.CreateSphere(data.Size.X, Matrix.Translation(15, 12f, 0), 1f, 1f, 0f);

            rigid2model = GetModelWorldFromRigid();

            WorldSpace.AddResource(ball_Model);
            WorldSpace.AddResource(ball_Model2);
            CreateWalls();
            ball.ApplyCentralImpulse(new Vector3(2, 0.01f, 0f));
            ball2.ApplyCentralImpulse(new Vector3(-2, 0, 0));
            brush  = SpriteBatch.CreateSolidColorBrush(Color.Brown);
            format = SpriteBatch.CreateTextformat("Meiriyo", 30);
            format.Format.ParagraphAlignment = ParagraphAlignment.Center;
            format.Format.TextAlignment      = TextAlignment.Center;
            timer1.Start();
        }
Пример #2
0
        /// <summary>
        ///     コンストラクタ
        /// </summary>
        /// <param name="renderContext">レンダーコンテキスト</param>
        public Billiard(RenderContext renderContext)
        {
            CreateBallRayout();
            Vector3 gravity = new Vector3(0, -9.8f * 2.5f, 0);

            bulletPhysics = new BulletPhysics(gravity);

            MMDModel model = MMDModel.OpenLoad("../../res/ビリヤード台.pmx", renderContext);

            models.Add(model);
            CreateBilliardRigids(model);

            for (int i = 0; i < ballRayout.Count; ++i)
            {
                model = MMDModel.OpenLoad("../../res/" + (i + 1) + ".pmx", renderContext);
                models.Add(model);
                CreateSphereRigid(model, ballRayout[i]);
            }
            transferMatrixFromRigidToModel = GetTransferMatrixFromRigidToModel();
        }
Пример #3
0
        private void Form1_Load(object sender, EventArgs e)
        {
            panel.Initialize();
            panel.RenderContext.CameraMotionProvider = new BasicCameraControllerMotionProvider(panel, this);
            panel.Dock = DockStyle.Fill;
            Controls.Add(panel);
            var grid = new NormalGrid();

            grid.Visiblity = true;
            grid.Load(panel.RenderContext);
            panel.RenderContext.AddResource(grid);
            const int Nball  = 20;              // 球の数
            var       models = new List <MMDModel>();

            for (int i = 0; i < Nball; ++i)
            {
                models.Add(MMDModel.OpenLoad("../../res/1.pmx", panel.RenderContext));
                panel.RenderContext.AddResource(models[i]);
            }
            freeFall = new FreeFall(models);
        }