| 9 |
|
|
| 10 |
namespace IdealistViewer |
namespace IdealistViewer |
| 11 |
{ |
{ |
| 12 |
|
|
| 13 |
|
public delegate void TextureCallback(string texname, SceneNode node); |
| 14 |
public class TextureManager |
public class TextureManager |
| 15 |
{ |
{ |
| 16 |
|
public event TextureCallback OnTextureLoaded; |
| 17 |
|
|
| 18 |
private VideoDriver driver = null; |
private VideoDriver driver = null; |
| 19 |
private string imagefolder = string.Empty; |
private string imagefolder = string.Empty; |
| 20 |
private Dictionary<UUID, Texture> memoryTextures = new Dictionary<UUID, Texture>(); |
private Dictionary<UUID, Texture> memoryTextures = new Dictionary<UUID, Texture>(); |
| 101 |
|
|
| 102 |
} |
} |
| 103 |
|
|
| 104 |
private void applyTexture(Texture tex, SceneNode requestor) |
public void applyTexture(Texture tex, SceneNode requestor) |
| 105 |
{ |
{ |
| 106 |
|
|
| 107 |
requestor.SetMaterialTexture(0, tex); |
requestor.SetMaterialTexture(0, tex); |
| 145 |
//fi.Close(); |
//fi.Close(); |
| 146 |
//fi.Dispose(); |
//fi.Dispose(); |
| 147 |
|
|
|
Texture tex = driver.GetTexture(asset.AssetID.ToString() + ".tga"); |
|
|
|
|
|
lock (memoryTextures) |
|
|
{ |
|
|
if (!memoryTextures.ContainsKey(asset.AssetID)) |
|
|
memoryTextures.Add(asset.AssetID, tex); |
|
| 148 |
|
|
|
} |
|
| 149 |
|
|
| 150 |
List<SceneNode> nodesToUpdate = new List<SceneNode>(); |
List<SceneNode> nodesToUpdate = new List<SceneNode>(); |
| 151 |
lock (ouststandingRequests) |
lock (ouststandingRequests) |
| 164 |
|
|
| 165 |
if (node != null) |
if (node != null) |
| 166 |
{ |
{ |
| 167 |
applyTexture(tex, node); |
if (OnTextureLoaded != null) |
| 168 |
|
{ |
| 169 |
|
OnTextureLoaded(asset.AssetID.ToString() + ".tga", node); |
| 170 |
|
} |
| 171 |
|
|
| 172 |
} |
} |
| 173 |
|
|