public override void Update() { base.Update(); // Dividers DrawLine(new Vector2(0, HALF_H), new Vector2(0, -HALF_H), Color.White); DrawLine(new Vector2(-HALF_W, 0), new Vector2(HALF_W, 0), Color.White); // Goal markers DrawCircle(goal, 10, 10, Color.Green); DrawCircle(goal + new Vector2(HALF_W, 0), 10, 10, Color.Green); DrawCircle(goal + new Vector2(0, -HALF_H), 10, 10, Color.Green); DrawCircle(goal + new Vector2(HALF_W, -HALF_H), 10, 10, Color.Green); // Solution Spaces DrawCircle(hingeJT.DefaultPosition, hingeJT.SolutionSpaceRadius(), 30, Color.DarkRed); DrawCircle(hingeJI.DefaultPosition, hingeJI.SolutionSpaceRadius(), 30, Color.DarkRed); DrawCircle(hingeDLS.DefaultPosition, hingeDLS.SolutionSpaceRadius(), 30, Color.DarkRed); DrawCircle(hingeCCD.DefaultPosition, hingeCCD.SolutionSpaceRadius(), 30, Color.DarkRed); // Joints Vertices.AddRange(hingeJT.GetVertices()); Vertices.AddRange(hingeJI.GetVertices()); Vertices.AddRange(hingeDLS.GetVertices()); Vertices.AddRange(hingeCCD.GetVertices()); }
public override void Update() { base.Update(); DrawCircle(goal, 10, 10, Color.Green); DrawCircle(Vector2.Zero, baseJoint.SolutionSpaceRadius(), 100, Color.DarkRed); Vertices.AddRange(baseJoint.GetVertices()); }
public override void Update() { base.Update(); // Goal Marker DrawCircle(goal, 5, 5, Color.Green); // Solution Spaces DrawCircle(leftJoint.DefaultPosition, leftJoint.SolutionSpaceRadius(), 30, new Color(50, 0, 0)); DrawCircle(rightJoint.DefaultPosition, rightJoint.SolutionSpaceRadius(), 30, new Color(50, 0, 0)); // Joints Vertices.AddRange(leftJoint.GetVertices()); Vertices.AddRange(rightJoint.GetVertices()); }
public override void Input(InputManager input) { if (input.IsKeyPressed(Keys.Escape)) { Exit(); } camera.Input(input, GameTime); if (updateFocusJoint) { var toMouse = new Vector2( input.CurrentMousePosition.X - (focusJoint.GlobalPosition.X + WIDTH / 2), -input.CurrentMousePosition.Y + (-focusJoint.GlobalPosition.Y + HEIGHT / 2) ); focusJoint.Angle = (float)Math.Atan2( toMouse.Y, toMouse.X ); if (input.IsKeyPressed(Keys.M)) { if (focusJoint.Child != null) { focusJoint = focusJoint.Child; } else { focusJoint = null; updateFocusJoint = false; } } if (input.IsKeyPressed(Keys.N)) { focusJoint = focusJoint.Parent != null ? focusJoint.Parent : focusJoint; } } if (input.IsKeyPressed(Keys.Space)) { updateFocusJoint = true; focusJoint = baseJoint; } if (input.IsKeyDown(Keys.LeftShift) || input.IsKeyDown(Keys.RightShift)) { if (input.IsKeyPressed(Keys.J)) { JTIterate(); } if (input.IsKeyPressed(Keys.K)) { JIIterate(); } if (input.IsKeyPressed(Keys.L)) { CCDIterate(); } if (input.IsKeyPressed(Keys.OemSemicolon)) { DLSIterate(); } } else { if (input.IsKeyDown(Keys.J)) { JTIterate(); } if (input.IsKeyDown(Keys.K)) { JIIterate(); } if (input.IsKeyDown(Keys.L)) { CCDIterate(); } if (input.IsKeyDown(Keys.OemSemicolon)) { DLSIterate(); } } if (input.IsMouseDown(MouseButtons.Left)) { goal = input.CurrentMousePosition.ToVector2(); goal -= new Vector2(WIDTH / 2, HEIGHT / 2); goal.Y = -goal.Y; var dist = Vector2.Distance(goal, Vector2.Zero); var rad = baseJoint.SolutionSpaceRadius(); if (dist > rad) { goal *= rad / dist; } } base.Input(input); }