public LinearSpring CreateLinearSpring(Body body1, Vector2 attachPoint1, Body body2, Vector2 attachPoint2, float springConstant, float dampingConstant) { LinearSpring linearSpring = new LinearSpring(body1, attachPoint1, body2, attachPoint2, springConstant, dampingConstant); return linearSpring; }
public LinearSpringBrush AddLinearSpringBrushToCanvas(LinearSpring spring) { LinearSpringBrush fls = new LinearSpringBrush(); fls.LinearSpring = spring; Children.Add(fls); drawingList.Add(fls); return fls; }
public override void LoadContent() { _chainTexture = DrawingHelper.CreateRectangleTexture(ScreenManager.GraphicsDevice, 20, 10, Color.White, Color.Black); _obstaclesTexture = DrawingHelper.CreateRectangleTexture(ScreenManager.GraphicsDevice, 40, 40, Color.Brown, Color.Black); _wheelTexture = DrawingHelper.CreateCircleTexture(ScreenManager.GraphicsDevice, 45, 2, Color.White, Color.Black); _chainOrigin = new Vector2(_chainTexture.Width / 2f, _chainTexture.Height / 2f); _wheelOrigin = new Vector2(_wheelTexture.Width / 2f, _wheelTexture.Height / 2f); _obstaclesOrigin = new Vector2(_obstaclesTexture.Width / 2f, _obstaclesTexture.Height / 2f); Vector2 center = new Vector2(400, 500); _controlPoints = new Vertices(); _controlPoints.Add(new Vector2(-15, -50) + center); _controlPoints.Add(new Vector2(-50, -50) + center); _controlPoints.Add(new Vector2(-100, -25) + center); _controlPoints.Add(new Vector2(-100, 25) + center); _controlPoints.Add(new Vector2(-50, 50) + center); _controlPoints.Add(new Vector2(50, 50) + center); _controlPoints.Add(new Vector2(100, 25) + center); _controlPoints.Add(new Vector2(100, -25) + center); _controlPoints.Add(new Vector2(50, -50) + center); _controlPoints.Add(new Vector2(-10, -50) + center); _track = ComplexFactory.Instance.CreateTrack(PhysicsSimulator, _controlPoints, 20.0f, 10.0f, 3.0f, true, 2, LinkType.RevoluteJoint); foreach (Geom g in _track.Geoms) g.FrictionCoefficient = 1.0f; _wheel1 = BodyFactory.Instance.CreateCircleBody(PhysicsSimulator, 45, 30); _wheel1.Position = new Vector2(-50, 0) + center; _wheel2 = BodyFactory.Instance.CreateCircleBody(PhysicsSimulator, 45, 30); _wheel2.Position = new Vector2(50, 0) + center; _wheelg = GeomFactory.Instance.CreateCircleGeom(PhysicsSimulator, _wheel1, 45, 36); _wheelg.FrictionCoefficient = 1.0f; _wheelg = GeomFactory.Instance.CreateCircleGeom(PhysicsSimulator, _wheel2, 45, 36); _wheelg.FrictionCoefficient = 1.0f; _spring = SpringFactory.Instance.CreateLinearSpring(PhysicsSimulator, _wheel1, new Vector2(), _wheel2, new Vector2(), 5200, 3050); _spring.RestLength += 20; _obstacles = new GenericList<Body>(8); base.LoadContent(); }