diff options
author | gareth | 2007-03-07 18:48:38 +0000 |
---|---|---|
committer | gareth | 2007-03-07 18:48:38 +0000 |
commit | b3844c1f7348b4296b5ab1df258935d7f971e412 (patch) | |
tree | 4b825dc642cb6eb9a060e54bf8d69288fbee4904 /src/world | |
parent | * Updating libsecondlife.dll to the latest version with a working LayerData f... (diff) | |
download | opensim-SC-b3844c1f7348b4296b5ab1df258935d7f971e412.zip opensim-SC-b3844c1f7348b4296b5ab1df258935d7f971e412.tar.gz opensim-SC-b3844c1f7348b4296b5ab1df258935d7f971e412.tar.bz2 opensim-SC-b3844c1f7348b4296b5ab1df258935d7f971e412.tar.xz |
Deleted old trunk code
Diffstat (limited to 'src/world')
-rw-r--r-- | src/world/Avatar.cs | 256 | ||||
-rw-r--r-- | src/world/Entity.cs | 65 | ||||
-rw-r--r-- | src/world/HeightmapGenHills.cs | 122 | ||||
-rw-r--r-- | src/world/PhysicsEngine.cs | 32 | ||||
-rw-r--r-- | src/world/Primitive.cs | 33 | ||||
-rw-r--r-- | src/world/ScriptEngine.cs | 18 | ||||
-rw-r--r-- | src/world/SurfacePatch.cs | 22 | ||||
-rw-r--r-- | src/world/World.cs | 112 | ||||
-rw-r--r-- | src/world/scripting/IScript.cs | 16 |
9 files changed, 0 insertions, 676 deletions
diff --git a/src/world/Avatar.cs b/src/world/Avatar.cs deleted file mode 100644 index 9d8d7d2..0000000 --- a/src/world/Avatar.cs +++ /dev/null | |||
@@ -1,256 +0,0 @@ | |||
1 | using System; | ||
2 | using System.Collections.Generic; | ||
3 | using System.IO; | ||
4 | using System.Text; | ||
5 | using libsecondlife; | ||
6 | using libsecondlife.Packets; | ||
7 | using Axiom.MathLib; | ||
8 | |||
9 | namespace OpenSim.world | ||
10 | { | ||
11 | public class Avatar : Entity | ||
12 | { | ||
13 | public string firstname; | ||
14 | public string lastname; | ||
15 | public OpenSimClient ControllingClient; | ||
16 | public LLVector3 oldvel; | ||
17 | public LLVector3 oldpos; | ||
18 | public uint CurrentKeyMask; | ||
19 | public bool walking; | ||
20 | |||
21 | private libsecondlife.Packets.ObjectUpdatePacket.ObjectDataBlock AvatarTemplate; | ||
22 | |||
23 | public Avatar(OpenSimClient TheClient) { | ||
24 | OpenSim_Main.localcons.WriteLine("Avatar.cs - Loading details from grid (DUMMY)"); | ||
25 | ControllingClient=TheClient; | ||
26 | SetupTemplate("avatar-template.dat"); | ||
27 | |||
28 | position = new LLVector3(100.0f,100.0f,60.0f); | ||
29 | } | ||
30 | |||
31 | public override void update() { | ||
32 | lock(this) { | ||
33 | base.update(); | ||
34 | |||
35 | oldvel=this.velocity; | ||
36 | oldpos=this.position; | ||
37 | if((this.CurrentKeyMask & (uint)MainAvatar.AgentUpdateFlags.AGENT_CONTROL_AT_POS) != 0) { | ||
38 | Vector3 tmpVelocity = this.rotation * new Vector3(1.0f,0.0f,0.0f); | ||
39 | tmpVelocity.Normalize(); tmpVelocity = tmpVelocity * 0.5f; | ||
40 | this.velocity.X = tmpVelocity.x; | ||
41 | this.velocity.Y = tmpVelocity.y; | ||
42 | this.velocity.Z = tmpVelocity.z; | ||
43 | this.walking=true; | ||
44 | } else { | ||
45 | this.velocity.X=0; | ||
46 | this.velocity.Y=0; | ||
47 | this.velocity.Z=0; | ||
48 | this.walking=false; | ||
49 | } | ||
50 | } | ||
51 | } | ||
52 | |||
53 | private void SetupTemplate(string name) | ||
54 | { | ||
55 | |||
56 | int i = 0; | ||
57 | FileInfo fInfo = new FileInfo(name); | ||
58 | long numBytes = fInfo.Length; | ||
59 | FileStream fStream = new FileStream(name, FileMode.Open, FileAccess.Read); | ||
60 | BinaryReader br = new BinaryReader(fStream); | ||
61 | byte [] data1 = br.ReadBytes((int)numBytes); | ||
62 | br.Close(); | ||
63 | fStream.Close(); | ||
64 | |||
65 | libsecondlife.Packets.ObjectUpdatePacket.ObjectDataBlock objdata = new libsecondlife.Packets.ObjectUpdatePacket.ObjectDataBlock(data1, ref i); | ||
66 | |||
67 | System.Text.Encoding enc = System.Text.Encoding.ASCII; | ||
68 | libsecondlife.LLVector3 pos = new LLVector3(objdata.ObjectData, 16); | ||
69 | pos.X = 100f; | ||
70 | objdata.ID = this.localid; | ||
71 | objdata.NameValue = enc.GetBytes("FirstName STRING RW SV Test \nLastName STRING RW SV User \0"); | ||
72 | libsecondlife.LLVector3 pos2 = new LLVector3(100f,100f,23f); | ||
73 | //objdata.FullID=user.AgentID; | ||
74 | byte[] pb = pos.GetBytes(); | ||
75 | Array.Copy(pb, 0, objdata.ObjectData, 16, pb.Length); | ||
76 | |||
77 | AvatarTemplate = objdata; | ||
78 | |||
79 | } | ||
80 | |||
81 | public void CompleteMovement(World RegionInfo) { | ||
82 | OpenSim_Main.localcons.WriteLine("Avatar.cs:CompleteMovement() - Constructing AgentMovementComplete packet"); | ||
83 | AgentMovementCompletePacket mov = new AgentMovementCompletePacket(); | ||
84 | mov.AgentData.SessionID = this.ControllingClient.SessionID; | ||
85 | mov.AgentData.AgentID = this.ControllingClient.AgentID; | ||
86 | mov.Data.RegionHandle = OpenSim_Main.cfg.RegionHandle; | ||
87 | // TODO - dynamicalise this stuff | ||
88 | mov.Data.Timestamp = 1172750370; | ||
89 | mov.Data.Position = new LLVector3((float)this.position.X, (float)this.position.Y, (float)this.position.Z); | ||
90 | mov.Data.LookAt = new LLVector3(0.99f, 0.042f, 0); | ||
91 | |||
92 | OpenSim_Main.localcons.WriteLine("Sending AgentMovementComplete packet"); | ||
93 | ControllingClient.OutPacket(mov); | ||
94 | } | ||
95 | |||
96 | public void SendInitialPosition() { | ||
97 | System.Text.Encoding _enc = System.Text.Encoding.ASCII; | ||
98 | |||
99 | |||
100 | //send a objectupdate packet with information about the clients avatar | ||
101 | ObjectUpdatePacket objupdate = new ObjectUpdatePacket(); | ||
102 | objupdate.RegionData.RegionHandle = OpenSim_Main.cfg.RegionHandle; | ||
103 | objupdate.RegionData.TimeDilation = 64096; | ||
104 | objupdate.ObjectData = new libsecondlife.Packets.ObjectUpdatePacket.ObjectDataBlock[1]; | ||
105 | |||
106 | objupdate.ObjectData[0] = AvatarTemplate; | ||
107 | //give this avatar object a local id and assign the user a name | ||
108 | objupdate.ObjectData[0].ID = this.localid; | ||
109 | //User_info.name="Test"+this.local_numer+" User"; | ||
110 | objupdate.ObjectData[0].FullID = ControllingClient.AgentID; | ||
111 | objupdate.ObjectData[0].NameValue = _enc.GetBytes("FirstName STRING RW SV " + firstname + "\nLastName STRING RW SV " + lastname + " \0"); | ||
112 | |||
113 | libsecondlife.LLVector3 pos2 = new LLVector3((float)this.position.X, (float)this.position.Y, (float)this.position.Z); | ||
114 | |||
115 | byte[] pb = pos2.GetBytes(); | ||
116 | |||
117 | Array.Copy(pb, 0, objupdate.ObjectData[0].ObjectData, 16, pb.Length); | ||
118 | OpenSim_Main.local_world._localNumber++; | ||
119 | this.ControllingClient.OutPacket(objupdate); | ||
120 | } | ||
121 | |||
122 | public override ImprovedTerseObjectUpdatePacket.ObjectDataBlock CreateTerseBlock() { | ||
123 | byte[] bytes = new byte[60]; | ||
124 | int i=0; | ||
125 | ImprovedTerseObjectUpdatePacket.ObjectDataBlock dat = new ImprovedTerseObjectUpdatePacket.ObjectDataBlock(); | ||
126 | |||
127 | dat.TextureEntry = AvatarTemplate.TextureEntry; | ||
128 | libsecondlife.LLVector3 pos2 = new LLVector3(this.position.X, this.position.Y, this.position.Z); | ||
129 | |||
130 | uint ID = this.localid; | ||
131 | bytes[i++] = (byte)(ID % 256); | ||
132 | bytes[i++] = (byte)((ID >> 8) % 256); | ||
133 | bytes[i++] = (byte)((ID >> 16) % 256); | ||
134 | bytes[i++] = (byte)((ID >> 24) % 256); | ||
135 | bytes[i++] = 0; | ||
136 | bytes[i++] = 1; | ||
137 | i += 14; | ||
138 | bytes[i++] = 128; | ||
139 | bytes[i++] = 63; | ||
140 | |||
141 | byte[] pb = pos2.GetBytes(); | ||
142 | Array.Copy(pb, 0, bytes, i, pb.Length); | ||
143 | i += 12; | ||
144 | |||
145 | |||
146 | ushort ac = 32767; | ||
147 | bytes[i++] = (byte)((ushort)(((this.velocity.X/128f)+1)*32767) % 256 ); | ||
148 | bytes[i++] = (byte)(((ushort)(((this.velocity.X/128f)+1)*32767) >> 8) % 256); | ||
149 | bytes[i++] = (byte)((ushort)(((this.velocity.Y/128f)+1)*32767) % 256); | ||
150 | bytes[i++] = (byte)(((ushort)(((this.velocity.Y/128f)+1)*32767) >> 8) % 256); | ||
151 | bytes[i++] = (byte)((ushort)(((this.velocity.Z/128f)+1)*32767) % 256); | ||
152 | bytes[i++] = (byte)(((ushort)(((this.velocity.Z/128f)+1)*32767) >> 8) % 256); | ||
153 | |||
154 | |||
155 | |||
156 | |||
157 | //accel | ||
158 | bytes[i++] = (byte)(ac % 256); | ||
159 | bytes[i++] = (byte)((ac >> 8) % 256); | ||
160 | bytes[i++] = (byte)(ac % 256); | ||
161 | bytes[i++] = (byte)((ac >> 8) % 256); | ||
162 | bytes[i++] = (byte)(ac % 256); | ||
163 | bytes[i++] = (byte)((ac >> 8) % 256); | ||
164 | |||
165 | //rot | ||
166 | bytes[i++] = (byte)(ac % 256); | ||
167 | bytes[i++] = (byte)((ac >> 8) % 256); | ||
168 | bytes[i++] = (byte)(ac % 256); | ||
169 | bytes[i++] = (byte)((ac >> 8) % 256); | ||
170 | bytes[i++] = (byte)(ac % 256); | ||
171 | bytes[i++] = (byte)((ac >> 8) % 256); | ||
172 | bytes[i++] = (byte)(ac % 256); | ||
173 | bytes[i++] = (byte)((ac >> 8) % 256); | ||
174 | |||
175 | //rotation vel | ||
176 | bytes[i++] = (byte)(ac % 256); | ||
177 | bytes[i++] = (byte)((ac >> 8) % 256); | ||
178 | bytes[i++] = (byte)(ac % 256); | ||
179 | bytes[i++] = (byte)((ac >> 8) % 256); | ||
180 | bytes[i++] = (byte)(ac % 256); | ||
181 | bytes[i++] = (byte)((ac >> 8) % 256); | ||
182 | |||
183 | dat.Data=bytes; | ||
184 | return(dat); | ||
185 | |||
186 | } | ||
187 | |||
188 | public void SendInitialAppearance() { | ||
189 | AgentWearablesUpdatePacket aw = new AgentWearablesUpdatePacket(); | ||
190 | aw.AgentData.AgentID = this.ControllingClient.AgentID; | ||
191 | aw.AgentData.SerialNum = 0; | ||
192 | aw.AgentData.SessionID = ControllingClient.SessionID; | ||
193 | |||
194 | aw.WearableData = new AgentWearablesUpdatePacket.WearableDataBlock[13]; | ||
195 | AgentWearablesUpdatePacket.WearableDataBlock awb = new AgentWearablesUpdatePacket.WearableDataBlock(); | ||
196 | awb.WearableType = (byte)0; | ||
197 | awb.AssetID = new LLUUID("66c41e39-38f9-f75a-024e-585989bfab73"); | ||
198 | awb.ItemID = LLUUID.Random(); | ||
199 | aw.WearableData[0] = awb; | ||
200 | |||
201 | for(int i=1; i<13; i++) { | ||
202 | awb = new AgentWearablesUpdatePacket.WearableDataBlock(); | ||
203 | awb.WearableType = (byte)i; | ||
204 | awb.AssetID = new LLUUID("00000000-0000-0000-0000-000000000000"); | ||
205 | awb.ItemID = new LLUUID("00000000-0000-0000-0000-000000000000"); | ||
206 | aw.WearableData[i] = awb; | ||
207 | } | ||
208 | |||
209 | ControllingClient.OutPacket(aw); | ||
210 | } | ||
211 | |||
212 | public void SendRegionHandshake(World RegionInfo) { | ||
213 | OpenSim_Main.localcons.WriteLine("Avatar.cs:SendRegionHandshake() - Creating empty RegionHandshake packet"); | ||
214 | System.Text.Encoding _enc = System.Text.Encoding.ASCII; | ||
215 | RegionHandshakePacket handshake = new RegionHandshakePacket(); | ||
216 | |||
217 | OpenSim_Main.localcons.WriteLine("Avatar.cs:SendRegionhandshake() - Filling in RegionHandshake details"); | ||
218 | handshake.RegionInfo.BillableFactor = 0; | ||
219 | handshake.RegionInfo.IsEstateManager = false; | ||
220 | handshake.RegionInfo.TerrainHeightRange00 = 60; | ||
221 | handshake.RegionInfo.TerrainHeightRange01 = 60; | ||
222 | handshake.RegionInfo.TerrainHeightRange10 = 60; | ||
223 | handshake.RegionInfo.TerrainHeightRange11 = 60; | ||
224 | handshake.RegionInfo.TerrainStartHeight00 = 10; | ||
225 | handshake.RegionInfo.TerrainStartHeight01 = 10; | ||
226 | handshake.RegionInfo.TerrainStartHeight10 = 10; | ||
227 | handshake.RegionInfo.TerrainStartHeight11 = 10; | ||
228 | handshake.RegionInfo.SimAccess = 13; | ||
229 | handshake.RegionInfo.WaterHeight = 20.0f; | ||
230 | handshake.RegionInfo.RegionFlags = 72458694; // TODO: WTF sirs? Use an enum! | ||
231 | handshake.RegionInfo.SimName = _enc.GetBytes(OpenSim_Main.cfg.RegionName + "\0"); | ||
232 | handshake.RegionInfo.SimOwner = new LLUUID("00000000-0000-0000-0000-000000000000"); | ||
233 | handshake.RegionInfo.TerrainBase0 = new LLUUID("b8d3965a-ad78-bf43-699b-bff8eca6c975"); | ||
234 | handshake.RegionInfo.TerrainBase1 = new LLUUID("abb783e6-3e93-26c0-248a-247666855da3"); | ||
235 | handshake.RegionInfo.TerrainBase2 = new LLUUID("179cdabd-398a-9b6b-1391-4dc333ba321f"); | ||
236 | handshake.RegionInfo.TerrainBase3 = new LLUUID("beb169c7-11ea-fff2-efe5-0f24dc881df2"); | ||
237 | handshake.RegionInfo.TerrainDetail0 = new LLUUID("00000000-0000-0000-0000-000000000000"); | ||
238 | handshake.RegionInfo.TerrainDetail1 = new LLUUID("00000000-0000-0000-0000-000000000000"); | ||
239 | handshake.RegionInfo.TerrainDetail2 = new LLUUID("00000000-0000-0000-0000-000000000000"); | ||
240 | handshake.RegionInfo.TerrainDetail3 = new LLUUID("00000000-0000-0000-0000-000000000000"); | ||
241 | handshake.RegionInfo.CacheID = new LLUUID("545ec0a5-5751-1026-8a0b-216e38a7ab37"); | ||
242 | |||
243 | OpenSim_Main.localcons.WriteLine("Avatar.cs:SendRegionHandshake() - Sending RegionHandshake packet"); | ||
244 | this.ControllingClient.OutPacket(handshake); | ||
245 | } | ||
246 | |||
247 | public void HandleAgentUpdate(AgentUpdatePacket update) { | ||
248 | lock(this) { | ||
249 | this.CurrentKeyMask = update.AgentData.ControlFlags; | ||
250 | this.rotation = new Quaternion(update.AgentData.BodyRotation.W, update.AgentData.BodyRotation.X, update.AgentData.BodyRotation.Y, update.AgentData.BodyRotation.Z); | ||
251 | this.needupdate = true; | ||
252 | } | ||
253 | } | ||
254 | |||
255 | } | ||
256 | } | ||
diff --git a/src/world/Entity.cs b/src/world/Entity.cs deleted file mode 100644 index 7880a46..0000000 --- a/src/world/Entity.cs +++ /dev/null | |||
@@ -1,65 +0,0 @@ | |||
1 | using System; | ||
2 | using System.Collections.Generic; | ||
3 | using System.Text; | ||
4 | using Axiom.MathLib; | ||
5 | using libsecondlife; | ||
6 | using OpenSim.types; | ||
7 | using libsecondlife.Packets; | ||
8 | |||
9 | namespace OpenSim.world | ||
10 | { | ||
11 | public class Entity | ||
12 | { | ||
13 | protected libsecondlife.LLUUID uuid; | ||
14 | protected uint localid; | ||
15 | public LLVector3 position; | ||
16 | public LLVector3 velocity; | ||
17 | protected Quaternion rotation; | ||
18 | protected string name; | ||
19 | protected List<Entity> children; | ||
20 | public bool needupdate; | ||
21 | |||
22 | public Entity() | ||
23 | { | ||
24 | uuid = new libsecondlife.LLUUID(); | ||
25 | localid = 8880000 + (OpenSim_Main.local_world._localNumber++); // FIXME - race condition! | ||
26 | position = new LLVector3(); | ||
27 | velocity = new LLVector3(); | ||
28 | rotation = new Quaternion(); | ||
29 | name = "(basic entity)"; | ||
30 | children = new List<Entity>(); | ||
31 | } | ||
32 | |||
33 | public virtual void update() { | ||
34 | // Do any per-frame updates needed that are applicable to every type of entity | ||
35 | foreach (Entity child in children) | ||
36 | { | ||
37 | if(child.needupdate) | ||
38 | child.update(); | ||
39 | } | ||
40 | this.needupdate=false; | ||
41 | } | ||
42 | |||
43 | public virtual ImprovedTerseObjectUpdatePacket.ObjectDataBlock CreateTerseBlock() { | ||
44 | return null; | ||
45 | } | ||
46 | |||
47 | |||
48 | public virtual string getName() | ||
49 | { | ||
50 | return name; | ||
51 | } | ||
52 | |||
53 | public virtual Mesh getMesh() | ||
54 | { | ||
55 | Mesh mesh = new Mesh(); | ||
56 | |||
57 | foreach (Entity child in children) | ||
58 | { | ||
59 | mesh += child.getMesh(); | ||
60 | } | ||
61 | |||
62 | return mesh; | ||
63 | } | ||
64 | } | ||
65 | } | ||
diff --git a/src/world/HeightmapGenHills.cs b/src/world/HeightmapGenHills.cs deleted file mode 100644 index 12af005..0000000 --- a/src/world/HeightmapGenHills.cs +++ /dev/null | |||
@@ -1,122 +0,0 @@ | |||
1 | using System; | ||
2 | |||
3 | namespace libsecondlife | ||
4 | { | ||
5 | public class HeightmapGenHills | ||
6 | { | ||
7 | private Random Rand = new Random(); | ||
8 | private int NumHills; | ||
9 | private float HillMin; | ||
10 | private float HillMax; | ||
11 | private bool Island; | ||
12 | private float[] heightmap; | ||
13 | |||
14 | public float[] GenerateHeightmap(int numHills, float hillMin, float hillMax, bool island) | ||
15 | { | ||
16 | NumHills = numHills; | ||
17 | HillMin = hillMin; | ||
18 | HillMax = hillMax; | ||
19 | Island = island; | ||
20 | |||
21 | heightmap = new float[256 * 256]; | ||
22 | |||
23 | for (int i = 0; i < numHills; i++) | ||
24 | { | ||
25 | AddHill(); | ||
26 | } | ||
27 | |||
28 | Normalize(); | ||
29 | |||
30 | return heightmap; | ||
31 | } | ||
32 | |||
33 | private void AddHill() | ||
34 | { | ||
35 | float x, y; | ||
36 | float radius = RandomRange(HillMin, HillMax); | ||
37 | |||
38 | if (Island) | ||
39 | { | ||
40 | // Which direction from the center of the map the hill is placed | ||
41 | float theta = RandomRange(0, 6.28f); | ||
42 | |||
43 | // How far from the center of the map to place the hill. The radius | ||
44 | // is subtracted from the range to prevent any part of the hill from | ||
45 | // reaching the edge of the map | ||
46 | float distance = RandomRange(radius / 2.0f, 128.0f - radius); | ||
47 | |||
48 | x = 128.0f + (float)Math.Cos(theta) * distance; | ||
49 | y = 128.0f + (float)Math.Sin(theta) * distance; | ||
50 | } | ||
51 | else | ||
52 | { | ||
53 | x = RandomRange(-radius, 256.0f + radius); | ||
54 | y = RandomRange(-radius, 256.0f + radius); | ||
55 | } | ||
56 | |||
57 | float radiusSq = radius * radius; | ||
58 | float distSq; | ||
59 | float height; | ||
60 | |||
61 | int xMin = (int)(x - radius) - 1; | ||
62 | int xMax = (int)(x + radius) + 1; | ||
63 | if (xMin < 0) xMin = 0; | ||
64 | if (xMax > 255) xMax = 255; | ||
65 | |||
66 | int yMin = (int)(y - radius) - 1; | ||
67 | int yMax = (int)(y + radius) + 1; | ||
68 | if (yMin < 0) yMin = 0; | ||
69 | if (yMax > 255) yMax = 255; | ||
70 | |||
71 | // Loop through each affected cell and determine the height at that point | ||
72 | for (int v = yMin; v <= yMax; ++v) | ||
73 | { | ||
74 | float fv = (float)v; | ||
75 | |||
76 | for (int h = xMin; h <= xMax; ++h) | ||
77 | { | ||
78 | float fh = (float)h; | ||
79 | |||
80 | // Determine how far from the center of this hill this point is | ||
81 | distSq = (x - fh) * (x - fh) + (y - fv) * (y - fv); | ||
82 | height = radiusSq - distSq; | ||
83 | |||
84 | // Don't add negative hill values | ||
85 | if (height > 0.0f) heightmap[h + v * 256] += height; | ||
86 | } | ||
87 | } | ||
88 | } | ||
89 | |||
90 | private void Normalize() | ||
91 | { | ||
92 | float min = heightmap[0]; | ||
93 | float max = heightmap[0]; | ||
94 | |||
95 | for (int x = 0; x < 256; x++) | ||
96 | { | ||
97 | for (int y = 0; y < 256; y++) | ||
98 | { | ||
99 | if (heightmap[x + y * 256] < min) min = heightmap[x + y * 256]; | ||
100 | if (heightmap[x + y * 256] > max) max = heightmap[x + y * 256]; | ||
101 | } | ||
102 | } | ||
103 | |||
104 | // Avoid a rare divide by zero | ||
105 | if (min != max) | ||
106 | { | ||
107 | for (int x = 0; x < 256; x++) | ||
108 | { | ||
109 | for (int y = 0; y < 256; y++) | ||
110 | { | ||
111 | heightmap[x + y * 256] = ((heightmap[x + y * 256] - min) / (max - min)) * (HillMax - HillMin); | ||
112 | } | ||
113 | } | ||
114 | } | ||
115 | } | ||
116 | |||
117 | private float RandomRange(float min, float max) | ||
118 | { | ||
119 | return (float)Rand.NextDouble() * (max - min) + min; | ||
120 | } | ||
121 | } | ||
122 | } | ||
diff --git a/src/world/PhysicsEngine.cs b/src/world/PhysicsEngine.cs deleted file mode 100644 index b237f5e..0000000 --- a/src/world/PhysicsEngine.cs +++ /dev/null | |||
@@ -1,32 +0,0 @@ | |||
1 | using System; | ||
2 | using System.Threading; | ||
3 | using libsecondlife; | ||
4 | using libsecondlife.Packets; | ||
5 | using System.Collections.Generic; | ||
6 | using System.Text; | ||
7 | |||
8 | namespace OpenSim.world | ||
9 | { | ||
10 | public class PhysicsEngine | ||
11 | { | ||
12 | |||
13 | public PhysicsEngine() { | ||
14 | } | ||
15 | |||
16 | public void Startup() { | ||
17 | OpenSim_Main.localcons.WriteLine("PhysicsEngine.cs:Startup() - DOING NOTHING, DUMMY FUNCTION!"); | ||
18 | } | ||
19 | |||
20 | public void DoStuff(World simworld) { | ||
21 | foreach (libsecondlife.LLUUID UUID in simworld.Entities.Keys) | ||
22 | { | ||
23 | simworld.Entities[UUID].position += simworld.Entities[UUID].velocity; | ||
24 | simworld.Entities[UUID].position.Z = simworld.LandMap[(int)simworld.Entities[UUID].position.Y * 256 + (int)simworld.Entities[UUID].position.X]+1; | ||
25 | if(simworld.Entities[UUID].position.X<0) simworld.Entities[UUID].position.X=0; | ||
26 | if(simworld.Entities[UUID].position.Y<0) simworld.Entities[UUID].position.Y=0; | ||
27 | if(simworld.Entities[UUID].position.X>255) simworld.Entities[UUID].position.X=255; | ||
28 | if(simworld.Entities[UUID].position.Y>255) simworld.Entities[UUID].position.Y=255; | ||
29 | } | ||
30 | } | ||
31 | } | ||
32 | } | ||
diff --git a/src/world/Primitive.cs b/src/world/Primitive.cs deleted file mode 100644 index 143fa55..0000000 --- a/src/world/Primitive.cs +++ /dev/null | |||
@@ -1,33 +0,0 @@ | |||
1 | using System; | ||
2 | using System.Collections.Generic; | ||
3 | using System.Text; | ||
4 | using OpenSim.types; | ||
5 | |||
6 | namespace OpenSim.world | ||
7 | { | ||
8 | public class Primitive : Entity | ||
9 | { | ||
10 | protected float mesh_cutbegin; | ||
11 | protected float mesh_cutend; | ||
12 | |||
13 | public Primitive() | ||
14 | { | ||
15 | mesh_cutbegin = 0.0f; | ||
16 | mesh_cutend = 1.0f; | ||
17 | } | ||
18 | |||
19 | public override Mesh getMesh() | ||
20 | { | ||
21 | Mesh mesh = new Mesh(); | ||
22 | Triangle tri = new Triangle( | ||
23 | new Axiom.MathLib.Vector3(0.0f, 1.0f, 1.0f), | ||
24 | new Axiom.MathLib.Vector3(1.0f, 0.0f, 1.0f), | ||
25 | new Axiom.MathLib.Vector3(1.0f, 1.0f, 0.0f)); | ||
26 | |||
27 | mesh.AddTri(tri); | ||
28 | mesh += base.getMesh(); | ||
29 | |||
30 | return mesh; | ||
31 | } | ||
32 | } | ||
33 | } | ||
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 @@ | |||
1 | using System; | ||
2 | using System.Collections.Generic; | ||
3 | using System.Text; | ||
4 | |||
5 | namespace 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 @@ | |||
1 | using System; | ||
2 | using System.Collections.Generic; | ||
3 | using System.Text; | ||
4 | |||
5 | namespace 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 158ddc2..0000000 --- a/src/world/World.cs +++ /dev/null | |||
@@ -1,112 +0,0 @@ | |||
1 | using System; | ||
2 | using System.Threading; | ||
3 | using System.Collections.Generic; | ||
4 | using System.Text; | ||
5 | using libsecondlife; | ||
6 | using libsecondlife.Packets; | ||
7 | |||
8 | namespace 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 | public PhysicsEngine physics; | ||
17 | |||
18 | private libsecondlife.TerrainManager TerrainManager; | ||
19 | private Random Rand = new Random(); | ||
20 | |||
21 | public World() | ||
22 | { | ||
23 | OpenSim_Main.localcons.WriteLine("World.cs - creating new entitities instance"); | ||
24 | Entities = new Dictionary<libsecondlife.LLUUID, Entity>(); | ||
25 | |||
26 | OpenSim_Main.localcons.WriteLine("World.cs - creating LandMap"); | ||
27 | TerrainManager = new TerrainManager(new SecondLife()); | ||
28 | } | ||
29 | |||
30 | public void InitLoop() | ||
31 | { | ||
32 | OpenSim_Main.localcons.WriteLine("World.cs:StartLoop() - Initialising physics"); | ||
33 | this.physics = new PhysicsEngine(); | ||
34 | physics.Startup(); | ||
35 | } | ||
36 | |||
37 | public void DoStuff() | ||
38 | { | ||
39 | lock (this) | ||
40 | { | ||
41 | physics.DoStuff(this); | ||
42 | this.Update(); | ||
43 | } | ||
44 | } | ||
45 | |||
46 | public void Update() | ||
47 | { | ||
48 | foreach (libsecondlife.LLUUID UUID in Entities.Keys) | ||
49 | { | ||
50 | if (Entities[UUID].needupdate) | ||
51 | { | ||
52 | Entities[UUID].update(); | ||
53 | |||
54 | if (Entities[UUID] is Avatar) | ||
55 | { | ||
56 | Avatar avatar = (Avatar)Entities[UUID]; | ||
57 | if ((avatar.oldpos != avatar.position) || (avatar.oldvel != avatar.velocity) || avatar.walking) | ||
58 | { | ||
59 | ImprovedTerseObjectUpdatePacket.ObjectDataBlock terseBlock = Entities[UUID].CreateTerseBlock(); | ||
60 | foreach (OpenSimClient client in OpenSim_Main.sim.ClientThreads.Values) | ||
61 | { | ||
62 | ImprovedTerseObjectUpdatePacket terse = new ImprovedTerseObjectUpdatePacket(); | ||
63 | terse.RegionData.RegionHandle = OpenSim_Main.cfg.RegionHandle; // FIXME | ||
64 | terse.RegionData.TimeDilation = 0; | ||
65 | terse.ObjectData = new ImprovedTerseObjectUpdatePacket.ObjectDataBlock[1]; | ||
66 | terse.ObjectData[0] = terseBlock; | ||
67 | client.OutPacket(terse); | ||
68 | } | ||
69 | } | ||
70 | } | ||
71 | } | ||
72 | } | ||
73 | } | ||
74 | |||
75 | public void SendLayerData(OpenSimClient RemoteClient) | ||
76 | { | ||
77 | int[] patches = new int[4]; | ||
78 | |||
79 | for (int y = 0; y < 16; y++) | ||
80 | { | ||
81 | for (int x = 0; x < 16; x = x + 4) | ||
82 | { | ||
83 | patches[0] = x + 0 + y * 16; | ||
84 | patches[1] = x + 1 + y * 16; | ||
85 | patches[2] = x + 2 + y * 16; | ||
86 | patches[3] = x + 3 + y * 16; | ||
87 | |||
88 | Packet layerpack = TerrainManager.CreateLandPacket(LandMap, patches); | ||
89 | RemoteClient.OutPacket(layerpack); | ||
90 | } | ||
91 | } | ||
92 | } | ||
93 | |||
94 | public void AddViewerAgent(OpenSimClient AgentClient) | ||
95 | { | ||
96 | OpenSim_Main.localcons.WriteLine("World.cs:AddViewerAgent() - Creating new avatar for remote viewer agent"); | ||
97 | Avatar NewAvatar = new Avatar(AgentClient); | ||
98 | OpenSim_Main.localcons.WriteLine("World.cs:AddViewerAgent() - Adding new avatar to world"); | ||
99 | this.Entities.Add(AgentClient.AgentID, NewAvatar); | ||
100 | OpenSim_Main.localcons.WriteLine("World.cs:AddViewerAgent() - Starting RegionHandshake "); | ||
101 | NewAvatar.SendRegionHandshake(this); | ||
102 | this.Update(); // will work for now, but needs to be optimised so we don't update everything in the sim for each new user | ||
103 | } | ||
104 | |||
105 | public bool Backup() | ||
106 | { | ||
107 | /* TODO: Save the current world entities state. */ | ||
108 | |||
109 | return false; | ||
110 | } | ||
111 | } | ||
112 | } | ||
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 @@ | |||
1 | using System; | ||
2 | using System.Collections.Generic; | ||
3 | using System.Text; | ||
4 | |||
5 | namespace 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 | } | ||