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


C# Mesh.Transform方法代码示例

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


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

示例1: Mesh

            public List<Mesh> Mesh()
            {
                List<Mesh> meshes = new List<Mesh>();
                Mesh tool_mesh = new Mesh();
                tool_mesh.CopyFrom(this.Tool.Geometry);

                for (int m = 0; m < Joints.Count; m++)
                {
                    meshes.Add(this.Joints[m].Mesh());
                }

                Transform o = Transform.PlaneToPlane(Plane.WorldXY, this.Position);
                meshes[0].Transform(o);
                for (int i = 0; i < Joints.Count - 1; i++)
                {
                    for (int j = i; j >= 0; j--)
                    {
                        meshes[i + 1].Transform(Joints[j + 1].Matrix());
                    }
                    meshes[i + 1].Transform(o);

                }

                tool_mesh.Transform(Transform.PlaneToPlane(this.Tool.PlaneRoot, Plane.WorldXY));
                for (int k = this.Joints.Count - 1; k >= 0; --k)
                {
                    tool_mesh.Transform(this.Joints[k].Matrix());
                }
                tool_mesh.Transform(o);

                meshes.Add(tool_mesh);
                return meshes;
            }
开发者ID:tsvilans,项目名称:brick_lib,代码行数:33,代码来源:bRobotBase.cs

示例2: CreateDisplayMesh

        Mesh CreateDisplayMesh()
        {
            var mesh = new Mesh();
            mesh.Append(BaseMesh);

            foreach (var joint in Joints)
                mesh.Append(joint.Mesh);

            mesh.Transform(BasePlane.ToTransform());
            return mesh;
        }
开发者ID:visose,项目名称:Robots,代码行数:11,代码来源:Mechanism.cs

示例3: Mesh2DMinimalBox

 public Mesh Mesh2DMinimalBox(Mesh mesh)
 {
     List<Point3d> x = new List<Point3d>();
     Rhino.Geometry.Collections.MeshTopologyVertexList vs = mesh.TopologyVertices;
     for (int i = 0; i < vs.Count; i++)
     {
         x.Add(new Point3d(vs[i]));
     }
     Grasshopper.Kernel.Geometry.Node2List list = new Grasshopper.Kernel.Geometry.Node2List(x);
     Polyline pl = Grasshopper.Kernel.Geometry.ConvexHull.Solver.ComputeHull(list);
     double t = double.MaxValue;
     Transform xform = new Transform();
     for (int i = 0; i < pl.Count - 1; i++)
     {
         Vector3d Xaxis = pl[i + 1] - pl[i];
         Vector3d Yaxis = Vector3d.CrossProduct(Xaxis, Vector3d.ZAxis);
         Plane p = new Plane(pl[i], Xaxis, Yaxis);
         Polyline pl2 = new Polyline(pl);
         pl2.Transform(Transform.PlaneToPlane(p, Plane.WorldXY));
         Rhino.Geometry.BoundingBox box = pl2.BoundingBox;
         double area = (box.Max.X - box.Min.X) * (box.Max.Y - box.Min.Y);
         if (area < t) { t = area; xform = Transform.PlaneToPlane(p, Plane.WorldXY); }
     }
     mesh.Transform(xform);
     return mesh;
 }
开发者ID:panhao4812,项目名称:MeshClassLibrary,代码行数:26,代码来源:MeshUnfold.cs

示例4: Mesh3DMinimalBox

 public Mesh Mesh3DMinimalBox(Mesh mesh)
 {
     List<Point3d> x = new List<Point3d>();
     Rhino.Geometry.Collections.MeshTopologyVertexList vs = mesh.TopologyVertices;
     for (int i = 0; i < vs.Count; i++)
     {
         x.Add(new Point3d(vs[i]));
     }
     Mesh mesh2 = ch.ConvexHull(x);
     mesh2.Faces.ConvertQuadsToTriangles();
     double t = double.MaxValue;
     Transform xform = new Transform();
     for (int i = 0; i < mesh2.Faces.Count - 1; i++)
     {
         Point3d p1 = new Point3d(mesh2.Vertices[mesh2.Faces[i].A]);
         Point3d p2 = new Point3d(mesh2.Vertices[mesh2.Faces[i].B]);
         Point3d p3 = new Point3d(mesh2.Vertices[mesh2.Faces[i].C]);
         Plane p = new Plane(p1, p2, p3);
         Mesh mesh3 = new Mesh(); mesh3.Append(mesh);
         mesh3.Transform(Transform.PlaneToPlane(p, Plane.WorldXY));
         Rhino.Geometry.BoundingBox box = mesh3.GetBoundingBox(true);
         double area = (box.Max.X - box.Min.X) * (box.Max.Y - box.Min.Y) * (box.Max.Z - box.Min.Z);
         if (area < t) { t = area; xform = Transform.PlaneToPlane(p, Plane.WorldXY); }
     }
     mesh.Transform(xform);
     return mesh;
 }
