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


C# MeshBuilder.AddCubeFace方法代码示例

本文整理汇总了C#中HelixToolkit.Wpf.MeshBuilder.AddCubeFace方法的典型用法代码示例。如果您正苦于以下问题:C# MeshBuilder.AddCubeFace方法的具体用法?C# MeshBuilder.AddCubeFace怎么用?C# MeshBuilder.AddCubeFace使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在HelixToolkit.Wpf.MeshBuilder的用法示例。


在下文中一共展示了MeshBuilder.AddCubeFace方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: Tessellate

        /// <summary>
        /// Do the tessellation and return the <see cref="MeshGeometry3D"/>.
        /// </summary>
        /// <returns>The mesh geometry.</returns>
        protected override MeshGeometry3D Tessellate()
        {
            var b = new MeshBuilder(false, true);
            b.AddCubeFace(
                this.Center, 
                new Vector3D(-1, 0, 0), 
                new Vector3D(0, 0, 1), 
                this.SideLength, 
                this.SideLength, 
                this.SideLength);
            b.AddCubeFace(
                this.Center, 
                new Vector3D(1, 0, 0), 
                new Vector3D(0, 0, -1), 
                this.SideLength, 
                this.SideLength, 
                this.SideLength);
            b.AddCubeFace(
                this.Center, 
                new Vector3D(0, -1, 0), 
                new Vector3D(0, 0, 1), 
                this.SideLength, 
                this.SideLength, 
                this.SideLength);
            b.AddCubeFace(
                this.Center, 
                new Vector3D(0, 1, 0), 
                new Vector3D(0, 0, -1), 
                this.SideLength, 
                this.SideLength, 
                this.SideLength);
            b.AddCubeFace(
                this.Center, 
                new Vector3D(0, 0, 1), 
                new Vector3D(0, -1, 0), 
                this.SideLength, 
                this.SideLength, 
                this.SideLength);
            b.AddCubeFace(
                this.Center, 
                new Vector3D(0, 0, -1), 
                new Vector3D(0, 1, 0), 
                this.SideLength, 
                this.SideLength, 
                this.SideLength);

            return b.ToMesh();
        }
开发者ID:dermeister0,项目名称:helix-toolkit,代码行数:52,代码来源:CubeVisual3D.cs

示例2: AddCubeFace

        /// <summary>
        /// Adds a cube face.
        /// </summary>
        /// <param name="normal">
        /// The normal.
        /// </param>
        /// <param name="up">
        /// The up vector.
        /// </param>
        /// <param name="b">
        /// The brush.
        /// </param>
        /// <param name="text">
        /// The text.
        /// </param>
        private void AddCubeFace(Vector3D normal, Vector3D up, Brush b, string text)
        {
            var grid = new Grid { Width = 20, Height = 20, Background = b };
            grid.Children.Add(
                new TextBlock
                {
                    Text = text,
                    VerticalAlignment = VerticalAlignment.Center,
                    HorizontalAlignment = HorizontalAlignment.Center,
                    FontSize = 15,
                    Foreground = Brushes.White
                });
            grid.Arrange(new Rect(new Point(0, 0), new Size(20, 20)));

            var bmp = new RenderTargetBitmap((int)grid.Width, (int)grid.Height, 96, 96, PixelFormats.Default);
            bmp.Render(grid);

            var material = MaterialHelper.CreateMaterial(new ImageBrush(bmp));

            double a = this.Size;

            var builder = new MeshBuilder(false, true);
            builder.AddCubeFace(this.Center, normal, up, a, a, a);
            var geometry = builder.ToMesh();
            geometry.Freeze();

            var model = new GeometryModel3D { Geometry = geometry, Material = material };
            var element = new ModelUIElement3D { Model = model };
            element.MouseLeftButtonDown += this.FaceMouseLeftButtonDown;

            this.faceNormals.Add(element, normal);
            this.faceUpVectors.Add(element, up);

            this.Children.Add(element);
        }
开发者ID:JeremyAnsel,项目名称:helix-toolkit,代码行数:50,代码来源:ViewCubeVisual3D.cs

