3 protected ref array<ref Shape> m_aShapes = {};
5 protected static const int DEFAULT_COLOUR = Color.RED;
6 protected static const ShapeFlags DEFAULT_FLAGS = ShapeFlags.NOZBUFFER | ShapeFlags.TRANSP;
9 Shape AddBBox(vector min, vector max,
int colour = DEFAULT_COLOUR, ShapeFlags additionalFlags = 0)
11 Shape shape = Shape.Create(ShapeType.BBOX, colour, DEFAULT_FLAGS | additionalFlags, min, max);
12 m_aShapes.Insert(shape);
17 Shape AddLine(vector from, vector to,
int colour = DEFAULT_COLOUR)
19 vector points[2] = { from, to };
20 Shape shape = Shape.CreateLines(colour, DEFAULT_FLAGS, points, 2);
21 m_aShapes.Insert(shape);
27 Shape AddPolyLine(notnull array<vector> points,
int colour = DEFAULT_COLOUR)
29 int count = points.Count();
37 for (
int i; i < count; i++)
39 pointsS[i] = points[i];
42 Shape shape = Shape.CreateLines(colour, DEFAULT_FLAGS, pointsS, count);
43 m_aShapes.Insert(shape);
48 Shape AddArrow(vector from, vector to,
int colour = DEFAULT_COLOUR)
50 Shape shape = Shape.CreateArrow(from, to, vector.Distance(from, to) * 0.333, colour, DEFAULT_FLAGS);
51 m_aShapes.Insert(shape);
56 Shape AddCircleXZ(vector centre,
float radius,
int colour = DEFAULT_COLOUR)
58 Shape shape =
CreateCircle(centre, vector.Up, radius, colour, radius * Math.PI, DEFAULT_FLAGS);
59 m_aShapes.Insert(shape);
66 Shape AddCircleArcXZ(vector centre,
float angleStartRad,
float coveredAngleRad,
float radius,
int colour = DEFAULT_COLOUR)
68 if (coveredAngleRad < 0)
70 angleStartRad += coveredAngleRad;
71 coveredAngleRad = -coveredAngleRad;
74 if (angleStartRad < 0 || angleStartRad > Math.PI2)
75 angleStartRad = Math.Repeat(angleStartRad, Math.PI2);
77 if ( coveredAngleRad > Math.PI2)
78 coveredAngleRad = Math.Repeat(coveredAngleRad, Math.PI2);
80 vector forward = { Math.Cos(angleStartRad), 0, Math.Sin(angleStartRad) };
82 Shape shape =
CreateCircleArc(centre, vector.Up, forward, 0, coveredAngleRad * Math.RAD2DEG, radius, colour, radius * (Math.PI2 - coveredAngleRad), DEFAULT_FLAGS);
83 m_aShapes.Insert(shape);
90 Shape AddCircleSliceXZ(vector centre,
float angleStartRad,
float coveredAngleRad,
float radius,
int colour = DEFAULT_COLOUR)
92 if (coveredAngleRad < 0)
94 angleStartRad -= coveredAngleRad;
95 coveredAngleRad *= -1;
98 if (angleStartRad < 0 || angleStartRad > Math.PI2)
99 angleStartRad = Math.Repeat(angleStartRad, Math.PI2);
101 if (coveredAngleRad < 0 || coveredAngleRad > Math.PI2)
102 coveredAngleRad = Math.Repeat(coveredAngleRad, Math.PI2);
104 vector forward = { Math.Cos(angleStartRad), 0, Math.Sin(angleStartRad) };
106 float angleDeg = coveredAngleRad * Math.RAD2DEG;
107 Shape shape =
CreateCircleSlice(centre, vector.Up, forward, 0, angleDeg, radius, colour, radius * (Math.PI2 - coveredAngleRad), DEFAULT_FLAGS);
108 m_aShapes.Insert(shape);
113 Shape AddRectangle(vector origin, vector vectorDir,
float length,
float width,
int colour = DEFAULT_COLOUR)
115 vector endPos = origin + vectorDir.Normalized() * length;
119 float directionRad = Math.Atan2(vectorDir[2], vectorDir[0]);
120 vector leftWidth = { Math.Cos(directionRad + Math.PI_HALF) * width, 0, Math.Sin(directionRad + Math.PI_HALF) * width };
121 vector rightWidth = { Math.Cos(directionRad - Math.PI_HALF) * width, 0, Math.Sin(directionRad - Math.PI_HALF) * width };
130 Shape shape = Shape.CreateLines(colour, DEFAULT_FLAGS, points, 5);
131 m_aShapes.Insert(shape);
135 Shape AddAABBRectangleXZ(vector min, vector max,
int colour = DEFAULT_COLOUR)
138 points[0] = Vector(min[0], min[1], max[2]);
139 points[1] = Vector(max[0], max[1], max[2]);
140 points[2] = Vector(max[0], max[1], min[2]);
141 points[3] = Vector(min[0], min[1], min[2]);
142 points[4] = Vector(min[0], min[1], max[2]);
143 Shape shape = Shape.CreateLines(colour, DEFAULT_FLAGS, points, 5);
144 m_aShapes.Insert(shape);
149 Shape AddRectangleXZ(vector origin,
float directionRad,
float length,
float width,
int colour = DEFAULT_COLOUR)
151 vector endPos = origin + { Math.Cos(directionRad) * length, 0, Math.Sin(directionRad) * length };
154 vector leftWidth = { Math.Cos(directionRad + Math.PI_HALF) * width, 0, Math.Sin(directionRad + Math.PI_HALF) * width };
155 vector rightWidth = { Math.Cos(directionRad - Math.PI_HALF) * width, 0, Math.Sin(directionRad - Math.PI_HALF) * width };
164 Shape shape = Shape.CreateLines(colour, DEFAULT_FLAGS, points, 5);
165 m_aShapes.Insert(shape);
170 array<ref Shape> AddParallelLines(vector origin, vector vectorDir,
float length,
float width,
int colour = DEFAULT_COLOUR)
172 vector endPos = origin + vectorDir.Normalized() * length;
174 float directionRad = Math.Atan2(vectorDir[2], vectorDir[0]);
175 vector leftWidth = { Math.Cos(directionRad + Math.PI_HALF) * width, 0, Math.Sin(directionRad + Math.PI_HALF) * width };
176 vector rightWidth = { Math.Cos(directionRad - Math.PI_HALF) * width, 0, Math.Sin(directionRad - Math.PI_HALF) * width };
179 AddLine(origin + leftWidth, endPos + leftWidth, colour),
180 AddLine(origin + rightWidth, endPos + rightWidth, colour),
185 Shape AddSphere(vector centre,
float radius,
int colour = DEFAULT_COLOUR, ShapeFlags additionalFlags = 0)
187 Shape shape = Shape.CreateSphere(colour, DEFAULT_FLAGS | additionalFlags, centre, radius);
188 m_aShapes.Insert(shape);
193 void Remove(notnull Shape shape)
195 m_aShapes.RemoveItem(shape);