开发者ID:panhao4812,项目名称:MeshClassLibrary,代码行数:27,代码来源:MeshUnfold.cs

示例5: Mesh2Topo

        public string Mesh2Topo(ref Mesh mesh, out Mesh mesh2, double length, double width, double mX, double mY, double maxX, double maxY)
        {
            //
            //construct a single bitmap but the edge is not fit well.The Vt has not been tested yet.
            //
            Rhino.Geometry.Collections.MeshTopologyEdgeList el = mesh.TopologyEdges;
            Rhino.Geometry.Collections.MeshTopologyVertexList vs = mesh.TopologyVertices;
            string str = "";
            List<int> firstLoop1;
            str += FirstEdge(mesh, out firstLoop1);
            double column = (double)vs.Count / (double)firstLoop1.Count;
            int Column = (int)column;
            if (column - Column != 0) str += "Points Count error,Please confirm the topo to be quad style";
            int[] energy = new int[vs.Count];
            List<int> indexPt = new List<int>();
            indexPt.AddRange(firstLoop1);
            for (int i = 0; i < firstLoop1.Count; i++) { energy[firstLoop1[i]] = 1; }
            for (int i = 0; i < Column - 1; i++)
            {
                bool sign = true;
                for (int j = 0; j < firstLoop1.Count; j++)
                {
                    int[] index = vs.ConnectedTopologyVertices(firstLoop1[j]);
                    for (int k = 0; k < index.Length; k++)
                    {
                        energy[index[k]]++;
                    }
                }
                for (int j = 0; j < firstLoop1.Count; j++)
                {
                    int[] index = vs.ConnectedTopologyVertices(firstLoop1[j]);
                    for (int k = 0; k < index.Length; k++)
                    {
                        if (energy[index[k]] == 1)
                        {
                            firstLoop1[j] = index[k]; sign = false; break;
                        }
                    }
                }
                if (sign) { str += " Loop false,Not quad topo Or To the end"; }
                else { indexPt.AddRange(firstLoop1); }
            }
            ///*******
            double MX = (double)Column - 1;
            double MY = (double)firstLoop1.Count - 1;
            List<Point3d> output1 = new List<Point3d>();
            List<Point3d> output2 = new List<Point3d>();
            int iCount = 0;
            Color[] cl = new Color[mesh.Vertices.Count];

            for (int i = 0; i < Column; i++)
            {
                for (int j = 0; j < firstLoop1.Count; j++)
                {
                    output1.Add(vs[indexPt[iCount]]);
                    int indexV = vs.MeshVertexIndices(indexPt[iCount])[0];
                    cl[iCount] = mesh.VertexColors[indexV];
                    iCount++;
                    Point3d pt = new Point3d(length / MX * i, width / MY * (double)j, 0);
                    output2.Add(pt);
                }
            }
            mesh2 = mc.MeshFromPoints(output2, firstLoop1.Count, Column);
            mesh = mc.MeshFromPoints(output1, firstLoop1.Count, Column);
            mesh2.Transform(Transform.Translation(mX, mY, 0));
            mesh.VertexColors.Clear();
            mesh.VertexColors.AppendColors(cl);
            mesh2.VertexColors.Clear();
            mesh2.VertexColors.AppendColors(cl);
            iCount = 0;
            //Print(mesh.TextureCoordinates.Count.ToString());//unit=100
            for (double i = 0; i < Column; i++)
            {
                for (double j = 0; j < firstLoop1.Count; j++)
                {
                    //not tested
                    mesh.TextureCoordinates.Add(new Point2f((Single)((i * length / MX + mX) / maxX),
                      (Single)(j * width / MY + mY) / maxY));
                    mesh2.TextureCoordinates.Add(new Point2f((Single)((i * length / MX + mX) / maxX),
                      (Single)(j * width / MY + mY) / maxY));
                    iCount++;
                }
            }
            return str;
        }
开发者ID:panhao4812,项目名称:MeshClassLibrary,代码行数:85,代码来源:MeshConvert.cs


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