public void OnPending(Graphic parent) { this.parent = parent as BodyGraphic; logic = new RaySegmentsCollisionLogic(this.parent.Body); parent.Parent.physicsLogics.Add(logic); logic.NewInfo += logic_NewInfo; }
void AddRays() { List<RaySegment> segments = new List<RaySegment>(); for (Scalar angle = 0; angle < MathHelper.PiOver2; angle += .05f) { RaySegment seg = new RaySegment(); seg.Length = 500; seg.RayInstance = new Ray(Vector2D.Zero, Vector2D.FromLengthAndAngle(1, angle)); segments.Add(seg); } lazer = new Body(new PhysicsState(), new RaySegmentsShape(segments.ToArray()), 1, new Coefficients(1, 1), new Lifespan()); lazer.State.Position.Linear = sparkPoint; lazer.State.Velocity.Angular = .91f; lazer.IgnoresGravity = true; lazer.ApplyPosition(); engine.AddBody(lazer); lazerLogic = new RaySegmentsCollisionLogic(lazer); engine.AddLogic(lazerLogic); lock (objects) { OpenGlObject o = new OpenGlObject(lazer, lazerLogic); lazer.Tag = o; objects.Add(o); } }
public OpenGlObject(Body entity, RaySegmentsCollisionLogic logic):this(entity) { this.logic = logic; }