Ejemplo n.º 1
0
        public void InitializeMaterials(bool has_mtl)
        {
            if (!has_mtl)
            {
                List <string> names = GetMaterialNames();
                foreach (var name in names)
                {
                    Materials.Add(new MaterialInfo(name, true));
                }
                return;
            }
            int i = 3; // ID 0 is Default, ID 1 is Local Map and ID 2 is Global Map

            foreach (var mat in mtl_data.Materials)
            {
                MaterialInfo temp = new MaterialInfo(mat.Name);
                try
                {
                    Bitmap bitmap = new Bitmap(new MemoryStream(File.ReadAllBytes(base_path + "\\" + mat.DiffuseMapPath)));
                    temp.Texture     = bitmap;
                    temp.OpenGLTexID = i;
                    temp.UpdateTex();
                    temp.UseTexture = true;
                    i++;
                }
                catch
                {
                }
                temp.DiffuseColor = mat.DiffuseColor;
                temp.AmbientColor = mat.AmbientColor;
                temp.Opacity      = mat.Alpha;
                Materials.Add(temp);
            }
        }