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


C# UI.Viewport3D类代码示例

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


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

示例1: Camera3DViewportListener

 public Camera3DViewportListener(Viewport3D vp)
 {
     LastKnownX = 0;
     LastKnownY = 0;
     PositionKnown = false;
     FreeLook = false;
     FreeLookToggle = false;
     CursorVisible = true;
     Focus = false;
     Viewport = vp;
     Camera = vp.Camera;
     _downKeys = new List<Keys>();
 }
开发者ID:jpiolho,项目名称:sledge,代码行数:13,代码来源:Camera3DViewportListener.cs

示例2: Camera3DViewportListener

 public Camera3DViewportListener(Viewport3D vp)
 {
     LastKnownX = 0;
     LastKnownY = 0;
     PositionKnown = false;
     FreeLook = false;
     FreeLookToggle = false;
     CursorVisible = true;
     Focus = false;
     Viewport = vp;
     Camera = vp.Camera;
     _downKeys = new List<Keys>();
     _downMillis = _lastMillis = 0;
     _easing = Easing.FromType(EasingType.Sinusoidal, EasingDirection.Out);
 }
开发者ID:KonstantinUb,项目名称:sledge,代码行数:15,代码来源:Camera3DViewportListener.cs

示例3: Render3D

        public void Render3D(Viewport3D vp, MapObject o)
        {
            var right = vp.Camera.GetRight();
            var up = Vector3.Cross(right, (vp.Camera.LookAt - vp.Camera.Location).Normalized());
            var entity = (Entity) o;

            var orig = new Vector3((float)entity.Origin.X, (float)entity.Origin.Y, (float)entity.Origin.Z);
            if (entity.IsSelected)
            {
                orig = Vector3.TransformPosition(orig, Document.SelectListTransform);
            }
            var normal = Vector3.Subtract(vp.Camera.Location, orig);

            var tex = entity.Sprite;
            GL.Color3(Color.White);
            tex.Bind();

            if (entity.GameData != null)
            {
                var col = entity.GameData.Properties.FirstOrDefault(x => x.VariableType == VariableType.Color255);
                if (col != null)
                {
                    var val = entity.EntityData.Properties.FirstOrDefault(x => x.Key == col.Name);
                    if (val != null)
                    {
                        GL.Color3(val.GetColour(Color.White));
                    }
                }
            }

            var tup = Vector3.Multiply(up, (float)entity.BoundingBox.Height / 2f);
            var tright = Vector3.Multiply(right, (float)entity.BoundingBox.Width / 2f);

            GL.Begin(PrimitiveType.Quads);

            GL.Normal3(normal); GL.TexCoord2(1, 1); GL.Vertex3(Vector3.Subtract(orig, Vector3.Add(tup, tright)));
            GL.Normal3(normal); GL.TexCoord2(1, 0); GL.Vertex3(Vector3.Add(orig, Vector3.Subtract(tup, tright)));
            GL.Normal3(normal); GL.TexCoord2(0, 0); GL.Vertex3(Vector3.Add(orig, Vector3.Add(tup, tright)));
            GL.Normal3(normal); GL.TexCoord2(0, 1); GL.Vertex3(Vector3.Subtract(orig, Vector3.Subtract(tup, tright)));

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

示例4: Render3D

        public void Render3D(Viewport3D vp, MapObject o)
        {
            // These billboards aren't perfect but they'll do (they rotate with the lookat vector rather than the location vector)

            var right = vp.Camera.GetRight();
            var up = vp.Camera.GetUp();
            var entity = (Entity) o;

            var orig = new Vector3((float)entity.Origin.X, (float)entity.Origin.Y, (float)entity.Origin.Z);
            var normal = Vector3.Subtract(vp.Camera.Location, orig);

            var tex = entity.Sprite;
            TextureHelper.EnableTexturing();
            GL.Color3(Color.White);
            tex.Bind();

            if (entity.GameData != null)
            {
                var col = entity.GameData.Properties.FirstOrDefault(x => x.VariableType == VariableType.Color255);
                if (col != null)
                {
                    var val = entity.EntityData.Properties.FirstOrDefault(x => x.Key == col.Name);
                    if (val != null)
                    {
                        GL.Color3(val.GetColour(Color.White));
                    }
                }
            }

            var tup = Vector3.Multiply(up, (float)entity.BoundingBox.Height / 2f);
            var tright = Vector3.Multiply(right, (float)entity.BoundingBox.Width / 2f);

            GL.Begin(BeginMode.Quads);

            GL.Normal3(normal); GL.TexCoord2(1, 1); GL.Vertex3(Vector3.Subtract(orig, Vector3.Add(tup, tright)));
            GL.Normal3(normal); GL.TexCoord2(1, 0); GL.Vertex3(Vector3.Add(orig, Vector3.Subtract(tup, tright)));
            GL.Normal3(normal); GL.TexCoord2(0, 0); GL.Vertex3(Vector3.Add(orig, Vector3.Add(tup, tright)));
            GL.Normal3(normal); GL.TexCoord2(0, 1); GL.Vertex3(Vector3.Subtract(orig, Vector3.Subtract(tup, tright)));

            GL.End();
        }
开发者ID:jpiolho,项目名称:sledge,代码行数:41,代码来源:EntitySpriteHelper.cs

示例5: BeforeRender3D

 public void BeforeRender3D(Viewport3D viewport)
 {
     throw new NotImplementedException();
 }
开发者ID:ChristopherHaws,项目名称:sledge,代码行数:4,代码来源:CordonHelper.cs

示例6: Render3D

 protected override void Render3D(Viewport3D viewport)
 {
     base.Render3D(viewport);
     if (ShouldDraw3DBox() && _preview != null)
     {
         GL.Disable(EnableCap.CullFace);
         TextureHelper.Unbind();
         if (viewport.Type != Viewport3D.ViewType.Flat) MapObjectRenderer.EnableLighting();
         MapObjectRenderer.DrawFilled(_preview, GetRenderColour(), false);
         MapObjectRenderer.DisableLighting();
         GL.Color4(Color.GreenYellow);
         MapObjectRenderer.DrawWireframe(_preview, true, false);
     }
 }
开发者ID:KonstantinUb,项目名称:sledge,代码行数:14,代码来源:BrushTool.cs

示例7: MouseMove3D

 protected override void MouseMove3D(Viewport3D viewport, ViewportEvent e)
 {
     base.MouseMove3D(viewport, e);
 }
开发者ID:074769,项目名称:sledge,代码行数:4,代码来源:SelectTool.cs

示例8: UpdateCurrentFace

        private void UpdateCurrentFace(Viewport3D viewport, ViewportEvent e)
        {
            var ray = viewport.CastRayFromScreen(e.X, e.Y);

            // The face doesn't change when drawing, just update the intersection
            if (_state == SketchState.DrawingBase || _state == SketchState.DrawingVolume)
            {
                _intersection = (_state == SketchState.DrawingBase ? _currentFace.Plane : _volumePlane).GetIntersectionPoint(ray, true, true);
                return;
            }

            var isect = Document.Map.WorldSpawn.GetAllNodesIntersectingWith(ray)
                .OfType<Solid>()
                .SelectMany(x => x.Faces)
                .Select(x => new { Item = x, Intersection = x.GetIntersectionPoint(ray) })
                .Where(x => x.Intersection != null)
                .OrderBy(x => (x.Intersection - ray.Start).VectorMagnitude())
                .FirstOrDefault();

            if (isect != null)
            {
                if (_currentFace != isect.Item)
                {
                    _cloneFace = isect.Item.Clone();
                    _cloneFace.Transform(new UnitTranslate(isect.Item.Plane.Normal * 0.1m), TransformFlags.None);
                }

                _currentFace = isect.Item;
                _intersection = isect.Intersection;
                _state = SketchState.Ready;
            }
            else
            {
                _cloneFace = null;
                _currentFace = null;
                _intersection = null;
                _state = SketchState.None;
            }
        }
开发者ID:074769,项目名称:sledge,代码行数:39,代码来源:SketchTool.cs

示例9: GetVerticesAtPoint

 public abstract List<VMPoint> GetVerticesAtPoint(int x, int y, Viewport3D viewport);
开发者ID:silky,项目名称:sledge,代码行数:1,代码来源:VMSubTool.cs

示例10: Render3D

        protected override void Render3D(Viewport3D vp)
        {
            base.Render3D(vp);

            if (_currentTool != null) _currentTool.Render3D(vp);

            TextureHelper.Unbind();

            if (_currentTool == null || _currentTool.DrawVertices())
            {
                // Get us into 2D rendering
                Matrix.Set(MatrixMode.Projection);
                Matrix.Identity();
                Graphics.Helpers.Viewport.Orthographic(0, 0, vp.Width, vp.Height);
                Matrix.Set(MatrixMode.Modelview);
                Matrix.Identity();

                var half = new Coordinate(vp.Width, vp.Height, 0) / 2;
                // Render out the point handles
                GL.Begin(PrimitiveType.Quads);
                foreach (var point in Points)
                {
                    var c = vp.WorldToScreen(point.Coordinate);
                    if (c == null || c.Z > 1) continue;
                    c -= half;

                    GL.Color3(Color.Black);
                    GL.Vertex2(c.DX - 4, c.DY - 4);
                    GL.Vertex2(c.DX - 4, c.DY + 4);
                    GL.Vertex2(c.DX + 4, c.DY + 4);
                    GL.Vertex2(c.DX + 4, c.DY - 4);

                    GL.Color3(point.GetColour());
                    GL.Vertex2(c.DX - 3, c.DY - 3);
                    GL.Vertex2(c.DX - 3, c.DY + 3);
                    GL.Vertex2(c.DX + 3, c.DY + 3);
                    GL.Vertex2(c.DX + 3, c.DY - 3);
                }
                GL.End();

                // Get back into 3D rendering
                Matrix.Set(MatrixMode.Projection);
                Matrix.Identity();
                Graphics.Helpers.Viewport.Perspective(0, 0, vp.Width, vp.Height, View.CameraFOV);
                Matrix.Set(MatrixMode.Modelview);
                Matrix.Identity();
                vp.Camera.Position();
            }

            var type = vp.Type;
            bool shaded = type == Viewport3D.ViewType.Shaded || type == Viewport3D.ViewType.Textured,
                 textured = type == Viewport3D.ViewType.Textured,
                 wireframe = type == Viewport3D.ViewType.Wireframe;

            // Render out the solid previews
            GL.Color3(Color.White);
            var faces = _copies.Keys.SelectMany(x => x.Faces).ToList();

            if (!wireframe)
            {
                if (shaded) MapObjectRenderer.EnableLighting();
                GL.Enable(EnableCap.Texture2D);
                MapObjectRenderer.DrawFilled(faces.Where(x => !x.IsSelected), Color.FromArgb(255, 64, 192, 64), textured);
                MapObjectRenderer.DrawFilled(faces.Where(x => x.IsSelected), Color.FromArgb(255, 255, 128, 128), textured);
                GL.Disable(EnableCap.Texture2D);
                MapObjectRenderer.DisableLighting();

                GL.Color3(Color.Pink);
                MapObjectRenderer.DrawWireframe(faces, true);
            }
            else
            {
                GL.Color4(Color.FromArgb(255, 64, 192, 64));
                MapObjectRenderer.DrawWireframe(faces.Where(x => !x.IsSelected), true);
                GL.Color4(Color.FromArgb(255, 255, 128, 128));
                MapObjectRenderer.DrawWireframe(faces.Where(x => x.IsSelected), true);
            }
        }
开发者ID:074769,项目名称:sledge,代码行数:78,代码来源:VMTool.cs

示例11: RenderCircleTypeNone

        private void RenderCircleTypeNone(Viewport3D viewport, Document document)
        {
            var center = _pivotPoint;
            var origin = new Vector3((float)center.DX, (float)center.DY, (float)center.DZ);
            var distance = (viewport.Camera.Location - origin).Length;

            if (distance <= 1) return;

            var radius = 0.15f * distance;

            var normal = Vector3.Subtract(viewport.Camera.Location, origin).Normalized();
            var right = Vector3.Cross(normal, Vector3.UnitZ).Normalized();
            var up = Vector3.Cross(normal, right).Normalized();

            GL.Disable(EnableCap.DepthTest);
            GL.Disable(EnableCap.Texture2D);

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

            GL.Begin(PrimitiveType.Lines);
            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));
                GL.Color4(Color.DarkGray);
                GL.Vertex3(origin + right * cos1 * radius + up * sin1 * radius);
                GL.Vertex3(origin + right * cos2 * radius + up * sin2 * radius);
                GL.Color4(_mouseOver == CircleType.Outer ? Color.White : Color.LightGray);
                GL.Vertex3(origin + right * cos1 * radius * 1.2f + up * sin1 * radius * 1.2f);
                GL.Vertex3(origin + right * cos2 * radius * 1.2f + up * sin2 * radius * 1.2f);
            }
            GL.End();

            GL.Enable(EnableCap.ClipPlane0);
            GL.ClipPlane(ClipPlaneName.ClipPlane0, new double[] { normal.X, normal.Y, normal.Z, -Vector3.Dot(origin, normal) });

            GL.LineWidth(2);
            GL.Begin(PrimitiveType.Lines);
            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;

                GL.Color4(_mouseOver == CircleType.Z ? Color.Blue : Color.DarkBlue);
                GL.Vertex3(origin + Vector3.UnitX * cos1 + Vector3.UnitY * sin1);
                GL.Vertex3(origin + Vector3.UnitX * cos2 + Vector3.UnitY * sin2);

                GL.Color4(_mouseOver == CircleType.X ? Color.Red : Color.DarkRed);
                GL.Vertex3(origin + Vector3.UnitY * cos1 + Vector3.UnitZ * sin1);
                GL.Vertex3(origin + Vector3.UnitY * cos2 + Vector3.UnitZ * sin2);

                GL.Color4(_mouseOver == CircleType.Y ? Color.Lime : Color.LimeGreen);
                GL.Vertex3(origin + Vector3.UnitZ * cos1 + Vector3.UnitX * sin1);
                GL.Vertex3(origin + Vector3.UnitZ * cos2 + Vector3.UnitX * sin2);
            }
            GL.End();
            GL.LineWidth(1);

            GL.Disable(EnableCap.ClipPlane0);

            GL.Enable(EnableCap.DepthTest);
        }