示例3: Tessellate

        /// <summary>
        /// Do the tesselation and return the <see cref="MeshGeometry3D"/>.
        /// </summary>
        /// <returns>The mesh geometry.</returns>
        protected override MeshGeometry3D Tessellate()
        {
            var b = new MeshBuilder(false,true);
            b.AddCubeFace(
                this.Center, new Vector3D(-1, 0, 0), new Vector3D(0, 0, 1), this.Length, this.Width, this.Height);
            b.AddCubeFace(
                this.Center, new Vector3D(1, 0, 0), new Vector3D(0, 0, -1), this.Length, this.Width, this.Height);
            b.AddCubeFace(
                this.Center, new Vector3D(0, -1, 0), new Vector3D(0, 0, 1), this.Width, this.Length, this.Height);
            b.AddCubeFace(
                this.Center, new Vector3D(0, 1, 0), new Vector3D(0, 0, -1), this.Width, this.Length, this.Height);
            if (this.TopFace)
            {
                b.AddCubeFace(
                    this.Center, new Vector3D(0, 0, 1), new Vector3D(0, -1, 0), this.Height, this.Length, this.Width);
            }

            if (this.BottomFace)
            {
                b.AddCubeFace(
                    this.Center, new Vector3D(0, 0, -1), new Vector3D(0, 1, 0), this.Height, this.Length, this.Width);
            }

            return b.ToMesh();
        }
开发者ID:litdev1,项目名称:LitDev,代码行数:29,代码来源:BoxVisual3D.cs

示例4: CreateFace

        private static GeometryModel3D CreateFace(int face, Point3D center, double width, double length, double height, Brush brush)
        {
            var m = new GeometryModel3D();
            var b = new MeshBuilder(false,true);
            switch (face)
            {
                case 0:
                    b.AddCubeFace(center, new Vector3D(-1, 0, 0), new Vector3D(0, 0, 1), length, width, height);
                    break;
                case 1:
                    b.AddCubeFace(center, new Vector3D(1, 0, 0), new Vector3D(0, 0, -1), length, width, height);
                    break;
                case 2:
                    b.AddCubeFace(center, new Vector3D(0, -1, 0), new Vector3D(0, 0, 1), width, length, height);
                    break;
                case 3:
                    b.AddCubeFace(center, new Vector3D(0, 1, 0), new Vector3D(0, 0, -1), width, length, height);
                    break;
                case 4:
                    b.AddCubeFace(center, new Vector3D(0, 0, -1), new Vector3D(0, 1, 0), height, length, width);
                    break;
                case 5:
                    b.AddCubeFace(center, new Vector3D(0, 0, 1), new Vector3D(0, -1, 0), height, length, width);
                    break;
            }

            m.Geometry = b.ToMesh();
            m.Material = MaterialHelper.CreateMaterial(brush);
            return m;
        }
开发者ID:ORRNY66,项目名称:helix-toolkit,代码行数:30,代码来源:RubikCube.cs

示例5: AddRectangle

        /// <summary>
        /// Add a rectangle geometry object centred at (0,0,0).
        /// </summary>
        /// <param name="shapeName">The 3DView object.</param>
        /// <param name="width">The width of the rectangle.</param>
        /// <param name="height">The height of the rectangle.</param>
        /// <param name="colour">A colour or gradient brush for the object.</param>
        /// <param name="materialType">A material for the object.
        /// The available options are:
        /// "E" Emmissive - constant brightness.
        /// "D" Diffusive - affected by lights.
        /// "S" Specular  - specular highlights.
        /// </param>
        /// <returns>The 3DView Geometry name.</returns>
        public static Primitive AddRectangle(Primitive shapeName, Primitive width, Primitive height, Primitive colour, Primitive materialType)
        {
            UIElement obj;

            try
            {
                if (_objectsMap.TryGetValue((string)shapeName, out obj))
                {
                    InvokeHelperWithReturn ret = new InvokeHelperWithReturn(delegate
                    {
                        try
                        {
                            if (obj.GetType() == typeof(Viewport3D))
                            {
                                Viewport3D viewport3D = (Viewport3D)obj;
                                ProjectionCamera camera = (ProjectionCamera)viewport3D.Camera;

                                MeshBuilder builder = new MeshBuilder(true, true);
                                builder.AddCubeFace(new Point3D(0, 0, 0), new Vector3D(0, 0, 1), new Vector3D(0, 1, 0), 0, width, height);
                                MeshGeometry3D mesh = builder.ToMesh();

                                return AddGeometry(viewport3D, mesh.Positions, mesh.TriangleIndices, mesh.Normals, mesh.TextureCoordinates, colour, materialType);
                            }
                        }
                        catch (Exception ex)
                        {
                            Utilities.OnError(Utilities.GetCurrentMethod(), ex);
                        }
                        return "";
                    });
                    return FastThread.InvokeWithReturn(ret).ToString();
                }
                else
                {
                    Utilities.OnShapeError(Utilities.GetCurrentMethod(), shapeName);
                }
            }
            catch (Exception ex)
            {
                Utilities.OnError(Utilities.GetCurrentMethod(), ex);
            }
            return "";
        }
开发者ID:litdev1,项目名称:LitDev,代码行数:57,代码来源:3DView.cs


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