private void CreateWalls() { walls[0] = bulletPhysics.CreatePlane(0, Matrix.RotationAxis(new Vector3(1, 0, 0), (float)Math.PI) * Matrix.Translation(0, 20, 0)); walls[1] = bulletPhysics.CreatePlane(0, Matrix.RotationAxis(new Vector3(1, 0, 0), (float)-(Math.PI / 2)) * Matrix.Translation(0, 0, 20)); walls[2] = bulletPhysics.CreatePlane(0, Matrix.RotationAxis(new Vector3(1, 0, 0), (float)(Math.PI / 2)) * Matrix.Translation(0, 0, -20)); walls[3] = bulletPhysics.CreatePlane(0, Matrix.RotationAxis(new Vector3(0, 0, 1), (float)(Math.PI / 2)) * Matrix.Translation(20, 0, 0)); walls[4] = bulletPhysics.CreatePlane(0, Matrix.RotationAxis(new Vector3(0, 0, 1), (float)-(Math.PI / 2)) * Matrix.Translation(-20, 0, 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(); }