当前位置: 首页>>代码示例>>C#>>正文


C# UI.ViewportBase类代码示例

本文整理汇总了C#中Sledge.UI.ViewportBase的典型用法代码示例。如果您正苦于以下问题:C# ViewportBase类的具体用法?C# ViewportBase怎么用?C# ViewportBase使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


ViewportBase类属于Sledge.UI命名空间,在下文中一共展示了ViewportBase类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: RenderDocument

        public void RenderDocument(ViewportBase viewport, Document document)
        {
            if (document.Pointfile == null) return;
            var pf = document.Pointfile;
            var vp2 = viewport as Viewport2D;
            Func<Coordinate, Coordinate> transform = x => x;
            if (vp2 != null) transform = vp2.Flatten;

            TextureHelper.Unbind();
            GL.LineWidth(3);
            GL.Begin(PrimitiveType.Lines);

            var r = 1f;
            var g = 0.5f;
            var b = 0.5f;
            var change = 0.5f / pf.Lines.Count;

            foreach (var line in pf.Lines)
            {
                var start = transform(line.Start);
                var end = transform(line.End);

                GL.Color3(r, g, b);
                GL.Vertex3(start.DX, start.DY, start.DZ);

                r -= change;
                b += change;

                GL.Color3(r, g, b);
                GL.Vertex3(end.DX, end.DY, end.DZ);
            }

            GL.End();
            GL.LineWidth(1);
        }
开发者ID:074769,项目名称:sledge,代码行数:35,代码来源:PointfileHelper.cs

示例2: Order

 public IEnumerable<MapObject> Order(ViewportBase viewport, IEnumerable<MapObject> mapObjects)
 {
     var vp3 = viewport as Viewport3D;
     if (vp3 == null) return mapObjects;
     var cam = vp3.Camera.Location.ToCoordinate();
     return mapObjects.OrderByDescending(x => (x.BoundingBox.Center - cam).LengthSquared());
 }
开发者ID:silky,项目名称:sledge,代码行数:7,代码来源:EntitySpriteHelper.cs

示例3: MouseDown

        public override void MouseDown(ViewportBase viewport, ViewportEvent e)
        {
            var vp = viewport as Viewport3D;
            if (vp == null || e.Button != MouseButtons.Left) return;

            // Do selection
            e.Handled = true;
            var ray = vp.CastRayFromScreen(e.X, e.Y);
            var hits = MainTool.GetCopies().Where(x => x.BoundingBox.IntersectsWith(ray));
            var clickedFace = hits.SelectMany(f => f.Faces)
                .Select(x => new { Item = x, Intersection = x.GetIntersectionPoint(ray) })
                .Where(x => x.Intersection != null)
                .OrderBy(x => (x.Intersection - ray.Start).VectorMagnitude())
                .Select(x => x.Item)
                .FirstOrDefault();

            var faces = new List<Face>();
            if (clickedFace != null)
            {
                if (KeyboardState.Shift) faces.AddRange(clickedFace.Parent.Faces);
                else faces.Add(clickedFace);
            }

            if (!KeyboardState.Ctrl) _selection.Clear();
            _selection.AddRange(faces);

            UpdateSelection();
        }
开发者ID:jpiolho,项目名称:sledge,代码行数:28,代码来源:EditFaceTool.cs

示例4: Render

 public void Render(ViewportBase viewport)
 {
     var vp2 = viewport as Viewport2D;
     var vp3 = viewport as Viewport3D;
     foreach (var helper in _helpers)
     {
         // Render document
         if (helper.IsDocumentHelper)
         {
             helper.RenderDocument(viewport, _document);
         }
         // Render 2D
         if (helper.Is2DHelper && vp2 != null && _helperCache.ContainsKey(helper))
         {
             helper.BeforeRender2D(vp2);
             foreach (var obj in _helperCache[helper])
             {
                 helper.Render2D(vp2, obj);
             }
             helper.AfterRender2D(vp2);
         }
         // Render 3D
         if (helper.Is3DHelper && vp3 != null && _helperCache.ContainsKey(helper))
         {
             helper.BeforeRender3D(vp3);
             foreach (var obj in _helperCache[helper])
             {
                 helper.Render3D(vp3, obj);
             }
             helper.AfterRender3D(vp3);
         }
     }
 }
开发者ID:jpiolho,项目名称:sledge,代码行数:33,代码来源:HelperManager.cs

示例5: RenderDocument

 public void RenderDocument(ViewportBase viewport, Document document)
 {
     if (!document.Map.Cordon || document.Map.CordonBounds.IsEmpty()) return;
     if (ToolManager.ActiveTool != null && ToolManager.ActiveTool.GetHotkeyToolType() == HotkeyTool.Cordon) return;
     if (viewport is Viewport2D) Render2D((Viewport2D)viewport, document);
     if (viewport is Viewport3D) Render3D((Viewport3D)viewport, document);
 }
开发者ID:ChristopherHaws,项目名称:sledge,代码行数:7,代码来源:CordonHelper.cs

