Exemple #1
0
        public TriMesh AddSelectionEdge(TriMesh mesh, int index)
        {
            List <TriMesh> sel = new List <TriMesh>();

            for (int i = 0; i < mesh.Edges.Count; i++)
            {
                if (mesh.Edges[i].Traits.SelectedFlag == index)
                {
                    TriMesh selV = TriMeshIO.FromObjFile(ConfigShape.Instance.EdgeFile);
                    TriMeshUtil.ScaleToUnit(selV, 1);
                    TriMeshUtil.ScaleToUnit(selV, ConfigShape.Instance.Scale);
                    Vector3D direction = mesh.Edges[i].Vertex1.Traits.Position - mesh.Edges[i].Vertex0.Traits.Position;
                    Vector3D loc       = (mesh.Edges[i].Vertex1.Traits.Position + mesh.Edges[i].Vertex0.Traits.Position) / 2;

                    Matrix4D scale = TriMeshUtil.ComputeMatrixScale(direction.Length() / ConfigShape.Instance.Scale, 1d, 1d);


                    //  TriMeshUtil.TransformationRotation(selV, direction);

                    TriMeshUtil.TransformationScale(selV, scale);
                    TriMeshUtil.TransformRoatationV(selV, direction, Vector3D.UnitX);
                    //TriMeshUtil.TransformRotationX(selV, direction.x);
                    //TriMeshUtil.TransformRotationY(selV, direction.y);
                    //TriMeshUtil.TransformRotationZ(selV, direction.z);
                    TriMeshUtil.TransformationMove(selV, loc);
                    sel.Add(selV);
                }
            }

            TriMesh result = TriMeshUtil.Combine(sel);

            result.FileName = Path.GetFileNameWithoutExtension(mesh.FileName) + "-E-" + index.ToString();

            TriMeshUtil.SetUpVertexNormal(result, EnumNormal.AreaWeight);
            return(result);
        }