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


C# Media3D.MeshGeometry3D类代码示例

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


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

示例1: Matches

 public bool Matches(MeshGeometry3D mesh)
 {
     foreach (GeometryModel3D part in modelGroup.Children)
         if (part.Geometry == mesh)
             return true;
     return false;
 }
开发者ID:buidan,项目名称:dreamviewer,代码行数:7,代码来源:Cover.cs

示例2: CreateGeometry

        private Geometry3D CreateGeometry()
        {
            MeshGeometry3D mesh = new MeshGeometry3D();

            mesh.Positions.Add(UL);
            mesh.Positions.Add(LL);
            mesh.Positions.Add(UR);

            mesh.TriangleIndices.Add(0);
            mesh.TriangleIndices.Add(1);
            mesh.TriangleIndices.Add(2);

            Vector3D verticalDirection = LL - UL;
            Vector3D horizontalDirection = UR - UL;

            Point3D LR = UL + verticalDirection + horizontalDirection;

            mesh.Positions.Add(UR);
            mesh.Positions.Add(LL);
            mesh.Positions.Add(LR);

            mesh.TriangleIndices.Add(3);
            mesh.TriangleIndices.Add(4);
            mesh.TriangleIndices.Add(5);

            mesh.Freeze();
            return mesh;
        }
开发者ID:Faham,项目名称:emophiz,代码行数:28,代码来源:Screen.cs

示例3: CreateMesh

        protected override Geometry3D CreateMesh()
        {
            _radius = Radius;
            _position = Position;

            MeshGeometry3D mesh = new MeshGeometry3D();
            Point3D prevPoint = PointForAngle(0);
            Vector3D normal = new Vector3D(0, 0, 1);

            const int div = 180;
            for (int i = 1; i <= div; ++i)
            {
                double angle = 2 * Math.PI / div * i;
                Point3D newPoint = PointForAngle(angle);
                mesh.Positions.Add(prevPoint);
                mesh.Positions.Add(_position);
                mesh.Positions.Add(newPoint);
                mesh.Normals.Add(normal);
                mesh.Normals.Add(normal);
                mesh.Normals.Add(normal);
                prevPoint = newPoint;
            }

            mesh.Freeze();
            return mesh;
        }
开发者ID:Moiraines,项目名称:TelerikAcademy,代码行数:26,代码来源:Circle.cs

示例4: CreateMesh

        private MeshGeometry3D CreateMesh()
        {
            var geometry = new MeshGeometry3D();
            int nx = solver.Width;
            int ny = solver.Height;
            int ij = 0;
            for (int i = 0; i < ny; i++)
            {
                for (int j = 0; j < nx; j++)
                {
                    double z = (double)solver.ImageBuffer[ij] / solver.MaxIterations;
                    geometry.Positions.Add(new Point3D(solver.Xvalues[ij], solver.Yvalues[ij], z * HeightFactor));
                    double u = z * 0.854;
                    geometry.TextureCoordinates.Add(new Point(u, 0));
                    ij++;
                }
            }

            ij = 0;
            for (int i = 0; i < ny - 1; i++)
            {
                for (int j = 0; j < nx - 1; j++)
                {
                    geometry.TriangleIndices.Add(ij);
                    geometry.TriangleIndices.Add(ij + 1);
                    geometry.TriangleIndices.Add(ij + nx);
                    geometry.TriangleIndices.Add(ij + 1);
                    geometry.TriangleIndices.Add(ij + 1 + nx);
                    geometry.TriangleIndices.Add(ij + nx);
                    ij++;
                }
                ij++;
            }
            return geometry;
        }
开发者ID:ORRNY66,项目名称:helix-toolkit,代码行数:35,代码来源:MandelbrotMountain.cs

示例5: addPointCombined

        /// <summary>   Adds a point combined. </summary>
        ///
        /// <param name="point">    The point. </param>
        /// <param name="mesh">     The mesh. </param>
        /// <param name="normal">   The normal. </param>
        public static void addPointCombined(Point3D point, MeshGeometry3D mesh, Vector3D normal)
        {
            bool found = false;

            int i = 0;

            foreach (Point3D p in mesh.Positions)
            {
                if (p.Equals(point))
                {
                    found = true;
                    mesh.TriangleIndices.Add(i);
                    mesh.Positions.Add(point);
                    mesh.Normals.Add(normal);
                    break;
                }

                i++;
            }

            if (!found)
            {
                mesh.Positions.Add(point);
                mesh.TriangleIndices.Add(mesh.TriangleIndices.Count);
                mesh.Normals.Add(normal);
            }

        }
开发者ID:BdGL3,项目名称:CXPortal,代码行数:33,代码来源:ObjectTriangle.cs

