/// <summary>
        /// 初期化
        /// </summary>
        /// <param name="shapeType">物理形状タイプ</param>
        /// <param name="world">登録するワールド</param>
        public PhysicalPolygonShape(PhysicalShapeType shapeType, PhysicalWorld world)
        {
            density       = 1.0f;
            restitution   = 0.3f;
            angle         = 0.0f;
            groupIndex    = 0;
            categoryBits  = 0x0001;
            maskBits      = 0xffff;
            b2BodyDef     = new BodyDef();
            b2PolygonDefs = new List <PolygonDef>();
            vertexes      = new List <asd.Vector2DF>();

            refWorld          = world;
            physicalShapeType = shapeType;
            b2Body            = refWorld.B2World.CreateBody(b2BodyDef);
            foreach (var item in b2PolygonDefs)
            {
                b2Body.CreateFixture(item);
            }
            if (physicalShapeType == PhysicalShapeType.Dynamic)
            {
                b2Body.SetMassFromShapes();
            }
            world.Add(this);
        }
Exemple #2
0
 /// <summary>
 /// 初期化
 /// </summary>
 /// <param name="shapeType">物理形状タイプ</param>
 /// <param name="world">登録するワールド</param>
 public PhysicalTriangleShape(PhysicalShapeType shapeType, PhysicalWorld world)
 {
     density                  = 1.0f;
     restitution              = 0.3f;
     angle                    = 0.0f;
     groupIndex               = 0;
     categoryBits             = 0x0001;
     maskBits                 = 0xffff;
     b2BodyDef                = new BodyDef();
     b2PolygonDef             = new PolygonDef();
     vertexes                 = new List <asd.Vector2DF>();
     b2PolygonDef.VertexCount = 3;
     vertexes.Add(new asd.Vector2DF(0, -1));
     vertexes.Add(new asd.Vector2DF(1, 0));
     vertexes.Add(new asd.Vector2DF(0, 1));
     refWorld          = world;
     physicalShapeType = shapeType;
     b2Body            = refWorld.B2World.CreateBody(b2BodyDef);
     b2Body.CreateFixture(b2PolygonDef);
     if (physicalShapeType == PhysicalShapeType.Dynamic)
     {
         b2Body.SetMassFromShapes();
     }
     world.Add(this);
 }
 /// <summary>
 /// 初期化
 /// </summary>
 /// <param name="shapeType">物理形状タイプ</param>
 /// <param name="world">登録するワールド</param>
 public PhysicalCircleShape(PhysicalShapeType shapeType, PhysicalWorld world)
 {
     density           = 1.0f;
     restitution       = 0.3f;
     base.Angle        = 0.0f;
     groupIndex        = 0;
     categoryBits      = 0x0001;
     maskBits          = 0xffff;
     b2BodyDef         = new BodyDef();
     b2CircleDef       = new CircleDef();
     refWorld          = world;
     physicalShapeType = shapeType;
     b2Body            = refWorld.B2World.CreateBody(b2BodyDef);
     b2Body.CreateFixture(b2CircleDef);
     if (physicalShapeType == PhysicalShapeType.Dynamic)
     {
         b2Body.SetMassFromShapes();
     }
     world.Add(this);
 }
Exemple #4
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);
 }
 public CollisionController(PhysicalWorld world)
 {
     refWorld        = world;
     collisionShapes = new List <CollisionData>();
 }