aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/OpenSim.RegionServer/world/Avatar.cs
diff options
context:
space:
mode:
Diffstat (limited to 'OpenSim/OpenSim.RegionServer/world/Avatar.cs')
-rw-r--r--OpenSim/OpenSim.RegionServer/world/Avatar.cs278
1 files changed, 6 insertions, 272 deletions
diff --git a/OpenSim/OpenSim.RegionServer/world/Avatar.cs b/OpenSim/OpenSim.RegionServer/world/Avatar.cs
index 9401036..a95b65d 100644
--- a/OpenSim/OpenSim.RegionServer/world/Avatar.cs
+++ b/OpenSim/OpenSim.RegionServer/world/Avatar.cs
@@ -109,109 +109,24 @@ namespace OpenSim.world
109 109
110 public override void addForces() 110 public override void addForces()
111 { 111 {
112 lock (this.forcesList) 112
113 {
114 if (this.forcesList.Count > 0)
115 {
116 for (int i = 0; i < this.forcesList.Count; i++)
117 {
118 NewForce force = this.forcesList[i];
119 PhysicsVector phyVector = new PhysicsVector(force.X, force.Y, force.Z);
120 lock (m_world.LockPhysicsEngine)
121 {
122 this._physActor.Velocity = phyVector;
123 }
124 this.updateflag = true;
125 this.velocity = new LLVector3(force.X, force.Y, force.Z); //shouldn't really be doing this
126 // but as we are setting the velocity (rather than using real forces) at the moment it is okay.
127 }
128 for (int i = 0; i < this.forcesList.Count; i++)
129 {
130 this.forcesList.RemoveAt(0);
131 }
132 }
133 }
134 } 113 }
135 114
136 public static void SetupTemplate(string name) 115 public static void SetupTemplate(string name)
137 { 116 {
138 FileInfo fInfo = new FileInfo(name); 117
139 long numBytes = fInfo.Length;
140 FileStream fStream = new FileStream(name, FileMode.Open, FileAccess.Read);
141 BinaryReader br = new BinaryReader(fStream);
142 byte[] data1 = br.ReadBytes((int)numBytes);
143 br.Close();
144 fStream.Close();
145
146 libsecondlife.Packets.ObjectUpdatePacket.ObjectDataBlock objdata = new ObjectUpdatePacket.ObjectDataBlock(); // new libsecondlife.Packets.ObjectUpdatePacket.ObjectDataBlock(data1, ref i);
147
148 SetDefaultPacketValues(objdata);
149 objdata.TextureEntry = data1;
150 objdata.UpdateFlags = 61 + (9 << 8) + (130 << 16) + (16 << 24);
151 objdata.PathCurve = 16;
152 objdata.ProfileCurve = 1;
153 objdata.PathScaleX = 100;
154 objdata.PathScaleY = 100;
155 objdata.ParentID = 0;
156 objdata.OwnerID = LLUUID.Zero;
157 objdata.Scale = new LLVector3(1, 1, 1);
158 objdata.PCode = 47;
159 System.Text.Encoding enc = System.Text.Encoding.ASCII;
160 libsecondlife.LLVector3 pos = new LLVector3(objdata.ObjectData, 16);
161 pos.X = 100f;
162 objdata.ID = 8880000;
163 objdata.NameValue = enc.GetBytes("FirstName STRING RW SV Test \nLastName STRING RW SV User \0");
164 libsecondlife.LLVector3 pos2 = new LLVector3(100f, 100f, 23f);
165 //objdata.FullID=user.AgentID;
166 byte[] pb = pos.GetBytes();
167 Array.Copy(pb, 0, objdata.ObjectData, 16, pb.Length);
168
169 Avatar.AvatarTemplate = objdata;
170 } 118 }
171 119
172 protected static void SetDefaultPacketValues(ObjectUpdatePacket.ObjectDataBlock objdata) 120 protected static void SetDefaultPacketValues(ObjectUpdatePacket.ObjectDataBlock objdata)
173 { 121 {
174 objdata.PSBlock = new byte[0]; 122
175 objdata.ExtraParams = new byte[1];
176 objdata.MediaURL = new byte[0];
177 objdata.NameValue = new byte[0];
178 objdata.Text = new byte[0];
179 objdata.TextColor = new byte[4];
180 objdata.JointAxisOrAnchor = new LLVector3(0, 0, 0);
181 objdata.JointPivot = new LLVector3(0, 0, 0);
182 objdata.Material = 4;
183 objdata.TextureAnim = new byte[0];
184 objdata.Sound = LLUUID.Zero;
185 LLObject.TextureEntry ntex = new LLObject.TextureEntry(new LLUUID("00000000-0000-0000-5005-000000000005"));
186 objdata.TextureEntry = ntex.ToBytes();
187 objdata.State = 0;
188 objdata.Data = new byte[0];
189
190 objdata.ObjectData = new byte[76];
191 objdata.ObjectData[15] = 128;
192 objdata.ObjectData[16] = 63;
193 objdata.ObjectData[56] = 128;
194 objdata.ObjectData[61] = 102;
195 objdata.ObjectData[62] = 40;
196 objdata.ObjectData[63] = 61;
197 objdata.ObjectData[64] = 189;
198 123
199 124
200 } 125 }
201 126
202 public void CompleteMovement() 127 public void CompleteMovement()
203 { 128 {
204 OpenSim.Framework.Console.MainConsole.Instance.WriteLine(OpenSim.Framework.Console.LogPriority.VERBOSE,"Avatar.cs:CompleteMovement() - Constructing AgentMovementComplete packet"); 129
205 AgentMovementCompletePacket mov = new AgentMovementCompletePacket();
206 mov.AgentData.SessionID = this.ControllingClient.SessionID;
207 mov.AgentData.AgentID = this.ControllingClient.AgentID;
208 mov.Data.RegionHandle = this.m_regionHandle;
209 // TODO - dynamicalise this stuff
210 mov.Data.Timestamp = 1172750370;
211 mov.Data.Position = this.ControllingClient.startpos;
212 mov.Data.LookAt = new LLVector3(0.99f, 0.042f, 0);
213
214 ControllingClient.OutPacket(mov);
215 } 130 }
216 131
217 public void HandleAgentUpdate(Packet pack) 132 public void HandleAgentUpdate(Packet pack)
@@ -221,194 +136,13 @@ namespace OpenSim.world
221 136
222 public void HandleUpdate(AgentUpdatePacket pack) 137 public void HandleUpdate(AgentUpdatePacket pack)
223 { 138 {
224 if (((uint)pack.AgentData.ControlFlags & (uint)MainAvatar.ControlFlags.AGENT_CONTROL_FLY) != 0) 139
225 {
226 if (this._physActor.Flying == false)
227 {
228 this.current_anim = Animations.AnimsLLUUID["ANIM_AGENT_FLY"];
229 this.anim_seq = 1;
230 this.SendAnimPack();
231 }
232 this._physActor.Flying = true;
233
234 }
235 else
236 {
237 if (this._physActor.Flying == true)
238 {
239 this.current_anim = Animations.AnimsLLUUID["ANIM_AGENT_STAND"];
240 this.anim_seq = 1;
241 this.SendAnimPack();
242 }
243 this._physActor.Flying = false;
244 }
245 if (((uint)pack.AgentData.ControlFlags & (uint)MainAvatar.ControlFlags.AGENT_CONTROL_AT_POS) != 0)
246 {
247 Axiom.MathLib.Quaternion q = new Axiom.MathLib.Quaternion(pack.AgentData.BodyRotation.W, pack.AgentData.BodyRotation.X, pack.AgentData.BodyRotation.Y, pack.AgentData.BodyRotation.Z);
248 if (((movementflag & 1) == 0) || (q != this.bodyRot))
249 {
250
251 if (((movementflag & 1) == 0) && (!this._physActor.Flying))
252 {
253 this.current_anim = Animations.AnimsLLUUID["ANIM_AGENT_WALK"];
254 this.anim_seq = 1;
255 this.SendAnimPack();
256 }
257
258
259 //we should add a new force to the list
260 // but for now we will deal with velocities
261 NewForce newVelocity = new NewForce();
262 Axiom.MathLib.Vector3 v3 = new Axiom.MathLib.Vector3(1, 0, 0);
263 Axiom.MathLib.Vector3 direc = q * v3;
264 direc.Normalize();
265
266 //work out velocity for sim physics system
267 direc = direc * ((0.03f) * 128f);
268 if (this._physActor.Flying)
269 direc *= 4;
270
271 newVelocity.X = direc.x;
272 newVelocity.Y = direc.y;
273 newVelocity.Z = direc.z;
274 this.forcesList.Add(newVelocity);
275 movementflag = 1;
276 this.bodyRot = q;
277 }
278 }
279 else if ((((uint)pack.AgentData.ControlFlags & (uint)MainAvatar.ControlFlags.AGENT_CONTROL_UP_POS) != 0) && (PhysicsEngineFlying))
280 {
281 if (((movementflag & 2) == 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.Vector3 direc = v3;
288 direc.Normalize();
289
290 //work out velocity for sim physics system
291 direc = direc * ((0.03f) * 128f * 2);
292 newVelocity.X = direc.x;
293 newVelocity.Y = direc.y;
294 newVelocity.Z = direc.z;
295 this.forcesList.Add(newVelocity);
296 movementflag = 2;
297 }
298 }
299 else if ((((uint)pack.AgentData.ControlFlags & (uint)MainAvatar.ControlFlags.AGENT_CONTROL_UP_NEG) != 0) && (PhysicsEngineFlying))
300 {
301 if (((movementflag & 4) == 0) && this._physActor.Flying)
302 {
303 //we should add a new force to the list
304 // but for now we will deal with velocities
305 NewForce newVelocity = new NewForce();
306 Axiom.MathLib.Vector3 v3 = new Axiom.MathLib.Vector3(0, 0, -1);
307 //Axiom.MathLib.Quaternion q = new Axiom.MathLib.Quaternion(pack.AgentData.BodyRotation.W, pack.AgentData.BodyRotation.X, pack.AgentData.BodyRotation.Y, pack.AgentData.BodyRotation.Z);
308 Axiom.MathLib.Vector3 direc = v3;
309 direc.Normalize();
310
311 //work out velocity for sim physics system
312 direc = direc * ((0.03f) * 128f * 2);
313 newVelocity.X = direc.x;
314 newVelocity.Y = direc.y;
315 newVelocity.Z = direc.z;
316 this.forcesList.Add(newVelocity);
317 movementflag = 4;
318 }
319 }
320 else if (((uint)pack.AgentData.ControlFlags & (uint)MainAvatar.ControlFlags.AGENT_CONTROL_AT_NEG) != 0)
321 {
322 Axiom.MathLib.Quaternion q = new Axiom.MathLib.Quaternion(pack.AgentData.BodyRotation.W, pack.AgentData.BodyRotation.X, pack.AgentData.BodyRotation.Y, pack.AgentData.BodyRotation.Z);
323 if (((movementflag & 8) == 0) || (q != this.bodyRot))
324 {
325 //we should add a new force to the list
326 // but for now we will deal with velocities
327 NewForce newVelocity = new NewForce();
328 Axiom.MathLib.Vector3 v3 = new Axiom.MathLib.Vector3(-1, 0, 0);
329 Axiom.MathLib.Vector3 direc = q * v3;
330 direc.Normalize();
331
332 //work out velocity for sim physics system
333 direc = direc * ((0.03f) * 128f);
334 if (this._physActor.Flying)
335 direc *= 2;
336
337 newVelocity.X = direc.x;
338 newVelocity.Y = direc.y;
339 newVelocity.Z = direc.z;
340 this.forcesList.Add(newVelocity);
341 movementflag = 8;
342 this.bodyRot = q;
343 }
344 }
345 else
346 {
347 if (movementflag == 16)
348 {
349 movementflag = 0;
350 }
351 if ((movementflag) != 0)
352 {
353 NewForce newVelocity = new NewForce();
354 newVelocity.X = 0;
355 newVelocity.Y = 0;
356 newVelocity.Z = 0;
357 this.forcesList.Add(newVelocity);
358 movementflag = 0;
359 // We're standing still, so make it show!
360 if (this._physActor.Flying == false)
361 {
362 this.current_anim = Animations.AnimsLLUUID["ANIM_AGENT_STAND"];
363 this.anim_seq = 1;
364 this.SendAnimPack();
365 }
366 this.movementflag = 16;
367
368 }
369 }
370 } 140 }
371 141
372 //really really should be moved somewhere else (RegionInfo.cs ?) 142 //really really should be moved somewhere else (RegionInfo.cs ?)
373 public void SendRegionHandshake(World regionInfo) 143 public void SendRegionHandshake(World regionInfo)
374 { 144 {
375 OpenSim.Framework.Console.MainConsole.Instance.WriteLine(OpenSim.Framework.Console.LogPriority.VERBOSE,"Avatar.cs:SendRegionHandshake() - Creating empty RegionHandshake packet"); 145
376 System.Text.Encoding _enc = System.Text.Encoding.ASCII;
377 RegionHandshakePacket handshake = new RegionHandshakePacket();
378
379 OpenSim.Framework.Console.MainConsole.Instance.WriteLine(OpenSim.Framework.Console.LogPriority.VERBOSE,"Avatar.cs:SendRegionhandshake() - Filling in RegionHandshake details");
380 handshake.RegionInfo.BillableFactor = 0;
381 handshake.RegionInfo.IsEstateManager = false;
382 handshake.RegionInfo.TerrainHeightRange00 = 60;
383 handshake.RegionInfo.TerrainHeightRange01 = 60;
384 handshake.RegionInfo.TerrainHeightRange10 = 60;
385 handshake.RegionInfo.TerrainHeightRange11 = 60;
386 handshake.RegionInfo.TerrainStartHeight00 = 10;
387 handshake.RegionInfo.TerrainStartHeight01 = 10;
388 handshake.RegionInfo.TerrainStartHeight10 = 10;
389 handshake.RegionInfo.TerrainStartHeight11 = 10;
390 handshake.RegionInfo.SimAccess = 13;
391 handshake.RegionInfo.WaterHeight = m_regionWaterHeight;
392 uint regionFlags = 72458694;
393 if (this.m_regionTerraform)
394 {
395 regionFlags -= 64;
396 }
397 handshake.RegionInfo.RegionFlags = regionFlags;
398 handshake.RegionInfo.SimName = _enc.GetBytes(m_regionName + "\0");
399 handshake.RegionInfo.SimOwner = new LLUUID("00000000-0000-0000-0000-000000000000");
400 handshake.RegionInfo.TerrainBase0 = new LLUUID("b8d3965a-ad78-bf43-699b-bff8eca6c975");
401 handshake.RegionInfo.TerrainBase1 = new LLUUID("abb783e6-3e93-26c0-248a-247666855da3");
402 handshake.RegionInfo.TerrainBase2 = new LLUUID("179cdabd-398a-9b6b-1391-4dc333ba321f");
403 handshake.RegionInfo.TerrainBase3 = new LLUUID("beb169c7-11ea-fff2-efe5-0f24dc881df2");
404 handshake.RegionInfo.TerrainDetail0 = new LLUUID("00000000-0000-0000-0000-000000000000");
405 handshake.RegionInfo.TerrainDetail1 = new LLUUID("00000000-0000-0000-0000-000000000000");
406 handshake.RegionInfo.TerrainDetail2 = new LLUUID("00000000-0000-0000-0000-000000000000");
407 handshake.RegionInfo.TerrainDetail3 = new LLUUID("00000000-0000-0000-0000-000000000000");
408 handshake.RegionInfo.CacheID = new LLUUID("545ec0a5-5751-1026-8a0b-216e38a7ab37");
409
410 OpenSim.Framework.Console.MainConsole.Instance.WriteLine(OpenSim.Framework.Console.LogPriority.VERBOSE,"Avatar.cs:SendRegionHandshake() - Sending RegionHandshake packet");
411 this.ControllingClient.OutPacket(handshake);
412 } 146 }
413 147
414 public static void LoadAnims() 148 public static void LoadAnims()