home *** CD-ROM | disk | FTP | other *** search
/ 404 Jogos / CLJG.iso / Diversos / pup_idol.swf / scripts / Box2D / Collision / Shapes / b2ShapeDef.as < prev   
Encoding:
Text File  |  2008-08-07  |  2.3 KB  |  84 lines

  1. package Box2D.Collision.Shapes
  2. {
  3.    import Box2D.Common.Math.b2Math;
  4.    import Box2D.Common.Math.b2Vec2;
  5.    import Box2D.Common.b2Settings;
  6.    
  7.    public class b2ShapeDef
  8.    {
  9.        
  10.       
  11.       public var type:int;
  12.       
  13.       public var groupIndex:int;
  14.       
  15.       public var localPosition:b2Vec2;
  16.       
  17.       public var categoryBits:int;
  18.       
  19.       public var localRotation:Number;
  20.       
  21.       public var density:Number;
  22.       
  23.       public var restitution:Number;
  24.       
  25.       public var userData:* = null;
  26.       
  27.       public var maskBits:int;
  28.       
  29.       public var friction:Number;
  30.       
  31.       public function b2ShapeDef()
  32.       {
  33.          super();
  34.          type = b2Shape.e_unknownShape;
  35.          userData = null;
  36.          localPosition = new b2Vec2(0,0);
  37.          localRotation = 0;
  38.          friction = 0.2;
  39.          restitution = 0;
  40.          density = 0;
  41.          categoryBits = 1;
  42.          maskBits = 65535;
  43.          groupIndex = 0;
  44.       }
  45.       
  46.       public function ComputeMass(param1:b2MassData) : void
  47.       {
  48.          var _loc2_:b2CircleDef = null;
  49.          var _loc3_:b2BoxDef = null;
  50.          var _loc4_:b2PolyDef = null;
  51.          param1.center = new b2Vec2(0,0);
  52.          if(density == 0)
  53.          {
  54.             param1.mass = 0;
  55.             param1.center.Set(0,0);
  56.             param1.I = 0;
  57.          }
  58.          switch(type)
  59.          {
  60.             case b2Shape.e_circleShape:
  61.                _loc2_ = this as b2CircleDef;
  62.                param1.mass = density * b2Settings.b2_pi * _loc2_.radius * _loc2_.radius;
  63.                param1.center.Set(0,0);
  64.                param1.I = 0.5 * param1.mass * _loc2_.radius * _loc2_.radius;
  65.                break;
  66.             case b2Shape.e_boxShape:
  67.                _loc3_ = this as b2BoxDef;
  68.                param1.mass = 4 * density * _loc3_.extents.x * _loc3_.extents.y;
  69.                param1.center.Set(0,0);
  70.                param1.I = param1.mass / 3 * b2Math.b2Dot(_loc3_.extents,_loc3_.extents);
  71.                break;
  72.             case b2Shape.e_polyShape:
  73.                _loc4_ = this as b2PolyDef;
  74.                b2Shape.PolyMass(param1,_loc4_.vertices,_loc4_.vertexCount,density);
  75.                break;
  76.             default:
  77.                param1.mass = 0;
  78.                param1.center.Set(0,0);
  79.                param1.I = 0;
  80.          }
  81.       }
  82.    }
  83. }
  84.