Implemented road & road mesh generator.

This commit is contained in:
2015-06-02 20:50:59 +03:00
parent 61a05289d3
commit f9b20b0226
27 changed files with 730 additions and 53 deletions

View File

@ -80,6 +80,33 @@ namespace TransportGame.Model.Road
[XmlAttribute("lanesTo1")]
public int LanesTo1 { get; set; }
/// <summary>
/// Gets the direction vector of this road segment
/// </summary>
[XmlIgnore]
public Vector2 Direction
{
get
{
if (Terminal1Id == -1 || Terminal2Id == -1 || ParentNetwork == null)
return Vector2.Zero;
return (Terminal2.Position - Terminal1.Position).Normalized;
}
}
/// <summary>
/// Gets the road segment as a line segment
/// </summary>
/// <returns></returns>
public LineSegment AsLineSegment()
{
if (Terminal1Id == -1 || Terminal2Id == -1 || ParentNetwork == null)
throw new InvalidOperationException("Terminals are not initialized.");
return new LineSegment(Terminal1.Position, Terminal2.Position);
}
/// <summary>
/// Initializes road segment
/// </summary>