示例6: CreateNormalizedCube

        public static GeometryModel3D CreateNormalizedCube(Material material)
        {
            MeshGeometry3D geometry = new MeshGeometry3D();

            var farPoint = new Point3D(-0.5, -0.5, -0.5);
            var nearPoint = new Point3D(0.5, 0.5, 0.5);

            var cube = new Model3DGroup();
            var p0 = new Point3D(farPoint.X, farPoint.Y, farPoint.Z);
            var p1 = new Point3D(nearPoint.X, farPoint.Y, farPoint.Z);
            var p2 = new Point3D(nearPoint.X, farPoint.Y, nearPoint.Z);
            var p3 = new Point3D(farPoint.X, farPoint.Y, nearPoint.Z);
            var p4 = new Point3D(farPoint.X, nearPoint.Y, farPoint.Z);
            var p5 = new Point3D(nearPoint.X, nearPoint.Y, farPoint.Z);
            var p6 = new Point3D(nearPoint.X, nearPoint.Y, nearPoint.Z);
            var p7 = new Point3D(farPoint.X, nearPoint.Y, nearPoint.Z);
            int startIndex = 0;
            startIndex = AddTriangleFace(geometry, p3, p2, p6, startIndex);
            startIndex = AddTriangleFace(geometry, p3, p6, p7, startIndex);
            startIndex = AddTriangleFace(geometry, p2, p1, p5, startIndex);
            startIndex = AddTriangleFace(geometry, p2, p5, p6, startIndex);
            startIndex = AddTriangleFace(geometry, p1, p0, p4, startIndex);
            startIndex = AddTriangleFace(geometry, p1, p4, p5, startIndex);
            startIndex = AddTriangleFace(geometry, p0, p3, p7, startIndex);
            startIndex = AddTriangleFace(geometry, p0, p7, p4, startIndex);
            startIndex = AddTriangleFace(geometry, p7, p6, p5, startIndex);
            startIndex = AddTriangleFace(geometry, p7, p5, p4, startIndex);
            startIndex = AddTriangleFace(geometry, p2, p3, p0, startIndex);
            startIndex = AddTriangleFace(geometry, p2, p0, p1, startIndex);

            return new GeometryModel3D(geometry, material);
        }
开发者ID:philipdaubmeier,项目名称:BodyOrientation,代码行数:32,代码来源:Model3DFactory.cs

示例7: CreateTriangleModel

        public Model3DGroup CreateTriangleModel(Point3D p0, Point3D p1, Point3D p2)
        {
            MeshGeometry3D mesh = new MeshGeometry3D();
            mesh.Positions.Add(p0);
            mesh.Positions.Add(p1);
            mesh.Positions.Add(p2);

            for (int i = 0; i < 3; i++)
            {
                mesh.TriangleIndices.Add(i);
            }

            Vector3D normal = CalculateNormal(p0, p1, p2);

            for (int i = 0; i < 3; i++)
            {
                mesh.Normals.Add(normal);
            }

            Material material = new DiffuseMaterial(new SolidColorBrush(Colors.DarkCyan));
            GeometryModel3D model = new GeometryModel3D(mesh, material);
            Model3DGroup group = new Model3DGroup();
            group.Children.Add(model);
            return group;
        }
开发者ID:AaronRevilla,项目名称:TT_2012b-049_ComputerGraphics,代码行数:25,代码来源:Graficos.cs

示例8: CreateMesh

        protected override Geometry3D CreateMesh()
        {
            this.radius = this.Radius;
            this.position = this.Position;

            var mesh = new MeshGeometry3D();
            var prevPoint = this.PointForAngle(0);
            var normal = new Vector3D(0, 0, 1);

            int div = 180;

            for (var i = 1; i <= div; ++i)
            {
                var angle = 2 * Math.PI / div * i;
                var newPoint = this.PointForAngle(angle);
                mesh.Positions.Add(prevPoint);
                mesh.Positions.Add(this.position);
                mesh.Positions.Add(newPoint);
                mesh.Normals.Add(normal);
                mesh.Normals.Add(normal);
                mesh.Normals.Add(normal);
                prevPoint = newPoint;
            }

            mesh.Freeze();
            return mesh;
        }
开发者ID:tddold,项目名称:Telerik-Academy-3,代码行数:27,代码来源:Circle.cs

