2012-09-17 15:41:18 +00:00
|
|
|
|
using System;
|
|
|
|
|
using CodeImp.DoomBuilder.Geometry;
|
2015-06-24 21:21:19 +00:00
|
|
|
|
using CodeImp.DoomBuilder.Rendering;
|
2012-09-17 15:41:18 +00:00
|
|
|
|
|
2014-12-03 23:15:26 +00:00
|
|
|
|
namespace CodeImp.DoomBuilder.GZBuilder.Geometry
|
|
|
|
|
{
|
|
|
|
|
public class Line3D
|
|
|
|
|
{
|
2013-09-11 09:47:53 +00:00
|
|
|
|
// Coordinates
|
2015-12-14 12:34:31 +00:00
|
|
|
|
public Vector3D Start;
|
|
|
|
|
public Vector3D End;
|
|
|
|
|
public PixelColor Color;
|
|
|
|
|
public readonly bool RenderArrowhead;
|
|
|
|
|
|
|
|
|
|
// Changed by Renderer2D.RenderArrows()
|
|
|
|
|
internal Vector2D Start2D;
|
|
|
|
|
internal Vector2D End2D;
|
|
|
|
|
internal bool SkipRendering;
|
2012-09-17 15:41:18 +00:00
|
|
|
|
|
2013-09-11 09:47:53 +00:00
|
|
|
|
// Constructors
|
2015-12-14 12:34:31 +00:00
|
|
|
|
public Line3D(Vector3D start, Vector3D end)
|
2014-12-03 23:15:26 +00:00
|
|
|
|
{
|
2015-12-14 12:34:31 +00:00
|
|
|
|
this.Start = start;
|
|
|
|
|
this.End = end;
|
2016-02-22 15:20:08 +00:00
|
|
|
|
this.Start2D = start;
|
|
|
|
|
this.End2D = end;
|
2015-12-14 12:34:31 +00:00
|
|
|
|
this.Color = General.Colors.InfoLine;
|
|
|
|
|
this.RenderArrowhead = true;
|
2015-08-08 21:56:43 +00:00
|
|
|
|
}
|
|
|
|
|
|
2015-12-14 12:34:31 +00:00
|
|
|
|
public Line3D(Vector3D start, Vector3D end, bool renderArrowhead)
|
2015-08-08 21:56:43 +00:00
|
|
|
|
{
|
2015-12-14 12:34:31 +00:00
|
|
|
|
this.Start = start;
|
|
|
|
|
this.End = end;
|
2016-02-22 15:20:08 +00:00
|
|
|
|
this.Start2D = start;
|
|
|
|
|
this.End2D = end;
|
2015-12-14 12:34:31 +00:00
|
|
|
|
this.Color = General.Colors.InfoLine;
|
|
|
|
|
this.RenderArrowhead = renderArrowhead;
|
2012-09-26 00:04:17 +00:00
|
|
|
|
}
|
|
|
|
|
|
2015-12-14 12:34:31 +00:00
|
|
|
|
public Line3D(Vector3D start, Vector3D end, PixelColor color)
|
2014-12-03 23:15:26 +00:00
|
|
|
|
{
|
2015-12-14 12:34:31 +00:00
|
|
|
|
this.Start = start;
|
|
|
|
|
this.End = end;
|
2016-02-22 15:20:08 +00:00
|
|
|
|
this.Start2D = start;
|
|
|
|
|
this.End2D = end;
|
2015-12-14 12:34:31 +00:00
|
|
|
|
this.Color = color;
|
|
|
|
|
this.RenderArrowhead = true;
|
2015-08-08 21:56:43 +00:00
|
|
|
|
}
|
|
|
|
|
|
2015-12-14 12:34:31 +00:00
|
|
|
|
public Line3D(Vector3D start, Vector3D end, PixelColor color, bool renderArrowhead)
|
2015-08-08 21:56:43 +00:00
|
|
|
|
{
|
2015-12-14 12:34:31 +00:00
|
|
|
|
this.Start = start;
|
|
|
|
|
this.End = end;
|
2016-02-22 15:20:08 +00:00
|
|
|
|
this.Start2D = start;
|
|
|
|
|
this.End2D = end;
|
2015-12-14 12:34:31 +00:00
|
|
|
|
this.Color = color;
|
|
|
|
|
this.RenderArrowhead = renderArrowhead;
|
2012-09-17 15:41:18 +00:00
|
|
|
|
}
|
|
|
|
|
|
2015-12-14 12:34:31 +00:00
|
|
|
|
public Vector3D GetDelta() { return End - Start; }
|
2012-09-17 15:41:18 +00:00
|
|
|
|
|
2013-09-11 09:47:53 +00:00
|
|
|
|
// This calculates the angle
|
2014-12-03 23:15:26 +00:00
|
|
|
|
public float GetAngle()
|
|
|
|
|
{
|
2013-09-11 09:47:53 +00:00
|
|
|
|
// Calculate and return the angle
|
|
|
|
|
Vector2D d = GetDelta();
|
2015-06-24 21:21:19 +00:00
|
|
|
|
return -(float)Math.Atan2(-d.y, d.x) + Angle2D.PIHALF;
|
2013-09-11 09:47:53 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
2012-09-17 15:41:18 +00:00
|
|
|
|
}
|