protected Shape(Phys2DTransform transform) { Debug.Assert(transform != null); this.Transform = transform; this.Transform.OnMove += this.HandleTransformMove; }
public static Phys2DTransform Lerp(Phys2DTransform a, Phys2DTransform b, float t) { var position = Vector2.Lerp(a.Position, b.Position, t); var rotation = Mathf.Lerp(a.Rotation, b.Rotation, t); return(new Phys2DTransform(position, rotation)); }
public Circle(Phys2DTransform transform, float radius) : base(transform) { Debug.Assert(radius > 0f); this.Radius = radius; this.HandleTransformMove(); }
public Body(Shape shape, float mass) { Debug.Assert(shape != null); Debug.Assert(mass > 0f); this.initialTransform = shape.Transform.Clone(); this.Shape = shape; this.Mass = mass; this.Reset(); }
public Polyline(Phys2DTransform transform, PointSet localPoints) : base(transform) { Debug.Assert(localPoints != null && localPoints.Count >= 2); this.localPoints = localPoints; this.localSegments = new List <LineSegment>(); FillMultiEdgeSegments(this.localPoints, this.localSegments); this.worldPoints = new PointSet(); this.worldSegments = new List <LineSegment>(); this.HandleTransformMove(); }
public Polygon(Phys2DTransform transform, PointSet localPoints) : base(transform) { Debug.Assert(localPoints != null && localPoints.Count >= 3); this.localPoints = localPoints; this.localEdges = new List <LineSegment>(); FillPolygonEdges(this.localPoints, this.localEdges); // TODO: Assert whether any edges intersect this.worldPoints = new PointSet(); this.worldEdges = new List <LineSegment>(); this.HandleTransformMove(); }
public void Transform(Phys2DTransform transform) { Debug.Assert(transform != null); var shouldRotate = !Mathf.Approximately(transform.Rotation, 0f); var shouldOffset = transform.Position != Vector2.zero; for (var i = 0; i < this.points.Count; i++) { var newP = this.points[i]; if (shouldRotate) { newP = newP.Rotate(transform.Rotation); } if (shouldOffset) { newP += transform.Position; } this.points[i] = newP; } }
public Phys2DTransform LerpedTransform(float t) { return(Phys2DTransform.Lerp(this.lastTransform, this.Shape.Transform, t)); }
public void Reset() { this.Shape.Transform.Set(this.initialTransform); this.lastTransform = this.Shape.Transform.Clone(); }
public Polygon(Phys2DTransform transform, List <Vector2> localPoints) : this(transform, new PointSet(localPoints)) { }
public void Set(Phys2DTransform transform) { this.Set(transform.Position, transform.Rotation); }