Пример #1
0
 /// <summary>
 /// Searches the internal list of materials to find a match to the given name. The match is partial and the name
 /// does not have to be exact. The first found instance will be returned.
 /// </summary>
 /// <param name="partialName">String that should be matched to the name string of the material.</param>
 /// <returns>The first matching observer. If no match is found then an exception will be thrown.</returns>
 public Material GetMaterialByPartialName(string partialName)
 {
     return(Materials.Find(delegate(Material mat)
     {
         return mat.Name.Contains(partialName);
     }));
 }
Пример #2
0
        public void AddMaterial(Material mat)
        {
            Material duplicate = Materials.Find(m => m.ID.Equals(mat.ID));

            if (duplicate != null)
            {
                Console.WriteLine("Material not added. Trying to add mat with duplicate ID.\nConflicting Materials:\nName: {0} ID: {1}\nName: {2} ID: {3}", mat.Name, mat.ID, duplicate.Name, duplicate.ID);
                return;
            }
            Materials.Add(mat);
        }
Пример #3
0
        private vdPolyface AddMeshToEntities(vdEntities entities, MeshData mesh)
        {
            vdPolyface onepolyface = new vdPolyface();

            onepolyface.SetUnRegisterDocument(vDraw.ActiveDocument);
            onepolyface.setDocumentDefaults();

            // 顶点数组输入
            foreach (PointData point in mesh.Vertexes)
            {
                onepolyface.VertexList.Add(point.X * Tools.Ft2MmScale, point.Y * Tools.Ft2MmScale, point.Z * Tools.Ft2MmScale);
            }

            // 面片索引输入
            foreach (TriangleIndexData index in mesh.TriangleIndexes)
            {
                onepolyface.AddFaceItem(index.V1 + 1, index.V2 + 1, index.V3 + 1, index.V1 + 1, -1);
            }

            onepolyface.SmoothAngle = 45;
            onepolyface.Layer       = vDraw.ActiveDocument.Layers.FindName(mesh.MaterialName);
            entities.Add(onepolyface);

            if (ExportSetting.SystemSetting.IsExportTextureFile)
            {
                var material = Materials.Find(m => m.Name == mesh.MaterialName);
                if (material != null && !string.IsNullOrEmpty(material.GetValidMapFile()))
                {
                    var img = vDraw.ActiveDocument.Images.FindName(Path.GetFileNameWithoutExtension(material.GetValidMapFile()));
                    if (img != null)
                    {
                        onepolyface.PenColor.SystemColor   = Color.Gray;
                        onepolyface.PenColor.MaterialImage = img;

                        Matrix mtx = new Matrix();
                        mtx.IdentityMatrix();
                        mtx.ScaleMatrix(0.001, 0.001, 1);
                        onepolyface.PenColor.MaterialMatrix = mtx;
                    }
                }
            }

            onepolyface.Invalidate();
            onepolyface.Update();

            return(onepolyface);
        }