Exemplo n.º 1
0
 public void Reset()
 {
     if (b2Body != null)
     {
         refWorld.B2World.DestroyBody(b2Body);
         b2Body.Dispose();
     }
     b2BodyDef          = new BodyDef();
     b2PolygonDef       = new PolygonDef();
     b2BodyDef.Position = PhysicalConvert.Tob2Vector(DrawingArea.Size / 2.0f + DrawingArea.Position);
     CenterPosition     = DrawingArea.Size / 2.0f;
     b2BodyDef.Angle    = Angle / 180.0f * 3.14f;
     b2PolygonDef.SetAsBox(PhysicalConvert.Tob2Single(DrawingArea.Width) / 2.0f, PhysicalConvert.Tob2Single(DrawingArea.Height) / 2.0f);
     b2PolygonDef.Density             = Density;
     b2PolygonDef.Restitution         = Restitution;
     b2PolygonDef.Friction            = Friction;
     b2PolygonDef.Filter.GroupIndex   = GroupIndex;
     b2PolygonDef.Filter.CategoryBits = CategoryBits;
     b2PolygonDef.Filter.MaskBits     = MaskBits;
     b2Body = refWorld.B2World.CreateBody(b2BodyDef);
     b2Body.CreateFixture(b2PolygonDef);
     if (physicalShapeType == PhysicalShapeType.Dynamic)
     {
         b2Body.SetMassFromShapes();
     }
 }
Exemplo n.º 2
0
 public void Reset()
 {
     if (b2Body != null)
     {
         refWorld.B2World.DestroyBody(b2Body);
         b2Body.Dispose();
     }
     b2BodyDef               = new BodyDef();
     b2CircleDef             = new CircleDef();
     b2BodyDef.Angle         = Angle / 180.0f * 3.14f;
     b2BodyDef.Position      = PhysicalConvert.Tob2Vector(Position);
     b2CircleDef.Radius      = PhysicalConvert.Tob2Single(OuterDiameter / 2.0f);
     b2CircleDef.Density     = Density;
     b2CircleDef.Restitution = Restitution;
     b2CircleDef.Friction    = Friction;
     b2CircleDef.Filter      = new FilterData()
     {
         GroupIndex   = GroupIndex,
         CategoryBits = CategoryBits,
         MaskBits     = MaskBits
     };
     b2Body = refWorld.B2World.CreateBody(b2BodyDef);
     b2Body.CreateFixture(b2CircleDef);
     if (physicalShapeType == PhysicalShapeType.Dynamic)
     {
         b2Body.SetMassFromShapes();
     }
 }
Exemplo n.º 3
0
 /// <summary>
 /// 初期化
 /// </summary>
 /// <param name="shapeType">物理形状タイプ</param>
 /// <param name="world">登録するワールド</param>
 public PhysicalRectangleShape(PhysicalShapeType shapeType, PhysicalWorld world)
 {
     density            = 1;
     restitution        = 0;
     friction           = 0.6f;
     groupIndex         = 0;
     categoryBits       = 0x0001;
     maskBits           = 0xffff;
     b2BodyDef          = new BodyDef();
     b2PolygonDef       = new PolygonDef();
     refWorld           = world;
     physicalShapeType  = shapeType;
     b2BodyDef.Position = PhysicalConvert.Tob2Vector(new asd.Vector2DF());
     b2PolygonDef.SetAsBox(PhysicalConvert.Tob2Single(1) / 2.0f, PhysicalConvert.Tob2Single(1) / 2.0f);
     b2Body = refWorld.B2World.CreateBody(b2BodyDef);
     b2Body.CreateFixture(b2PolygonDef);
     if (physicalShapeType == PhysicalShapeType.Dynamic)
     {
         b2Body.SetMassFromShapes();
     }
     world.Add(this);
 }