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

            for (int i = 0; i < mesh.Vertices.Count; i++)
            {
                if (mesh.Vertices[i].Traits.SelectedFlag == index)
                {
                    TriMesh selV = TriMeshIO.FromObjFile(ConfigShape.Instance.VertexFile);
                    for (int j = 0; j < selV.Vertices.Count; j++)
                    {
                        selV.Vertices[j].Traits.SelectedFlag = (byte)index;
                    }
                    TriMeshUtil.ScaleToUnit(selV, ConfigShape.Instance.Scale);
                    TriMeshUtil.TransformationMove(selV, mesh.Vertices[i].Traits.Position);
                    sel.Add(selV);
                }
            }

            TriMesh result = TriMeshUtil.Combine(sel);

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

            TriMeshUtil.SetUpVertexNormal(result, EnumNormal.AreaWeight);
            return(result);
        }
Exemple #2
0
        public TriMesh CreateSelectionVertex(TriMesh mesh)
        {
            List <TriMesh> meshes = AddSelectionVertex(mesh);

            if (!ConfigShape.Instance.SelectionOnly)
            {
                meshes.Add(mesh);
            }
            TriMesh result = TriMeshUtil.Combine(meshes);

            TriMeshUtil.SetUpVertexNormal(result, EnumNormal.AreaWeight);

            return(result);
        }
Exemple #3
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);
        }