aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/Texture_manager.cs
diff options
context:
space:
mode:
Diffstat (limited to 'Texture_manager.cs')
-rw-r--r--Texture_manager.cs73
1 files changed, 45 insertions, 28 deletions
diff --git a/Texture_manager.cs b/Texture_manager.cs
index 1321358..0d88041 100644
--- a/Texture_manager.cs
+++ b/Texture_manager.cs
@@ -36,26 +36,26 @@ using libsecondlife.AssetSystem;
36using System.IO; 36using System.IO;
37 37
38 38
39namespace Second_server 39namespace OpenSim
40{ 40{
41 /// <summary> 41 /// <summary>
42 /// Description of Texture_manager. 42 /// Description of Texture_manager.
43 /// </summary> 43 /// </summary>
44 public class Texture_manager 44 public class TextureManager
45 { 45 {
46 public Dictionary<libsecondlife.LLUUID,Texture_image> textures; 46 public Dictionary<libsecondlife.LLUUID,TextureImage> textures;
47 public ArrayList requests=new ArrayList(); //should change to a generic 47 public ArrayList requests=new ArrayList(); //should change to a generic
48 public ArrayList uploads=new ArrayList(); 48 public ArrayList uploads=new ArrayList();
49 private Server server; 49 private Server server;
50 50
51 public Texture_manager(Server serve) 51 public TextureManager(Server serve)
52 { 52 {
53 server=serve; 53 server=serve;
54 textures=new Dictionary<libsecondlife.LLUUID,Texture_image> (); 54 textures=new Dictionary<libsecondlife.LLUUID,TextureImage> ();
55 this.initialise(); 55 this.initialise();
56 } 56 }
57 57
58 public void add_request(User_Agent_info user, LLUUID image_id) 58 public void AddRequest(User_Agent_info user, LLUUID image_id)
59 { 59 {
60 60
61 if(!this.textures.ContainsKey(image_id)) 61 if(!this.textures.ContainsKey(image_id))
@@ -66,10 +66,10 @@ namespace Second_server
66 server.SendPacket(im_not,true,user); 66 server.SendPacket(im_not,true,user);
67 return; 67 return;
68 } 68 }
69 Texture_image imag=this.textures[image_id]; 69 TextureImage imag=this.textures[image_id];
70 Texture_request req=new Texture_request(); 70 TextureRequest req=new TextureRequest();
71 req.req_user=user; 71 req.RequestUser=user;
72 req.req_image=image_id; 72 req.RequestImage=image_id;
73 req.image_info=imag; 73 req.image_info=imag;
74 74
75 if(imag.data.LongLength>1000) //should be bigger or smaller? 75 if(imag.data.LongLength>1000) //should be bigger or smaller?
@@ -87,11 +87,11 @@ namespace Second_server
87 87
88 } 88 }
89 89
90 public void add_texture(LLUUID image_id, string name, byte[] data) 90 public void AddTexture(LLUUID image_id, string name, byte[] data)
91 { 91 {
92 92
93 } 93 }
94 public void Do_work(ulong time) 94 public void DoWork(ulong time)
95 { 95 {
96 if(this.requests.Count==0) 96 if(this.requests.Count==0)
97 { 97 {
@@ -109,10 +109,10 @@ namespace Second_server
109 { 109 {
110 num=5; 110 num=5;
111 } 111 }
112 Texture_request req; 112 TextureRequest req;
113 for(int i=0; i<num; i++) 113 for(int i=0; i<num; i++)
114 { 114 {
115 req=(Texture_request)this.requests[i]; 115 req=(TextureRequest)this.requests[i];
116 116
117 if(req.packet_counter==0) 117 if(req.packet_counter==0)
118 { 118 {
@@ -126,9 +126,10 @@ namespace Second_server
126 im.ImageID.Size=(uint)req.image_info.data.Length; 126 im.ImageID.Size=(uint)req.image_info.data.Length;
127 im.ImageData.Data=req.image_info.data; 127 im.ImageData.Data=req.image_info.data;
128 im.ImageID.Codec=2; 128 im.ImageID.Codec=2;
129 server.SendPacket(im,true,req.req_user); 129 server.SendPacket(im,true,req.RequestUser);
130 req.packet_counter++; 130 req.packet_counter++;
131 req.image_info.last_used=time; 131 req.image_info.last_used=time;
132 System.Console.WriteLine("sent texture: "+req.image_info.Full_ID);
132 } 133 }
133 else 134 else
134 { 135 {
@@ -145,7 +146,7 @@ namespace Second_server
145 //remove requests that have been completed 146 //remove requests that have been completed
146 for(int i=0; i<num; i++) 147 for(int i=0; i<num; i++)
147 { 148 {
148 req=(Texture_request)this.requests[i]; 149 req=(TextureRequest)this.requests[i];
149 if(req.packet_counter==req.num_packets) 150 if(req.packet_counter==req.num_packets)
150 { 151 {
151 this.requests.Remove(req); 152 this.requests.Remove(req);
@@ -153,7 +154,7 @@ namespace Second_server
153 } 154 }
154 } 155 }
155 156
156 public void recieve_texture(Packet pack) 157 public void RecieveTexture(Packet pack)
157 { 158 {
158 159
159 } 160 }
@@ -161,15 +162,31 @@ namespace Second_server
161 private void initialise() 162 private void initialise()
162 { 163 {
163 //for now read in our test image 164 //for now read in our test image
164 Texture_image im=new Texture_image(); 165 TextureImage im=new TextureImage();
165 im.filename="testpic2.jp2"; 166 im.filename="testpic2.jp2";
166 im.Full_ID=new LLUUID("00000000-0000-0000-5005-000000000005"); 167 im.Full_ID=new LLUUID("00000000-0000-0000-5005-000000000005");
167 this.load_image(im); 168 this.LoadImage(im);
168 this.textures.Add(im.Full_ID,im); 169 this.textures.Add(im.Full_ID,im);
170
171 im=new TextureImage();
172 im.filename="map_base.jp2";
173 im.Full_ID=new LLUUID("00000000-0000-0000-7007-000000000006");
174 this.LoadImage(im);
175 this.textures.Add(im.Full_ID,im);
176
177 im=new TextureImage();
178 im.filename="map1.jp2";
179 im.Full_ID=new LLUUID("00000000-0000-0000-7009-000000000008");
180 this.LoadImage(im);
181 this.textures.Add(im.Full_ID,im);
182
169 } 183 }
170 private void load_image(Texture_image im) 184 private void LoadImage(TextureImage im)
171 { 185 {
172 string data_path=System.AppDomain.CurrentDomain.BaseDirectory + @"\textures\"; 186 //should request Image from StorageManager
187 //but for now read from file
188
189 string data_path=System.AppDomain.CurrentDomain.BaseDirectory + @"\textures\";
173 string filename=data_path+@im.filename; 190 string filename=data_path+@im.filename;
174 FileInfo fInfo = new FileInfo(filename); 191 FileInfo fInfo = new FileInfo(filename);
175 192
@@ -187,21 +204,21 @@ namespace Second_server
187 204
188 } 205 }
189 206
190 public class Texture_request 207 public class TextureRequest
191 { 208 {
192 public User_Agent_info req_user; 209 public User_Agent_info RequestUser;
193 public LLUUID req_image; 210 public LLUUID RequestImage;
194 public Texture_image image_info; 211 public TextureImage image_info;
195 public long data_pointer=0; 212 public long data_pointer=0;
196 public int num_packets=0; 213 public int num_packets=0;
197 public int packet_counter=0; 214 public int packet_counter=0;
198 215
199 public Texture_request() 216 public TextureRequest()
200 { 217 {
201 218
202 } 219 }
203 } 220 }
204 public class Texture_image 221 public class TextureImage
205 { 222 {
206 public byte[] data; 223 public byte[] data;
207 public LLUUID Full_ID; 224 public LLUUID Full_ID;
@@ -211,7 +228,7 @@ namespace Second_server
211 public ulong last_used; //need to add a tick/time counter and keep record 228 public ulong last_used; //need to add a tick/time counter and keep record
212 // of how often images are requested to unload unused ones. 229 // of how often images are requested to unload unused ones.
213 230
214 public Texture_image() 231 public TextureImage()
215 { 232 {
216 233
217 } 234 }