public Mesh() : base() { Diffuse = new Ratio() { X = 1, Y = 1, Z = 1 }; Lighting = true; Vertices = new i3DMLCollection<Vertex>(); TextureResource = new Resource(); TextureResource.ResourceType = ResourceType.Texture; }
/// <summary> /// Downloads the resource. /// </summary> /// <param name="res">The resource</param> public static void Download(Resource res) { if (Resources[res.ResourceType].ContainsKey(res.Url)) { if (Resources[res.ResourceType][res.Url] != null) { res.Data = Resources[res.ResourceType][res.Url]; Downloaded(res); } else { NotDownloaded.Add(res); } return; } Resources[res.ResourceType].Add(res.Url, null); ResourceConverter conv =ResourceConverters[res.ResourceType]; Task download = new Task((obj) => { i3DML.ObjectModel.Resource resource = obj as i3DML.ObjectModel.Resource; while (true) { try { Stream dat = UrlManager.GetStream(resource.Url); object converted = conv(dat); Resources[res.ResourceType][resource.Url] = converted; resource.Data = converted; Downloaded(resource); break; } catch { System.Threading.Thread.Sleep(Timeout); } } }, res); download.Start(); }
public HeightMap() { HeightMapResource = new Resource(); HeightMapResource.ResourceType = ResourceType.HeightMap; HeightMapResource.Downloaded += new EventHandler((o, e) => { Build(); }); }
public Model() { ModelResource = new Resource(); ModelResource.ResourceType = ResourceType.Model; }
private static void Downloaded(Resource r) { r.AlertDownloaded(); List<Resource> rc=NotDownloaded.Where(res => res.Url == r.Url&&res.ResourceType==r.ResourceType).ToList(); foreach(Resource re in rc) { re.Data=r.Data; re.AlertDownloaded(); NotDownloaded.Remove(re); } }