示例6: Draw2D

        public void Draw2D(ViewportBase context, Matrix4 viewport, Matrix4 camera, Matrix4 modelView)
        {
            UpdateCache();

            RenderGrid(((Viewport2D)context).Zoom);

            Matrix4 current;
            GL.GetFloat(GetPName.ModelviewMatrix, out current);
            GL.MatrixMode(MatrixMode.Modelview);
            GL.MultMatrix(ref modelView);

            // Draw unselected stuff
            MapObjectRenderer.DrawWireframe(_unselected.Where(x => x.Parent == null || !x.Parent.IsRenderHidden2D), false);
            MapObjectRenderer.DrawWireframe(_decals.Where(x => !x.IsSelected && !x.IsRenderHidden2D).SelectMany(x => x.GetDecalGeometry()), false);
            MapObjectRenderer.DrawWireframe(_models.Where(x => !x.IsSelected && !x.IsRenderHidden2D).SelectMany(x => x.GetBoxFaces()), false);

            // Draw selection (untransformed)
            GL.Color4(Color.FromArgb(128, 0, 0));
            MapObjectRenderer.DrawWireframe(_selected.Where(x => x.Parent == null || !x.Parent.IsRenderHidden2D), true);
            MapObjectRenderer.DrawWireframe(_decals.Where(x => x.IsSelected && !x.IsRenderHidden2D).SelectMany(x => x.GetDecalGeometry()), true);
            MapObjectRenderer.DrawWireframe(_models.Where(x => x.IsSelected && !x.IsRenderHidden2D).SelectMany(x => x.GetBoxFaces()), true);

            GL.LoadMatrix(ref current);
            GL.MultMatrix(ref modelView);
            GL.MultMatrix(ref _selectionTransform);

            // Draw selection (transformed)
            GL.Color4(Color.Red);
            MapObjectRenderer.DrawWireframe(_selected.Where(x => x.Parent == null || !x.Parent.IsRenderHidden2D), true);
            MapObjectRenderer.DrawWireframe(_decals.Where(x => x.IsSelected && !x.IsRenderHidden2D).SelectMany(x => x.GetDecalGeometry()), true);
            MapObjectRenderer.DrawWireframe(_models.Where(x => x.IsSelected && !x.IsRenderHidden2D).SelectMany(x => x.GetBoxFaces()), true);

            GL.LoadMatrix(ref current);
        }
开发者ID:074769,项目名称:sledge,代码行数:34,代码来源:ImmediateRenderer.cs

示例7: MouseDown

 public override void MouseDown(ViewportBase viewport, ViewportEvent e)
 {
     if (!(viewport is Viewport3D) || (e.Button != MouseButtons.Left && e.Button != MouseButtons.Right)) return;
     _multiplier = e.Button == MouseButtons.Left ? 1 : -1;
     //PaintCurrentPoint((Viewport3D) viewport);
     _mouseDown = true;
     _moveCount = 0;
 }
开发者ID:silky,项目名称:sledge,代码行数:8,代码来源:GeometryTool.cs

示例8: AddNonSelectionItems

 public void AddNonSelectionItems(Document doc, ViewportBase viewport)
 {
     Items.Clear();
     Add("Paste", HotkeysMediator.OperationsPaste, Clipboard.ClipboardManager.CanPaste());
     Add("Paste Special", HotkeysMediator.OperationsPasteSpecial, Clipboard.ClipboardManager.CanPaste());
     Items.Add(new ToolStripSeparator());
     Add(doc.History.GetUndoString(), HotkeysMediator.HistoryUndo, doc.History.CanUndo());
     Add(doc.History.GetRedoString(), HotkeysMediator.HistoryRedo, doc.History.CanRedo());
 }
开发者ID:silky,项目名称:sledge,代码行数:9,代码来源:ViewportContextMenu.cs

示例9: ViewportEvent

 public ViewportEvent(ViewportBase sender, MouseEventArgs e)
 {
     Sender = sender;
     Button = e.Button;
     Clicks = e.Clicks;
     X = e.X;
     Y = e.Y;
     Delta = e.Delta;
     Location = e.Location;
 }
开发者ID:silky,项目名称:sledge,代码行数:10,代码来源:ViewportEvent.cs

示例10: KeyDown

 public override void KeyDown(ViewportBase viewport, ViewportEvent e)
 {
     switch (e.KeyCode)
     {
         case Keys.Enter:
             CreateEntity(_location);
             _state = EntityState.None;
             break;
         case Keys.Escape:
             _state = EntityState.None;
             break;
     }
 }
开发者ID:KonstantinUb,项目名称:sledge,代码行数:13,代码来源:EntityTool.cs

示例11: MouseMove

        public override void MouseMove(ViewportBase viewport, ViewportEvent e)
        {
            var vp = viewport as Viewport3D;
            if (vp == null) return;

            _mousePos.X = e.X;
            _mousePos.Y = e.Y;

            if (_currentPoint == null) return;

            if (_mouseDown)
            {
                _moveCount++;
                //PaintCurrentPoint(vp);
            }
        }
开发者ID:jpiolho,项目名称:sledge,代码行数:16,代码来源:GeometryTool.cs

