/* Convert world space coordinates (doubles) to view space (floats) */ private Vector3[] ConvertPointsToViewSpace(List<Position> points, Camera camera) { Vector3[] verts = new Vector3[points.Count]; for (int i = 0; i < points.Count; ++i) verts[i] = points[i].Diff(camera.Position); return verts; }
/* Called by GraphicsSystem when it is time to draw the queued list */ public void Flush(Camera camera) { /* Turn off lighting and texturing which will change the color * of the visualization lines */ GraphicsSystem.Lighting = false; GraphicsSystem.Texture = null; if (_points.Count > 0) { Vector3[] verts = ConvertPointsToViewSpace(_points, camera); if (!Toolkit.utDrawPoints(ref verts[0].X, verts.Length)) throw new FrameworkException(); } if (_lines.Count > 0) { Vector3[] verts = ConvertPointsToViewSpace(_lines, camera); if (!Toolkit.utDrawLines(ref verts[0].X, verts.Length)) throw new FrameworkException(); } /* These will move down to Swap() once I code the double buffering */ _points.Clear(); _lines.Clear(); }