Пример #1
0
        private void RenderAxisRotating(IViewport viewport, PerspectiveCamera camera, Graphics graphics)
        {
            if (_activeViewport.Viewport != viewport || !_mouseDownPoint.HasValue || !_mouseMovePoint.HasValue)
            {
                return;
            }


            graphics.SmoothingMode = SmoothingMode.HighQuality;

            using (var p = new Pen(Color.Gray))
            {
                var st = camera.WorldToScreen(_pivotPoint);
                var en = _mouseDownPoint.Value;
                p.DashPattern = new float[] { 4, 4 };
                graphics.DrawLine(p, st.X, st.Y, en.X, en.Y);
            }

            using (var p = new Pen(Color.LightGray))
            {
                var st = camera.WorldToScreen(_pivotPoint);
                var en = _mouseMovePoint.Value;
                p.DashPattern = new float[] { 4, 4 };
                graphics.DrawLine(p, st.X, st.Y, en.X, en.Y);
            }

            graphics.SmoothingMode = SmoothingMode.Default;
        }
Пример #2
0
            public override void Render(IViewport viewport, PerspectiveCamera camera, I2DRenderer im)
            {
                const int size = 4;

                var spos = camera.WorldToScreen(Position);

                var color = Color.FromArgb(255, GetColor());

                im.AddRectOutlineOpaque(new Vector2(spos.X - size, spos.Y - size), new Vector2(spos.X + size, spos.Y + size), Color.Black, color);
            }
Пример #3
0
        private void RenderAxisRotating(IViewport viewport, PerspectiveCamera camera, I2DRenderer im)
        {
            if (ActiveViewport.Viewport != viewport || !_mouseDownPoint.HasValue || !_mouseMovePoint.HasValue)
            {
                return;
            }

            var st = camera.WorldToScreen(_pivotPoint);
            var en = _mouseDownPoint.Value;

            im.AddLine(st.ToVector2(), en.ToVector2(), Color.Gray);

            en = _mouseMovePoint.Value;
            im.AddLine(st.ToVector2(), en.ToVector2(), Color.LightGray);
        }
Пример #4
0
            public override void Render(IViewport viewport, PerspectiveCamera camera, Graphics graphics)
            {
                const int size = 8;

                var spos = camera.WorldToScreen(Position);
                var rect = new Rectangle((int)spos.X - size / 2, (int)spos.Y - size / 2, size, size);

                var color = Color.FromArgb(255, GetColor());

                using (var brush = new SolidBrush(color))
                {
                    graphics.FillRectangle(brush, rect);
                    graphics.DrawRectangle(Pens.Black, rect);
                }
            }
Пример #5
0
        private void RenderCircleTypeNone(PerspectiveCamera camera, I2DRenderer im)
        {
            var center = _pivotPoint;
            var origin = new Vector3(center.X, center.Y, center.Z);

            var distance = (camera.EyeLocation - origin).Length();

            if (distance <= 1)
            {
                return;
            }

            // Ensure points that can't be projected properly don't get rendered
            var screenOrigin = camera.WorldToScreen(origin);
            var sop          = new PointF(screenOrigin.X, screenOrigin.Y);
            var rec          = new RectangleF(-200, -200, camera.Width + 400, camera.Height + 400);

            if (!rec.Contains(sop))
            {
                return;
            }

            var radius = 0.15f * distance;

            var normal = Vector3.Normalize(Vector3.Subtract(camera.EyeLocation, origin));
            var right  = Vector3.Normalize(Vector3.Cross(normal, Vector3.UnitZ));
            var up     = Vector3.Normalize(Vector3.Cross(normal, right));

            const int   sides = 32;
            const float diff  = (float)(2 * Math.PI) / sides;

            for (var i = 0; i < sides; i++)
            {
                var cos1 = (float)Math.Cos(diff * i);
                var sin1 = (float)Math.Sin(diff * i);
                var cos2 = (float)Math.Cos(diff * (i + 1));
                var sin2 = (float)Math.Sin(diff * (i + 1));

                var line = new Line(
                    origin + right * cos1 * radius + up * sin1 * radius,
                    origin + right * cos2 * radius + up * sin2 * radius
                    );

                var st = camera.WorldToScreen(line.Start);
                var en = camera.WorldToScreen(line.End);

                im.AddLine(st.ToVector2(), en.ToVector2(), Color.DarkGray);

                line = new Line(
                    origin + right * cos1 * radius * 1.2f + up * sin1 * radius * 1.2f,
                    origin + right * cos2 * radius * 1.2f + up * sin2 * radius * 1.2f
                    );

                st = camera.WorldToScreen(line.Start);
                en = camera.WorldToScreen(line.End);

                var c = _mouseOver == CircleType.Outer ? Color.White : Color.LightGray;
                im.AddLine(st.ToVector2(), en.ToVector2(), c);
            }

            var plane = new Plane(normal, Vector3.Dot(origin, normal));

            for (var i = 0; i < sides; i++)
            {
                var cos1 = (float)Math.Cos(diff * i) * radius;
                var sin1 = (float)Math.Sin(diff * i) * radius;
                var cos2 = (float)Math.Cos(diff * (i + 1)) * radius;
                var sin2 = (float)Math.Sin(diff * (i + 1)) * radius;

                RenderLine(
                    (origin + Vector3.UnitX * cos1 + Vector3.UnitY * sin1),
                    (origin + Vector3.UnitX * cos2 + Vector3.UnitY * sin2),
                    plane,
                    _mouseOver == CircleType.Z ? Color.Blue : Color.DarkBlue,
                    camera, im);

                RenderLine(
                    (origin + Vector3.UnitY * cos1 + Vector3.UnitZ * sin1),
                    (origin + Vector3.UnitY * cos2 + Vector3.UnitZ * sin2),
                    plane,
                    _mouseOver == CircleType.X ? Color.Red : Color.DarkRed,
                    camera, im);

                RenderLine(
                    (origin + Vector3.UnitZ * cos1 + Vector3.UnitX * sin1),
                    (origin + Vector3.UnitZ * cos2 + Vector3.UnitX * sin2),
                    plane,
                    _mouseOver == CircleType.Y ? Color.Lime : Color.LimeGreen,
                    camera, im);
            }
        }