aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim-Source/OpenSim.RegionServer/world/Avatar.cs
diff options
context:
space:
mode:
authorMW2007-05-24 12:35:32 +0000
committerMW2007-05-24 12:35:32 +0000
commitf95b6081cba084d1b067acea99c0effa2b3bf42c (patch)
tree7a7ab4aa037f75afa54f403c701a735acb101575 /OpenSim-Source/OpenSim.RegionServer/world/Avatar.cs
parentDie ServiceManager! (Not really Gareth, just the old directory, new directory... (diff)
downloadopensim-SC_OLD-f95b6081cba084d1b067acea99c0effa2b3bf42c.zip
opensim-SC_OLD-f95b6081cba084d1b067acea99c0effa2b3bf42c.tar.gz
opensim-SC_OLD-f95b6081cba084d1b067acea99c0effa2b3bf42c.tar.bz2
opensim-SC_OLD-f95b6081cba084d1b067acea99c0effa2b3bf42c.tar.xz
Renamed the new Directories. (removed the "-Source" from the end of them)
Diffstat (limited to 'OpenSim-Source/OpenSim.RegionServer/world/Avatar.cs')
-rw-r--r--OpenSim-Source/OpenSim.RegionServer/world/Avatar.cs418
1 files changed, 0 insertions, 418 deletions
diff --git a/OpenSim-Source/OpenSim.RegionServer/world/Avatar.cs b/OpenSim-Source/OpenSim.RegionServer/world/Avatar.cs
deleted file mode 100644
index 680d059..0000000
--- a/OpenSim-Source/OpenSim.RegionServer/world/Avatar.cs
+++ /dev/null
@@ -1,418 +0,0 @@
1using System;
2using System.Collections.Generic;
3using System.IO;
4using System.Text;
5using libsecondlife;
6using libsecondlife.Packets;
7using OpenSim.Physics.Manager;
8using OpenSim.Framework.Inventory;
9using OpenSim.Framework.Interfaces;
10using Axiom.MathLib;
11
12namespace OpenSim.world
13{
14 public partial class Avatar : Entity
15 {
16 public static bool PhysicsEngineFlying = false;
17 public static AvatarAnimations Animations;
18 public string firstname;
19 public string lastname;
20 public ClientView ControllingClient;
21 public LLUUID current_anim;
22 public int anim_seq;
23 private static libsecondlife.Packets.ObjectUpdatePacket.ObjectDataBlock AvatarTemplate;
24 private bool updateflag = false;
25 private byte movementflag = 0;
26 private List<NewForce> forcesList = new List<NewForce>();
27 private short _updateCount = 0;
28 private Axiom.MathLib.Quaternion bodyRot;
29 private LLObject.TextureEntry avatarAppearanceTexture = null;
30 private byte[] visualParams;
31 private AvatarWearable[] Wearables;
32 private LLVector3 positionLastFrame = new LLVector3(0, 0, 0);
33 private ulong m_regionHandle;
34 //private Dictionary<uint, ClientView> m_clientThreads;
35 private string m_regionName;
36 private ushort m_regionWaterHeight;
37 private bool m_regionTerraform;
38 //private bool childShadowAvatar = false;
39
40 public Avatar(ClientView TheClient, World world, string regionName, Dictionary<uint, ClientView> clientThreads, ulong regionHandle, bool regionTerraform, ushort regionWater)
41 {
42 m_world = world;
43 // m_clientThreads = clientThreads;
44 m_regionName = regionName;
45 m_regionHandle = regionHandle;
46 m_regionTerraform = regionTerraform;
47 m_regionWaterHeight = regionWater;
48
49 OpenSim.Framework.Console.MainConsole.Instance.WriteLine(OpenSim.Framework.Console.LogPriority.LOW,"Avatar.cs - Loading details from grid (DUMMY)");
50 ControllingClient = TheClient;
51 localid = 8880000 + (this.m_world._localNumber++);
52 Pos = ControllingClient.startpos;
53 visualParams = new byte[218];
54 for (int i = 0; i < 218; i++)
55 {
56 visualParams[i] = 100;
57 }
58 Wearables = new AvatarWearable[13]; //should be 13 of these
59 for (int i = 0; i < 13; i++)
60 {
61 Wearables[i] = new AvatarWearable();
62 }
63 this.Wearables[0].AssetID = new LLUUID("66c41e39-38f9-f75a-024e-585989bfab73");
64 this.Wearables[0].ItemID = LLUUID.Random();
65
66 this.avatarAppearanceTexture = new LLObject.TextureEntry(new LLUUID("00000000-0000-0000-5005-000000000005"));
67
68 //register for events
69 ControllingClient.OnRequestWearables += new ClientView.GenericCall(this.SendOurAppearance);
70 ControllingClient.OnSetAppearance += new SetAppearance(this.SetAppearance);
71 ControllingClient.OnCompleteMovementToRegion += new ClientView.GenericCall2(this.CompleteMovement);
72 ControllingClient.OnCompleteMovementToRegion += new ClientView.GenericCall2(this.SendInitialPosition);
73 ControllingClient.OnAgentUpdate += new ClientView.GenericCall3(this.HandleAgentUpdate);
74 ControllingClient.OnStartAnim += new StartAnim(this.SendAnimPack);
75
76 }
77
78 public PhysicsActor PhysActor
79 {
80 set
81 {
82 this._physActor = value;
83 }
84 get
85 {
86 return _physActor;
87 }
88 }
89
90 public override void addForces()
91 {
92 lock (this.forcesList)
93 {
94 if (this.forcesList.Count > 0)
95 {
96 for (int i = 0; i < this.forcesList.Count; i++)
97 {
98 NewForce force = this.forcesList[i];
99 PhysicsVector phyVector = new PhysicsVector(force.X, force.Y, force.Z);
100 lock (m_world.LockPhysicsEngine)
101 {
102 this._physActor.Velocity = phyVector;
103 }
104 this.updateflag = true;
105 this.velocity = new LLVector3(force.X, force.Y, force.Z); //shouldn't really be doing this
106 // but as we are setting the velocity (rather than using real forces) at the moment it is okay.
107 }
108 for (int i = 0; i < this.forcesList.Count; i++)
109 {
110 this.forcesList.RemoveAt(0);
111 }
112 }
113 }
114 }
115
116 public static void SetupTemplate(string name)
117 {
118 FileInfo fInfo = new FileInfo(name);
119 long numBytes = fInfo.Length;
120 FileStream fStream = new FileStream(name, FileMode.Open, FileAccess.Read);
121 BinaryReader br = new BinaryReader(fStream);
122 byte[] data1 = br.ReadBytes((int)numBytes);
123 br.Close();
124 fStream.Close();
125
126 libsecondlife.Packets.ObjectUpdatePacket.ObjectDataBlock objdata = new ObjectUpdatePacket.ObjectDataBlock(); // new libsecondlife.Packets.ObjectUpdatePacket.ObjectDataBlock(data1, ref i);
127
128 SetDefaultPacketValues(objdata);
129 objdata.TextureEntry = data1;
130 objdata.UpdateFlags = 61 + (9 << 8) + (130 << 16) + (16 << 24);
131 objdata.PathCurve = 16;
132 objdata.ProfileCurve = 1;
133 objdata.PathScaleX = 100;
134 objdata.PathScaleY = 100;
135 objdata.ParentID = 0;
136 objdata.OwnerID = LLUUID.Zero;
137 objdata.Scale = new LLVector3(1, 1, 1);
138 objdata.PCode = 47;
139 System.Text.Encoding enc = System.Text.Encoding.ASCII;
140 libsecondlife.LLVector3 pos = new LLVector3(objdata.ObjectData, 16);
141 pos.X = 100f;
142 objdata.ID = 8880000;
143 objdata.NameValue = enc.GetBytes("FirstName STRING RW SV Test \nLastName STRING RW SV User \0");
144 libsecondlife.LLVector3 pos2 = new LLVector3(100f, 100f, 23f);
145 //objdata.FullID=user.AgentID;
146 byte[] pb = pos.GetBytes();
147 Array.Copy(pb, 0, objdata.ObjectData, 16, pb.Length);
148
149 Avatar.AvatarTemplate = objdata;
150 }
151
152 protected static void SetDefaultPacketValues(ObjectUpdatePacket.ObjectDataBlock objdata)
153 {
154 objdata.PSBlock = new byte[0];
155 objdata.ExtraParams = new byte[1];
156 objdata.MediaURL = new byte[0];
157 objdata.NameValue = new byte[0];
158 objdata.Text = new byte[0];
159 objdata.TextColor = new byte[4];
160 objdata.JointAxisOrAnchor = new LLVector3(0, 0, 0);
161 objdata.JointPivot = new LLVector3(0, 0, 0);
162 objdata.Material = 4;
163 objdata.TextureAnim = new byte[0];
164 objdata.Sound = LLUUID.Zero;
165 LLObject.TextureEntry ntex = new LLObject.TextureEntry(new LLUUID("00000000-0000-0000-5005-000000000005"));
166 objdata.TextureEntry = ntex.ToBytes();
167 objdata.State = 0;
168 objdata.Data = new byte[0];
169
170 objdata.ObjectData = new byte[76];
171 objdata.ObjectData[15] = 128;
172 objdata.ObjectData[16] = 63;
173 objdata.ObjectData[56] = 128;
174 objdata.ObjectData[61] = 102;
175 objdata.ObjectData[62] = 40;
176 objdata.ObjectData[63] = 61;
177 objdata.ObjectData[64] = 189;
178
179
180 }
181
182 public void CompleteMovement()
183 {
184 OpenSim.Framework.Console.MainConsole.Instance.WriteLine(OpenSim.Framework.Console.LogPriority.VERBOSE,"Avatar.cs:CompleteMovement() - Constructing AgentMovementComplete packet");
185 AgentMovementCompletePacket mov = new AgentMovementCompletePacket();
186 mov.AgentData.SessionID = this.ControllingClient.SessionID;
187 mov.AgentData.AgentID = this.ControllingClient.AgentID;
188 mov.Data.RegionHandle = this.m_regionHandle;
189 // TODO - dynamicalise this stuff
190 mov.Data.Timestamp = 1172750370;
191 mov.Data.Position = this.ControllingClient.startpos;
192 mov.Data.LookAt = new LLVector3(0.99f, 0.042f, 0);
193
194 ControllingClient.OutPacket(mov);
195 }
196
197 public void HandleAgentUpdate(Packet pack)
198 {
199 this.HandleUpdate((AgentUpdatePacket)pack);
200 }
201
202 public void HandleUpdate(AgentUpdatePacket pack)
203 {
204 if (((uint)pack.AgentData.ControlFlags & (uint)MainAvatar.ControlFlags.AGENT_CONTROL_FLY) != 0)
205 {
206 if (this._physActor.Flying == false)
207 {
208 this.current_anim = Animations.AnimsLLUUID["ANIM_AGENT_FLY"];
209 this.anim_seq = 1;
210 this.SendAnimPack();
211 }
212 this._physActor.Flying = true;
213
214 }
215 else
216 {
217 if (this._physActor.Flying == true)
218 {
219 this.current_anim = Animations.AnimsLLUUID["ANIM_AGENT_STAND"];
220 this.anim_seq = 1;
221 this.SendAnimPack();
222 }
223 this._physActor.Flying = false;
224 }
225 if (((uint)pack.AgentData.ControlFlags & (uint)MainAvatar.ControlFlags.AGENT_CONTROL_AT_POS) != 0)
226 {
227 Axiom.MathLib.Quaternion q = new Axiom.MathLib.Quaternion(pack.AgentData.BodyRotation.W, pack.AgentData.BodyRotation.X, pack.AgentData.BodyRotation.Y, pack.AgentData.BodyRotation.Z);
228 if (((movementflag & 1) == 0) || (q != this.bodyRot))
229 {
230
231 if (((movementflag & 1) == 0) && (!this._physActor.Flying))
232 {
233 this.current_anim = Animations.AnimsLLUUID["ANIM_AGENT_WALK"];
234 this.anim_seq = 1;
235 this.SendAnimPack();
236 }
237
238
239 //we should add a new force to the list
240 // but for now we will deal with velocities
241 NewForce newVelocity = new NewForce();
242 Axiom.MathLib.Vector3 v3 = new Axiom.MathLib.Vector3(1, 0, 0);
243 Axiom.MathLib.Vector3 direc = q * v3;
244 direc.Normalize();
245
246 //work out velocity for sim physics system
247 direc = direc * ((0.03f) * 128f);
248 if (this._physActor.Flying)
249 direc *= 4;
250
251 newVelocity.X = direc.x;
252 newVelocity.Y = direc.y;
253 newVelocity.Z = direc.z;
254 this.forcesList.Add(newVelocity);
255 movementflag = 1;
256 this.bodyRot = q;
257 }
258 }
259 else if ((((uint)pack.AgentData.ControlFlags & (uint)MainAvatar.ControlFlags.AGENT_CONTROL_UP_POS) != 0) && (PhysicsEngineFlying))
260 {
261 if (((movementflag & 2) == 0) && this._physActor.Flying)
262 {
263 //we should add a new force to the list
264 // but for now we will deal with velocities
265 NewForce newVelocity = new NewForce();
266 Axiom.MathLib.Vector3 v3 = new Axiom.MathLib.Vector3(0, 0, 1);
267 Axiom.MathLib.Vector3 direc = v3;
268 direc.Normalize();
269
270 //work out velocity for sim physics system
271 direc = direc * ((0.03f) * 128f * 2);
272 newVelocity.X = direc.x;
273 newVelocity.Y = direc.y;
274 newVelocity.Z = direc.z;
275 this.forcesList.Add(newVelocity);
276 movementflag = 2;
277 }
278 }
279 else if ((((uint)pack.AgentData.ControlFlags & (uint)MainAvatar.ControlFlags.AGENT_CONTROL_UP_NEG) != 0) && (PhysicsEngineFlying))
280 {
281 if (((movementflag & 4) == 0) && this._physActor.Flying)
282 {
283 //we should add a new force to the list
284 // but for now we will deal with velocities
285 NewForce newVelocity = new NewForce();
286 Axiom.MathLib.Vector3 v3 = new Axiom.MathLib.Vector3(0, 0, -1);
287 //Axiom.MathLib.Quaternion q = new Axiom.MathLib.Quaternion(pack.AgentData.BodyRotation.W, pack.AgentData.BodyRotation.X, pack.AgentData.BodyRotation.Y, pack.AgentData.BodyRotation.Z);
288 Axiom.MathLib.Vector3 direc = v3;
289 direc.Normalize();
290
291 //work out velocity for sim physics system
292 direc = direc * ((0.03f) * 128f * 2);
293 newVelocity.X = direc.x;
294 newVelocity.Y = direc.y;
295 newVelocity.Z = direc.z;
296 this.forcesList.Add(newVelocity);
297 movementflag = 4;
298 }
299 }
300 else if (((uint)pack.AgentData.ControlFlags & (uint)MainAvatar.ControlFlags.AGENT_CONTROL_AT_NEG) != 0)
301 {
302 Axiom.MathLib.Quaternion q = new Axiom.MathLib.Quaternion(pack.AgentData.BodyRotation.W, pack.AgentData.BodyRotation.X, pack.AgentData.BodyRotation.Y, pack.AgentData.BodyRotation.Z);
303 if (((movementflag & 8) == 0) || (q != this.bodyRot))
304 {
305 //we should add a new force to the list
306 // but for now we will deal with velocities
307 NewForce newVelocity = new NewForce();
308 Axiom.MathLib.Vector3 v3 = new Axiom.MathLib.Vector3(-1, 0, 0);
309 Axiom.MathLib.Vector3 direc = q * v3;
310 direc.Normalize();
311
312 //work out velocity for sim physics system
313 direc = direc * ((0.03f) * 128f);
314 if (this._physActor.Flying)
315 direc *= 2;
316
317 newVelocity.X = direc.x;
318 newVelocity.Y = direc.y;
319 newVelocity.Z = direc.z;
320 this.forcesList.Add(newVelocity);
321 movementflag = 8;
322 this.bodyRot = q;
323 }
324 }
325 else
326 {
327 if (movementflag == 16)
328 {
329 movementflag = 0;
330 }
331 if ((movementflag) != 0)
332 {
333 NewForce newVelocity = new NewForce();
334 newVelocity.X = 0;
335 newVelocity.Y = 0;
336 newVelocity.Z = 0;
337 this.forcesList.Add(newVelocity);
338 movementflag = 0;
339 // We're standing still, so make it show!
340 if (this._physActor.Flying == false)
341 {
342 this.current_anim = Animations.AnimsLLUUID["ANIM_AGENT_STAND"];
343 this.anim_seq = 1;
344 this.SendAnimPack();
345 }
346 this.movementflag = 16;
347
348 }
349 }
350 }
351
352 //really really should be moved somewhere else (RegionInfo.cs ?)
353 public void SendRegionHandshake(World regionInfo)
354 {
355 OpenSim.Framework.Console.MainConsole.Instance.WriteLine(OpenSim.Framework.Console.LogPriority.VERBOSE,"Avatar.cs:SendRegionHandshake() - Creating empty RegionHandshake packet");
356 System.Text.Encoding _enc = System.Text.Encoding.ASCII;
357 RegionHandshakePacket handshake = new RegionHandshakePacket();
358
359 OpenSim.Framework.Console.MainConsole.Instance.WriteLine(OpenSim.Framework.Console.LogPriority.VERBOSE,"Avatar.cs:SendRegionhandshake() - Filling in RegionHandshake details");
360 handshake.RegionInfo.BillableFactor = 0;
361 handshake.RegionInfo.IsEstateManager = false;
362 handshake.RegionInfo.TerrainHeightRange00 = 60;
363 handshake.RegionInfo.TerrainHeightRange01 = 60;
364 handshake.RegionInfo.TerrainHeightRange10 = 60;
365 handshake.RegionInfo.TerrainHeightRange11 = 60;
366 handshake.RegionInfo.TerrainStartHeight00 = 10;
367 handshake.RegionInfo.TerrainStartHeight01 = 10;
368 handshake.RegionInfo.TerrainStartHeight10 = 10;
369 handshake.RegionInfo.TerrainStartHeight11 = 10;
370 handshake.RegionInfo.SimAccess = 13;
371 handshake.RegionInfo.WaterHeight = m_regionWaterHeight;
372 uint regionFlags = 72458694;
373 if (this.m_regionTerraform)
374 {
375 regionFlags -= 64;
376 }
377 handshake.RegionInfo.RegionFlags = regionFlags;
378 handshake.RegionInfo.SimName = _enc.GetBytes(m_regionName + "\0");
379 handshake.RegionInfo.SimOwner = new LLUUID("00000000-0000-0000-0000-000000000000");
380 handshake.RegionInfo.TerrainBase0 = new LLUUID("b8d3965a-ad78-bf43-699b-bff8eca6c975");
381 handshake.RegionInfo.TerrainBase1 = new LLUUID("abb783e6-3e93-26c0-248a-247666855da3");
382 handshake.RegionInfo.TerrainBase2 = new LLUUID("179cdabd-398a-9b6b-1391-4dc333ba321f");
383 handshake.RegionInfo.TerrainBase3 = new LLUUID("beb169c7-11ea-fff2-efe5-0f24dc881df2");
384 handshake.RegionInfo.TerrainDetail0 = new LLUUID("00000000-0000-0000-0000-000000000000");
385 handshake.RegionInfo.TerrainDetail1 = new LLUUID("00000000-0000-0000-0000-000000000000");
386 handshake.RegionInfo.TerrainDetail2 = new LLUUID("00000000-0000-0000-0000-000000000000");
387 handshake.RegionInfo.TerrainDetail3 = new LLUUID("00000000-0000-0000-0000-000000000000");
388 handshake.RegionInfo.CacheID = new LLUUID("545ec0a5-5751-1026-8a0b-216e38a7ab37");
389
390 OpenSim.Framework.Console.MainConsole.Instance.WriteLine(OpenSim.Framework.Console.LogPriority.VERBOSE,"Avatar.cs:SendRegionHandshake() - Sending RegionHandshake packet");
391 this.ControllingClient.OutPacket(handshake);
392 }
393
394 public static void LoadAnims()
395 {
396 Avatar.Animations = new AvatarAnimations();
397 Avatar.Animations.LoadAnims();
398 }
399
400 public override void LandRenegerated()
401 {
402 Pos = new LLVector3(100.0f, 100.0f, m_world.Terrain[(int)Pos.X, (int)Pos.Y] + 50.0f);
403 }
404 }
405
406 public class NewForce
407 {
408 public float X;
409 public float Y;
410 public float Z;
411
412 public NewForce()
413 {
414
415 }
416 }
417
418}