Beispiel #1
0
		public void Set(PSweepAndPrune sap, PShape s, AABB aabb) {
			set = true;
			this.sap = sap;
			parent = s;
			this.aabb = aabb;
			beginX = new PSortableObject(s, this, aabb.minX, true);
			beginY = new PSortableObject(s, this, aabb.minY, true);
			endX = new PSortableObject(s, this, aabb.maxX, false);
			endY = new PSortableObject(s, this, aabb.maxY, false);
			sap.AddObject(beginX, beginY);
			sap.AddObject(endX, endY);
		}
Beispiel #2
0
		public PShape(bool randColor) {
			_fric = 0.5F;
			_rest = 0.5F;
			_localPos = new Vector2f();
			_pos = new Vector2f();
			_mAng = new PTransformer();
			_aabb = new AABB();
			_sapAABB = new PSortableAABB();
			_type = Physics.PShapeType.NULL_SHAPE;
			_rnd = randColor;
			if (randColor) {
				SetColor((int) (MathUtils.Random() * 160F + 96F),
						(int) (MathUtils.Random() * 160F + 96F),
						(int) (MathUtils.Random() * 160F + 96F));
			}
		}
Beispiel #3
0
		public PBody(float angle, bool fixate, PShape[] ss) {
			pos = new Vector2f();
			vel = new Vector2f();
			correctVel = new Vector2f();
			mAng = new PTransformer();
			aabb = new AABB();
			ang = angle;
			numShapes = ss.Length;
			shapes = new PShape[1024];
			for (int i_0 = 0; i_0 < numShapes; i_0++) {
				shapes[i_0] = ss[i_0];
				shapes[i_0]._parent = this;
				if (shapes[i_0]._type == PShapeType.CONCAVE_SHAPE) {
					PConcavePolygonShape cp = (PConcavePolygonShape) shapes[i_0];
					for (int j = 0; j < cp.numConvexes; j++) {
						cp.convexes[j]._parent = this;
					}
	
				}
			}
			fix = fixate;
			CalcMassData();
		}
Beispiel #4
0
 public AABB GetAABB()
 {
     if (aabb == null) {
         aabb = new AABB(minX, minY, maxX, maxY);
     } else {
         aabb.Set(minX, minY, maxX, maxY);
     }
     return aabb;
 }