diff options
Diffstat (limited to 'OpenSim.RegionServer/world/Avatar.cs')
-rw-r--r-- | OpenSim.RegionServer/world/Avatar.cs | 287 |
1 files changed, 4 insertions, 283 deletions
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 | ||
11 | namespace OpenSim.world | 11 | namespace 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(); |