示例9: addToMesh

        public void addToMesh(MeshGeometry3D mesh, bool combineVertices)
        {
            if (sphereCirces[0].Points.Count > 2)
            {
                List<Point3D> ListOfPoints = new List<Point3D>();
                for (int i = 0; i <= 2*nStacks - 2; i++)
                {
                    foreach (Point3D p in sphereCirces[i].Points)
                    {
                        ListOfPoints.Add(p);
                    }
                    ListOfPoints.Add(sphereCirces[i].Points[0]);
                }

                MessageBox.Show(ListOfPoints.Count.ToString());
                MessageBox.Show(sphereCirces[0].Points.Count.ToString());
                for (int i = 0; i <= 2 * nStacks -3; i++)
                {
                    for (int j = 1; j < sphereCirces[i].Points.Count + 1 ; j++)
                    {
                        Triangle.addTriangleToMesh(ListOfPoints[(j - 1) + i * (sphereCirces[i].Points.Count + 1)],
                            ListOfPoints[(j - 1) + (i + 1) * (sphereCirces[i].Points.Count + 1)],
                            ListOfPoints[j + i * (sphereCirces[8].Points.Count + 1)], mesh, combineVertices);
                        Triangle.addTriangleToMesh(ListOfPoints[j + i * (sphereCirces[i].Points.Count + 1)],
                            ListOfPoints[(j - 1) + (i + 1) * (sphereCirces[i].Points.Count + 1)],
                            ListOfPoints[(j) + (i + 1) * (sphereCirces[i].Points.Count + 1)], mesh, combineVertices);
                    }
                }
            }
        }
开发者ID:kulturberikare,项目名称:RUNKinect,代码行数:30,代码来源:Sphere.cs

示例10: simpleButtonClick

        private void simpleButtonClick(object sender, RoutedEventArgs e)
        {
            MeshGeometry3D triagleMesh = new MeshGeometry3D();
            Point3D p0 = new Point3D(0, 0, 0);
            Point3D p1 = new Point3D(5, 0, 0);
            Point3D p2 = new Point3D(0, 0, 5);

            triagleMesh.Positions.Add(p0);
            triagleMesh.Positions.Add(p1);
            triagleMesh.Positions.Add(p2);

            triagleMesh.TriangleIndices.Add(0);
            triagleMesh.TriangleIndices.Add(2);
            triagleMesh.TriangleIndices.Add(1);

            Vector3D normal = new Vector3D(0, 1, 0);
            triagleMesh.Normals.Add(normal);
            triagleMesh.Normals.Add(normal);
            triagleMesh.Normals.Add(normal);

            Material material = new DiffuseMaterial(new SolidColorBrush(Colors.LawnGreen));
            GeometryModel3D triangleModel = new GeometryModel3D(triagleMesh, material);

            ModelVisual3D model = new ModelVisual3D();
            model.Content = triangleModel;
            this.mainViewport.Children.Add(model);
        }
开发者ID:AaronRevilla,项目名称:TT_2012b-049_ComputerGraphics,代码行数:27,代码来源:MainWindow.xaml.cs

示例11: GetSkeletonModel

        public static Model3D GetSkeletonModel(AnimData animData, int frameNo)
        {
            if (null == animData) {
                return null;
            }

            GeometryModel3D model = new GeometryModel3D();
            MeshGeometry3D mesh = new MeshGeometry3D();

            Point3D[] parentPoints = new Point3D[64];
            parentPoints[0] = new Point3D(0, 0, 0);

            for (int jointNum = 0; jointNum < animData.skeletonDef.GetLength(0); ++jointNum)
            {
                int parentIndex = animData.skeletonDef[jointNum];
                // Binding position
                Point3D pos = animData.bindingPose[jointNum];

                if (frameNo >= 0)
                {
                    AnimMeshPose pose = animData.perFrameFKPoses[frameNo, jointNum];
                    pos = pose.Position;
                }
                parentPoints[parentIndex + 1] = pos;
                AddBone(mesh, parentPoints[parentIndex], pos);
            }

            model.Geometry = mesh;

            DiffuseMaterial dm = new DiffuseMaterial();
            dm.Brush = new SolidColorBrush(Colors.DarkGreen);
            model.Material = dm;

            return model;
        }
开发者ID:Stranho,项目名称:bgda-explorer,代码行数:35,代码来源:SkeletonProcessor.cs

示例12: BuildMesh

        private MeshGeometry3D BuildMesh(Point3D p0, Point3D p1, Point3D p2, Point3D p3,
            Point2D q0, Point2D q1, Point2D q2, Point2D q3)
        {
            var mesh = new MeshGeometry3D();
            mesh.Positions.Add(p0);
            mesh.Positions.Add(p1);
            mesh.Positions.Add(p2);
            mesh.Positions.Add(p3);

            var normal = CalculateNormal(p0, p1, p2);
            mesh.TriangleIndices.Add(0);
            mesh.TriangleIndices.Add(1);
            mesh.TriangleIndices.Add(2);
            mesh.Normals.Add(normal);
            mesh.Normals.Add(normal);
            mesh.Normals.Add(normal);
            mesh.TextureCoordinates.Add(q3);
            mesh.TextureCoordinates.Add(q2);
            mesh.TextureCoordinates.Add(q1);

            normal = CalculateNormal(p2, p3, p0);
            mesh.TriangleIndices.Add(2);
            mesh.TriangleIndices.Add(3);
            mesh.TriangleIndices.Add(0);
            mesh.Normals.Add(normal);
            mesh.Normals.Add(normal);
            mesh.Normals.Add(normal);
            mesh.TextureCoordinates.Add(q0);
            mesh.TextureCoordinates.Add(q1);
            mesh.TextureCoordinates.Add(q2);

            mesh.Freeze();
            return mesh;
        }
