Example #1
0
 public GLCommand(string name, string returnType, string alias, string vecEquiv, string parameters, GLX glx)
 {
     this.name = name;
     this.returnType = returnType;
     this.alias = alias;
     this.vecEquiv = vecEquiv;
     this.parameters = parameters;
     this.glx = glx;
 }
Example #2
0
        private void Render2D(Viewport2D viewport)
        {
            var pp = viewport.Flatten(_pivotPoint);

            GL.Begin(PrimitiveType.Lines);
            GL.Color3(Color.Cyan);
            GLX.Circle(new Vector2d(pp.DX, pp.DY), 4, (double)viewport.Zoom);
            GL.Color3(Color.White);
            GLX.Circle(new Vector2d(pp.DX, pp.DY), 8, (double)viewport.Zoom);
            GL.End();
        }
Example #3
0
        public override void Render2D(Viewport2D viewport)
        {
            var pos = viewport.Flatten(_origin.Coordinate);

            GL.Color3(Color.Cyan);
            GL.Begin(PrimitiveType.Lines);
            GLX.Circle(new Vector2d(pos.DX, pos.DY), 8, (double)viewport.Zoom);
            GL.End();
            GL.Begin(PrimitiveType.Points);
            GL.Vertex2(pos.DX, pos.DY);
            GL.End();
        }
Example #4
0
        /// <summary>
        /// Render all the handles as squares or circles depending on class implementation
        /// </summary>
        /// <param name="viewport">The viewport to draw in</param>
        /// <param name="start">The start of the box</param>
        /// <param name="end">The end of the box</param>
        private void RenderHandles(Viewport2D viewport, Coordinate start, Coordinate end)
        {
            if (_currentTool == null)
            {
                return;
            }
            var circles = _currentTool.RenderCircleHandles;

            // Get the filtered list of handles, and convert them to vector locations
            var z       = (double)viewport.Zoom;
            var handles = _currentTool.GetHandles(start, end, viewport.Zoom)
                          .Where(x => _currentTool.FilterHandle(x.Item1))
                          .Select(x => new Vector2d((double)x.Item2, (double)x.Item3))
                          .ToList();

            // Draw the insides of the handles in white
            GL.Color3(Color.White);
            foreach (var handle in handles)
            {
                GL.Begin(BeginMode.Polygon);
                if (circles)
                {
                    GLX.Circle(handle, 4, z, loop: true);
                }
                else
                {
                    GLX.Square(handle, 4, z, true);
                }
                GL.End();
            }

            // Draw the borders of the handles in black
            GL.Color3(Color.Black);
            GL.Begin(BeginMode.Lines);
            foreach (var handle in handles)
            {
                if (circles)
                {
                    GLX.Circle(handle, 4, z);
                }
                else
                {
                    GLX.Square(handle, 4, z);
                }
            }
            GL.End();
        }
Example #5
0
        protected override void Render2D(Viewport2D vp)
        {
            base.Render2D(vp);

            if (_currentTool != null)
            {
                _currentTool.Render2D(vp);
            }

            // Render out the solid previews
            GL.Color3(Color.Pink);
            Matrix.Push();
            var matrix = vp.GetModelViewMatrix();

            GL.MultMatrix(ref matrix);
            MapObjectRenderer.DrawWireframe(_copies.Keys.SelectMany(x => x.Faces), true, false);
            Matrix.Pop();

            // Draw in order by the unused coordinate (the up axis for this viewport)
            var ordered = (from point in Points
                           where (point.IsMidPoint && _showPoints != ShowPoints.Vertices) || (!point.IsMidPoint && _showPoints != ShowPoints.Midpoints)
                           let unused = vp.GetUnusedCoordinate(point.Coordinate)
                                        orderby point.IsSelected, unused.X + unused.Y + unused.Z
                           select point).ToList();
            // Render out the point handles
            var z = (double)vp.Zoom;

            GL.Begin(BeginMode.Quads);
            foreach (var point in ordered)
            {
                var c = vp.Flatten(point.Coordinate);
                GL.Color3(Color.Black);
                GLX.Square(new Vector2d(c.DX, c.DY), 4, z, true);
                GL.Color3(point.GetColour());
                GLX.Square(new Vector2d(c.DX, c.DY), 3, z, true);
            }
            GL.End();
        }
