aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/ConvertToPlugins/src/world
diff options
context:
space:
mode:
authorgareth2007-03-07 18:49:20 +0000
committergareth2007-03-07 18:49:20 +0000
commit16476f06b867adf01fa0d17c6761f4a862fc17ad (patch)
treec3a1147578ae33d269812adfe8de5ece8c62d586 /ConvertToPlugins/src/world
parentDeleted old trunk code (diff)
downloadopensim-SC-16476f06b867adf01fa0d17c6761f4a862fc17ad.zip
opensim-SC-16476f06b867adf01fa0d17c6761f4a862fc17ad.tar.gz
opensim-SC-16476f06b867adf01fa0d17c6761f4a862fc17ad.tar.bz2
opensim-SC-16476f06b867adf01fa0d17c6761f4a862fc17ad.tar.xz
Imported branch
Diffstat (limited to '')
-rw-r--r--ConvertToPlugins/src/world/Avatar.cs355
-rw-r--r--ConvertToPlugins/src/world/Entity.cs62
-rw-r--r--ConvertToPlugins/src/world/Primitive.cs136
-rw-r--r--ConvertToPlugins/src/world/ScriptEngine.cs18
-rw-r--r--ConvertToPlugins/src/world/SurfacePatch.cs22
-rw-r--r--ConvertToPlugins/src/world/World.cs117
-rw-r--r--ConvertToPlugins/src/world/scripting/IScript.cs16
7 files changed, 726 insertions, 0 deletions
diff --git a/ConvertToPlugins/src/world/Avatar.cs b/ConvertToPlugins/src/world/Avatar.cs
new file mode 100644
index 0000000..c8469f8
--- /dev/null
+++ b/ConvertToPlugins/src/world/Avatar.cs
@@ -0,0 +1,355 @@
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 string firstname;
15 public string lastname;
16 public OpenSimClient ControllingClient;
17 private PhysicsActor _physActor;
18 private libsecondlife.Packets.ObjectUpdatePacket.ObjectDataBlock AvatarTemplate;
19 private bool updateflag;
20 private bool walking;
21 private List<NewForce> forcesList = new List<NewForce>();
22 private short _updateCount;
23
24 public Avatar(OpenSimClient TheClient) {
25 ServerConsole.MainConsole.Instance.WriteLine("Avatar.cs - Loading details from grid (DUMMY)");
26 ControllingClient=TheClient;
27 SetupTemplate("avatar-template.dat");
28 position = new LLVector3(100.0f,100.0f,30.0f);
29 position.Z = OpenSim_Main.local_world.LandMap[(int)position.Y * 256 + (int)position.X]+1;
30 }
31
32 public PhysicsActor PhysActor
33 {
34 set
35 {
36 this._physActor = value;
37 }
38 }
39 public override void addForces()
40 {
41 lock(this.forcesList)
42 {
43 if(this.forcesList.Count>0)
44 {
45 for(int i=0 ; i < this.forcesList.Count; i++)
46 {
47 NewForce force = this.forcesList[i];
48 PhysicsVector phyVector = new PhysicsVector(force.X, force.Y, force.Z);
49 this._physActor.Velocity = phyVector;
50 this.updateflag = true;
51 this.velocity = new LLVector3(force.X, force.Y, force.Z); //shouldn't really be doing this
52 // but as we are setting the velocity (rather than using real forces) at the moment it is okay.
53 }
54 for(int i=0 ; i < this.forcesList.Count; i++)
55 {
56 this.forcesList.RemoveAt(0);
57 }
58 }
59 }
60 }
61
62 public override void update()
63 {
64
65 if(this.updateflag)
66 {
67 //need to send movement info
68 //so create the improvedterseobjectupdate packet
69 //use CreateTerseBlock()
70 ImprovedTerseObjectUpdatePacket.ObjectDataBlock terseBlock = CreateTerseBlock();
71 ImprovedTerseObjectUpdatePacket terse = new ImprovedTerseObjectUpdatePacket();
72 terse.RegionData.RegionHandle = OpenSim_Main.cfg.RegionHandle; // FIXME
73 terse.RegionData.TimeDilation = 64096;
74 terse.ObjectData = new ImprovedTerseObjectUpdatePacket.ObjectDataBlock[1];
75 terse.ObjectData[0] = terseBlock;
76 foreach(OpenSimClient client in OpenSim_Main.sim.ClientThreads.Values) {
77 client.OutPacket(terse);
78 }
79
80 updateflag =false;
81 this._updateCount = 0;
82 }
83 else
84 {
85 if(walking)
86 {
87 _updateCount++;
88 if(_updateCount>3)
89 {
90 //It has been a while since last update was sent so lets send one.
91 ImprovedTerseObjectUpdatePacket.ObjectDataBlock terseBlock = CreateTerseBlock();
92 ImprovedTerseObjectUpdatePacket terse = new ImprovedTerseObjectUpdatePacket();
93 terse.RegionData.RegionHandle = OpenSim_Main.cfg.RegionHandle; // FIXME
94 terse.RegionData.TimeDilation = 64096;
95 terse.ObjectData = new ImprovedTerseObjectUpdatePacket.ObjectDataBlock[1];
96 terse.ObjectData[0] = terseBlock;
97 foreach(OpenSimClient client in OpenSim_Main.sim.ClientThreads.Values) {
98 client.OutPacket(terse);
99 }
100 _updateCount = 0;
101 }
102 }
103 }
104 }
105
106 private void SetupTemplate(string name)
107 {
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 AvatarTemplate = objdata;
131
132 }
133
134 public void CompleteMovement(World RegionInfo) {
135 ServerConsole.MainConsole.Instance.WriteLine("Avatar.cs:CompleteMovement() - Constructing AgentMovementComplete packet");
136 AgentMovementCompletePacket mov = new AgentMovementCompletePacket();
137 mov.AgentData.SessionID = this.ControllingClient.SessionID;
138 mov.AgentData.AgentID = this.ControllingClient.AgentID;
139 mov.Data.RegionHandle = OpenSim_Main.cfg.RegionHandle;
140 // TODO - dynamicalise this stuff
141 mov.Data.Timestamp = 1172750370;
142 mov.Data.Position = new LLVector3(100f, 100f, 23f);
143 mov.Data.LookAt = new LLVector3(0.99f, 0.042f, 0);
144
145 ControllingClient.OutPacket(mov);
146 }
147
148 public void SendInitialPosition() {
149
150 System.Text.Encoding _enc = System.Text.Encoding.ASCII;
151 //send a objectupdate packet with information about the clients avatar
152 ObjectUpdatePacket objupdate = new ObjectUpdatePacket();
153 objupdate.RegionData.RegionHandle = OpenSim_Main.cfg.RegionHandle;
154 objupdate.RegionData.TimeDilation = 64096;
155 objupdate.ObjectData = new libsecondlife.Packets.ObjectUpdatePacket.ObjectDataBlock[1];
156
157 objupdate.ObjectData[0] = AvatarTemplate;
158 //give this avatar object a local id and assign the user a name
159 objupdate.ObjectData[0].ID = this.localid;
160 objupdate.ObjectData[0].FullID = ControllingClient.AgentID;
161 objupdate.ObjectData[0].NameValue = _enc.GetBytes("FirstName STRING RW SV " + firstname + "\nLastName STRING RW SV " + lastname + " \0");
162
163 libsecondlife.LLVector3 pos2 = new LLVector3((float)this.position.X, (float)this.position.Y, (float)this.position.Z);
164
165 byte[] pb = pos2.GetBytes();
166
167 Array.Copy(pb, 0, objupdate.ObjectData[0].ObjectData, 16, pb.Length);
168 OpenSim_Main.local_world._localNumber++;
169 this.ControllingClient.OutPacket(objupdate);
170 }
171
172 public void SendInitialAppearance() {
173 AgentWearablesUpdatePacket aw = new AgentWearablesUpdatePacket();
174 aw.AgentData.AgentID = this.ControllingClient.AgentID;
175 aw.AgentData.SerialNum = 0;
176 aw.AgentData.SessionID = ControllingClient.SessionID;
177
178 aw.WearableData = new AgentWearablesUpdatePacket.WearableDataBlock[13];
179 AgentWearablesUpdatePacket.WearableDataBlock awb = new AgentWearablesUpdatePacket.WearableDataBlock();
180 awb.WearableType = (byte)0;
181 awb.AssetID = new LLUUID("66c41e39-38f9-f75a-024e-585989bfab73");
182 awb.ItemID = LLUUID.Random();
183 aw.WearableData[0] = awb;
184
185 for(int i=1; i<13; i++) {
186 awb = new AgentWearablesUpdatePacket.WearableDataBlock();
187 awb.WearableType = (byte)i;
188 awb.AssetID = new LLUUID("00000000-0000-0000-0000-000000000000");
189 awb.ItemID = new LLUUID("00000000-0000-0000-0000-000000000000");
190 aw.WearableData[i] = awb;
191 }
192
193 ControllingClient.OutPacket(aw);
194 }
195
196 public void HandleUpdate(AgentUpdatePacket pack) {
197 if(((uint)pack.AgentData.ControlFlags & (uint)MainAvatar.AgentUpdateFlags.AGENT_CONTROL_AT_POS) !=0) {
198 if(!walking)
199 {
200 //we should add a new force to the list
201 // but for now we will deal with velocities
202 NewForce newVelocity = new NewForce();
203 Axiom.MathLib.Vector3 v3 = new Axiom.MathLib.Vector3(1, 0, 0);
204 Axiom.MathLib.Quaternion q = new Axiom.MathLib.Quaternion(pack.AgentData.BodyRotation.W, pack.AgentData.BodyRotation.X, pack.AgentData.BodyRotation.Y, pack.AgentData.BodyRotation.Z);
205 Axiom.MathLib.Vector3 direc = q * v3;
206 direc.Normalize();
207
208 //work out velocity for sim physics system
209 direc = direc * ((0.03f) * 128f);
210 newVelocity.X = direc.x;
211 newVelocity.Y = direc.y;
212 newVelocity.Z = direc.z;
213 this.forcesList.Add(newVelocity);
214 walking=true;
215 }
216 }
217 else
218 {
219 if(walking)
220 {
221 NewForce newVelocity = new NewForce();
222 newVelocity.X = 0;
223 newVelocity.Y = 0;
224 newVelocity.Z = 0;
225 this.forcesList.Add(newVelocity);
226 walking = false;
227 }
228 }
229 }
230
231 //should be moved somewhere else
232 public void SendRegionHandshake(World RegionInfo) {
233 ServerConsole.MainConsole.Instance.WriteLine("Avatar.cs:SendRegionHandshake() - Creating empty RegionHandshake packet");
234 System.Text.Encoding _enc = System.Text.Encoding.ASCII;
235 RegionHandshakePacket handshake = new RegionHandshakePacket();
236
237 ServerConsole.MainConsole.Instance.WriteLine("Avatar.cs:SendRegionhandshake() - Filling in RegionHandshake details");
238 handshake.RegionInfo.BillableFactor = 0;
239 handshake.RegionInfo.IsEstateManager = false;
240 handshake.RegionInfo.TerrainHeightRange00 = 60;
241 handshake.RegionInfo.TerrainHeightRange01 = 60;
242 handshake.RegionInfo.TerrainHeightRange10 = 60;
243 handshake.RegionInfo.TerrainHeightRange11 = 60;
244 handshake.RegionInfo.TerrainStartHeight00 = 10;
245 handshake.RegionInfo.TerrainStartHeight01 = 10;
246 handshake.RegionInfo.TerrainStartHeight10 = 10;
247 handshake.RegionInfo.TerrainStartHeight11 = 10;
248 handshake.RegionInfo.SimAccess = 13;
249 handshake.RegionInfo.WaterHeight = 5;
250 handshake.RegionInfo.RegionFlags = 72458694;
251 handshake.RegionInfo.SimName = _enc.GetBytes(OpenSim_Main.cfg.RegionName + "\0");
252 handshake.RegionInfo.SimOwner = new LLUUID("00000000-0000-0000-0000-000000000000");
253 handshake.RegionInfo.TerrainBase0 = new LLUUID("b8d3965a-ad78-bf43-699b-bff8eca6c975");
254 handshake.RegionInfo.TerrainBase1 = new LLUUID("abb783e6-3e93-26c0-248a-247666855da3");
255 handshake.RegionInfo.TerrainBase2 = new LLUUID("179cdabd-398a-9b6b-1391-4dc333ba321f");
256 handshake.RegionInfo.TerrainBase3 = new LLUUID("beb169c7-11ea-fff2-efe5-0f24dc881df2");
257 handshake.RegionInfo.TerrainDetail0 = new LLUUID("00000000-0000-0000-0000-000000000000");
258 handshake.RegionInfo.TerrainDetail1 = new LLUUID("00000000-0000-0000-0000-000000000000");
259 handshake.RegionInfo.TerrainDetail2 = new LLUUID("00000000-0000-0000-0000-000000000000");
260 handshake.RegionInfo.TerrainDetail3 = new LLUUID("00000000-0000-0000-0000-000000000000");
261 handshake.RegionInfo.CacheID = new LLUUID("545ec0a5-5751-1026-8a0b-216e38a7ab37");
262
263 ServerConsole.MainConsole.Instance.WriteLine("Avatar.cs:SendRegionHandshake() - Sending RegionHandshake packet");
264 this.ControllingClient.OutPacket(handshake);
265 }
266
267 public ImprovedTerseObjectUpdatePacket.ObjectDataBlock CreateTerseBlock()
268 {
269 byte[] bytes = new byte[60];
270 int i=0;
271 ImprovedTerseObjectUpdatePacket.ObjectDataBlock dat = new ImprovedTerseObjectUpdatePacket.ObjectDataBlock();
272
273 dat.TextureEntry = AvatarTemplate.TextureEntry;
274 libsecondlife.LLVector3 pos2 = new LLVector3(this._physActor.Position.X, this._physActor.Position.Y, this._physActor.Position.Z);
275
276 uint ID = this.localid;
277
278 bytes[i++] = (byte)(ID % 256);
279 bytes[i++] = (byte)((ID >> 8) % 256);
280 bytes[i++] = (byte)((ID >> 16) % 256);
281 bytes[i++] = (byte)((ID >> 24) % 256);
282 bytes[i++] = 0;
283 bytes[i++] = 1;
284 i += 14;
285 bytes[i++] = 128;
286 bytes[i++] = 63;
287
288 byte[] pb = pos2.GetBytes();
289 Array.Copy(pb, 0, bytes, i, pb.Length);
290 i += 12;
291 ushort InternVelocityX;
292 ushort InternVelocityY;
293 ushort InternVelocityZ;
294
295 Axiom.MathLib.Vector3 internDirec = new Axiom.MathLib.Vector3(this._physActor.Velocity.X, this._physActor.Velocity.Y, this._physActor.Velocity.Z);
296 internDirec = internDirec /128.0f;
297 internDirec.x += 1;
298 internDirec.y += 1;
299 internDirec.z += 1;
300
301 InternVelocityX = (ushort)(32768 * internDirec.x);
302 InternVelocityY = (ushort)(32768 * internDirec.y);
303 InternVelocityZ = (ushort)(32768 * internDirec.z);
304
305 ushort ac = 32767;
306 bytes[i++] = (byte)(InternVelocityX % 256);
307 bytes[i++] = (byte)((InternVelocityX >> 8) % 256);
308 bytes[i++] = (byte)(InternVelocityY % 256);
309 bytes[i++] = (byte)((InternVelocityY>> 8) % 256);
310 bytes[i++] = (byte)(InternVelocityZ % 256);
311 bytes[i++] = (byte)((InternVelocityZ >> 8) % 256);
312
313 //accel
314 bytes[i++] = (byte)(ac % 256);
315 bytes[i++] = (byte)((ac >> 8) % 256);
316 bytes[i++] = (byte)(ac % 256);
317 bytes[i++] = (byte)((ac >> 8) % 256);
318 bytes[i++] = (byte)(ac % 256);
319 bytes[i++] = (byte)((ac >> 8) % 256);
320
321 //rot
322 bytes[i++] = (byte)(ac % 256);
323 bytes[i++] = (byte)((ac >> 8) % 256);
324 bytes[i++] = (byte)(ac % 256);
325 bytes[i++] = (byte)((ac >> 8) % 256);
326 bytes[i++] = (byte)(ac % 256);
327 bytes[i++] = (byte)((ac >> 8) % 256);
328 bytes[i++] = (byte)(ac % 256);
329 bytes[i++] = (byte)((ac >> 8) % 256);
330
331 //rotation vel
332 bytes[i++] = (byte)(ac % 256);
333 bytes[i++] = (byte)((ac >> 8) % 256);
334 bytes[i++] = (byte)(ac % 256);
335 bytes[i++] = (byte)((ac >> 8) % 256);
336 bytes[i++] = (byte)(ac % 256);
337 bytes[i++] = (byte)((ac >> 8) % 256);
338
339 dat.Data=bytes;
340 return(dat);
341 }
342 }
343
344 public class NewForce
345 {
346 public float X;
347 public float Y;
348 public float Z;
349
350 public NewForce()
351 {
352
353 }
354 }
355}
diff --git a/ConvertToPlugins/src/world/Entity.cs b/ConvertToPlugins/src/world/Entity.cs
new file mode 100644
index 0000000..147478b
--- /dev/null
+++ b/ConvertToPlugins/src/world/Entity.cs
@@ -0,0 +1,62 @@
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}
diff --git a/ConvertToPlugins/src/world/Primitive.cs b/ConvertToPlugins/src/world/Primitive.cs
new file mode 100644
index 0000000..18b5715
--- /dev/null
+++ b/ConvertToPlugins/src/world/Primitive.cs
@@ -0,0 +1,136 @@
1using System;
2using System.Collections.Generic;
3using System.Text;
4using OpenSim.types;
5using libsecondlife;
6using libsecondlife.Packets;
7
8namespace OpenSim.world
9{
10 public class Primitive : Entity
11 {
12 protected float mesh_cutbegin;
13 protected float mesh_cutend;
14 protected PrimData primData;
15 protected bool newPrimFlag;
16 protected ObjectUpdatePacket OurPacket;
17
18 public Primitive()
19 {
20 mesh_cutbegin = 0.0f;
21 mesh_cutend = 1.0f;
22 }
23
24 public override Mesh getMesh()
25 {
26 Mesh mesh = new Mesh();
27 Triangle tri = new Triangle(
28 new Axiom.MathLib.Vector3(0.0f, 1.0f, 1.0f),
29 new Axiom.MathLib.Vector3(1.0f, 0.0f, 1.0f),
30 new Axiom.MathLib.Vector3(1.0f, 1.0f, 0.0f));
31
32 mesh.AddTri(tri);
33 mesh += base.getMesh();
34
35 return mesh;
36 }
37
38 public override void update()
39 {
40 if(this.newPrimFlag)
41 {
42 foreach(OpenSimClient client in OpenSim_Main.sim.ClientThreads.Values) {
43 client.OutPacket(OurPacket);
44 }
45 this.newPrimFlag = false;
46 }
47 }
48
49 public void CreateFromPacket( ObjectAddPacket addPacket, LLUUID agentID, uint localID)
50 {
51 ObjectUpdatePacket objupdate = new ObjectUpdatePacket();
52 objupdate.RegionData.RegionHandle = OpenSim_Main.cfg.RegionHandle;
53 objupdate.RegionData.TimeDilation = 64096;
54
55 objupdate.ObjectData = new libsecondlife.Packets.ObjectUpdatePacket.ObjectDataBlock[1];
56 PrimData PData = new PrimData();
57 this.primData = PData;
58 objupdate.ObjectData[0] = new ObjectUpdatePacket.ObjectDataBlock();//OpenSim_Main.local_world.PrimTemplate;
59 objupdate.ObjectData[0].PSBlock = new byte[0];
60 objupdate.ObjectData[0].ExtraParams = new byte[1];
61 objupdate.ObjectData[0].MediaURL = new byte[0];
62 objupdate.ObjectData[0].NameValue = new byte[0];
63 objupdate.ObjectData[0].PSBlock = new byte[0];
64 objupdate.ObjectData[0].Text = new byte[0];
65 objupdate.ObjectData[0].TextColor = new byte[4];
66 objupdate.ObjectData[0].JointAxisOrAnchor = new LLVector3(0,0,0);
67 objupdate.ObjectData[0].JointPivot = new LLVector3(0,0,0);
68 objupdate.ObjectData[0].Material = 3;
69 objupdate.ObjectData[0].TextureAnim = new byte[0];
70 objupdate.ObjectData[0].Sound = LLUUID.Zero;
71 LLObject.TextureEntry ntex = new LLObject.TextureEntry(new LLUUID("00000000-0000-0000-5005-000000000005"));
72 objupdate.ObjectData[0].TextureEntry = ntex.ToBytes();
73 objupdate.ObjectData[0].State = 0;
74 objupdate.ObjectData[0].Data = new byte[0];
75 PData.OwnerID = objupdate.ObjectData[0].OwnerID = agentID;
76 PData.PCode = objupdate.ObjectData[0].PCode = addPacket.ObjectData.PCode;
77 PData.PathBegin = objupdate.ObjectData[0].PathBegin = addPacket.ObjectData.PathBegin;
78 PData.PathEnd = objupdate.ObjectData[0].PathEnd = addPacket.ObjectData.PathEnd;
79 PData.PathScaleX = objupdate.ObjectData[0].PathScaleX = addPacket.ObjectData.PathScaleX;
80 PData.PathScaleY = objupdate.ObjectData[0].PathScaleY = addPacket.ObjectData.PathScaleY;
81 PData.PathShearX = objupdate.ObjectData[0].PathShearX = addPacket.ObjectData.PathShearX;
82 PData.PathShearY = objupdate.ObjectData[0].PathShearY = addPacket.ObjectData.PathShearY;
83 PData.PathSkew = objupdate.ObjectData[0].PathSkew = addPacket.ObjectData.PathSkew;
84 PData.ProfileBegin = objupdate.ObjectData[0].ProfileBegin = addPacket.ObjectData.ProfileBegin;
85 PData.ProfileEnd = objupdate.ObjectData[0].ProfileEnd = addPacket.ObjectData.ProfileEnd;
86 PData.Scale = objupdate.ObjectData[0].Scale = addPacket.ObjectData.Scale;
87 PData.PathCurve = objupdate.ObjectData[0].PathCurve = addPacket.ObjectData.PathCurve;
88 PData.ProfileCurve = objupdate.ObjectData[0].ProfileCurve = addPacket.ObjectData.ProfileCurve;
89 PData.ParentID = objupdate.ObjectData[0].ParentID = 0;
90 PData.ProfileHollow = objupdate.ObjectData[0].ProfileHollow = addPacket.ObjectData.ProfileHollow;
91 //finish off copying rest of shape data
92
93 objupdate.ObjectData[0].ID = (uint)(localID);
94 objupdate.ObjectData[0].FullID = new LLUUID("edba7151-5857-acc5-b30b-f01efefda" + (localID- 702000).ToString("000"));
95
96 objupdate.ObjectData[0].ObjectData = new byte[60];
97 objupdate.ObjectData[0].ObjectData[46] = 128;
98 objupdate.ObjectData[0].ObjectData[47] = 63;
99 LLVector3 pos1= addPacket.ObjectData.RayEnd;
100 //update position
101 byte[] pb = pos1.GetBytes();
102 Array.Copy(pb, 0, objupdate.ObjectData[0].ObjectData, 0, pb.Length);
103
104 this.newPrimFlag = true;
105 this.uuid = objupdate.ObjectData[0].FullID;
106 this.localid = objupdate.ObjectData[0].ID;
107 this.position = pos1;
108 this.OurPacket = objupdate;
109 }
110 }
111
112 public class PrimData
113 {
114 public LLUUID OwnerID;
115 public byte PCode;
116 public byte PathBegin;
117 public byte PathEnd;
118 public byte PathScaleX;
119 public byte PathScaleY;
120 public byte PathShearX;
121 public byte PathShearY;
122 public sbyte PathSkew;
123 public byte ProfileBegin;
124 public byte ProfileEnd;
125 public LLVector3 Scale;
126 public byte PathCurve;
127 public byte ProfileCurve;
128 public uint ParentID=0;
129 public byte ProfileHollow;
130
131 public PrimData()
132 {
133
134 }
135 }
136}
diff --git a/ConvertToPlugins/src/world/ScriptEngine.cs b/ConvertToPlugins/src/world/ScriptEngine.cs
new file mode 100644
index 0000000..f20a08e
--- /dev/null
+++ b/ConvertToPlugins/src/world/ScriptEngine.cs
@@ -0,0 +1,18 @@
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/ConvertToPlugins/src/world/SurfacePatch.cs b/ConvertToPlugins/src/world/SurfacePatch.cs
new file mode 100644
index 0000000..71e4116
--- /dev/null
+++ b/ConvertToPlugins/src/world/SurfacePatch.cs
@@ -0,0 +1,22 @@
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/ConvertToPlugins/src/world/World.cs b/ConvertToPlugins/src/world/World.cs
new file mode 100644
index 0000000..8427a38
--- /dev/null
+++ b/ConvertToPlugins/src/world/World.cs
@@ -0,0 +1,117 @@
1using System;
2using libsecondlife;
3using libsecondlife.Packets;
4using System.Collections.Generic;
5using System.Text;
6using PhysicsSystem;
7
8namespace OpenSim.world
9{
10 public class World
11 {
12 public Dictionary<libsecondlife.LLUUID, Entity> Entities;
13 public float[] LandMap;
14 public ScriptEngine Scripts;
15 public uint _localNumber=0;
16 private PhysicsScene phyScene;
17 private float timeStep= 0.1f;
18 private libsecondlife.TerrainManager TerrainManager;
19
20 private Random Rand = new Random();
21 private uint _primCount = 702000;
22
23 public World()
24 {
25 ServerConsole.MainConsole.Instance.WriteLine("World.cs - creating new entitities instance");
26 Entities = new Dictionary<libsecondlife.LLUUID, Entity>();
27
28 ServerConsole.MainConsole.Instance.WriteLine("World.cs - creating LandMap");
29 TerrainManager = new TerrainManager(new SecondLife());
30
31 // ServerConsole.MainConsole.Instance.WriteLine("World.cs - Creating script engine instance");
32 // Initialise this only after the world has loaded
33 // Scripts = new ScriptEngine(this);
34 }
35
36 public PhysicsScene PhysScene
37 {
38 set
39 {
40 this.phyScene = value;
41 }
42 get
43 {
44 return(this.phyScene);
45 }
46 }
47
48 public void Update()
49 {
50
51 if(this.phyScene.IsThreaded)
52 {
53 this.phyScene.GetResults();
54
55 }
56
57 foreach (libsecondlife.LLUUID UUID in Entities.Keys)
58 {
59 Entities[UUID].addForces();
60 }
61
62 this.phyScene.Simulate(timeStep);
63
64 foreach (libsecondlife.LLUUID UUID in Entities.Keys)
65 {
66 Entities[UUID].update();
67 }
68 }
69
70 public void SendLayerData(OpenSimClient RemoteClient) {
71 int[] patches = new int[4];
72
73 for (int y = 0; y < 16; y++)
74 {
75 for (int x = 0; x < 16; x = x + 4)
76 {
77 patches[0] = x + 0 + y * 16;
78 patches[1] = x + 1 + y * 16;
79 patches[2] = x + 2 + y * 16;
80 patches[3] = x + 3 + y * 16;
81
82 Packet layerpack = TerrainManager.CreateLandPacket(LandMap, patches);
83 RemoteClient.OutPacket(layerpack);
84 }
85 }
86 }
87
88 public void AddViewerAgent(OpenSimClient AgentClient) {
89 ServerConsole.MainConsole.Instance.WriteLine("World.cs:AddViewerAgent() - Creating new avatar for remote viewer agent");
90 Avatar NewAvatar = new Avatar(AgentClient);
91 ServerConsole.MainConsole.Instance.WriteLine("World.cs:AddViewerAgent() - Adding new avatar to world");
92 ServerConsole.MainConsole.Instance.WriteLine("World.cs:AddViewerAgent() - Starting RegionHandshake ");
93 NewAvatar.SendRegionHandshake(this);
94
95 NewAvatar.PhysActor = this.phyScene.AddAvatar(new PhysicsVector(NewAvatar.position.X, NewAvatar.position.Y, NewAvatar.position.Z));
96 //this.Update(); // will work for now, but needs to be optimised so we don't update everything in the sim for each new user
97 this.Entities.Add(AgentClient.AgentID, NewAvatar);
98 }
99
100 public void AddNewPrim(ObjectAddPacket addPacket, OpenSimClient AgentClient)
101 {
102 ServerConsole.MainConsole.Instance.WriteLine("World.cs: AddNewPrim() - Creating new prim");
103 Primitive prim = new Primitive();
104 prim.CreateFromPacket(addPacket, AgentClient.AgentID, this._primCount);
105 this.Entities.Add(prim.uuid, prim);
106 this._primCount++;
107 }
108
109 public bool Backup() {
110 /* TODO: Save the current world entities state. */
111
112 return false;
113 }
114
115
116 }
117}
diff --git a/ConvertToPlugins/src/world/scripting/IScript.cs b/ConvertToPlugins/src/world/scripting/IScript.cs
new file mode 100644
index 0000000..550594d
--- /dev/null
+++ b/ConvertToPlugins/src/world/scripting/IScript.cs
@@ -0,0 +1,16 @@
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}