Implemented road & road mesh generator.
This commit is contained in:
@ -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>
|
||||
|
Reference in New Issue
Block a user