aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/src/world
diff options
context:
space:
mode:
authorgareth2007-03-22 10:11:15 +0000
committergareth2007-03-22 10:11:15 +0000
commit7daa3955bc3a1918e40962851f9e8d38597a245e (patch)
treebee3e1372a7eed0c1b220a8a49f7bee7d29a6b91 /src/world
parentLoad XML for neighbourinfo from grid (diff)
downloadopensim-SC-7daa3955bc3a1918e40962851f9e8d38597a245e.zip
opensim-SC-7daa3955bc3a1918e40962851f9e8d38597a245e.tar.gz
opensim-SC-7daa3955bc3a1918e40962851f9e8d38597a245e.tar.bz2
opensim-SC-7daa3955bc3a1918e40962851f9e8d38597a245e.tar.xz
brought zircon branch into trunk
Diffstat (limited to 'src/world')
-rw-r--r--src/world/Avatar.cs487
-rw-r--r--src/world/Entity.cs67
-rw-r--r--src/world/Primitive.cs429
-rw-r--r--src/world/ScriptEngine.cs18
-rw-r--r--src/world/SurfacePatch.cs22
-rw-r--r--src/world/World.cs208
-rw-r--r--src/world/scripting/IScript.cs16
7 files changed, 0 insertions, 1247 deletions
diff --git a/src/world/Avatar.cs b/src/world/Avatar.cs
deleted file mode 100644
index facfeee..0000000
--- a/src/world/Avatar.cs
+++ /dev/null
@@ -1,487 +0,0 @@
1using System;
2using System.Collections.Generic;
3using System.IO;
4using System.Text;
5using libsecondlife;
6using libsecondlife.Packets;
7using PhysicsSystem;
8using Axiom.MathLib;
9
10namespace OpenSim.world
11{
12 public class Avatar : Entity
13 {
14 public static bool PhysicsEngineFlying;
15 public string firstname;
16 public string lastname;
17 public OpenSimClient ControllingClient;
18 private PhysicsActor _physActor;
19 private static libsecondlife.Packets.ObjectUpdatePacket.ObjectDataBlock AvatarTemplate;
20 private bool updateflag;
21 private byte movementflag;
22 private List<NewForce> forcesList = new List<NewForce>();
23 private short _updateCount;
24 private Axiom.MathLib.Quaternion bodyRot;
25
26 public Avatar(OpenSimClient TheClient) {
27 ServerConsole.MainConsole.Instance.WriteLine("Avatar.cs - Loading details from grid (DUMMY)");
28 ControllingClient=TheClient;
29 position = new LLVector3(100.0f,100.0f,30.0f);
30 position.Z = OpenSim_Main.local_world.LandMap[(int)position.Y * 256 + (int)position.X]+1;
31 }
32
33 public PhysicsActor PhysActor
34 {
35 set
36 {
37 this._physActor = value;
38 }
39 }
40 public override void addForces()
41 {
42 lock(this.forcesList)
43 {
44 if(this.forcesList.Count>0)
45 {
46 for(int i=0 ; i < this.forcesList.Count; i++)
47 {
48 NewForce force = this.forcesList[i];
49 PhysicsVector phyVector = new PhysicsVector(force.X, force.Y, force.Z);
50 this._physActor.Velocity = phyVector;
51 this.updateflag = true;
52 this.velocity = new LLVector3(force.X, force.Y, force.Z); //shouldn't really be doing this
53 // but as we are setting the velocity (rather than using real forces) at the moment it is okay.
54 }
55 for(int i=0 ; i < this.forcesList.Count; i++)
56 {
57 this.forcesList.RemoveAt(0);
58 }
59 }
60 }
61 }
62
63 public override void update()
64 {
65
66 if(this.updateflag)
67 {
68 //need to send movement info
69 //so create the improvedterseobjectupdate packet
70 //use CreateTerseBlock()
71 ImprovedTerseObjectUpdatePacket.ObjectDataBlock terseBlock = CreateTerseBlock();
72 ImprovedTerseObjectUpdatePacket terse = new ImprovedTerseObjectUpdatePacket();
73 terse.RegionData.RegionHandle = OpenSim_Main.cfg.RegionHandle; // FIXME
74 terse.RegionData.TimeDilation = 64096;
75 terse.ObjectData = new ImprovedTerseObjectUpdatePacket.ObjectDataBlock[1];
76 terse.ObjectData[0] = terseBlock;
77 foreach(OpenSimClient client in OpenSim_Main.sim.ClientThreads.Values) {
78 client.OutPacket(terse);
79 }
80
81 updateflag =false;
82 //this._updateCount = 0;
83 }
84 else
85 {
86 //if((movementflag & 1) !=0)
87 //{
88 _updateCount++;
89 if(( (!PhysicsEngineFlying) && (_updateCount>3)) || (_updateCount>0))
90 {
91 //It has been a while since last update was sent so lets send one.
92 ImprovedTerseObjectUpdatePacket.ObjectDataBlock terseBlock = CreateTerseBlock();
93 ImprovedTerseObjectUpdatePacket terse = new ImprovedTerseObjectUpdatePacket();
94 terse.RegionData.RegionHandle = OpenSim_Main.cfg.RegionHandle; // FIXME
95 terse.RegionData.TimeDilation = 64096;
96 terse.ObjectData = new ImprovedTerseObjectUpdatePacket.ObjectDataBlock[1];
97 terse.ObjectData[0] = terseBlock;
98 foreach(OpenSimClient client in OpenSim_Main.sim.ClientThreads.Values) {
99 client.OutPacket(terse);
100 }
101 _updateCount = 0;
102 }
103 //}
104 }
105 }
106
107 public static void SetupTemplate(string name)
108 {
109 int i = 0;
110 FileInfo fInfo = new FileInfo(name);
111 long numBytes = fInfo.Length;
112 FileStream fStream = new FileStream(name, FileMode.Open, FileAccess.Read);
113 BinaryReader br = new BinaryReader(fStream);
114 byte [] data1 = br.ReadBytes((int)numBytes);
115 br.Close();
116 fStream.Close();
117
118 libsecondlife.Packets.ObjectUpdatePacket.ObjectDataBlock objdata = new libsecondlife.Packets.ObjectUpdatePacket.ObjectDataBlock(data1, ref i);
119
120 System.Text.Encoding enc = System.Text.Encoding.ASCII;
121 libsecondlife.LLVector3 pos = new LLVector3(objdata.ObjectData, 16);
122 pos.X = 100f;
123 objdata.ID = 8880000;
124 objdata.NameValue = enc.GetBytes("FirstName STRING RW SV Test \nLastName STRING RW SV User \0");
125 libsecondlife.LLVector3 pos2 = new LLVector3(100f,100f,23f);
126 //objdata.FullID=user.AgentID;
127 byte[] pb = pos.GetBytes();
128 Array.Copy(pb, 0, objdata.ObjectData, 16, pb.Length);
129
130 Avatar.AvatarTemplate = objdata;
131 }
132
133 public void CompleteMovement(World RegionInfo) {
134 ServerConsole.MainConsole.Instance.WriteLine("Avatar.cs:CompleteMovement() - Constructing AgentMovementComplete packet");
135 AgentMovementCompletePacket mov = new AgentMovementCompletePacket();
136 mov.AgentData.SessionID = this.ControllingClient.SessionID;
137 mov.AgentData.AgentID = this.ControllingClient.AgentID;
138 mov.Data.RegionHandle = OpenSim_Main.cfg.RegionHandle;
139 // TODO - dynamicalise this stuff
140 mov.Data.Timestamp = 1172750370;
141 mov.Data.Position = new LLVector3(100f, 100f, 23f);
142 mov.Data.LookAt = new LLVector3(0.99f, 0.042f, 0);
143
144 ControllingClient.OutPacket(mov);
145 }
146
147 public void SendInitialPosition() {
148
149 System.Text.Encoding _enc = System.Text.Encoding.ASCII;
150 //send a objectupdate packet with information about the clients avatar
151 ObjectUpdatePacket objupdate = new ObjectUpdatePacket();
152 objupdate.RegionData.RegionHandle = OpenSim_Main.cfg.RegionHandle;
153 objupdate.RegionData.TimeDilation = 64096;
154 objupdate.ObjectData = new libsecondlife.Packets.ObjectUpdatePacket.ObjectDataBlock[1];
155
156 objupdate.ObjectData[0] = AvatarTemplate;
157 //give this avatar object a local id and assign the user a name
158 objupdate.ObjectData[0].ID = this.localid;
159 objupdate.ObjectData[0].FullID = ControllingClient.AgentID;
160 objupdate.ObjectData[0].NameValue = _enc.GetBytes("FirstName STRING RW SV " + firstname + "\nLastName STRING RW SV " + lastname + " \0");
161
162 libsecondlife.LLVector3 pos2 = new LLVector3((float)this.position.X, (float)this.position.Y, (float)this.position.Z);
163
164 byte[] pb = pos2.GetBytes();
165
166 Array.Copy(pb, 0, objupdate.ObjectData[0].ObjectData, 16, pb.Length);
167 OpenSim_Main.local_world._localNumber++;
168
169 foreach(OpenSimClient client in OpenSim_Main.sim.ClientThreads.Values)
170 {
171 client.OutPacket(objupdate);
172 if(client.AgentID != ControllingClient.AgentID)
173 {
174 SendAppearanceToOtherAgent(client);
175 }
176 }
177 //this.ControllingClient.OutPacket(objupdate);
178 }
179
180 public void SendInitialAppearance() {
181 AgentWearablesUpdatePacket aw = new AgentWearablesUpdatePacket();
182 aw.AgentData.AgentID = this.ControllingClient.AgentID;
183 aw.AgentData.SerialNum = 0;
184 aw.AgentData.SessionID = ControllingClient.SessionID;
185
186 aw.WearableData = new AgentWearablesUpdatePacket.WearableDataBlock[13];
187 AgentWearablesUpdatePacket.WearableDataBlock awb = new AgentWearablesUpdatePacket.WearableDataBlock();
188 awb.WearableType = (byte)0;
189 awb.AssetID = new LLUUID("66c41e39-38f9-f75a-024e-585989bfab73");
190 awb.ItemID = LLUUID.Random();
191 aw.WearableData[0] = awb;
192
193 for(int i=1; i<13; i++)
194 {
195 awb = new AgentWearablesUpdatePacket.WearableDataBlock();
196 awb.WearableType = (byte)i;
197 awb.AssetID = new LLUUID("00000000-0000-0000-0000-000000000000");
198 awb.ItemID = new LLUUID("00000000-0000-0000-0000-000000000000");
199 aw.WearableData[i] = awb;
200 }
201
202 ControllingClient.OutPacket(aw);
203 }
204
205 public ObjectUpdatePacket CreateUpdatePacket()
206 {
207 System.Text.Encoding _enc = System.Text.Encoding.ASCII;
208 //send a objectupdate packet with information about the clients avatar
209 ObjectUpdatePacket objupdate = new ObjectUpdatePacket();
210 objupdate.RegionData.RegionHandle = OpenSim_Main.cfg.RegionHandle;
211 objupdate.RegionData.TimeDilation = 64096;
212 objupdate.ObjectData = new libsecondlife.Packets.ObjectUpdatePacket.ObjectDataBlock[1];
213
214 objupdate.ObjectData[0] = AvatarTemplate;
215 //give this avatar object a local id and assign the user a name
216 objupdate.ObjectData[0].ID = this.localid;
217 objupdate.ObjectData[0].FullID = ControllingClient.AgentID;
218 objupdate.ObjectData[0].NameValue = _enc.GetBytes("FirstName STRING RW SV " + firstname + "\nLastName STRING RW SV " + lastname + " \0");
219
220 libsecondlife.LLVector3 pos2 = new LLVector3((float)this._physActor.Position.X, (float)this._physActor.Position.Y, (float)this._physActor.Position.Z);
221
222 byte[] pb = pos2.GetBytes();
223
224 Array.Copy(pb, 0, objupdate.ObjectData[0].ObjectData, 16, pb.Length);
225 return objupdate;
226 }
227
228 public void SendAppearanceToOtherAgent(OpenSimClient userInfo)
229 {
230 AvatarAppearancePacket avp = new AvatarAppearancePacket();
231
232
233 avp.VisualParam = new AvatarAppearancePacket.VisualParamBlock[218];
234 //avp.ObjectData.TextureEntry=this.avatar_template.TextureEntry;// br.ReadBytes((int)numBytes);
235
236 LLObject.TextureEntry ntex = new LLObject.TextureEntry(new LLUUID("00000000-0000-0000-0000-000000000005"));
237 avp.ObjectData.TextureEntry = ntex.ToBytes();
238
239 AvatarAppearancePacket.VisualParamBlock avblock = null;
240 for(int i = 0; i < 218; i++)
241 {
242 avblock = new AvatarAppearancePacket.VisualParamBlock();
243 avblock.ParamValue = (byte)100;
244 avp.VisualParam[i] = avblock;
245 }
246
247 avp.Sender.IsTrial = false;
248 avp.Sender.ID = ControllingClient.AgentID;
249 userInfo.OutPacket(avp);
250
251 }
252
253 public void HandleUpdate(AgentUpdatePacket pack) {
254 if(((uint)pack.AgentData.ControlFlags & (uint)MainAvatar.AgentUpdateFlags.AGENT_CONTROL_FLY) !=0)
255 {
256 this._physActor.Flying = true;
257 }
258 else
259 {
260 this._physActor.Flying = false;
261 }
262 if(((uint)pack.AgentData.ControlFlags & (uint)MainAvatar.AgentUpdateFlags.AGENT_CONTROL_AT_POS) !=0) {
263 Axiom.MathLib.Quaternion q = new Axiom.MathLib.Quaternion(pack.AgentData.BodyRotation.W, pack.AgentData.BodyRotation.X, pack.AgentData.BodyRotation.Y, pack.AgentData.BodyRotation.Z);
264 if(((movementflag & 1) ==0) || (q!= this.bodyRot))
265 {
266 //we should add a new force to the list
267 // but for now we will deal with velocities
268 NewForce newVelocity = new NewForce();
269 Axiom.MathLib.Vector3 v3 = new Axiom.MathLib.Vector3(1, 0, 0);
270 Axiom.MathLib.Vector3 direc = q * v3;
271 direc.Normalize();
272
273 //work out velocity for sim physics system
274 direc = direc * ((0.03f) * 128f);
275 if(this._physActor.Flying)
276 direc *=2;
277
278 newVelocity.X = direc.x;
279 newVelocity.Y = direc.y;
280 newVelocity.Z = direc.z;
281 this.forcesList.Add(newVelocity);
282 movementflag = 1;
283 this.bodyRot = q;
284 }
285 }
286 else if((((uint)pack.AgentData.ControlFlags & (uint)MainAvatar.AgentUpdateFlags.AGENT_CONTROL_UP_POS) !=0) &&(PhysicsEngineFlying)) {
287 if(((movementflag & 2) ==0) && this._physActor.Flying)
288 {
289 //we should add a new force to the list
290 // but for now we will deal with velocities
291 NewForce newVelocity = new NewForce();
292 Axiom.MathLib.Vector3 v3 = new Axiom.MathLib.Vector3(0, 0, 1);
293 Axiom.MathLib.Vector3 direc = v3;
294 direc.Normalize();
295
296 //work out velocity for sim physics system
297 direc = direc * ((0.03f) * 128f *2);
298 newVelocity.X = direc.x;
299 newVelocity.Y = direc.y;
300 newVelocity.Z = direc.z;
301 this.forcesList.Add(newVelocity);
302 movementflag = 2;
303 }
304 }
305 else if((((uint)pack.AgentData.ControlFlags & (uint)MainAvatar.AgentUpdateFlags.AGENT_CONTROL_UP_NEG) !=0) && (PhysicsEngineFlying)) {
306 if(((movementflag & 4) ==0) && this._physActor.Flying)
307 {
308 //we should add a new force to the list
309 // but for now we will deal with velocities
310 NewForce newVelocity = new NewForce();
311 Axiom.MathLib.Vector3 v3 = new Axiom.MathLib.Vector3(0, 0, -1);
312 //Axiom.MathLib.Quaternion q = new Axiom.MathLib.Quaternion(pack.AgentData.BodyRotation.W, pack.AgentData.BodyRotation.X, pack.AgentData.BodyRotation.Y, pack.AgentData.BodyRotation.Z);
313 Axiom.MathLib.Vector3 direc = v3;
314 direc.Normalize();
315
316 //work out velocity for sim physics system
317 direc = direc * ((0.03f) * 128f *2);
318 newVelocity.X = direc.x;
319 newVelocity.Y = direc.y;
320 newVelocity.Z = direc.z;
321 this.forcesList.Add(newVelocity);
322 movementflag = 4;
323 }
324 }
325 else if(((uint)pack.AgentData.ControlFlags & (uint)MainAvatar.AgentUpdateFlags.AGENT_CONTROL_AT_NEG) !=0) {
326 Axiom.MathLib.Quaternion q = new Axiom.MathLib.Quaternion(pack.AgentData.BodyRotation.W, pack.AgentData.BodyRotation.X, pack.AgentData.BodyRotation.Y, pack.AgentData.BodyRotation.Z);
327 if(((movementflag & 8) ==0) || (q!= this.bodyRot))
328 {
329 //we should add a new force to the list
330 // but for now we will deal with velocities
331 NewForce newVelocity = new NewForce();
332 Axiom.MathLib.Vector3 v3 = new Axiom.MathLib.Vector3(-1, 0, 0);
333 Axiom.MathLib.Vector3 direc = q * v3;
334 direc.Normalize();
335
336 //work out velocity for sim physics system
337 direc = direc * ((0.03f) * 128f);
338 if(this._physActor.Flying)
339 direc *=2;
340
341 newVelocity.X = direc.x;
342 newVelocity.Y = direc.y;
343 newVelocity.Z = direc.z;
344 this.forcesList.Add(newVelocity);
345 movementflag = 8;
346 this.bodyRot = q;
347 }
348 }
349 else
350 {
351 if((movementflag) !=0)
352 {
353 NewForce newVelocity = new NewForce();
354 newVelocity.X = 0;
355 newVelocity.Y = 0;
356 newVelocity.Z = 0;
357 this.forcesList.Add(newVelocity);
358 movementflag = 0;
359 }
360 }
361 }
362
363 //should be moved somewhere else
364 public void SendRegionHandshake(World RegionInfo) {
365 ServerConsole.MainConsole.Instance.WriteLine("Avatar.cs:SendRegionHandshake() - Creating empty RegionHandshake packet");
366 System.Text.Encoding _enc = System.Text.Encoding.ASCII;
367 RegionHandshakePacket handshake = new RegionHandshakePacket();
368
369 ServerConsole.MainConsole.Instance.WriteLine("Avatar.cs:SendRegionhandshake() - Filling in RegionHandshake details");
370 handshake.RegionInfo.BillableFactor = 0;
371 handshake.RegionInfo.IsEstateManager = false;
372 handshake.RegionInfo.TerrainHeightRange00 = 60;
373 handshake.RegionInfo.TerrainHeightRange01 = 60;
374 handshake.RegionInfo.TerrainHeightRange10 = 60;
375 handshake.RegionInfo.TerrainHeightRange11 = 60;
376 handshake.RegionInfo.TerrainStartHeight00 = 10;
377 handshake.RegionInfo.TerrainStartHeight01 = 10;
378 handshake.RegionInfo.TerrainStartHeight10 = 10;
379 handshake.RegionInfo.TerrainStartHeight11 = 10;
380 handshake.RegionInfo.SimAccess = 13;
381 handshake.RegionInfo.WaterHeight = 20;
382 handshake.RegionInfo.RegionFlags = 72458694;
383 handshake.RegionInfo.SimName = _enc.GetBytes(OpenSim_Main.cfg.RegionName + "\0");
384 handshake.RegionInfo.SimOwner = new LLUUID("00000000-0000-0000-0000-000000000000");
385 handshake.RegionInfo.TerrainBase0 = new LLUUID("b8d3965a-ad78-bf43-699b-bff8eca6c975");
386 handshake.RegionInfo.TerrainBase1 = new LLUUID("abb783e6-3e93-26c0-248a-247666855da3");
387 handshake.RegionInfo.TerrainBase2 = new LLUUID("179cdabd-398a-9b6b-1391-4dc333ba321f");
388 handshake.RegionInfo.TerrainBase3 = new LLUUID("beb169c7-11ea-fff2-efe5-0f24dc881df2");
389 handshake.RegionInfo.TerrainDetail0 = new LLUUID("00000000-0000-0000-0000-000000000000");
390 handshake.RegionInfo.TerrainDetail1 = new LLUUID("00000000-0000-0000-0000-000000000000");
391 handshake.RegionInfo.TerrainDetail2 = new LLUUID("00000000-0000-0000-0000-000000000000");
392 handshake.RegionInfo.TerrainDetail3 = new LLUUID("00000000-0000-0000-0000-000000000000");
393 handshake.RegionInfo.CacheID = new LLUUID("545ec0a5-5751-1026-8a0b-216e38a7ab37");
394
395 ServerConsole.MainConsole.Instance.WriteLine("Avatar.cs:SendRegionHandshake() - Sending RegionHandshake packet");
396 this.ControllingClient.OutPacket(handshake);
397 }
398
399 public ImprovedTerseObjectUpdatePacket.ObjectDataBlock CreateTerseBlock()
400 {
401 byte[] bytes = new byte[60];
402 int i=0;
403 ImprovedTerseObjectUpdatePacket.ObjectDataBlock dat = new ImprovedTerseObjectUpdatePacket.ObjectDataBlock();
404
405 dat.TextureEntry = AvatarTemplate.TextureEntry;
406 libsecondlife.LLVector3 pos2 = new LLVector3(this._physActor.Position.X, this._physActor.Position.Y, this._physActor.Position.Z);
407
408 uint ID = this.localid;
409
410 bytes[i++] = (byte)(ID % 256);
411 bytes[i++] = (byte)((ID >> 8) % 256);
412 bytes[i++] = (byte)((ID >> 16) % 256);
413 bytes[i++] = (byte)((ID >> 24) % 256);
414 bytes[i++] = 0;
415 bytes[i++] = 1;
416 i += 14;
417 bytes[i++] = 128;
418 bytes[i++] = 63;
419
420 byte[] pb = pos2.GetBytes();
421 Array.Copy(pb, 0, bytes, i, pb.Length);
422 i += 12;
423 ushort InternVelocityX;
424 ushort InternVelocityY;
425 ushort InternVelocityZ;
426
427 Axiom.MathLib.Vector3 internDirec = new Axiom.MathLib.Vector3(this._physActor.Velocity.X, this._physActor.Velocity.Y, this._physActor.Velocity.Z);
428 internDirec = internDirec /128.0f;
429 internDirec.x += 1;
430 internDirec.y += 1;
431 internDirec.z += 1;
432
433 InternVelocityX = (ushort)(32768 * internDirec.x);
434 InternVelocityY = (ushort)(32768 * internDirec.y);
435 InternVelocityZ = (ushort)(32768 * internDirec.z);
436
437 ushort ac = 32767;
438 bytes[i++] = (byte)(InternVelocityX % 256);
439 bytes[i++] = (byte)((InternVelocityX >> 8) % 256);
440 bytes[i++] = (byte)(InternVelocityY % 256);
441 bytes[i++] = (byte)((InternVelocityY>> 8) % 256);
442 bytes[i++] = (byte)(InternVelocityZ % 256);
443 bytes[i++] = (byte)((InternVelocityZ >> 8) % 256);
444
445 //accel
446 bytes[i++] = (byte)(ac % 256);
447 bytes[i++] = (byte)((ac >> 8) % 256);
448 bytes[i++] = (byte)(ac % 256);
449 bytes[i++] = (byte)((ac >> 8) % 256);
450 bytes[i++] = (byte)(ac % 256);
451 bytes[i++] = (byte)((ac >> 8) % 256);
452
453 //rot
454 bytes[i++] = (byte)(ac % 256);
455 bytes[i++] = (byte)((ac >> 8) % 256);
456 bytes[i++] = (byte)(ac % 256);
457 bytes[i++] = (byte)((ac >> 8) % 256);
458 bytes[i++] = (byte)(ac % 256);
459 bytes[i++] = (byte)((ac >> 8) % 256);
460 bytes[i++] = (byte)(ac % 256);
461 bytes[i++] = (byte)((ac >> 8) % 256);
462
463 //rotation vel
464 bytes[i++] = (byte)(ac % 256);
465 bytes[i++] = (byte)((ac >> 8) % 256);
466 bytes[i++] = (byte)(ac % 256);
467 bytes[i++] = (byte)((ac >> 8) % 256);
468 bytes[i++] = (byte)(ac % 256);
469 bytes[i++] = (byte)((ac >> 8) % 256);
470
471 dat.Data=bytes;
472 return(dat);
473 }
474 }
475
476 public class NewForce
477 {
478 public float X;
479 public float Y;
480 public float Z;
481
482 public NewForce()
483 {
484
485 }
486 }
487}
diff --git a/src/world/Entity.cs b/src/world/Entity.cs
deleted file mode 100644
index ee4b2e4..0000000
--- a/src/world/Entity.cs
+++ /dev/null
@@ -1,67 +0,0 @@
1using System;
2using System.Collections.Generic;
3using System.Text;
4using Axiom.MathLib;
5using OpenSim.types;
6using libsecondlife;
7
8namespace OpenSim.world
9{
10 public class Entity
11 {
12 public libsecondlife.LLUUID uuid;
13 public uint localid;
14 public LLVector3 position;
15 public LLVector3 velocity;
16 public Quaternion rotation;
17 protected string name;
18 protected List<Entity> children;
19
20 public Entity()
21 {
22 uuid = new libsecondlife.LLUUID();
23 localid = 8880000 + (OpenSim_Main.local_world._localNumber++); // FIXME - race condition!
24 position = new LLVector3();
25 velocity = new LLVector3();
26 rotation = new Quaternion();
27 name = "(basic entity)";
28 children = new List<Entity>();
29 }
30 public virtual void addForces()
31 {
32 foreach (Entity child in children)
33 {
34 child.addForces();
35 }
36 }
37 public virtual void update() {
38 // Do any per-frame updates needed that are applicable to every type of entity
39 foreach (Entity child in children)
40 {
41 child.update();
42 }
43 }
44
45 public virtual string getName()
46 {
47 return name;
48 }
49
50 public virtual Mesh getMesh()
51 {
52 Mesh mesh = new Mesh();
53
54 foreach (Entity child in children)
55 {
56 mesh += child.getMesh();
57 }
58
59 return mesh;
60 }
61
62 public virtual void BackUp()
63 {
64
65 }
66 }
67}
diff --git a/src/world/Primitive.cs b/src/world/Primitive.cs
deleted file mode 100644
index 6be33ef..0000000
--- a/src/world/Primitive.cs
+++ /dev/null
@@ -1,429 +0,0 @@
1using System;
2using System.Collections.Generic;
3using System.Text;
4using OpenSim.types;
5using libsecondlife;
6using libsecondlife.Packets;
7using GridInterfaces;
8using PhysicsSystem;
9
10namespace OpenSim.world
11{
12 public class Primitive : Entity
13 {
14 protected float mesh_cutbegin;
15 protected float mesh_cutend;
16 protected PrimData primData;
17 protected bool newPrimFlag;
18 protected bool updateFlag;
19 protected bool dirtyFlag;
20 private ObjectUpdatePacket OurPacket;
21 private PhysicsActor _physActor;
22 private bool physicsEnabled;
23
24 public bool PhysicsEnabled
25 {
26 get
27 {
28 return physicsEnabled;
29 }
30 set
31 {
32 physicsEnabled = value;
33 }
34 }
35 public bool UpdateFlag
36 {
37 get
38 {
39 return updateFlag;
40 }
41 set
42 {
43 updateFlag = value;
44 }
45 }
46 public LLVector3 Scale
47 {
48 set
49 {
50 this.primData.Scale = value;
51 this.dirtyFlag = true;
52 }
53 get
54 {
55 return this.primData.Scale;
56 }
57 }
58 public PhysicsActor PhysActor
59 {
60 set
61 {
62 this._physActor = value;
63 }
64 }
65
66 public Primitive()
67 {
68 mesh_cutbegin = 0.0f;
69 mesh_cutend = 1.0f;
70 }
71
72 public override Mesh getMesh()
73 {
74 Mesh mesh = new Mesh();
75 Triangle tri = new Triangle(
76 new Axiom.MathLib.Vector3(0.0f, 1.0f, 1.0f),
77 new Axiom.MathLib.Vector3(1.0f, 0.0f, 1.0f),
78 new Axiom.MathLib.Vector3(1.0f, 1.0f, 0.0f));
79
80 mesh.AddTri(tri);
81 mesh += base.getMesh();
82
83 return mesh;
84 }
85
86 public void UpdatePosition( LLVector3 pos)
87 {
88 this.position = pos;
89 if(this._physActor != null && this.physicsEnabled)
90 {
91 this._physActor.Position = new PhysicsVector(pos.X, pos.Y, pos.Z);
92 }
93 this.updateFlag = true;
94 }
95
96 public override void update()
97 {
98 if(this.newPrimFlag)
99 {
100 foreach(OpenSimClient client in OpenSim_Main.sim.ClientThreads.Values) {
101 client.OutPacket(OurPacket);
102 }
103 this.newPrimFlag = false;
104 }
105 else if(this.updateFlag)
106 {
107 ImprovedTerseObjectUpdatePacket terse = new ImprovedTerseObjectUpdatePacket();
108 terse.RegionData.RegionHandle = OpenSim_Main.cfg.RegionHandle; // FIXME
109 terse.RegionData.TimeDilation = 64096;
110 terse.ObjectData = new ImprovedTerseObjectUpdatePacket.ObjectDataBlock[1];
111 terse.ObjectData[0] = this.CreateImprovedBlock();
112 foreach(OpenSimClient client in OpenSim_Main.sim.ClientThreads.Values) {
113 client.OutPacket(terse);
114 }
115 this.updateFlag = false;
116 }
117 else if(this.dirtyFlag)
118 {
119 foreach(OpenSimClient client in OpenSim_Main.sim.ClientThreads.Values) {
120 UpdateClient(client);
121 }
122 this.dirtyFlag = false;
123 }
124 else
125 {
126 if(this._physActor != null && this.physicsEnabled)
127 {
128 ImprovedTerseObjectUpdatePacket terse = new ImprovedTerseObjectUpdatePacket();
129 terse.RegionData.RegionHandle = OpenSim_Main.cfg.RegionHandle; // FIXME
130 terse.RegionData.TimeDilation = 64096;
131 terse.ObjectData = new ImprovedTerseObjectUpdatePacket.ObjectDataBlock[1];
132 terse.ObjectData[0] = this.CreateImprovedBlock();
133 foreach(OpenSimClient client in OpenSim_Main.sim.ClientThreads.Values) {
134 client.OutPacket(terse);
135 }
136 }
137 }
138 }
139
140 public void UpdateClient(OpenSimClient RemoteClient)
141 {
142
143 LLVector3 lPos;
144 if( this._physActor != null && this.physicsEnabled)
145 {
146 PhysicsVector pPos = this._physActor.Position;
147 lPos = new LLVector3( pPos.X, pPos.Y, pPos.Z);
148 }
149 else
150 {
151 lPos = this.position;
152 }
153 byte[] pb = lPos.GetBytes();
154 Array.Copy(pb, 0, OurPacket.ObjectData[0].ObjectData, 0, pb.Length);
155
156 // OurPacket should be update with the follwing in updateShape() rather than having to do it here
157 OurPacket.ObjectData[0].OwnerID = this.primData.OwnerID;
158 OurPacket.ObjectData[0].PCode = this.primData.PCode;
159 OurPacket.ObjectData[0].PathBegin = this.primData.PathBegin;
160 OurPacket.ObjectData[0].PathEnd = this.primData.PathEnd;
161 OurPacket.ObjectData[0].PathScaleX = this.primData.PathScaleX;
162 OurPacket.ObjectData[0].PathScaleY = this.primData.PathScaleY;
163 OurPacket.ObjectData[0].PathShearX = this.primData.PathShearX;
164 OurPacket.ObjectData[0].PathShearY = this.primData.PathShearY;
165 OurPacket.ObjectData[0].PathSkew = this.primData.PathSkew;
166 OurPacket.ObjectData[0].ProfileBegin = this.primData.ProfileBegin;
167 OurPacket.ObjectData[0].ProfileEnd = this.primData.ProfileEnd;
168 OurPacket.ObjectData[0].Scale = this.primData.Scale;
169 OurPacket.ObjectData[0].PathCurve = this.primData.PathCurve;
170 OurPacket.ObjectData[0].ProfileCurve = this.primData.ProfileCurve;
171 OurPacket.ObjectData[0].ParentID = 0;
172 OurPacket.ObjectData[0].ProfileHollow = this.primData.ProfileHollow;
173 //finish off copying rest of shape data
174 OurPacket.ObjectData[0].PathRadiusOffset = this.primData.PathRadiusOffset;
175 OurPacket.ObjectData[0].PathRevolutions = this.primData.PathRevolutions;
176 OurPacket.ObjectData[0].PathTaperX = this.primData.PathTaperX;
177 OurPacket.ObjectData[0].PathTaperY = this.primData.PathTaperY;
178 OurPacket.ObjectData[0].PathTwist = this.primData.PathTwist;
179 OurPacket.ObjectData[0].PathTwistBegin= this.primData.PathTwistBegin;
180
181 RemoteClient.OutPacket(OurPacket);
182 }
183
184 public void UpdateShape(ObjectShapePacket.ObjectDataBlock addPacket)
185 {
186 this.primData.PathBegin = addPacket.PathBegin;
187 this.primData.PathEnd = addPacket.PathEnd;
188 this.primData.PathScaleX = addPacket.PathScaleX;
189 this.primData.PathScaleY = addPacket.PathScaleY;
190 this.primData.PathShearX = addPacket.PathShearX;
191 this.primData.PathShearY = addPacket.PathShearY;
192 this.primData.PathSkew = addPacket.PathSkew;
193 this.primData.ProfileBegin = addPacket.ProfileBegin;
194 this.primData.ProfileEnd = addPacket.ProfileEnd;
195 this.primData.PathCurve = addPacket.PathCurve;
196 this.primData.ProfileCurve = addPacket.ProfileCurve;
197 this.primData.ProfileHollow = addPacket.ProfileHollow;
198 this.primData.PathRadiusOffset = addPacket.PathRadiusOffset;
199 this.primData.PathRevolutions = addPacket.PathRevolutions;
200 this.primData.PathTaperX = addPacket.PathTaperX;
201 this.primData.PathTaperY = addPacket.PathTaperY;
202 this.primData.PathTwist = addPacket.PathTwist;
203 this.primData.PathTwistBegin =addPacket.PathTwistBegin;
204 this.dirtyFlag = true;
205 }
206
207 public void CreateFromPacket( ObjectAddPacket addPacket, LLUUID agentID, uint localID)
208 {
209 ObjectUpdatePacket objupdate = new ObjectUpdatePacket();
210 objupdate.RegionData.RegionHandle = OpenSim_Main.cfg.RegionHandle;
211 objupdate.RegionData.TimeDilation = 64096;
212
213 objupdate.ObjectData = new libsecondlife.Packets.ObjectUpdatePacket.ObjectDataBlock[1];
214 PrimData PData = new PrimData();
215 this.primData = PData;
216 objupdate.ObjectData[0] = new ObjectUpdatePacket.ObjectDataBlock();
217 objupdate.ObjectData[0].PSBlock = new byte[0];
218 objupdate.ObjectData[0].ExtraParams = new byte[1];
219 objupdate.ObjectData[0].MediaURL = new byte[0];
220 objupdate.ObjectData[0].NameValue = new byte[0];
221 objupdate.ObjectData[0].Text = new byte[0];
222 objupdate.ObjectData[0].TextColor = new byte[4];
223 objupdate.ObjectData[0].JointAxisOrAnchor = new LLVector3(0,0,0);
224 objupdate.ObjectData[0].JointPivot = new LLVector3(0,0,0);
225 objupdate.ObjectData[0].Material = 3;
226 objupdate.ObjectData[0].UpdateFlags=32+65536+131072+256+4+8+2048+524288+268435456;
227 objupdate.ObjectData[0].TextureAnim = new byte[0];
228 objupdate.ObjectData[0].Sound = LLUUID.Zero;
229 LLObject.TextureEntry ntex = new LLObject.TextureEntry(new LLUUID("00000000-0000-0000-5005-000000000005"));
230 objupdate.ObjectData[0].TextureEntry = ntex.ToBytes();
231 objupdate.ObjectData[0].State = 0;
232 objupdate.ObjectData[0].Data = new byte[0];
233 PData.OwnerID = objupdate.ObjectData[0].OwnerID = agentID;
234 PData.PCode = objupdate.ObjectData[0].PCode = addPacket.ObjectData.PCode;
235 PData.PathBegin = objupdate.ObjectData[0].PathBegin = addPacket.ObjectData.PathBegin;
236 PData.PathEnd = objupdate.ObjectData[0].PathEnd = addPacket.ObjectData.PathEnd;
237 PData.PathScaleX = objupdate.ObjectData[0].PathScaleX = addPacket.ObjectData.PathScaleX;
238 PData.PathScaleY = objupdate.ObjectData[0].PathScaleY = addPacket.ObjectData.PathScaleY;
239 PData.PathShearX = objupdate.ObjectData[0].PathShearX = addPacket.ObjectData.PathShearX;
240 PData.PathShearY = objupdate.ObjectData[0].PathShearY = addPacket.ObjectData.PathShearY;
241 PData.PathSkew = objupdate.ObjectData[0].PathSkew = addPacket.ObjectData.PathSkew;
242 PData.ProfileBegin = objupdate.ObjectData[0].ProfileBegin = addPacket.ObjectData.ProfileBegin;
243 PData.ProfileEnd = objupdate.ObjectData[0].ProfileEnd = addPacket.ObjectData.ProfileEnd;
244 PData.Scale = objupdate.ObjectData[0].Scale = addPacket.ObjectData.Scale;
245 PData.PathCurve = objupdate.ObjectData[0].PathCurve = addPacket.ObjectData.PathCurve;
246 PData.ProfileCurve = objupdate.ObjectData[0].ProfileCurve = addPacket.ObjectData.ProfileCurve;
247 PData.ParentID = objupdate.ObjectData[0].ParentID = 0;
248 PData.ProfileHollow = objupdate.ObjectData[0].ProfileHollow = addPacket.ObjectData.ProfileHollow;
249
250 PData.PathRadiusOffset = objupdate.ObjectData[0].PathRadiusOffset = addPacket.ObjectData.PathRadiusOffset;
251 PData.PathRevolutions = objupdate.ObjectData[0].PathRevolutions = addPacket.ObjectData.PathRevolutions;
252 PData.PathTaperX = objupdate.ObjectData[0].PathTaperX = addPacket.ObjectData.PathTaperX;
253 PData.PathTaperY = objupdate.ObjectData[0].PathTaperY = addPacket.ObjectData.PathTaperY;
254 PData.PathTwist = objupdate.ObjectData[0].PathTwist = addPacket.ObjectData.PathTwist;
255 PData.PathTwistBegin = objupdate.ObjectData[0].PathTwistBegin = addPacket.ObjectData.PathTwistBegin;
256
257 //finish off copying rest of shape data
258
259 objupdate.ObjectData[0].ID = (uint)(localID);
260 objupdate.ObjectData[0].FullID = new LLUUID("edba7151-5857-acc5-b30b-f01efef" + (localID- 702000).ToString("00000"));
261 objupdate.ObjectData[0].ObjectData = new byte[60];
262 objupdate.ObjectData[0].ObjectData[46] = 128;
263 objupdate.ObjectData[0].ObjectData[47] = 63;
264 LLVector3 pos1= addPacket.ObjectData.RayEnd;
265 //update position
266 byte[] pb = pos1.GetBytes();
267 Array.Copy(pb, 0, objupdate.ObjectData[0].ObjectData, 0, pb.Length);
268
269 this.newPrimFlag = true;
270 this.uuid = objupdate.ObjectData[0].FullID;
271 this.localid = objupdate.ObjectData[0].ID;
272 this.position = pos1;
273 this.OurPacket = objupdate;
274 }
275
276 public void CreateFromStorage(PrimData store)
277 {
278 //need to clean this up as it shares a lot of code with CreateFromPacket()
279 ObjectUpdatePacket objupdate = new ObjectUpdatePacket();
280 objupdate.RegionData.RegionHandle = OpenSim_Main.cfg.RegionHandle;
281 objupdate.RegionData.TimeDilation = 64096;
282 objupdate.ObjectData = new libsecondlife.Packets.ObjectUpdatePacket.ObjectDataBlock[1];
283
284 this.primData = store;
285 objupdate.ObjectData[0] = new ObjectUpdatePacket.ObjectDataBlock();
286 objupdate.ObjectData[0].PSBlock = new byte[0];
287 objupdate.ObjectData[0].ExtraParams = new byte[1];
288 objupdate.ObjectData[0].MediaURL = new byte[0];
289 objupdate.ObjectData[0].NameValue = new byte[0];
290 objupdate.ObjectData[0].Text = new byte[0];
291 objupdate.ObjectData[0].TextColor = new byte[4];
292 objupdate.ObjectData[0].JointAxisOrAnchor = new LLVector3(0,0,0);
293 objupdate.ObjectData[0].JointPivot = new LLVector3(0,0,0);
294 objupdate.ObjectData[0].Material = 3;
295 objupdate.ObjectData[0].UpdateFlags=32+65536+131072+256+4+8+2048+524288+268435456;
296 objupdate.ObjectData[0].TextureAnim = new byte[0];
297 objupdate.ObjectData[0].Sound = LLUUID.Zero;
298 LLObject.TextureEntry ntex = new LLObject.TextureEntry(new LLUUID("00000000-0000-0000-5005-000000000005"));
299 objupdate.ObjectData[0].TextureEntry = ntex.ToBytes();
300 objupdate.ObjectData[0].State = 0;
301 objupdate.ObjectData[0].Data = new byte[0];
302 objupdate.ObjectData[0].OwnerID = this.primData.OwnerID;
303 objupdate.ObjectData[0].PCode = this.primData.PCode;
304 objupdate.ObjectData[0].PathBegin = this.primData.PathBegin;
305 objupdate.ObjectData[0].PathEnd = this.primData.PathEnd;
306 objupdate.ObjectData[0].PathScaleX = this.primData.PathScaleX;
307 objupdate.ObjectData[0].PathScaleY = this.primData.PathScaleY;
308 objupdate.ObjectData[0].PathShearX = this.primData.PathShearX;
309 objupdate.ObjectData[0].PathShearY = this.primData.PathShearY;
310 objupdate.ObjectData[0].PathSkew = this.primData.PathSkew;
311 objupdate.ObjectData[0].ProfileBegin = this.primData.ProfileBegin;
312 objupdate.ObjectData[0].ProfileEnd = this.primData.ProfileEnd;
313 objupdate.ObjectData[0].Scale = this.primData.Scale;
314 objupdate.ObjectData[0].PathCurve = this.primData.PathCurve;
315 objupdate.ObjectData[0].ProfileCurve = this.primData.ProfileCurve;
316 objupdate.ObjectData[0].ParentID = 0;
317 objupdate.ObjectData[0].ProfileHollow = this.primData.ProfileHollow;
318 //finish off copying rest of shape data
319 objupdate.ObjectData[0].PathRadiusOffset = this.primData.PathRadiusOffset;
320 objupdate.ObjectData[0].PathRevolutions = this.primData.PathRevolutions;
321 objupdate.ObjectData[0].PathTaperX = this.primData.PathTaperX;
322 objupdate.ObjectData[0].PathTaperY = this.primData.PathTaperY;
323 objupdate.ObjectData[0].PathTwist = this.primData.PathTwist;
324 objupdate.ObjectData[0].PathTwistBegin= this.primData.PathTwistBegin;
325
326 objupdate.ObjectData[0].ID = (uint)store.LocalID;
327 objupdate.ObjectData[0].FullID = store.FullID;
328
329 objupdate.ObjectData[0].ObjectData = new byte[60];
330 objupdate.ObjectData[0].ObjectData[46] = 128;
331 objupdate.ObjectData[0].ObjectData[47] = 63;
332 LLVector3 pos1= store.Position;
333 //update position
334 byte[] pb = pos1.GetBytes();
335 Array.Copy(pb, 0, objupdate.ObjectData[0].ObjectData, 0, pb.Length);
336
337 this.uuid = objupdate.ObjectData[0].FullID;
338 this.localid = objupdate.ObjectData[0].ID;
339 this.position = pos1;
340 this.OurPacket = objupdate;
341
342 }
343 public ImprovedTerseObjectUpdatePacket.ObjectDataBlock CreateImprovedBlock()
344 {
345 uint ID = this.localid;
346 byte[] bytes = new byte[60];
347
348 int i = 0;
349 ImprovedTerseObjectUpdatePacket.ObjectDataBlock dat = new ImprovedTerseObjectUpdatePacket.ObjectDataBlock();
350 dat.TextureEntry = this.OurPacket.ObjectData[0].TextureEntry;
351
352 bytes[i++] = (byte)(ID % 256);
353 bytes[i++] = (byte)((ID >> 8) % 256);
354 bytes[i++] = (byte)((ID >> 16) % 256);
355 bytes[i++] = (byte)((ID >> 24) % 256);
356 bytes[i++]= 0;
357 bytes[i++]= 0;
358
359 LLVector3 lPos;
360 if( this._physActor != null && this.physicsEnabled)
361 {
362 PhysicsVector pPos = this._physActor.Position;
363 lPos = new LLVector3( pPos.X, pPos.Y, pPos.Z);
364 }
365 else
366 {
367 lPos = this.position;
368 }
369 byte[] pb = lPos.GetBytes();
370 Array.Copy(pb, 0, bytes, i, pb.Length);
371 i += 12;
372 ushort ac = 32767;
373
374 //vel
375 bytes[i++] = (byte)(ac % 256);
376 bytes[i++] = (byte)((ac >> 8) % 256);
377 bytes[i++] = (byte)(ac % 256);
378 bytes[i++] = (byte)((ac >> 8) % 256);
379 bytes[i++] = (byte)(ac % 256);
380 bytes[i++] = (byte)((ac >> 8) % 256);
381
382 //accel
383 bytes[i++] = (byte)(ac % 256);
384 bytes[i++] = (byte)((ac >> 8) % 256);
385 bytes[i++] = (byte)(ac % 256);
386 bytes[i++] = (byte)((ac >> 8) % 256);
387 bytes[i++] = (byte)(ac % 256);
388 bytes[i++] = (byte)((ac >> 8) % 256);
389
390 ushort rw, rx,ry,rz;
391 rw = (ushort)(32768 * (this.rotation.w+1));
392 rx = (ushort)(32768 * (this.rotation.x+1));
393 ry = (ushort)(32768 * (this.rotation.y+1));
394 rz = (ushort)(32768 * (this.rotation.z+1));
395
396 //rot
397 bytes[i++] = (byte)(rx % 256);
398 bytes[i++] = (byte)((rx >> 8) % 256);
399 bytes[i++] = (byte)(ry % 256);
400 bytes[i++] = (byte)((ry >> 8) % 256);
401 bytes[i++] = (byte)(rz % 256);
402 bytes[i++] = (byte)((rz >> 8) % 256);
403 bytes[i++] = (byte)(rw % 256);
404 bytes[i++] = (byte)((rw >> 8) % 256);
405
406 //rotation vel
407 bytes[i++] = (byte)(ac % 256);
408 bytes[i++] = (byte)((ac >> 8) % 256);
409 bytes[i++] = (byte)(ac % 256);
410 bytes[i++] = (byte)((ac >> 8) % 256);
411 bytes[i++] = (byte)(ac % 256);
412 bytes[i++] = (byte)((ac >> 8) % 256);
413
414 dat.Data=bytes;
415 return dat;
416 }
417
418 public override void BackUp()
419 {
420
421 this.primData.FullID = this.uuid;
422 this.primData.LocalID = this.localid;
423 this.primData.Position = this.position;
424 this.primData.Rotation = new LLQuaternion(this.rotation.x, this.rotation.y, this.rotation.z , this.rotation.w);
425 OpenSim_Main.local_world.localStorage.StorePrim(this.primData);
426 }
427 }
428
429}
diff --git a/src/world/ScriptEngine.cs b/src/world/ScriptEngine.cs
deleted file mode 100644
index f20a08e..0000000
--- a/src/world/ScriptEngine.cs
+++ /dev/null
@@ -1,18 +0,0 @@
1using System;
2using System.Collections.Generic;
3using System.Text;
4
5namespace OpenSim.world
6{
7 public class ScriptEngine
8 {
9 public ScriptEngine(World env)
10 {
11 }
12
13 public void LoadScript()
14 {
15
16 }
17 }
18}
diff --git a/src/world/SurfacePatch.cs b/src/world/SurfacePatch.cs
deleted file mode 100644
index 71e4116..0000000
--- a/src/world/SurfacePatch.cs
+++ /dev/null
@@ -1,22 +0,0 @@
1using System;
2using System.Collections.Generic;
3using System.Text;
4
5namespace OpenSim.world
6{
7 public class SurfacePatch
8 {
9 public float[] HeightMap;
10
11 public SurfacePatch() {
12 HeightMap = new float[16*16];
13
14 int xinc;
15 int yinc;
16 for(xinc=0; xinc<16; xinc++) for(yinc=0; yinc<16; yinc++) {
17 HeightMap[xinc+(yinc*16)]=100.0f;
18 }
19
20 }
21 }
22}
diff --git a/src/world/World.cs b/src/world/World.cs
deleted file mode 100644
index e1c84bc..0000000
--- a/src/world/World.cs
+++ /dev/null
@@ -1,208 +0,0 @@
1using System;
2using libsecondlife;
3using libsecondlife.Packets;
4using System.Collections.Generic;
5using System.Text;
6using System.Reflection;
7using System.IO;
8using PhysicsSystem;
9using GridInterfaces;
10
11namespace OpenSim.world
12{
13 public class World : ILocalStorageReceiver
14 {
15 public Dictionary<libsecondlife.LLUUID, Entity> Entities;
16 public float[] LandMap;
17 public ScriptEngine Scripts;
18 public uint _localNumber=0;
19 private PhysicsScene phyScene;
20 private float timeStep= 0.1f;
21 private libsecondlife.TerrainManager TerrainManager;
22 public ILocalStorage localStorage;
23 private Random Rand = new Random();
24 private uint _primCount = 702000;
25 private int storageCount;
26
27 public World()
28 {
29 ServerConsole.MainConsole.Instance.WriteLine("World.cs - creating new entitities instance");
30 Entities = new Dictionary<libsecondlife.LLUUID, Entity>();
31
32 ServerConsole.MainConsole.Instance.WriteLine("World.cs - creating LandMap");
33 TerrainManager = new TerrainManager(new SecondLife());
34 Avatar.SetupTemplate("avatar-template.dat");
35 // ServerConsole.MainConsole.Instance.WriteLine("World.cs - Creating script engine instance");
36 // Initialise this only after the world has loaded
37 // Scripts = new ScriptEngine(this);
38 }
39
40 public PhysicsScene PhysScene
41 {
42 set
43 {
44 this.phyScene = value;
45 }
46 get
47 {
48 return(this.phyScene);
49 }
50 }
51
52 public void Update()
53 {
54 if(this.phyScene.IsThreaded)
55 {
56 this.phyScene.GetResults();
57
58 }
59
60 foreach (libsecondlife.LLUUID UUID in Entities.Keys)
61 {
62 Entities[UUID].addForces();
63 }
64
65 this.phyScene.Simulate(timeStep);
66
67 foreach (libsecondlife.LLUUID UUID in Entities.Keys)
68 {
69 Entities[UUID].update();
70 }
71
72 //backup world data
73 this.storageCount++;
74 if(storageCount> 300) //set to how often you want to backup
75 {
76 this.Backup();
77 storageCount =0;
78 }
79 }
80
81 public bool LoadStorageDLL(string dllName)
82 {
83 Assembly pluginAssembly = Assembly.LoadFrom(dllName);
84 ILocalStorage store = null;
85
86 foreach (Type pluginType in pluginAssembly.GetTypes())
87 {
88 if (pluginType.IsPublic)
89 {
90 if (!pluginType.IsAbstract)
91 {
92 Type typeInterface = pluginType.GetInterface("ILocalStorage", true);
93
94 if (typeInterface != null)
95 {
96 ILocalStorage plug = (ILocalStorage)Activator.CreateInstance(pluginAssembly.GetType(pluginType.ToString()));
97 store = plug;
98 break;
99 }
100
101 typeInterface = null;
102 }
103 }
104 }
105 pluginAssembly = null;
106 this.localStorage = store;
107 return(store == null);
108 }
109
110 public void RegenerateTerrain()
111 {
112 HeightmapGenHills hills = new HeightmapGenHills();
113 this.LandMap = hills.GenerateHeightmap(200, 4.0f, 80.0f, false);
114 this.phyScene.SetTerrain(this.LandMap);
115 OpenSim_Main.cfg.SaveMap();
116
117 foreach(OpenSimClient client in OpenSim_Main.sim.ClientThreads.Values) {
118 this.SendLayerData(client);
119 }
120 }
121 public void LoadPrimsFromStorage()
122 {
123 ServerConsole.MainConsole.Instance.WriteLine("World.cs: LoadPrimsFromStorage() - Loading primitives");
124 this.localStorage.LoadPrimitives(this);
125 }
126
127 public void PrimFromStorage(PrimData prim)
128 {
129 if(prim.LocalID >= this._primCount)
130 {
131 _primCount = prim.LocalID + 1;
132 }
133 ServerConsole.MainConsole.Instance.WriteLine("World.cs: PrimFromStorage() - Reloading prim (localId "+ prim.LocalID+ " ) from storage");
134 Primitive nPrim = new Primitive();
135 nPrim.CreateFromStorage(prim);
136 this.Entities.Add(nPrim.uuid, nPrim);
137 }
138
139 public void Close()
140 {
141 this.localStorage.ShutDown();
142 }
143
144 public void SendLayerData(OpenSimClient RemoteClient) {
145 int[] patches = new int[4];
146
147 for (int y = 0; y < 16; y++)
148 {
149 for (int x = 0; x < 16; x = x + 4)
150 {
151 patches[0] = x + 0 + y * 16;
152 patches[1] = x + 1 + y * 16;
153 patches[2] = x + 2 + y * 16;
154 patches[3] = x + 3 + y * 16;
155
156 Packet layerpack = TerrainManager.CreateLandPacket(LandMap, patches);
157 RemoteClient.OutPacket(layerpack);
158 }
159 }
160 }
161
162 public void GetInitialPrims(OpenSimClient RemoteClient)
163 {
164 foreach (libsecondlife.LLUUID UUID in Entities.Keys)
165 {
166 if(Entities[UUID].ToString()== "OpenSim.world.Primitive")
167 {
168 ((OpenSim.world.Primitive)Entities[UUID]).UpdateClient(RemoteClient);
169 }
170 }
171 }
172
173 public void AddViewerAgent(OpenSimClient AgentClient) {
174 ServerConsole.MainConsole.Instance.WriteLine("World.cs:AddViewerAgent() - Creating new avatar for remote viewer agent");
175 Avatar NewAvatar = new Avatar(AgentClient);
176 ServerConsole.MainConsole.Instance.WriteLine("World.cs:AddViewerAgent() - Adding new avatar to world");
177 ServerConsole.MainConsole.Instance.WriteLine("World.cs:AddViewerAgent() - Starting RegionHandshake ");
178 NewAvatar.SendRegionHandshake(this);
179 PhysicsVector pVec = new PhysicsVector(NewAvatar.position.X, NewAvatar.position.Y, NewAvatar.position.Z);
180 NewAvatar.PhysActor = this.phyScene.AddAvatar(pVec);
181 this.Entities.Add(AgentClient.AgentID, NewAvatar);
182 }
183
184 public void AddNewPrim(ObjectAddPacket addPacket, OpenSimClient AgentClient)
185 {
186 ServerConsole.MainConsole.Instance.WriteLine("World.cs: AddNewPrim() - Creating new prim");
187 Primitive prim = new Primitive();
188 prim.CreateFromPacket(addPacket, AgentClient.AgentID, this._primCount);
189 PhysicsVector pVec = new PhysicsVector(prim.position.X, prim.position.Y, prim.position.Z);
190 PhysicsVector pSize = new PhysicsVector( 0.25f, 0.25f, 0.25f);
191 //prim.PhysActor = this.phyScene.AddPrim(pVec, pSize );
192 //prim.PhysicsEnabled = true;
193 this.Entities.Add(prim.uuid, prim);
194 this._primCount++;
195 }
196
197 public bool Backup() {
198 /* TODO: Save the current world entities state. */
199 ServerConsole.MainConsole.Instance.WriteLine("World.cs: Backup() - Backing up Primitives");
200 foreach (libsecondlife.LLUUID UUID in Entities.Keys)
201 {
202 Entities[UUID].BackUp();
203 }
204 return true;
205 }
206
207 }
208}
diff --git a/src/world/scripting/IScript.cs b/src/world/scripting/IScript.cs
deleted file mode 100644
index 550594d..0000000
--- a/src/world/scripting/IScript.cs
+++ /dev/null
@@ -1,16 +0,0 @@
1using System;
2using System.Collections.Generic;
3using System.Text;
4
5namespace OpenSim.world.scripting
6{
7 public interface IScriptHost {
8 bool Register(IScript iscript);
9 }
10 public interface IScript
11 {
12 string Name{get;set;}
13 IScriptHost Host{get;set;}
14 void Show();
15 }
16}