开发者ID:silky,项目名称:sledge,代码行数:67,代码来源:RotationWidget.cs

示例12: RenderAxisRotating

        private void RenderAxisRotating(Viewport3D viewport, Document document)
        {
            var axis = Vector3.UnitX;
            var c = Color.Red;

            if (_mouseDown == CircleType.Y)
            {
                axis = Vector3.UnitY;
                c = Color.Lime;
            }

            if (_mouseDown == CircleType.Z)
            {
                axis = Vector3.UnitZ;
                c = Color.Blue;
            }

            if (_mouseDown == CircleType.Outer)
            {
                var vp3 = _activeViewport as Viewport3D;
                if (vp3 != null) axis = (vp3.Camera.LookAt - vp3.Camera.Location).Normalized();
                c = Color.White;
            }

            if (_activeViewport != viewport || _mouseDown != CircleType.Outer)
            {
                GL.Begin(PrimitiveType.Lines);

                var zero = new Vector3((float) _pivotPoint.DX, (float) _pivotPoint.DY, (float) _pivotPoint.DZ);

                GL.Color4(c);
                GL.Vertex3(zero - axis * 100000);
                GL.Vertex3(zero + axis * 100000);

                GL.End();
            }

            if (_activeViewport == viewport)
            {
                GL.Disable(EnableCap.DepthTest);
                GL.Enable(EnableCap.LineStipple);
                GL.LineStipple(5, 0xAAAA);
                GL.Begin(PrimitiveType.Lines);

                GL.Color4(Color.FromArgb(64, Color.Gray));
                GL.Vertex3(_pivotPoint.ToVector3());
                GL.Vertex3(viewport.ScreenToWorld(_mouseDownPoint).ToVector3());

                GL.Color4(Color.LightGray);
                GL.Vertex3(_pivotPoint.ToVector3());
                GL.Vertex3(viewport.ScreenToWorld(_mouseMovePoint).ToVector3());

                GL.End();
                GL.Disable(EnableCap.LineStipple);
                GL.Enable(EnableCap.DepthTest);
            }
        }
