Beispiel #1
0
        public override void Draw(Cairo.Context ctx, Vector3 origin, Graphics.Camera camera)
        {
            // just draw a circle
            var pos = camera.Transform(this.position) - camera.Transform(origin);
            var cl  = this.color;

            ctx.SetSourceRGB(cl.x, cl.y, cl.z);
            ctx.Arc(pos.x, pos.y, this.radius, 0, 2 * Math.PI);
            ctx.Fill();
        }
Beispiel #2
0
        public override void Draw(Cairo.Context ctx, Vector3 origin, Graphics.Camera camera)
        {
            Vector3[] vertices = new Vector3[] {
                ToExternalPosition(new Vector3((dimensions.x - line_width) / 2, (dimensions.y - line_width) / 2, (dimensions.z - line_width) / 2)),
                ToExternalPosition(new Vector3((dimensions.x - line_width) / 2, (dimensions.y - line_width) / 2, -(dimensions.z - line_width) / 2)),
                ToExternalPosition(new Vector3((dimensions.x - line_width) / 2, -(dimensions.y - line_width) / 2, (dimensions.z - line_width) / 2)),
                ToExternalPosition(new Vector3((dimensions.x - line_width) / 2, -(dimensions.y - line_width) / 2, -(dimensions.z - line_width) / 2)),
                ToExternalPosition(new Vector3(-(dimensions.x - line_width) / 2, (dimensions.y - line_width) / 2, (dimensions.z - line_width) / 2)),
                ToExternalPosition(new Vector3(-(dimensions.x - line_width) / 2, (dimensions.y - line_width) / 2, -(dimensions.z - line_width) / 2)),
                ToExternalPosition(new Vector3(-(dimensions.x - line_width) / 2, -(dimensions.y - line_width) / 2, (dimensions.z - line_width) / 2)),
                ToExternalPosition(new Vector3(-(dimensions.x - line_width) / 2, -(dimensions.y - line_width) / 2, -(dimensions.z - line_width) / 2)),
            };
            // vertices adjacent to each (but not repeated)
            int[][] adjacency = new int[][] {
                new int[] { 1, 2, 4 },
                new int[] { 3, 5 },
                new int[] { 3, 6 },
                new int[] { 7 },
                new int[] { 5, 6 },
                new int[] { 7 },
                new int[] { 7 }
            };
            var cl = this.color;

            ctx.SetSourceRGB(cl.x, cl.y, cl.z);
            ctx.LineWidth = this.line_width;
            for (int i = 0; i < 7; i++)
            {
                foreach (int j in adjacency[i])
                {
                    var p1 = camera.Transform(vertices[i]) - camera.Transform(origin);
                    var p2 = camera.Transform(vertices[j]) - camera.Transform(origin);
                    ctx.MoveTo(p1.x, p1.y);
                    ctx.LineTo(p2.x, p2.y);
                    ctx.Stroke();
                }
            }
        }