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


C# MeshGeometry3D.Freeze方法代码示例

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


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

示例1: CreateGeometry

        void CreateGeometry()
        {

            double r = Diameter / 2;
            double l = HeadLength * Diameter;

            // arrowhead
            var pc = new PointCollection();
            pc.Add(new Point(-l, r));
            pc.Add(new Point(-l, r * 2));
            pc.Add(new Point(0, 0));

            var headBuilder = new MeshBuilder();
            headBuilder.AddRevolvedGeometry(pc, new Point3D(0, 0, 0), new Vector3D(0, 0, 1), ThetaDiv);
            _head = headBuilder.ToMesh();
            _head.Freeze(); 
            

            // body
            pc = new PointCollection();
            pc.Add(new Point(0, 0));
            pc.Add(new Point(0, r));
            pc.Add(new Point(1, r));

            var bodyBuilder = new MeshBuilder();
            bodyBuilder.AddRevolvedGeometry(pc, new Point3D(0, 0, 0), new Vector3D(0, 0, 1), ThetaDiv);
            _body = bodyBuilder.ToMesh();
            _body.Freeze();
        }
开发者ID:XiBeichuan,项目名称:hydronumerics,代码行数:29,代码来源:VectorFieldVisual3D.cs

示例2: 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

示例3: 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

示例4: CreateGeometry

 private void CreateGeometry()
 {
     var builder = new MeshBuilder();
     builder.AddSphere(new Point3D(0, 0, 0), Diameter/2, ThetaDiv, PhiDiv);
     _sphere = builder.ToMesh();
     _sphere.Freeze();
 }
开发者ID:XiBeichuan,项目名称:hydronumerics,代码行数:7,代码来源:SphereCollectionVisual3D.cs

示例5: 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

