Exemplo n.º 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();
        }
Exemplo n.º 2
0
        protected override void OnLoad(EventArgs e)
        {
            base.OnLoad(e);
            //②-A 描画に利用するリソースの初期化
            textFormat = SpriteBatch.CreateTextformat("Meiriyo", 30, FontWeight.Bold);
            //Specify the text format alignment do。
            textFormat.Format.ParagraphAlignment = ParagraphAlignment.Center; //Vertical alignment。Center:中央、Near:上、Far:下
            textFormat.Format.TextAlignment      = TextAlignment.Center;      //Horizontal alignment。Center:中央、Near:左、Far:右


            colorBrush = SpriteBatch.CreateSolidColorBrush(Color.OrangeRed);


            OpenFileDialog ofd = new OpenFileDialog();

            ofd.Filter = "ビットマップファイル(*.bmp)|*.bmp|PNGファイル(*.png)|*.png|JPGファイル(*.jpg)|*.jpg|すべてのファイル(*.*)|*.*";
            if (ofd.ShowDialog(this) == DialogResult.OK)
            {
                bitmap = SpriteBatch.CreateBitmap(ofd.FileName);
            }
            else
            {
                Close();
            }



            /*
             * 画面がリサイズされた時などには、SpriteBatchが自動的にリサイズされる。
             * この時、リソースも作り直す必要性があるためSpriteBatch.Create~~として取得できるD2DSprite~~は自動的に
             * リサイズ時などに同じ設定で再作成される。
             * ただし、すべてのDirectWriteに利用するクラスについてこれは実装を完了していない。
             */
            OpenFileDialog ofd2 = new OpenFileDialog();

            ofd2.Filter = "PMXモデルファイル(*.pmx)|*.pmx";
            if (ofd2.ShowDialog(this) == DialogResult.OK)
            {
                WorldSpace.AddResource(PMXModelWithPhysics.OpenLoad(ofd2.FileName, RenderContext));
            }
        }