aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim.RegionServer
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--OpenSim.RegionServer/OpenSim.RegionServer.csproj6
-rw-r--r--OpenSim.RegionServer/OpenSim.RegionServer.dll.build2
-rw-r--r--OpenSim.RegionServer/world/Avatar.cs287
-rw-r--r--OpenSim.RegionServer/world/AvatarAnimations.cs4
-rw-r--r--OpenSim.RegionServer/world/AvatarClient.cs27
-rw-r--r--OpenSim.RegionServer/world/AvatarUpdate.cs279
-rw-r--r--OpenSim.RegionServer/world/Primitive2.cs66
-rw-r--r--OpenSim.RegionServer/world/World.cs4
8 files changed, 389 insertions, 286 deletions
diff --git a/OpenSim.RegionServer/OpenSim.RegionServer.csproj b/OpenSim.RegionServer/OpenSim.RegionServer.csproj
index 5f396ac..cee91f8 100644
--- a/OpenSim.RegionServer/OpenSim.RegionServer.csproj
+++ b/OpenSim.RegionServer/OpenSim.RegionServer.csproj
@@ -166,6 +166,12 @@
166 <Compile Include="world\AvatarAnimations.cs"> 166 <Compile Include="world\AvatarAnimations.cs">
167 <SubType>Code</SubType> 167 <SubType>Code</SubType>
168 </Compile> 168 </Compile>
169 <Compile Include="world\AvatarClient.cs">
170 <SubType>Code</SubType>
171 </Compile>
172 <Compile Include="world\AvatarUpdate.cs">
173 <SubType>Code</SubType>
174 </Compile>
169 <Compile Include="world\Entity.cs"> 175 <Compile Include="world\Entity.cs">
170 <SubType>Code</SubType> 176 <SubType>Code</SubType>
171 </Compile> 177 </Compile>
diff --git a/OpenSim.RegionServer/OpenSim.RegionServer.dll.build b/OpenSim.RegionServer/OpenSim.RegionServer.dll.build
index cd5fb43..c0289e7 100644
--- a/OpenSim.RegionServer/OpenSim.RegionServer.dll.build
+++ b/OpenSim.RegionServer/OpenSim.RegionServer.dll.build
@@ -29,6 +29,8 @@
29 <include name="types/Triangle.cs" /> 29 <include name="types/Triangle.cs" />
30 <include name="world/Avatar.cs" /> 30 <include name="world/Avatar.cs" />
31 <include name="world/AvatarAnimations.cs" /> 31 <include name="world/AvatarAnimations.cs" />
32 <include name="world/AvatarClient.cs" />
33 <include name="world/AvatarUpdate.cs" />
32 <include name="world/Entity.cs" /> 34 <include name="world/Entity.cs" />
33 <include name="world/Primitive.cs" /> 35 <include name="world/Primitive.cs" />
34 <include name="world/Primitive2.cs" /> 36 <include name="world/Primitive2.cs" />
diff --git a/OpenSim.RegionServer/world/Avatar.cs b/OpenSim.RegionServer/world/Avatar.cs
index be47eda..186fb5c 100644
--- a/OpenSim.RegionServer/world/Avatar.cs
+++ b/OpenSim.RegionServer/world/Avatar.cs
@@ -10,7 +10,7 @@ using Axiom.MathLib;
10 10
11namespace OpenSim.world 11namespace OpenSim.world
12{ 12{
13 public class Avatar : Entity 13 public partial class Avatar : Entity
14 { 14 {
15 public static bool PhysicsEngineFlying = false; 15 public static bool PhysicsEngineFlying = false;
16 public static AvatarAnimations Animations; 16 public static AvatarAnimations Animations;
@@ -32,6 +32,7 @@ namespace OpenSim.world
32 private ulong m_regionHandle; 32 private ulong m_regionHandle;
33 private Dictionary<uint, SimClient> m_clientThreads; 33 private Dictionary<uint, SimClient> m_clientThreads;
34 private string m_regionName; 34 private string m_regionName;
35 private bool childShadowAvatar = false;
35 36
36 public Avatar(SimClient TheClient, World world, string regionName, Dictionary<uint, SimClient> clientThreads, ulong regionHandle) 37 public Avatar(SimClient TheClient, World world, string regionName, Dictionary<uint, SimClient> clientThreads, ulong regionHandle)
37 { 38 {
@@ -95,60 +96,6 @@ namespace OpenSim.world
95 } 96 }
96 } 97 }
97 98
98 public override void update()
99 {
100 libsecondlife.LLVector3 pos2 = new LLVector3(this._physActor.Position.X, this._physActor.Position.Y, this._physActor.Position.Z);
101 if (this.updateflag)
102 {
103 //need to send movement info
104 //so create the improvedterseobjectupdate packet
105 //use CreateTerseBlock()
106 ImprovedTerseObjectUpdatePacket.ObjectDataBlock terseBlock = CreateTerseBlock();
107 ImprovedTerseObjectUpdatePacket terse = new ImprovedTerseObjectUpdatePacket();
108 terse.RegionData.RegionHandle = m_regionHandle; // FIXME
109 terse.RegionData.TimeDilation = 64096;
110 terse.ObjectData = new ImprovedTerseObjectUpdatePacket.ObjectDataBlock[1];
111 terse.ObjectData[0] = terseBlock;
112 foreach (SimClient client in m_clientThreads.Values)
113 {
114 client.OutPacket(terse);
115 }
116
117 updateflag = false;
118 //this._updateCount = 0;
119 }
120 else
121 {
122
123 if ((pos2 != this.positionLastFrame) || (this.movementflag == 16))
124 {
125 _updateCount++;
126 if (((!PhysicsEngineFlying) && (_updateCount > 3)) || (PhysicsEngineFlying) && (_updateCount > 0))
127 {
128 //It has been a while since last update was sent so lets send one.
129 ImprovedTerseObjectUpdatePacket.ObjectDataBlock terseBlock = CreateTerseBlock();
130 ImprovedTerseObjectUpdatePacket terse = new ImprovedTerseObjectUpdatePacket();
131 terse.RegionData.RegionHandle = m_regionHandle; // FIXME
132 terse.RegionData.TimeDilation = 64096;
133 terse.ObjectData = new ImprovedTerseObjectUpdatePacket.ObjectDataBlock[1];
134 terse.ObjectData[0] = terseBlock;
135 foreach (SimClient client in m_clientThreads.Values)
136 {
137 client.OutPacket(terse);
138 }
139 _updateCount = 0;
140 }
141
142 if (this.movementflag == 16)
143 {
144 movementflag = 0;
145 }
146 }
147
148 }
149 this.positionLastFrame = pos2;
150 }
151
152 public static void SetupTemplate(string name) 99 public static void SetupTemplate(string name)
153 { 100 {
154 int i = 0; 101 int i = 0;
@@ -190,128 +137,6 @@ namespace OpenSim.world
190 ControllingClient.OutPacket(mov); 137 ControllingClient.OutPacket(mov);
191 } 138 }
192 139
193 public void SendInitialPosition()
194 {
195
196 System.Text.Encoding _enc = System.Text.Encoding.ASCII;
197 //send a objectupdate packet with information about the clients avatar
198 ObjectUpdatePacket objupdate = new ObjectUpdatePacket();
199 objupdate.RegionData.RegionHandle = m_regionHandle;
200 objupdate.RegionData.TimeDilation = 64096;
201 objupdate.ObjectData = new libsecondlife.Packets.ObjectUpdatePacket.ObjectDataBlock[1];
202
203 objupdate.ObjectData[0] = AvatarTemplate;
204 //give this avatar object a local id and assign the user a name
205 objupdate.ObjectData[0].ID = this.localid;
206 this.uuid = objupdate.ObjectData[0].FullID = ControllingClient.AgentID;
207 objupdate.ObjectData[0].NameValue = _enc.GetBytes("FirstName STRING RW SV " + firstname + "\nLastName STRING RW SV " + lastname + " \0");
208
209 libsecondlife.LLVector3 pos2 = new LLVector3((float)this.Pos.X, (float)this.Pos.Y, (float)this.Pos.Z);
210
211 byte[] pb = pos2.GetBytes();
212
213 Array.Copy(pb, 0, objupdate.ObjectData[0].ObjectData, 16, pb.Length);
214 m_world._localNumber++;
215
216 foreach (SimClient client in m_clientThreads.Values)
217 {
218 client.OutPacket(objupdate);
219 if (client.AgentID != ControllingClient.AgentID)
220 {
221 SendAppearanceToOtherAgent(client);
222 }
223 }
224 //this.ControllingClient.OutPacket(objupdate);
225 }
226
227 public void SendInitialAppearance()
228 {
229 AgentWearablesUpdatePacket aw = new AgentWearablesUpdatePacket();
230 aw.AgentData.AgentID = this.ControllingClient.AgentID;
231 aw.AgentData.SerialNum = 0;
232 aw.AgentData.SessionID = ControllingClient.SessionID;
233
234 aw.WearableData = new AgentWearablesUpdatePacket.WearableDataBlock[13];
235 AgentWearablesUpdatePacket.WearableDataBlock awb;
236 for (int i = 0; i < 13; i++)
237 {
238 awb = new AgentWearablesUpdatePacket.WearableDataBlock();
239 awb.WearableType = (byte)i;
240 awb.AssetID = this.Wearables[i].AssetID;
241 awb.ItemID = this.Wearables[i].ItemID;
242 aw.WearableData[i] = awb;
243 }
244
245 ControllingClient.OutPacket(aw);
246 }
247
248 public ObjectUpdatePacket CreateUpdatePacket()
249 {
250 System.Text.Encoding _enc = System.Text.Encoding.ASCII;
251 //send a objectupdate packet with information about the clients avatar
252 ObjectUpdatePacket objupdate = new ObjectUpdatePacket();
253 objupdate.RegionData.RegionHandle = m_regionHandle;
254 objupdate.RegionData.TimeDilation = 64096;
255 objupdate.ObjectData = new libsecondlife.Packets.ObjectUpdatePacket.ObjectDataBlock[1];
256
257 objupdate.ObjectData[0] = AvatarTemplate;
258 //give this avatar object a local id and assign the user a name
259 objupdate.ObjectData[0].ID = this.localid;
260 objupdate.ObjectData[0].FullID = ControllingClient.AgentID;
261 objupdate.ObjectData[0].NameValue = _enc.GetBytes("FirstName STRING RW SV " + firstname + "\nLastName STRING RW SV " + lastname + " \0");
262
263 libsecondlife.LLVector3 pos2 = new LLVector3((float)this._physActor.Position.X, (float)this._physActor.Position.Y, (float)this._physActor.Position.Z);
264
265 byte[] pb = pos2.GetBytes();
266
267 Array.Copy(pb, 0, objupdate.ObjectData[0].ObjectData, 16, pb.Length);
268 return objupdate;
269 }
270
271 public void SendAppearanceToOtherAgent(SimClient userInfo)
272 {
273 AvatarAppearancePacket avp = new AvatarAppearancePacket();
274
275
276 avp.VisualParam = new AvatarAppearancePacket.VisualParamBlock[218];
277 //avp.ObjectData.TextureEntry=this.avatar_template.TextureEntry;// br.ReadBytes((int)numBytes);
278
279 //LLObject.TextureEntry ntex = new LLObject.TextureEntry(new LLUUID("00000000-0000-0000-0000-000000000005"));
280 //avp.ObjectData.TextureEntry = ntex.ToBytes();
281 avp.ObjectData.TextureEntry = this.avatarAppearanceTexture.ToBytes();
282
283 AvatarAppearancePacket.VisualParamBlock avblock = null;
284 for (int i = 0; i < 218; i++)
285 {
286 avblock = new AvatarAppearancePacket.VisualParamBlock();
287 avblock.ParamValue = visualParams[i];
288 avp.VisualParam[i] = avblock;
289 }
290
291 avp.Sender.IsTrial = false;
292 avp.Sender.ID = ControllingClient.AgentID;
293 userInfo.OutPacket(avp);
294
295 }
296 public void SetAppearance(AgentSetAppearancePacket appear)
297 {
298 LLObject.TextureEntry tex = new LLObject.TextureEntry(appear.ObjectData.TextureEntry, 0, appear.ObjectData.TextureEntry.Length);
299 this.avatarAppearanceTexture = tex;
300 for (int i = 0; i < appear.VisualParam.Length; i++)
301 {
302 this.visualParams[i] = appear.VisualParam[i].ParamValue;
303 }
304
305 foreach (SimClient client in m_clientThreads.Values)
306 {
307 if (client.AgentID != ControllingClient.AgentID)
308 {
309 SendAppearanceToOtherAgent(client);
310 }
311 }
312 }
313
314
315 public void HandleUpdate(AgentUpdatePacket pack) 140 public void HandleUpdate(AgentUpdatePacket pack)
316 { 141 {
317 if (((uint)pack.AgentData.ControlFlags & (uint)MainAvatar.AgentUpdateFlags.AGENT_CONTROL_FLY) != 0) 142 if (((uint)pack.AgentData.ControlFlags & (uint)MainAvatar.AgentUpdateFlags.AGENT_CONTROL_FLY) != 0)
@@ -323,7 +148,7 @@ namespace OpenSim.world
323 this.SendAnimPack(); 148 this.SendAnimPack();
324 } 149 }
325 this._physActor.Flying = true; 150 this._physActor.Flying = true;
326 151
327 } 152 }
328 else 153 else
329 { 154 {
@@ -462,28 +287,7 @@ namespace OpenSim.world
462 } 287 }
463 } 288 }
464 289
465 // Sends animation update 290 //really really should be moved somewhere else
466 public void SendAnimPack()
467 {
468 AvatarAnimationPacket ani = new AvatarAnimationPacket();
469 ani.AnimationSourceList = new AvatarAnimationPacket.AnimationSourceListBlock[1];
470 ani.AnimationSourceList[0] = new AvatarAnimationPacket.AnimationSourceListBlock();
471 ani.AnimationSourceList[0].ObjectID = ControllingClient.AgentID;
472 ani.Sender = new AvatarAnimationPacket.SenderBlock();
473 ani.Sender.ID = ControllingClient.AgentID;
474 ani.AnimationList = new AvatarAnimationPacket.AnimationListBlock[1];
475 ani.AnimationList[0] = new AvatarAnimationPacket.AnimationListBlock();
476 ani.AnimationList[0].AnimID = this.current_anim;
477 ani.AnimationList[0].AnimSequenceID = this.anim_seq;
478
479 //ControllingClient.OutPacket(ani);
480 foreach (SimClient client in m_clientThreads.Values)
481 {
482 client.OutPacket(ani);
483 }
484 }
485
486 //should be moved somewhere else
487 public void SendRegionHandshake(World RegionInfo) 291 public void SendRegionHandshake(World RegionInfo)
488 { 292 {
489 OpenSim.Framework.Console.MainConsole.Instance.WriteLine("Avatar.cs:SendRegionHandshake() - Creating empty RegionHandshake packet"); 293 OpenSim.Framework.Console.MainConsole.Instance.WriteLine("Avatar.cs:SendRegionHandshake() - Creating empty RegionHandshake packet");
@@ -520,89 +324,6 @@ namespace OpenSim.world
520 this.ControllingClient.OutPacket(handshake); 324 this.ControllingClient.OutPacket(handshake);
521 } 325 }
522 326
523 public ImprovedTerseObjectUpdatePacket.ObjectDataBlock CreateTerseBlock()
524 {
525 byte[] bytes = new byte[60];
526 int i = 0;
527 ImprovedTerseObjectUpdatePacket.ObjectDataBlock dat = new ImprovedTerseObjectUpdatePacket.ObjectDataBlock();
528
529 dat.TextureEntry = new byte[0];// AvatarTemplate.TextureEntry;
530 libsecondlife.LLVector3 pos2 = new LLVector3(0, 0, 0);
531 lock (m_world.LockPhysicsEngine)
532 {
533 pos2 = new LLVector3(this._physActor.Position.X, this._physActor.Position.Y, this._physActor.Position.Z);
534 }
535
536 uint ID = this.localid;
537
538 bytes[i++] = (byte)(ID % 256);
539 bytes[i++] = (byte)((ID >> 8) % 256);
540 bytes[i++] = (byte)((ID >> 16) % 256);
541 bytes[i++] = (byte)((ID >> 24) % 256);
542 bytes[i++] = 0;
543 bytes[i++] = 1;
544 i += 14;
545 bytes[i++] = 128;
546 bytes[i++] = 63;
547
548 byte[] pb = pos2.GetBytes();
549 Array.Copy(pb, 0, bytes, i, pb.Length);
550 i += 12;
551 ushort InternVelocityX;
552 ushort InternVelocityY;
553 ushort InternVelocityZ;
554 Axiom.MathLib.Vector3 internDirec = new Axiom.MathLib.Vector3(0, 0, 0);
555 lock (m_world.LockPhysicsEngine)
556 {
557 internDirec = new Axiom.MathLib.Vector3(this._physActor.Velocity.X, this._physActor.Velocity.Y, this._physActor.Velocity.Z);
558 }
559 internDirec = internDirec / 128.0f;
560 internDirec.x += 1;
561 internDirec.y += 1;
562 internDirec.z += 1;
563
564 InternVelocityX = (ushort)(32768 * internDirec.x);
565 InternVelocityY = (ushort)(32768 * internDirec.y);
566 InternVelocityZ = (ushort)(32768 * internDirec.z);
567
568 ushort ac = 32767;
569 bytes[i++] = (byte)(InternVelocityX % 256);
570 bytes[i++] = (byte)((InternVelocityX >> 8) % 256);
571 bytes[i++] = (byte)(InternVelocityY % 256);
572 bytes[i++] = (byte)((InternVelocityY >> 8) % 256);
573 bytes[i++] = (byte)(InternVelocityZ % 256);
574 bytes[i++] = (byte)((InternVelocityZ >> 8) % 256);
575
576 //accel
577 bytes[i++] = (byte)(ac % 256);
578 bytes[i++] = (byte)((ac >> 8) % 256);
579 bytes[i++] = (byte)(ac % 256);
580 bytes[i++] = (byte)((ac >> 8) % 256);
581 bytes[i++] = (byte)(ac % 256);
582 bytes[i++] = (byte)((ac >> 8) % 256);
583
584 //rot
585 bytes[i++] = (byte)(ac % 256);
586 bytes[i++] = (byte)((ac >> 8) % 256);
587 bytes[i++] = (byte)(ac % 256);
588 bytes[i++] = (byte)((ac >> 8) % 256);
589 bytes[i++] = (byte)(ac % 256);
590 bytes[i++] = (byte)((ac >> 8) % 256);
591 bytes[i++] = (byte)(ac % 256);
592 bytes[i++] = (byte)((ac >> 8) % 256);
593
594 //rotation vel
595 bytes[i++] = (byte)(ac % 256);
596 bytes[i++] = (byte)((ac >> 8) % 256);
597 bytes[i++] = (byte)(ac % 256);
598 bytes[i++] = (byte)((ac >> 8) % 256);
599 bytes[i++] = (byte)(ac % 256);
600 bytes[i++] = (byte)((ac >> 8) % 256);
601
602 dat.Data = bytes;
603 return (dat);
604 }
605
606 public static void LoadAnims() 327 public static void LoadAnims()
607 { 328 {
608 Avatar.Animations = new AvatarAnimations(); 329 Avatar.Animations = new AvatarAnimations();
diff --git a/OpenSim.RegionServer/world/AvatarAnimations.cs b/OpenSim.RegionServer/world/AvatarAnimations.cs
index eea29de..36c4c7e 100644
--- a/OpenSim.RegionServer/world/AvatarAnimations.cs
+++ b/OpenSim.RegionServer/world/AvatarAnimations.cs
@@ -10,8 +10,7 @@ namespace OpenSim.world
10 10
11 public Dictionary<string, LLUUID> AnimsLLUUID = new Dictionary<string, LLUUID>(); 11 public Dictionary<string, LLUUID> AnimsLLUUID = new Dictionary<string, LLUUID>();
12 public Dictionary<LLUUID, string> AnimsNames = new Dictionary<LLUUID, string>(); 12 public Dictionary<LLUUID, string> AnimsNames = new Dictionary<LLUUID, string>();
13 13
14
15 public AvatarAnimations() 14 public AvatarAnimations()
16 { 15 {
17 } 16 }
@@ -155,7 +154,6 @@ namespace OpenSim.world
155 AnimsLLUUID.Add("ANIM_AGENT_YES_HAPPY", new LLUUID("b8c8b2a3-9008-1771-3bfc-90924955ab2d")); 154 AnimsLLUUID.Add("ANIM_AGENT_YES_HAPPY", new LLUUID("b8c8b2a3-9008-1771-3bfc-90924955ab2d"));
156 AnimsLLUUID.Add("ANIM_AGENT_YOGA_FLOAT", new LLUUID("42ecd00b-9947-a97c-400a-bbc9174c7aeb")); 155 AnimsLLUUID.Add("ANIM_AGENT_YOGA_FLOAT", new LLUUID("42ecd00b-9947-a97c-400a-bbc9174c7aeb"));
157 156
158
159 foreach (KeyValuePair<string, LLUUID> kp in OpenSim.world.Avatar.Animations.AnimsLLUUID) 157 foreach (KeyValuePair<string, LLUUID> kp in OpenSim.world.Avatar.Animations.AnimsLLUUID)
160 { 158 {
161 AnimsNames.Add(kp.Value, kp.Key); 159 AnimsNames.Add(kp.Value, kp.Key);
diff --git a/OpenSim.RegionServer/world/AvatarClient.cs b/OpenSim.RegionServer/world/AvatarClient.cs
new file mode 100644
index 0000000..bad8761
--- /dev/null
+++ b/OpenSim.RegionServer/world/AvatarClient.cs
@@ -0,0 +1,27 @@
1using System;
2using System.Collections.Generic;
3using System.Text;
4using libsecondlife.Packets;
5
6namespace OpenSim.world
7{
8 partial class Avatar
9 {
10 private List<ImprovedTerseObjectUpdatePacket.ObjectDataBlock> updateList = new List<ImprovedTerseObjectUpdatePacket.ObjectDataBlock>();
11
12 public void SendPacketToViewer(Packet packet)
13 {
14 this.ControllingClient.OutPacket(packet);
15 }
16
17 public void AddTerseUpdateToViewersList(ImprovedTerseObjectUpdatePacket.ObjectDataBlock terseBlock)
18 {
19
20 }
21
22 public void SendUpdateListToViewer()
23 {
24
25 }
26 }
27}
diff --git a/OpenSim.RegionServer/world/AvatarUpdate.cs b/OpenSim.RegionServer/world/AvatarUpdate.cs
new file mode 100644
index 0000000..d20ba28
--- /dev/null
+++ b/OpenSim.RegionServer/world/AvatarUpdate.cs
@@ -0,0 +1,279 @@
1using System;
2using System.Collections.Generic;
3using System.Text;
4using libsecondlife;
5using libsecondlife.Packets;
6
7namespace OpenSim.world
8{
9 partial class Avatar
10 {
11 public override void update()
12 {
13 libsecondlife.LLVector3 pos2 = new LLVector3(this._physActor.Position.X, this._physActor.Position.Y, this._physActor.Position.Z);
14 if (this.updateflag)
15 {
16 //need to send movement info
17 //so create the improvedterseobjectupdate packet
18 //use CreateTerseBlock()
19 ImprovedTerseObjectUpdatePacket.ObjectDataBlock terseBlock = CreateTerseBlock();
20 ImprovedTerseObjectUpdatePacket terse = new ImprovedTerseObjectUpdatePacket();
21 terse.RegionData.RegionHandle = m_regionHandle; // FIXME
22 terse.RegionData.TimeDilation = 64096;
23 terse.ObjectData = new ImprovedTerseObjectUpdatePacket.ObjectDataBlock[1];
24 terse.ObjectData[0] = terseBlock;
25 foreach (SimClient client in m_clientThreads.Values)
26 {
27 client.OutPacket(terse);
28 }
29
30 updateflag = false;
31 //this._updateCount = 0;
32 }
33 else
34 {
35
36 if ((pos2 != this.positionLastFrame) || (this.movementflag == 16))
37 {
38 _updateCount++;
39 if (((!PhysicsEngineFlying) && (_updateCount > 3)) || (PhysicsEngineFlying) && (_updateCount > 0))
40 {
41 //It has been a while since last update was sent so lets send one.
42 ImprovedTerseObjectUpdatePacket.ObjectDataBlock terseBlock = CreateTerseBlock();
43 ImprovedTerseObjectUpdatePacket terse = new ImprovedTerseObjectUpdatePacket();
44 terse.RegionData.RegionHandle = m_regionHandle; // FIXME
45 terse.RegionData.TimeDilation = 64096;
46 terse.ObjectData = new ImprovedTerseObjectUpdatePacket.ObjectDataBlock[1];
47 terse.ObjectData[0] = terseBlock;
48 foreach (SimClient client in m_clientThreads.Values)
49 {
50 client.OutPacket(terse);
51 }
52 _updateCount = 0;
53 }
54
55 if (this.movementflag == 16)
56 {
57 movementflag = 0;
58 }
59 }
60
61 }
62 this.positionLastFrame = pos2;
63 }
64
65 public ObjectUpdatePacket CreateUpdatePacket()
66 {
67 System.Text.Encoding _enc = System.Text.Encoding.ASCII;
68 //send a objectupdate packet with information about the clients avatar
69 ObjectUpdatePacket objupdate = new ObjectUpdatePacket();
70 objupdate.RegionData.RegionHandle = m_regionHandle;
71 objupdate.RegionData.TimeDilation = 64096;
72 objupdate.ObjectData = new libsecondlife.Packets.ObjectUpdatePacket.ObjectDataBlock[1];
73
74 objupdate.ObjectData[0] = AvatarTemplate;
75 //give this avatar object a local id and assign the user a name
76 objupdate.ObjectData[0].ID = this.localid;
77 objupdate.ObjectData[0].FullID = ControllingClient.AgentID;
78 objupdate.ObjectData[0].NameValue = _enc.GetBytes("FirstName STRING RW SV " + firstname + "\nLastName STRING RW SV " + lastname + " \0");
79
80 libsecondlife.LLVector3 pos2 = new LLVector3((float)this._physActor.Position.X, (float)this._physActor.Position.Y, (float)this._physActor.Position.Z);
81
82 byte[] pb = pos2.GetBytes();
83
84 Array.Copy(pb, 0, objupdate.ObjectData[0].ObjectData, 16, pb.Length);
85 return objupdate;
86 }
87
88 public void SendInitialPosition()
89 {
90 System.Text.Encoding _enc = System.Text.Encoding.ASCII;
91 //send a objectupdate packet with information about the clients avatar
92 ObjectUpdatePacket objupdate = new ObjectUpdatePacket();
93 objupdate.RegionData.RegionHandle = m_regionHandle;
94 objupdate.RegionData.TimeDilation = 64096;
95 objupdate.ObjectData = new libsecondlife.Packets.ObjectUpdatePacket.ObjectDataBlock[1];
96
97 objupdate.ObjectData[0] = AvatarTemplate;
98 //give this avatar object a local id and assign the user a name
99 objupdate.ObjectData[0].ID = this.localid;
100 this.uuid = objupdate.ObjectData[0].FullID = ControllingClient.AgentID;
101 objupdate.ObjectData[0].NameValue = _enc.GetBytes("FirstName STRING RW SV " + firstname + "\nLastName STRING RW SV " + lastname + " \0");
102 libsecondlife.LLVector3 pos2 = new LLVector3((float)this.Pos.X, (float)this.Pos.Y, (float)this.Pos.Z);
103 byte[] pb = pos2.GetBytes();
104 Array.Copy(pb, 0, objupdate.ObjectData[0].ObjectData, 16, pb.Length);
105 m_world._localNumber++;
106
107 foreach (SimClient client in m_clientThreads.Values)
108 {
109 client.OutPacket(objupdate);
110 if (client.AgentID != ControllingClient.AgentID)
111 {
112 SendAppearanceToOtherAgent(client);
113 }
114 }
115 }
116
117 public void SendInitialAppearance()
118 {
119 AgentWearablesUpdatePacket aw = new AgentWearablesUpdatePacket();
120 aw.AgentData.AgentID = this.ControllingClient.AgentID;
121 aw.AgentData.SerialNum = 0;
122 aw.AgentData.SessionID = ControllingClient.SessionID;
123
124 aw.WearableData = new AgentWearablesUpdatePacket.WearableDataBlock[13];
125 AgentWearablesUpdatePacket.WearableDataBlock awb;
126 for (int i = 0; i < 13; i++)
127 {
128 awb = new AgentWearablesUpdatePacket.WearableDataBlock();
129 awb.WearableType = (byte)i;
130 awb.AssetID = this.Wearables[i].AssetID;
131 awb.ItemID = this.Wearables[i].ItemID;
132 aw.WearableData[i] = awb;
133 }
134
135 ControllingClient.OutPacket(aw);
136 }
137
138 public void SendAppearanceToOtherAgent(SimClient userInfo)
139 {
140 AvatarAppearancePacket avp = new AvatarAppearancePacket();
141 avp.VisualParam = new AvatarAppearancePacket.VisualParamBlock[218];
142 avp.ObjectData.TextureEntry = this.avatarAppearanceTexture.ToBytes();
143
144 AvatarAppearancePacket.VisualParamBlock avblock = null;
145 for (int i = 0; i < 218; i++)
146 {
147 avblock = new AvatarAppearancePacket.VisualParamBlock();
148 avblock.ParamValue = visualParams[i];
149 avp.VisualParam[i] = avblock;
150 }
151
152 avp.Sender.IsTrial = false;
153 avp.Sender.ID = ControllingClient.AgentID;
154 userInfo.OutPacket(avp);
155 }
156
157 public void SetAppearance(AgentSetAppearancePacket appear)
158 {
159 LLObject.TextureEntry tex = new LLObject.TextureEntry(appear.ObjectData.TextureEntry, 0, appear.ObjectData.TextureEntry.Length);
160 this.avatarAppearanceTexture = tex;
161 for (int i = 0; i < appear.VisualParam.Length; i++)
162 {
163 this.visualParams[i] = appear.VisualParam[i].ParamValue;
164 }
165 foreach (SimClient client in m_clientThreads.Values)
166 {
167 if (client.AgentID != ControllingClient.AgentID)
168 {
169 SendAppearanceToOtherAgent(client);
170 }
171 }
172 }
173
174 public ImprovedTerseObjectUpdatePacket.ObjectDataBlock CreateTerseBlock()
175 {
176 byte[] bytes = new byte[60];
177 int i = 0;
178 ImprovedTerseObjectUpdatePacket.ObjectDataBlock dat = new ImprovedTerseObjectUpdatePacket.ObjectDataBlock();
179
180 dat.TextureEntry = new byte[0];// AvatarTemplate.TextureEntry;
181 libsecondlife.LLVector3 pos2 = new LLVector3(0, 0, 0);
182 lock (m_world.LockPhysicsEngine)
183 {
184 pos2 = new LLVector3(this._physActor.Position.X, this._physActor.Position.Y, this._physActor.Position.Z);
185 }
186
187 uint ID = this.localid;
188
189 bytes[i++] = (byte)(ID % 256);
190 bytes[i++] = (byte)((ID >> 8) % 256);
191 bytes[i++] = (byte)((ID >> 16) % 256);
192 bytes[i++] = (byte)((ID >> 24) % 256);
193 bytes[i++] = 0;
194 bytes[i++] = 1;
195 i += 14;
196 bytes[i++] = 128;
197 bytes[i++] = 63;
198
199 byte[] pb = pos2.GetBytes();
200 Array.Copy(pb, 0, bytes, i, pb.Length);
201 i += 12;
202 ushort InternVelocityX;
203 ushort InternVelocityY;
204 ushort InternVelocityZ;
205 Axiom.MathLib.Vector3 internDirec = new Axiom.MathLib.Vector3(0, 0, 0);
206 lock (m_world.LockPhysicsEngine)
207 {
208 internDirec = new Axiom.MathLib.Vector3(this._physActor.Velocity.X, this._physActor.Velocity.Y, this._physActor.Velocity.Z);
209 }
210 internDirec = internDirec / 128.0f;
211 internDirec.x += 1;
212 internDirec.y += 1;
213 internDirec.z += 1;
214
215 InternVelocityX = (ushort)(32768 * internDirec.x);
216 InternVelocityY = (ushort)(32768 * internDirec.y);
217 InternVelocityZ = (ushort)(32768 * internDirec.z);
218
219 ushort ac = 32767;
220 bytes[i++] = (byte)(InternVelocityX % 256);
221 bytes[i++] = (byte)((InternVelocityX >> 8) % 256);
222 bytes[i++] = (byte)(InternVelocityY % 256);
223 bytes[i++] = (byte)((InternVelocityY >> 8) % 256);
224 bytes[i++] = (byte)(InternVelocityZ % 256);
225 bytes[i++] = (byte)((InternVelocityZ >> 8) % 256);
226
227 //accel
228 bytes[i++] = (byte)(ac % 256);
229 bytes[i++] = (byte)((ac >> 8) % 256);
230 bytes[i++] = (byte)(ac % 256);
231 bytes[i++] = (byte)((ac >> 8) % 256);
232 bytes[i++] = (byte)(ac % 256);
233 bytes[i++] = (byte)((ac >> 8) % 256);
234
235 //rot
236 bytes[i++] = (byte)(ac % 256);
237 bytes[i++] = (byte)((ac >> 8) % 256);
238 bytes[i++] = (byte)(ac % 256);
239 bytes[i++] = (byte)((ac >> 8) % 256);
240 bytes[i++] = (byte)(ac % 256);
241 bytes[i++] = (byte)((ac >> 8) % 256);
242 bytes[i++] = (byte)(ac % 256);
243 bytes[i++] = (byte)((ac >> 8) % 256);
244
245 //rotation vel
246 bytes[i++] = (byte)(ac % 256);
247 bytes[i++] = (byte)((ac >> 8) % 256);
248 bytes[i++] = (byte)(ac % 256);
249 bytes[i++] = (byte)((ac >> 8) % 256);
250 bytes[i++] = (byte)(ac % 256);
251 bytes[i++] = (byte)((ac >> 8) % 256);
252
253 dat.Data = bytes;
254 return (dat);
255 }
256
257 // Sends animation update
258 public void SendAnimPack()
259 {
260 AvatarAnimationPacket ani = new AvatarAnimationPacket();
261 ani.AnimationSourceList = new AvatarAnimationPacket.AnimationSourceListBlock[1];
262 ani.AnimationSourceList[0] = new AvatarAnimationPacket.AnimationSourceListBlock();
263 ani.AnimationSourceList[0].ObjectID = ControllingClient.AgentID;
264 ani.Sender = new AvatarAnimationPacket.SenderBlock();
265 ani.Sender.ID = ControllingClient.AgentID;
266 ani.AnimationList = new AvatarAnimationPacket.AnimationListBlock[1];
267 ani.AnimationList[0] = new AvatarAnimationPacket.AnimationListBlock();
268 ani.AnimationList[0].AnimID = this.current_anim;
269 ani.AnimationList[0].AnimSequenceID = this.anim_seq;
270
271 //ControllingClient.OutPacket(ani);
272 foreach (SimClient client in m_clientThreads.Values)
273 {
274 client.OutPacket(ani);
275 }
276 }
277
278 }
279}
diff --git a/OpenSim.RegionServer/world/Primitive2.cs b/OpenSim.RegionServer/world/Primitive2.cs
index 87a1d65..4a19040 100644
--- a/OpenSim.RegionServer/world/Primitive2.cs
+++ b/OpenSim.RegionServer/world/Primitive2.cs
@@ -169,6 +169,72 @@ namespace OpenSim.world
169 169
170 } 170 }
171 171
172 public void CreateFromPacket(ObjectAddPacket addPacket, LLUUID agentID, uint localID)
173 {
174 ObjectUpdatePacket objupdate = new ObjectUpdatePacket();
175 objupdate.RegionData.RegionHandle = m_regionHandle;
176 objupdate.RegionData.TimeDilation = 64096;
177
178 objupdate.ObjectData = new libsecondlife.Packets.ObjectUpdatePacket.ObjectDataBlock[1];
179 PrimData PData = new PrimData();
180 this.primData = PData;
181 this.primData.CreationDate = (Int32)(DateTime.UtcNow - new DateTime(1970, 1, 1)).TotalSeconds;
182
183 objupdate.ObjectData[0] = new ObjectUpdatePacket.ObjectDataBlock();
184 objupdate.ObjectData[0].PSBlock = new byte[0];
185 objupdate.ObjectData[0].ExtraParams = new byte[1];
186 objupdate.ObjectData[0].MediaURL = new byte[0];
187 objupdate.ObjectData[0].NameValue = new byte[0];
188 objupdate.ObjectData[0].Text = new byte[0];
189 objupdate.ObjectData[0].TextColor = new byte[4];
190 objupdate.ObjectData[0].JointAxisOrAnchor = new LLVector3(0, 0, 0);
191 objupdate.ObjectData[0].JointPivot = new LLVector3(0, 0, 0);
192 objupdate.ObjectData[0].Material = 3;
193 objupdate.ObjectData[0].UpdateFlags = 32 + 65536 + 131072 + 256 + 4 + 8 + 2048 + 524288 + 268435456;
194 objupdate.ObjectData[0].TextureAnim = new byte[0];
195 objupdate.ObjectData[0].Sound = LLUUID.Zero;
196 LLObject.TextureEntry ntex = new LLObject.TextureEntry(new LLUUID("00000000-0000-0000-5005-000000000005"));
197 this.primData.Texture = objupdate.ObjectData[0].TextureEntry = ntex.ToBytes();
198 objupdate.ObjectData[0].State = 0;
199 objupdate.ObjectData[0].Data = new byte[0];
200 PData.OwnerID = objupdate.ObjectData[0].OwnerID = agentID;
201 PData.PCode = objupdate.ObjectData[0].PCode = addPacket.ObjectData.PCode;
202 PData.PathBegin = objupdate.ObjectData[0].PathBegin = addPacket.ObjectData.PathBegin;
203 PData.PathEnd = objupdate.ObjectData[0].PathEnd = addPacket.ObjectData.PathEnd;
204 PData.PathScaleX = objupdate.ObjectData[0].PathScaleX = addPacket.ObjectData.PathScaleX;
205 PData.PathScaleY = objupdate.ObjectData[0].PathScaleY = addPacket.ObjectData.PathScaleY;
206 PData.PathShearX = objupdate.ObjectData[0].PathShearX = addPacket.ObjectData.PathShearX;
207 PData.PathShearY = objupdate.ObjectData[0].PathShearY = addPacket.ObjectData.PathShearY;
208 PData.PathSkew = objupdate.ObjectData[0].PathSkew = addPacket.ObjectData.PathSkew;
209 PData.ProfileBegin = objupdate.ObjectData[0].ProfileBegin = addPacket.ObjectData.ProfileBegin;
210 PData.ProfileEnd = objupdate.ObjectData[0].ProfileEnd = addPacket.ObjectData.ProfileEnd;
211 PData.Scale = objupdate.ObjectData[0].Scale = addPacket.ObjectData.Scale;
212 PData.PathCurve = objupdate.ObjectData[0].PathCurve = addPacket.ObjectData.PathCurve;
213 PData.ProfileCurve = objupdate.ObjectData[0].ProfileCurve = addPacket.ObjectData.ProfileCurve;
214 PData.ParentID = objupdate.ObjectData[0].ParentID = 0;
215 PData.ProfileHollow = objupdate.ObjectData[0].ProfileHollow = addPacket.ObjectData.ProfileHollow;
216 PData.PathRadiusOffset = objupdate.ObjectData[0].PathRadiusOffset = addPacket.ObjectData.PathRadiusOffset;
217 PData.PathRevolutions = objupdate.ObjectData[0].PathRevolutions = addPacket.ObjectData.PathRevolutions;
218 PData.PathTaperX = objupdate.ObjectData[0].PathTaperX = addPacket.ObjectData.PathTaperX;
219 PData.PathTaperY = objupdate.ObjectData[0].PathTaperY = addPacket.ObjectData.PathTaperY;
220 PData.PathTwist = objupdate.ObjectData[0].PathTwist = addPacket.ObjectData.PathTwist;
221 PData.PathTwistBegin = objupdate.ObjectData[0].PathTwistBegin = addPacket.ObjectData.PathTwistBegin;
222 objupdate.ObjectData[0].ID = (uint)(localID);
223 objupdate.ObjectData[0].FullID = new LLUUID("edba7151-5857-acc5-b30b-f01efef" + (localID - 702000).ToString("00000"));
224 objupdate.ObjectData[0].ObjectData = new byte[60];
225 objupdate.ObjectData[0].ObjectData[46] = 128;
226 objupdate.ObjectData[0].ObjectData[47] = 63;
227 LLVector3 pos1 = addPacket.ObjectData.RayEnd;
228 //update position
229 byte[] pb = pos1.GetBytes();
230 Array.Copy(pb, 0, objupdate.ObjectData[0].ObjectData, 0, pb.Length);
231 //this.newPrimFlag = true;
232 this.primData.FullID = this.uuid = objupdate.ObjectData[0].FullID;
233 this.localid = objupdate.ObjectData[0].ID;
234 this.primData.Position = this.Pos = pos1;
235 this.OurPacket = objupdate;
236 }
237
172 public void SendFullUpdateToClient(SimClient RemoteClient) 238 public void SendFullUpdateToClient(SimClient RemoteClient)
173 { 239 {
174 240
diff --git a/OpenSim.RegionServer/world/World.cs b/OpenSim.RegionServer/world/World.cs
index b6f71aa..4661a90 100644
--- a/OpenSim.RegionServer/world/World.cs
+++ b/OpenSim.RegionServer/world/World.cs
@@ -21,6 +21,8 @@ namespace OpenSim.world
21 { 21 {
22 public object LockPhysicsEngine = new object(); 22 public object LockPhysicsEngine = new object();
23 public Dictionary<libsecondlife.LLUUID, Entity> Entities; 23 public Dictionary<libsecondlife.LLUUID, Entity> Entities;
24 public Dictionary<libsecondlife.LLUUID, Avatar> Avatars;
25 public Dictionary<libsecondlife.LLUUID, Primitive> Prims;
24 public float[] LandMap; 26 public float[] LandMap;
25 public ScriptEngine Scripts; 27 public ScriptEngine Scripts;
26 public uint _localNumber = 0; 28 public uint _localNumber = 0;
@@ -50,6 +52,8 @@ namespace OpenSim.world
50 52
51 OpenSim.Framework.Console.MainConsole.Instance.WriteLine("World.cs - creating new entitities instance"); 53 OpenSim.Framework.Console.MainConsole.Instance.WriteLine("World.cs - creating new entitities instance");
52 Entities = new Dictionary<libsecondlife.LLUUID, Entity>(); 54 Entities = new Dictionary<libsecondlife.LLUUID, Entity>();
55 Avatars = new Dictionary<LLUUID, Avatar>();
56 Prims = new Dictionary<LLUUID, Primitive>();
53 57
54 OpenSim.Framework.Console.MainConsole.Instance.WriteLine("World.cs - creating LandMap"); 58 OpenSim.Framework.Console.MainConsole.Instance.WriteLine("World.cs - creating LandMap");
55 TerrainManager = new TerrainManager(new SecondLife()); 59 TerrainManager = new TerrainManager(new SecondLife());