示例6: CreateMesh

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

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

            for (int i = 1; i <= Divider; ++i)
            {
                double angle = 2 * Math.PI / Divider * i;
                Point3D 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:Vyara,项目名称:Telerik-High-Quality-Code-Homeworks,代码行数:25,代码来源:Circle.cs

示例7: Tessellate

        internal override Geometry3D Tessellate()
        {
            int tDiv = 32;
            int yDiv = 32;
            double maxTheta = DegToRad(360.0);
            double minY = -1.0;
            double maxY = 1.0;

            double dt = maxTheta / tDiv;
            double dy = (maxY - minY) / yDiv;

            MeshGeometry3D mesh = new MeshGeometry3D();

            for (int yi = 0; yi <= yDiv; yi++)
            {
                double y = minY + yi * dy;

                for (int ti = 0; ti <= tDiv; ti++)
                {
                    double t = ti * dt;

                    mesh.Positions.Add(GetPosition(t, y));
                    mesh.Normals.Add(GetNormal(t, y));
                    mesh.TextureCoordinates.Add(GetTextureCoordinate(t, y));
                }
            }

            for (int yi = 0; yi < yDiv; yi++)
            {
                for (int ti = 0; ti < tDiv; ti++)
                {
                    int x0 = ti;
                    int x1 = (ti + 1);
                    int y0 = yi * (tDiv + 1);
                    int y1 = (yi + 1) * (tDiv + 1);

                    mesh.TriangleIndices.Add(x0 + y0);
                    mesh.TriangleIndices.Add(x0 + y1);
                    mesh.TriangleIndices.Add(x1 + y0);

                    mesh.TriangleIndices.Add(x1 + y0);
                    mesh.TriangleIndices.Add(x0 + y1);
                    mesh.TriangleIndices.Add(x1 + y1);
                }
            }

            mesh.Freeze();
            return mesh;
        }
开发者ID:jayawantsawant,项目名称:WPFSamples,代码行数:49,代码来源:Cylinder3D.cs

示例8: CreateGeometry

        void CreateGeometry()
        {

            double r = Diameter / 2;

            var pc = new PointCollection();
            pc.Add(new Point(0, 0));
            pc.Add(new Point(0, r));
            pc.Add(new Point(1, r));
            pc.Add(new Point(1, 0));

            var builder = new MeshBuilder();
            builder.AddRevolvedGeometry(pc, new Point3D(0, 0, 0), new Vector3D(0, 0, 1), ThetaDiv);
            _tube= builder.ToMesh();
            _tube.Freeze();
        }
开发者ID:XiBeichuan,项目名称:hydronumerics,代码行数:16,代码来源:SegmentCollectionVisual3D.cs

示例9: CreateMesh

        /// <summary>
        /// The create mesh.
        /// </summary>
        /// <returns>
        /// The <see cref="Geometry3D"/>.
        /// </returns>
        protected override Geometry3D CreateMesh()
        {
            this.radius = this.Radius;
            this.position = this.Position;

            const int AngleSteps = 32;
            const double MinAngle = 0;
            const double MaxAngle = 2 * Math.PI;
            const double DAngle = (MaxAngle - MinAngle) / AngleSteps;

            const int YSteps = 32;
            const double MinY = -1.0;
            const double MaxY = 1.0;
            const double Dy = (MaxY - MinY) / YSteps;

            MeshGeometry3D mesh = new MeshGeometry3D();

            for (int yi = 0; yi <= YSteps; yi++)
            {
                double y = MinY + (yi * Dy);

                for (int ai = 0; ai <= AngleSteps; ai++)
                {
                    double angle = ai * DAngle;

                    mesh.Positions.Add(this.GetPosition(angle, y));
                    mesh.Normals.Add(this.GetNormal(angle, y));
                    mesh.TextureCoordinates.Add(this.GetTextureCoordinate(angle, y));
                }
            }

            for (int yi = 0; yi < YSteps; yi++)
            {
                for (int ai = 0; ai < AngleSteps; ai++)
                {
                    int a1 = ai;
                    int a2 = ai + 1;
                    int y1 = yi * (AngleSteps + 1);
                    int y2 = (yi + 1) * (AngleSteps + 1);

                    mesh.TriangleIndices.Add(y1 + a1);
                    mesh.TriangleIndices.Add(y2 + a1);
                    mesh.TriangleIndices.Add(y1 + a2);

                    mesh.TriangleIndices.Add(y1 + a2);
                    mesh.TriangleIndices.Add(y2 + a1);
                    mesh.TriangleIndices.Add(y2 + a2);
                }
            }

            mesh.Freeze();
            return mesh;
        }
开发者ID:KatyaMarincheva,项目名称:High-Quality-Code-Course,代码行数:59,代码来源:Sphere.cs

示例10: AddedToEmitter

        /// <summary>
        /// Initializes the image brush if need.
        /// </summary>
        public override void AddedToEmitter(Emitter emitter)
        {
            base.AddedToEmitter(emitter);

            if (m_image == null)
            {
                var uri =
                    (m_imageUri.IsAbsoluteUri
                    ? m_imageUri
                    : new Uri(m_baseUri, m_imageUri));

                m_image = GetImage(uri);
                m_mesh = Particle.CreateDefaultMesh(1.0, 1.0, m_image.Width, m_image.Height);
                m_mesh.Freeze();
            }
        }
开发者ID:JuroGandalf,项目名称:Ragnarok,代码行数:19,代码来源:SharedImage.cs

示例11: ProvideValue

        public override object ProvideValue(IServiceProvider serviceProvider)
        {
            var s = System.Windows.Application.GetResourceStream(Source);
            if (s == null)
                throw new ArgumentException("Object not Found", "Source");

            using (s.Stream)
            using (var sr = new StreamReader(s.Stream, Encoding.ASCII))
            {
                MeshGeometry3D geom = new MeshGeometry3D();

                List<Point3D> verts = new List<Point3D>();
                List<Vector3D> normals = new List<Vector3D>();
                List<Face3D> faces = new List<Face3D>();

                string line;
                while ((line = sr.ReadLine()) != null)
                {
                    if (line.Length == 0 || line[0] == '#')
                        continue;

                    var ls = line.Split(' ');
                    switch (ls[0])
                    {
                        case "v":
                            {
                                float x, y, z;
                                float.TryParse(ls[1], NumberStyles.Any, CultureInfo.InvariantCulture, out x);
                                float.TryParse(ls[2], NumberStyles.Any, CultureInfo.InvariantCulture, out y);
                                float.TryParse(ls[3], NumberStyles.Any, CultureInfo.InvariantCulture, out z);
                                Point3D p = new Point3D(x, y, z);
                                verts.Add(p);
                                break;
                            }
                        case "vn":
                            {
                                float x, y, z;
                                float.TryParse(ls[1], NumberStyles.Any, CultureInfo.InvariantCulture, out x);
                                float.TryParse(ls[2], NumberStyles.Any, CultureInfo.InvariantCulture, out y);
                                float.TryParse(ls[3], NumberStyles.Any, CultureInfo.InvariantCulture, out z);
                                Vector3D p = new Vector3D(x, y, z);
                                normals.Add(p);
                                break;
                            }
                        case "f":
                            {
                                var v0 = ls[1].Split('/');
                                var v1 = ls[2].Split('/');
                                var v2 = ls[3].Split('/');
                                Face3D f = new Face3D
                                {
                                    A = new Vertex3D(verts[int.Parse(v0[0]) - 1], normals[int.Parse(v0[2]) - 1], new Vector3D()),
                                    B = new Vertex3D(verts[int.Parse(v1[0]) - 1], normals[int.Parse(v1[2]) - 1], new Vector3D()),
                                    C = new Vertex3D(verts[int.Parse(v2[0]) - 1], normals[int.Parse(v2[2]) - 1], new Vector3D()),
                                };
                                faces.Add(f);
                                break;
                            }
                    }
                }

                int i = 0;
                foreach (var face3D in faces)
                {
                    geom.Positions.Add(face3D.A.Position);
                    geom.Positions.Add(face3D.B.Position);
                    geom.Positions.Add(face3D.C.Position);

                    geom.Normals.Add(face3D.A.Normal);
                    geom.Normals.Add(face3D.B.Normal);
                    geom.Normals.Add(face3D.C.Normal);

                    geom.TriangleIndices.Add(i++);
                    geom.TriangleIndices.Add(i++);
                    geom.TriangleIndices.Add(i++);
                }

                geom.Freeze();

                return geom;
            }
        }
开发者ID:usagirei,项目名称:3DS-Theme-Editor,代码行数:82,代码来源:ObjMeshExtension.cs

示例12: CreatePushpinGeometry

            private static void CreatePushpinGeometry()
            {
                MeshGeometry3D geometry = new MeshGeometry3D();

                // Create a collection of vertex positions for the MeshGeometry3D.
                Point3DCollection ptrVertices = new Point3DCollection();
                ptrVertices.Add(new Point3D(0, 0, 0));
                ptrVertices.Add(new Point3D(-0.01, -0.01, 1.2));
                ptrVertices.Add(new Point3D(0.01, -0.01, 1.2));
                ptrVertices.Add(new Point3D(0, 0.01, 1.2));
                geometry.Positions = ptrVertices;

                // Create a collection of triangle indices for the MeshGeometry3D.
                Int32Collection ptrTriangleIndices = new Int32Collection();
                ptrTriangleIndices.Add(1);
                ptrTriangleIndices.Add(2);
                ptrTriangleIndices.Add(3);

                ptrTriangleIndices.Add(0);
                ptrTriangleIndices.Add(1);
                ptrTriangleIndices.Add(3);

                ptrTriangleIndices.Add(0);
                ptrTriangleIndices.Add(3);
                ptrTriangleIndices.Add(2);

                ptrTriangleIndices.Add(0);
                ptrTriangleIndices.Add(2);
                ptrTriangleIndices.Add(1);
                geometry.TriangleIndices = ptrTriangleIndices;

                // create a collection of texture coordinates for the MeshGeometry3D
                PointCollection ptrTexCoordindates = new PointCollection();
                ptrTexCoordindates.Add(new Point(0.5, 0.5));
                ptrTexCoordindates.Add(new Point(0.5, 0.5));
                ptrTexCoordindates.Add(new Point(0.5, 0.5));

                ptrTexCoordindates.Add(new Point(0.5, 0.5));
                ptrTexCoordindates.Add(new Point(0.5, 0.5));
                ptrTexCoordindates.Add(new Point(0.5, 0.5));

                ptrTexCoordindates.Add(new Point(0.5, 0.5));
                ptrTexCoordindates.Add(new Point(0.5, 0.5));
                ptrTexCoordindates.Add(new Point(0.5, 0.5));

                ptrTexCoordindates.Add(new Point(0.5, 0.5));
                ptrTexCoordindates.Add(new Point(0.5, 0.5));
                ptrTexCoordindates.Add(new Point(0.5, 0.5));
                geometry.TextureCoordinates = ptrTexCoordindates;

                // Apply the mesh to the geometry model.
                geometry.Freeze();

                _geometry = geometry;
            }
开发者ID:dingxinbei,项目名称:OLdBck,代码行数:55,代码来源:Window1.xaml.cs

示例13: BuildMeshes

        private void BuildMeshes(OptFile opt)
        {
            this.meshes = null;

            if (opt == null)
            {
                return;
            }

            this.meshes = new MeshGeometry3D[opt.Meshes.Count][][][];

            for (int meshIndex = 0; meshIndex < opt.Meshes.Count; meshIndex++)
            {
                var mesh = opt.Meshes[meshIndex];

                var positions = new Point3DCollection(
                    mesh.Vertices
                    .Select(t => new Point3D(-t.Y, -t.X, t.Z)));

                var normals = new Vector3DCollection(
                    mesh.VertexNormals
                    .Select(t => new Vector3D(-t.Y, -t.X, t.Z)));

                var textureCoordinates = new PointCollection(
                    mesh.TextureCoordinates
                    .Select(t => new Point(t.U, t.V)));

                this.meshes[meshIndex] = new MeshGeometry3D[mesh.Lods.Count][][];

                for (int lodIndex = 0; lodIndex < mesh.Lods.Count; lodIndex++)
                {
                    var lod = mesh.Lods[lodIndex];

                    this.meshes[meshIndex][lodIndex] = new MeshGeometry3D[lod.FaceGroups.Count][];

                    for (int faceGroupIndex = 0; faceGroupIndex < lod.FaceGroups.Count; faceGroupIndex++)
                    {
                        var faceGroup = lod.FaceGroups[faceGroupIndex];

                        MeshGeometry3D[] geometries = new MeshGeometry3D[faceGroup.Faces.Count + 1];

                        for (int faceIndex = 0; faceIndex < faceGroup.Faces.Count; faceIndex++)
                        {
                            var face = faceGroup.Faces[faceIndex];

                            MeshGeometry3D geometry = new MeshGeometry3D();
                            int index = 0;

                            Index positionsIndex = face.VerticesIndex;
                            Index normalsIndex = face.VertexNormalsIndex;
                            Index textureCoordinatesIndex = face.TextureCoordinatesIndex;

                            geometry.Positions.Add(positions.ElementAtOrDefault(positionsIndex.A));
                            geometry.Normals.Add(normals.ElementAtOrDefault(normalsIndex.A));
                            geometry.TextureCoordinates.Add(textureCoordinates.ElementAtOrDefault(textureCoordinatesIndex.A));
                            geometry.TriangleIndices.Add(index);
                            index++;

                            geometry.Positions.Add(positions.ElementAtOrDefault(positionsIndex.B));
                            geometry.Normals.Add(normals.ElementAtOrDefault(normalsIndex.B));
                            geometry.TextureCoordinates.Add(textureCoordinates.ElementAtOrDefault(textureCoordinatesIndex.B));
                            geometry.TriangleIndices.Add(index);
                            index++;

                            geometry.Positions.Add(positions.ElementAtOrDefault(positionsIndex.C));
                            geometry.Normals.Add(normals.ElementAtOrDefault(normalsIndex.C));
                            geometry.TextureCoordinates.Add(textureCoordinates.ElementAtOrDefault(textureCoordinatesIndex.C));
                            geometry.TriangleIndices.Add(index);
                            index++;

                            if (positionsIndex.D >= 0)
                            {
                                geometry.TriangleIndices.Add(index - 3);
                                geometry.TriangleIndices.Add(index - 1);

                                geometry.Positions.Add(positions.ElementAtOrDefault(positionsIndex.D));
                                geometry.Normals.Add(normals.ElementAtOrDefault(normalsIndex.D));
                                geometry.TextureCoordinates.Add(textureCoordinates.ElementAtOrDefault(textureCoordinatesIndex.D));
                                geometry.TriangleIndices.Add(index);
                                index++;
                            }

                            geometry.Freeze();
                            geometries[1 + faceIndex] = geometry;
                        }

                        MeshGeometry3D geometryGroup = new MeshGeometry3D();

                        for (int i = 1; i < geometries.Length; i++)
                        {
                            MergeGeometry(geometryGroup, geometries[i]);
                        }

                        geometryGroup.Freeze();
                        geometries[0] = geometryGroup;

                        this.meshes[meshIndex][lodIndex][faceGroupIndex] = geometries;
                    }
                }
            }
//.........这里部分代码省略.........
开发者ID:JeremyAnsel,项目名称:XwaOptEditor,代码行数:101,代码来源:OptCache.cs

示例14: CreateMesh

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

            int angleSteps = 32;
            double minAngle = 0;
            double maxAngle = 2 * Math.PI;
            double angle = (maxAngle - minAngle) / angleSteps;

            int steps = 32;
            double minY = -1.0;
            double maxY = 1.0;
            double dy = (maxY - minY) / steps;

            var mesh = new MeshGeometry3D();

            for (var yi = 0; yi <= steps; yi++)
            {
                var y = minY + (yi * dy);

                for (var ai = 0; ai <= angleSteps; ai++)
                {
                    var ang = ai * angle;

                    mesh.Positions.Add(this.GetPosition(ang, y));
                    mesh.Normals.Add(this.GetNormal(ang, y));
                    mesh.TextureCoordinates.Add(this.GetTextureCoordinate(ang, y));
                }
            }

            for (var yi = 0; yi < steps; yi++)
            {
                for (var ai = 0; ai < angleSteps; ai++)
                {
                    var a1 = ai;
                    var a2 = ai + 1;
                    var y1 = yi * (angleSteps + 1);
                    var y2 = (yi + 1) * (angleSteps + 1);

                    mesh.TriangleIndices.Add(y1 + a1);
                    mesh.TriangleIndices.Add(y2 + a1);
                    mesh.TriangleIndices.Add(y1 + a2);

                    mesh.TriangleIndices.Add(y1 + a2);
                    mesh.TriangleIndices.Add(y2 + a1);
                    mesh.TriangleIndices.Add(y2 + a2);
                }
            }

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

示例15: CircleMesh

        private MeshGeometry3D CircleMesh(Vector3D inpNormal, Point3D startPoint, double radius, Point[] texturePoint)
        {
            try
            {
                double maxTheta = (360 / 180.0) * Math.PI;
                double dt = maxTheta / 32;
                int point1 = 0;
                int point2 = 0;

                Point3D center = startPoint;

                MeshGeometry3D mesh = new MeshGeometry3D();
                mesh.Positions.Add(center);
                mesh.TextureCoordinates.Add(texturePoint[0]);
                mesh.TextureCoordinates.Add(texturePoint[1]);
                mesh.TextureCoordinates.Add(texturePoint[2]);

                if (inpNormal.Y == 1)
                {
                    point1 = 2;
                    point2 = 1;
                }
                else if (inpNormal.Y == -1)
                {
                    point1 = 1;
                    point2 = 2;
                }

                for (int ti = 0; ti <= 360; ti++)
                {
                    double t = ti * dt;

                    if (ti % 3 == 0 && ti > 0)
                    {
                        mesh.TriangleIndices.Add(0);
                        mesh.TriangleIndices.Add(ti + point1);
                        mesh.TriangleIndices.Add(ti + point2);
                        mesh.Normals.Add(inpNormal);
                    }

                    mesh.Positions.Add(GetPositionCirCle(t, radius, startPoint));
                }

                mesh.Freeze();
                return mesh;
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
开发者ID:kse-jp,项目名称:RM-3000,代码行数:51,代码来源:EllipseModel.cs


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