public void Update(double elapsedTime) { if (_input.Mouse.LeftPressed) { _navMesh.AddPolygon(new ConvexPolygon(_input.Mouse.Position)); } }
public void Update(double elapsedTime) { _selectedPolygon = _navMesh.FindNearestPolygon(_input.Mouse.Position); _selectedVertexIndex = FindSelectedVertex(_input.Mouse.Position, _selectedPolygon, VertexEditRadius); if (_draggingVertex) { if (_input.Mouse.LeftHeld && _selectedVertexIndex != -1) { _selectedPolygon.TryToUpdateVertPosition(_selectedVertexIndex, _input.Mouse.Position); return; } else { _draggingVertex = false; } } if (_input.Keyboard.IsKeyPressed(System.Windows.Forms.Keys.A)) { _navMesh.AddPolygon(new ConvexPolygon(_input.Mouse.Position)); } if (_input.Mouse.LeftHeld && _selectedVertexIndex != -1) { _draggingVertex = true; } }
private static void LoadSinglePolygon(XmlTextReader xmlReader, NavMesh navMesh) { ConvexPolygon polygon = new ConvexPolygon(); xmlReader.MoveToContent(); while (xmlReader.Read()) { if ("point" == xmlReader.Name) { float x = float.Parse(xmlReader.GetAttribute("x")); float y = float.Parse(xmlReader.GetAttribute("y")); polygon.Vertices.Add(new Point(x, y)); } else if ("polygon" == xmlReader.Name) { polygon.GenerateEdges(); navMesh.AddPolygon(polygon); return; } } }