Example #6
0
        public override void Render(ViewportBase viewport)
        {
            var vp = viewport as Viewport2D;

            if (vp == null)
            {
                return;
            }

            var cams = GetCameras().ToList();

            if (!cams.Any())
            {
                return;
            }

            var z = (double)vp.Zoom;

            GL.Enable(EnableCap.LineSmooth);
            GL.Hint(HintTarget.LineSmoothHint, HintMode.Nicest);

            // Draw lines between points and point outlines
            GL.Begin(BeginMode.Lines);

            foreach (var camera in cams)
            {
                var p1 = vp.Flatten(camera.EyePosition);
                var p2 = vp.Flatten(camera.LookPosition);

                GL.Color3(camera == Document.Map.ActiveCamera ? Color.Red : Color.Cyan);
                GL.Vertex2(p1.DX, p1.DY);
                GL.Vertex2(p2.DX, p2.DY);
                GL.Vertex2(p2.DX, p2.DY);
                GL.Vertex2(p1.DX, p1.DY);
            }

            GL.End();

            GL.Enable(EnableCap.PolygonSmooth);
            GL.Hint(HintTarget.PolygonSmoothHint, HintMode.Nicest);

            foreach (var camera in cams)
            {
                var p1 = vp.Flatten(camera.EyePosition);

                // Position circle
                GL.Begin(BeginMode.Polygon);
                GL.Color3(camera == Document.Map.ActiveCamera ? Color.DarkOrange : Color.LawnGreen);
                GLX.Circle(new Vector2d(p1.DX, p1.DY), 4, z, loop: true);
                GL.End();
            }
            foreach (var camera in cams)
            {
                var p1 = vp.Flatten(camera.EyePosition);
                var p2 = vp.Flatten(camera.LookPosition);

                var multiplier = 4 / vp.Zoom;
                var dir        = (p2 - p1).Normalise();
                var cp         = new Coordinate(-dir.Y, dir.X, 0).Normalise();

                // Direction Triangle
                GL.Begin(BeginMode.Triangles);
                GL.Color3(camera == Document.Map.ActiveCamera ? Color.Red : Color.Cyan);
                Coord(p2 - (dir - cp) * multiplier);
                Coord(p2 - (dir + cp) * multiplier);
                Coord(p2 + dir * 1.5m * multiplier);
                GL.End();
            }

            GL.Disable(EnableCap.PolygonSmooth);

            GL.Begin(BeginMode.Lines);

            foreach (var camera in cams)
            {
                var p1 = vp.Flatten(camera.EyePosition);
                var p2 = vp.Flatten(camera.LookPosition);

                var multiplier = 4 / vp.Zoom;
                var dir        = (p2 - p1).Normalise();
                var cp         = new Coordinate(-dir.Y, dir.X, 0).Normalise();

                GL.Color3(Color.Black);
                GLX.Circle(new Vector2d(p1.DX, p1.DY), 4, z);
                Coord(p2 + dir * 1.5m * multiplier);
                Coord(p2 - (dir + cp) * multiplier);
                Coord(p2 - (dir + cp) * multiplier);
                Coord(p2 - (dir - cp) * multiplier);
                Coord(p2 - (dir - cp) * multiplier);
                Coord(p2 + dir * 1.5m * multiplier);
            }

            GL.End();

            GL.Disable(EnableCap.LineSmooth);
        }
Example #7
0
        public static GLCommand Parse(string line)
        {
            var keys = new List<string>();
            keys.Add("name");
            keys.Add("return");
            keys.Add("params");
            keys.Add("alias");
            keys.Add("vecEquiv");
            var datas = CodeReader.GrabData(line, keys, "command");

            if (datas == null)
            {
                return null;
            }

            GLX glx = null;

            if (line.Contains("[") && line.Contains("]"))
            {
                int glxValueFrom = line.IndexOf("[") + "[".Length;
                int glxValueTo = line.LastIndexOf("]");
                var glxSingle = line.Substring(glxValueFrom, glxValueTo - glxValueFrom);
                glx = GLX.Parse(glxSingle);
            }

            return new GLCommand(datas["name"], datas["return"], datas["alias"], datas["vecEquiv"], datas["params"], glx);
        }