示例12: MouseDown

        public override void MouseDown(ViewportBase viewport, ViewportEvent e)
        {
            return;

            var vp = viewport as Viewport3D;
            if (vp == null || (e.Button != MouseButtons.Left && e.Button != MouseButtons.Right)) return;

            var ray = vp.CastRayFromScreen(e.X, e.Y);
            var hits = Document.Map.WorldSpawn.GetAllNodesIntersectingWith(ray).OfType<Solid>();
            var clickedFace = hits.SelectMany(f => f.Faces)
                .Select(x => new { Item = x, Intersection = x.GetIntersectionPoint(ray) })
                .Where(x => x.Intersection != null)
                .OrderBy(x => (x.Intersection - ray.Start).VectorMagnitude())
                .Select(x => x.Item)
                .FirstOrDefault();
            // TODO: Select
            //TextureItem itemToSelect = null;
            // if ((behaviour == SelectBehaviour.Select || behaviour == SelectBehaviour.LiftSelect) && !KeyboardState.Ctrl)
            // {
            //     Selection.Clear();
            // }
            //if (clickedFace != null)
            //{
            //    var faces = new List<Face>();
            //    if (KeyboardState.Shift) faces.AddRange(clickedFace.Parent.Faces);
            //    else faces.Add(clickedFace);
            //    if (behaviour == SelectBehaviour.Select || behaviour == SelectBehaviour.LiftSelect)
            //    {
            //        foreach (var face in faces)
            //        {
            //            if (face.IsSelected) Selection.Deselect(face);
            //            else Selection.Select(face);
            //        }
            //    }
            //    if (behaviour == SelectBehaviour.Lift || behaviour == SelectBehaviour.LiftSelect)
            //    {
            //        var tex = faces.Where(face => face.Texture.Texture != null).FirstOrDefault();
            //        itemToSelect = tex != null ? TexturePackage.GetItem(tex.Texture.Name) : null;
            //    }
            //}
            //Document.UpdateDisplayLists();
            //_form.SelectionChanged();
            //if (itemToSelect != null)
            //{
            //    _form.SelectTexture(itemToSelect);
            //}
        }
开发者ID:jpiolho,项目名称:sledge,代码行数:47,代码来源:SelectTool.cs

示例13: BoxDrawnConfirm

 public override void BoxDrawnConfirm(ViewportBase viewport)
 {
     var box = new Box(State.BoxStart, State.BoxEnd);
     if (box.Start.X != box.End.X && box.Start.Y != box.End.Y && box.Start.Z != box.End.Z)
     {
         CreateBrush(box);
         _lastBox = box;
     }
     _preview = null;
     base.BoxDrawnConfirm(viewport);
     if (Select.SwitchToSelectAfterCreation)
     {
         Mediator.Publish(HotkeysMediator.SwitchTool, HotkeyTool.Selection);
     }
     if (Select.ResetBrushTypeOnCreation)
     {
         Mediator.Publish(EditorMediator.ResetSelectedBrushType);
     }
 }
开发者ID:KonstantinUb,项目名称:sledge,代码行数:19,代码来源:BrushTool.cs

示例14: Draw2D

        public void Draw2D(ViewportBase context, Matrix4 viewport, Matrix4 camera, Matrix4 modelView)
        {
            UpdateCache();

            RenderGrid(((Viewport2D)context).Zoom);

            Matrix4 current;
            GL.GetFloat(GetPName.ModelviewMatrix, out current);
            GL.MatrixMode(MatrixMode.Modelview);
            GL.MultMatrix(ref modelView);

            GL.CallList(_listUntransformed2D);

            GL.LoadMatrix(ref current);
            GL.MultMatrix(ref modelView);
            GL.MultMatrix(ref _selectionTransform);

            GL.CallList(_listTransformed2D);

            GL.LoadMatrix(ref current);
        }
开发者ID:jpiolho,项目名称:sledge,代码行数:21,代码来源:DisplayListRenderer.cs

示例15: Draw2D

        public void Draw2D(ViewportBase context, Matrix4 viewport, Matrix4 camera, Matrix4 modelView)
        {
            UpdateCache();

            RenderGrid(((Viewport2D)context).Zoom);

            Matrix4 current;
            GL.GetFloat(GetPName.ModelviewMatrix, out current);
            GL.MatrixMode(MatrixMode.Modelview);
            GL.MultMatrix(ref modelView);

            DataStructures.Rendering.Rendering.DrawWireframe(_unselected.Where(x => x.Parent == null || !x.Parent.IsRenderHidden2D), false);
            GL.Color4(Color.Red);

            GL.LoadMatrix(ref current);
            GL.MultMatrix(ref modelView);
            GL.MultMatrix(ref _selectionTransform);
            DataStructures.Rendering.Rendering.DrawWireframe(_selected.Where(x => x.Parent == null || !x.Parent.IsRenderHidden2D), true);

            GL.LoadMatrix(ref current);
        }
开发者ID:ChristopherHaws,项目名称:sledge,代码行数:21,代码来源:ImmediateRendererGL1.cs


注:本文中的Sledge.UI.ViewportBase类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。