开发者ID:buidan,项目名称:dreamviewer,代码行数:34,代码来源:Cover.cs

示例13: CreateBottomFace

        private void CreateBottomFace(int width, int height)
        {
            MeshGeometry3D mesh = new MeshGeometry3D();

            mesh.Positions.Add(new Point3D(-width, height, -10));
            mesh.Positions.Add(new Point3D(width, height, -10));
            mesh.Positions.Add(new Point3D(width, height, +1000));
            mesh.Positions.Add(new Point3D(-width, height, +1000));

            mesh.TriangleIndices.Add(0);
            mesh.TriangleIndices.Add(1);
            mesh.TriangleIndices.Add(3);
            mesh.TriangleIndices.Add(1);
            mesh.TriangleIndices.Add(2);
            mesh.TriangleIndices.Add(3);

            // These are the lines you need to allow an image to be painted onto the 3d model
            mesh.TextureCoordinates.Add(new Point(0, 0));
            mesh.TextureCoordinates.Add(new Point(1, 0));
            mesh.TextureCoordinates.Add(new Point(1, 1));
            mesh.TextureCoordinates.Add(new Point(0, 1));

            GeometryModel3D geometry = new GeometryModel3D(mesh, new DiffuseMaterial(new SolidColorBrush(Colors.Red)));

            group.Children.Add(geometry);
        }
开发者ID:jefflequeux,项目名称:DarkangeUtils,代码行数:26,代码来源:MainWindow.xaml.cs

示例14: CreatePolygonModel

        public Model3DGroup CreatePolygonModel(Point3D[] points)
        {
            MeshGeometry3D mesh = new MeshGeometry3D();
            int indexPoints = 0;
            int totalPoints = points.Count();

            for (indexPoints = 0; indexPoints < totalPoints; indexPoints++)
            {
                mesh.Positions.Add(points.ElementAt(indexPoints));
            }

            //Solo se necesitan tres puntos para poder obtener la normal del triangulo
            for (int i = 0; i < 3; i++)
            {
                mesh.TriangleIndices.Add(i);
            }

            //Para obtener el vector normal solo se necesitan tres puntos del plano
            Vector3D normal = CalculateNormal(points.ElementAt(0), points.ElementAt(1), points.ElementAt(2));

            //¿Checar por que se agrega 3 veces la normal?
            //for (int i = 0; i < 3; i++)
            //{
            mesh.Normals.Add(normal);
            //}

            Material material = new DiffuseMaterial(new SolidColorBrush(Colors.DarkCyan));
            GeometryModel3D model = new GeometryModel3D(mesh, material);
            Model3DGroup group = new Model3DGroup();
            group.Children.Add(model);
            return group;
        }
开发者ID:AaronRevilla,项目名称:TT_2012b-049_ComputerGraphics,代码行数:32,代码来源:Graficos.cs

示例15: ExplodingMesh

        public ExplodingMesh(MeshGeometry3D inputMesh, Point3D hitpos)
        {
            var mesh = MeshGeometryHelper.NoSharedVertices(inputMesh);

            double cx, cy, cz;
            cx = cy = cz = 0;
            for (int i = 0; i < mesh.Positions.Count; i++)
            {
                cx += mesh.Positions[i].X;
                cy += mesh.Positions[i].Y;
                cz += mesh.Positions[i].Z;
            }
            int n = mesh.Positions.Count;
            var center = new Point3D(cx / n, cy / n, cz / n);

            integrator = new VerletIntegrator();
            integrator.Resize(mesh.Positions.Count);
            var r = new Random();
            for (int i = 0; i < mesh.Positions.Count; i++)
            {
                var delta = mesh.Positions[i] - center;
                delta.Normalize();
                integrator.Positions[i] = mesh.Positions[i] + delta * (1 + r.NextDouble() * 2);
                integrator.Positions0[i] = mesh.Positions[i];
                integrator.Accelerations[i] = new Vector3D(0, 0, -1000);
                integrator.InverseMass[i] = 0.01;
            }

            integrator.CreateConstraintsByMesh(mesh, 0.7);
            integrator.AddFloor(0.3);
            this.Mesh = mesh;
            watch.Start();
        }
开发者ID:chantsunman,项目名称:helix-toolkit,代码行数:33,代码来源:MainWindow.xaml.cs


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