Example #8
0
        public void extension_details()
        {
            Console.WriteLine("\n\n---- extension details");

            try {
                Console.WriteLine(new gnu.x11.extension.
                                  BigRequests(display) + "\n");
            } catch (NotFoundException e) {
                Console.WriteLine("big requests not found\n");
            }

            try {
                Console.WriteLine(new gnu.x11.extension.DBE(display) + "\n");
            } catch (NotFoundException e) {
                Console.WriteLine("dbe not found\n");
            }

            try {
                Console.WriteLine(new gnu.x11.extension.DPMS(display) + "\n");
            } catch (NotFoundException e) {
                Console.WriteLine("dpms not found\n");
            }

            try {
                Console.WriteLine(new gnu.x11.extension.EVI(display) + "\n");
            } catch (NotFoundException e) {
                Console.WriteLine("evi not found\n");
            }

            try {
                GLX glx = new GLX(display);
                Console.WriteLine(glx + Misc.to_string(glx.visual_configs(0)));

                GL gl = glx.create_context(display.default_screen.root_visual_id(),
                                           display.default_screen_no, GL.NONE0);
                gl.make_current(display.default_root);
                Console.WriteLine(gl + "\n");
            } catch (NotFoundException e) {
                Console.WriteLine("glx not found\n");
            }

            try {
                Render render = new Render(display);
                Console.WriteLine(render
                                  + Misc.to_string(render.picture_formats()));
            } catch (NotFoundException e) {
                Console.WriteLine("render not found\n");
            }

            try {
                Console.WriteLine(new gnu.x11.extension.Shape(display) + "\n");
            } catch (NotFoundException e) {
                Console.WriteLine("shape not found\n");
            }

            try {
                Console.WriteLine(new gnu.x11.extension.XCMisc(display) + "\n");
            } catch (NotFoundException e) {
                Console.WriteLine("xcmic not found\n");
            }

            try {
                Console.WriteLine(new gnu.x11.extension.XTest(display) + "\n");
            } catch (NotFoundException e) {
                Console.WriteLine("xtest not found\n");
            }
        }
Example #9
0
        private void Render2D(Viewport2D vp)
        {
            if (_state == ClipState.None ||
                _clipPlanePoint1 == null ||
                _clipPlanePoint2 == null ||
                _clipPlanePoint3 == null)
            {
                return;                              // Nothing to draw at this point
            }
            var z  = (double)vp.Zoom;
            var p1 = vp.Flatten(_clipPlanePoint1);
            var p2 = vp.Flatten(_clipPlanePoint2);
            var p3 = vp.Flatten(_clipPlanePoint3);

            // Draw points
            GL.Begin(PrimitiveType.Quads);
            GL.Color3(Color.White);
            GLX.Square(new Vector2d(p1.DX, p1.DY), 4, z, true);
            GLX.Square(new Vector2d(p2.DX, p2.DY), 4, z, true);
            GLX.Square(new Vector2d(p3.DX, p3.DY), 4, z, true);
            GL.End();

            GL.Enable(EnableCap.LineSmooth);
            GL.Hint(HintTarget.LineSmoothHint, HintMode.Nicest);

            // Draw lines between points and point outlines
            GL.Begin(PrimitiveType.Lines);
            GL.Color3(Color.White);
            GL.Vertex2(p1.DX, p1.DY);
            GL.Vertex2(p2.DX, p2.DY);
            GL.Vertex2(p2.DX, p2.DY);
            GL.Vertex2(p3.DX, p3.DY);
            GL.Vertex2(p3.DX, p3.DY);
            GL.Vertex2(p1.DX, p1.DY);
            GL.Color3(Color.Black);
            GLX.Square(new Vector2d(p1.DX, p1.DY), 4, z);
            GLX.Square(new Vector2d(p2.DX, p2.DY), 4, z);
            GLX.Square(new Vector2d(p3.DX, p3.DY), 4, z);
            GL.End();

            // Draw the clipped brushes
            if (!_clipPlanePoint1.EquivalentTo(_clipPlanePoint2) &&
                !_clipPlanePoint2.EquivalentTo(_clipPlanePoint3) &&
                !_clipPlanePoint1.EquivalentTo(_clipPlanePoint3))
            {
                var plane = new Plane(_clipPlanePoint1, _clipPlanePoint2, _clipPlanePoint3);
                var faces = new List <Face>();
                var idg   = new IDGenerator();
                foreach (var solid in Document.Selection.GetSelectedObjects().OfType <Solid>().ToList())
                {
                    Solid back, front;
                    if (solid.Split(plane, out back, out front, idg))
                    {
                        if (_side != ClipSide.Front)
                        {
                            faces.AddRange(back.Faces);
                        }
                        if (_side != ClipSide.Back)
                        {
                            faces.AddRange(front.Faces);
                        }
                    }
                }
                GL.LineWidth(2);
                GL.Color3(Color.White);
                Matrix.Push();
                var mat = vp.GetModelViewMatrix();
                GL.MultMatrix(ref mat);
                Rendering.Immediate.MapObjectRenderer.DrawWireframe(faces, true, false);
                Matrix.Pop();
                GL.LineWidth(1);
            }

            GL.Hint(HintTarget.LineSmoothHint, HintMode.Fastest);
            GL.Disable(EnableCap.LineSmooth);
        }