Exemple #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();
        }
Exemple #2
0
        // 球の剛体を作る
        private void CreateSphereRigid(MMDModel model, Vector3 rigid_position)
        {
            RigidBodyData rigidBody    = model.Model.RigidBodyList.RigidBodies[0];
            float         radius       = rigidBody.Size.X;
            float         mass         = rigidBody.Mass;
            float         restitution  = 1; //rigidBody.Repulsion;
            float         friction     = 0; //rigidBody.Friction;
            float         linear_damp  = 0; // rigidBody.MoveAttenuation;
            float         angular_damp = rigidBody.RotationAttenuation;
            Matrix        world        = Matrix.Translation(rigid_position);
            ConvexShape   shape;

            balls.Add(bulletPhysics.CreateSphere(radius, world, mass, restitution, friction, linear_damp, angular_damp));
            count++;
        }
Exemple #3
0
        // 玉を作る
        void CreateSphereRigids()
        {
            var mmdRigidBody = models[0].Model.rigidBodyList.RigidBodies[0];
            var radius       = mmdRigidBody.Size.X;
            var mass         = mmdRigidBody.Mass;
            var restitution  = mmdRigidBody.Repulsion;
            var friction     = mmdRigidBody.Friction;
            var linear_damp  = mmdRigidBody.MoveAttenuation;
            var angular_damp = mmdRigidBody.RotationAttenuation;

            for (int i = 0; i < models.Count; ++i)
            {
                var world = Matrix.Translation(i * 0.003f, 1.0f * i + 1.0f, i * 0.002f);                // 剛体のワールド変換行列
                bodies.Add(bulletPhysics.CreateSphere(radius, world, mass, restitution, friction, linear_damp, angular_damp));
            }
        }