/// <summary> /// 剛体を生成する /// </summary> /// <param name="rigidBodyData_s">剛体データ</param> private void CreateRigid(List <RigidBodyData> rigidBodyData_s) { foreach (var r in rigidBodyData_s) { var tempRigidBodyData = new TempRigidBodyData(r); var init_matrix = tempRigidBodyData.init_matrix; tempRigidBodyData_s.Add(tempRigidBodyData); BulletSharp.RigidBody rigidBody = null; CollisionShape collisionShape; switch (r.Shape) { case RigidBodyShape.Sphere: // 球体 collisionShape = new SphereShape(r.Size.X); break; case RigidBodyShape.Box: // ボックス collisionShape = new BoxShape(r.Size.X, r.Size.Y, r.Size.Z); break; case RigidBodyShape.Capsule: // カプセル collisionShape = new CapsuleShape(r.Size.X, r.Size.Y); break; default: // 例外処理 throw new System.Exception("Invalid rigid body data"); } var rigidProperty = new RigidProperty(r.Mass, r.Repulsion, r.Friction, r.MoveAttenuation, r.RotationAttenuation); var superProperty = new SuperProperty(r.PhysicsCalcType == PhysicsCalcType.Static, (CollisionFilterGroups)(1 << r.RigidBodyGroup), (CollisionFilterGroups)r.UnCollisionGroupFlag); rigidBody = bulletManager.CreateRigidBody(collisionShape, init_matrix, rigidProperty, superProperty); rigidBodies.Add(rigidBody); } }
/// <summary> /// To create a rigid /// </summary> /// <param name="rigidBodyData">Rigid data</param> private void CreateRigid(List <RigidBodyData> rigidBodyData) { foreach (var r in rigidBodyData) { var tempRigidBodyData = new TempRigidBodyData(r); //Debug.WriteLine("名字: {0}, 质量: {1}, 排斥力: {2}, 摩擦: {3}, 移动衰减: {4}, 旋转衰减: {5}", // r.RigidBodyName, r.Mass, r.Repulsion, r.Friction, r.MoveAttenuation, r.Rotation); var init_matrix = tempRigidBodyData.init_matrix; this.tempRigidBodyData.Add(tempRigidBodyData); RigidBody rigidBody = null; CollisionShape collisionShape; switch (r.Shape) { case RigidBodyShape.Sphere: // 球体 collisionShape = new SphereShape(r.Size.X); break; case RigidBodyShape.Box: // box collisionShape = new BoxShape(r.Size.X, r.Size.Y, r.Size.Z); break; case RigidBodyShape.Capsule: // capsule collisionShape = new CapsuleShape(r.Size.X, r.Size.Y); break; default: // Exception handling throw new System.Exception("Invalid rigid body data"); } //质量, 排斥力, 摩擦, 移动衰减, 旋转衰减 var rigidProperty = new RigidProperty(r.Mass, r.Repulsion, r.Friction, r.MoveAttenuation, r.RotationAttenuation); var superProperty = new SuperProperty(r.PhysicsCalcType == PhysicsCalcType.Static, (CollisionFilterGroups)(1 << r.RigidBodyGroup), (CollisionFilterGroups)r.UnCollisionGroupFlag); rigidBody = this.bulletManager.CreateRigidBody(collisionShape, init_matrix, rigidProperty, superProperty); this.rigidBodies.Add(rigidBody); } }