| 81 |
if (ouststandingRequests.ContainsKey(assetID)) |
if (ouststandingRequests.ContainsKey(assetID)) |
| 82 |
{ |
{ |
| 83 |
ouststandingRequests[assetID].Add(requestor); |
ouststandingRequests[assetID].Add(requestor); |
| 84 |
|
m_log.Debug("[TEXTURE]: Added to OutstandingRequest receivers"); |
| 85 |
return; |
return; |
| 86 |
} |
} |
| 87 |
else |
else |
| 89 |
List<SceneNode> requestors = new List<SceneNode>(); |
List<SceneNode> requestors = new List<SceneNode>(); |
| 90 |
requestors.Add(requestor); |
requestors.Add(requestor); |
| 91 |
ouststandingRequests.Add(assetID,requestors); |
ouststandingRequests.Add(assetID,requestors); |
| 92 |
|
m_log.Debug("[TEXTURE]: created new OutstandingRequest receivers"); |
| 93 |
} |
} |
| 94 |
} |
} |
| 95 |
m_log.DebugFormat("[TEXTURE]: Requesting TextureID: {0} from simulator", assetID); |
m_log.DebugFormat("[TEXTURE]: Requesting TextureID: {0} from simulator", assetID); |
| 107 |
public void imageReceivedCallback(AssetTexture asset) |
public void imageReceivedCallback(AssetTexture asset) |
| 108 |
{ |
{ |
| 109 |
if (asset == null) |
if (asset == null) |
| 110 |
|
{ |
| 111 |
|
m_log.Debug("[TEXTURE]: GotLIBOMV callback but asset was null"); |
| 112 |
|
lock (ouststandingRequests) |
| 113 |
|
{ |
| 114 |
|
} |
| 115 |
return; |
return; |
| 116 |
|
} |
| 117 |
m_log.Debug("[TEXTURE]: GotLIBOMV callback for asset" + asset.AssetID); |
m_log.Debug("[TEXTURE]: GotLIBOMV callback for asset" + asset.AssetID); |
| 118 |
bool result = false; |
bool result = false; |
| 119 |
|
|
| 123 |
} |
} |
| 124 |
catch (Exception) |
catch (Exception) |
| 125 |
{ |
{ |
| 126 |
|
m_log.Debug("[TEXTURE]: Failed to decode asset " + asset.AssetID); |
| 127 |
} |
} |
| 128 |
if (result) |
if (result) |
| 129 |
{ |
{ |
| 132 |
|
|
| 133 |
string texturepath = System.IO.Path.Combine(texturefolderpath,asset.AssetID.ToString() + ".tga"); |
string texturepath = System.IO.Path.Combine(texturefolderpath,asset.AssetID.ToString() + ".tga"); |
| 134 |
byte[] imgdata = asset.Image.ExportTGA(); |
byte[] imgdata = asset.Image.ExportTGA(); |
| 135 |
BinaryWriter bw = new BinaryWriter(File.Open(texturepath, FileMode.Create)); |
FileStream fi = (File.Open(texturepath, FileMode.Create)); |
| 136 |
|
BinaryWriter bw = new BinaryWriter(fi); |
| 137 |
bw.Write(imgdata); |
bw.Write(imgdata); |
| 138 |
bw.Flush(); |
bw.Flush(); |
| 139 |
bw.Close(); |
bw.Close(); |
| 140 |
|
//fi.Flush(); |
| 141 |
|
//fi.Close(); |
| 142 |
|
//fi.Dispose(); |
| 143 |
|
|
| 144 |
Texture tex = driver.GetTexture(texturepath); |
Texture tex = driver.GetTexture(asset.AssetID.ToString() + ".tga"); |
| 145 |
|
|
| 146 |
lock (memoryTextures) |
lock (memoryTextures) |
| 147 |
{ |
{ |
| 149 |
memoryTextures.Add(asset.AssetID, tex); |
memoryTextures.Add(asset.AssetID, tex); |
| 150 |
|
|
| 151 |
} |
} |
| 152 |
|
|
| 153 |
List<SceneNode> nodesToUpdate = new List<SceneNode>(); |
List<SceneNode> nodesToUpdate = new List<SceneNode>(); |
| 154 |
lock (ouststandingRequests) |
lock (ouststandingRequests) |
| 155 |
{ |
{ |
| 156 |
if (ouststandingRequests.ContainsKey(asset.AssetID)) |
if (ouststandingRequests.ContainsKey(asset.AssetID)) |
| 157 |
{ |
{ |
| 158 |
nodesToUpdate = ouststandingRequests[asset.AssetID]; |
nodesToUpdate = ouststandingRequests[asset.AssetID]; |
| 159 |
|
ouststandingRequests.Remove(asset.AssetID); |
| 160 |
} |
} |
| 161 |
} |
} |
| 162 |
lock (nodesToUpdate) |
lock (nodesToUpdate) |