开发者ID:silky,项目名称:sledge,代码行数:57,代码来源:RotationWidget.cs

示例13: MouseOver

 private bool MouseOver(CircleType type, ViewportEvent ev, Viewport3D viewport)
 {
     var cache = _cachedLines.FirstOrDefault(x => x.Viewport3D == viewport);
     if (cache == null) return false;
     var lines = cache.Cache[type];
     var point = new Coordinate(ev.X, viewport.Height - ev.Y, 0);
     return lines.Any(x => (x.ClosestPoint(point) - point).VectorMagnitude() <= 8);
 }
开发者ID:silky,项目名称:sledge,代码行数:8,代码来源:RotationWidget.cs

示例14: GetTransformationMatrix

        private Matrix4? GetTransformationMatrix(Viewport3D viewport)
        {
            if (_mouseMovePoint == null || _mouseDownPoint == null || _pivotPoint == null) return null;

            var originPoint = viewport.WorldToScreen(_pivotPoint);
            var origv = (_mouseDownPoint - originPoint).Normalise();
            var newv = (_mouseMovePoint - originPoint).Normalise();
            var angle = DMath.Acos(Math.Max(-1, Math.Min(1, origv.Dot(newv))));
            if ((origv.Cross(newv).Z < 0)) angle = 2 * DMath.PI - angle;

            var shf = KeyboardState.Shift;
            var def = Select.RotationStyle;
            var snap = (def == RotationStyle.SnapOnShift && shf) || (def == RotationStyle.SnapOffShift && !shf);
            if (snap)
            {
                var deg = angle * (180 / DMath.PI);
                var rnd = Math.Round(deg / 15) * 15;
                angle = rnd * (DMath.PI / 180);
            }

            Vector3 axis;
            var dir = (viewport.Camera.Location - _pivotPoint.ToVector3()).Normalized();
            switch (_mouseDown)
            {
                case CircleType.Outer:
                    axis = dir;
                    break;
                case CircleType.X:
                    axis = Vector3.UnitX;
                    break;
                case CircleType.Y:
                    axis = Vector3.UnitY;
                    break;
                case CircleType.Z:
                    axis = Vector3.UnitZ;
                    break;
                default:
                    return null;
            }
            var dirAng = Math.Acos(Vector3.Dot(dir, axis)) * 180 / Math.PI;
            if (dirAng > 90) angle = -angle;

            var rotm = Matrix4.CreateFromAxisAngle(axis, (float)angle);
            var mov = Matrix4.CreateTranslation(-_pivotPoint.ToVector3());
            var rot = Matrix4.Mult(mov, rotm);
            return Matrix4.Mult(rot, Matrix4.Invert(mov));
        }
开发者ID:silky,项目名称:sledge,代码行数:47,代码来源:RotationWidget.cs

示例15: MouseDown

        private void MouseDown(Viewport3D vp, ViewportEvent e)
        {
            if (vp == null || e.Button != MouseButtons.Left) return;

            // Get the ray that is cast from the clicked point along the viewport frustrum
            var ray = vp.CastRayFromScreen(e.X, e.Y);

            // Grab all the elements that intersect with the ray
            var hits = Document.Map.WorldSpawn.GetAllNodesIntersectingWith(ray);

            // Sort the list of intersecting elements by distance from ray origin and grab the first hit
            var hit = hits
                .Select(x => new { Item = x, Intersection = x.GetIntersectionPoint(ray) })
                .Where(x => x.Intersection != null)
                .OrderBy(x => (x.Intersection - ray.Start).VectorMagnitude())
                .FirstOrDefault();

            if (hit == null) return; // Nothing was clicked

            CreateEntity(hit.Intersection);
        }
开发者ID:jpiolho,项目名称:sledge,代码行数:21,代码来源:EntityTool.cs


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