diff options
Diffstat (limited to 'OpenSim/OpenSim.RegionServer/Simulator/Avatar.Update.cs')
-rw-r--r-- | OpenSim/OpenSim.RegionServer/Simulator/Avatar.Update.cs | 371 |
1 files changed, 0 insertions, 371 deletions
diff --git a/OpenSim/OpenSim.RegionServer/Simulator/Avatar.Update.cs b/OpenSim/OpenSim.RegionServer/Simulator/Avatar.Update.cs deleted file mode 100644 index 03da861..0000000 --- a/OpenSim/OpenSim.RegionServer/Simulator/Avatar.Update.cs +++ /dev/null | |||
@@ -1,371 +0,0 @@ | |||
1 | /* | ||
2 | * Copyright (c) Contributors, http://www.openmetaverse.org/ | ||
3 | * See CONTRIBUTORS.TXT for a full list of copyright holders. | ||
4 | * | ||
5 | * Redistribution and use in source and binary forms, with or without | ||
6 | * modification, are permitted provided that the following conditions are met: | ||
7 | * * Redistributions of source code must retain the above copyright | ||
8 | * notice, this list of conditions and the following disclaimer. | ||
9 | * * Redistributions in binary form must reproduce the above copyright | ||
10 | * notice, this list of conditions and the following disclaimer in the | ||
11 | * documentation and/or other materials provided with the distribution. | ||
12 | * * Neither the name of the OpenSim Project nor the | ||
13 | * names of its contributors may be used to endorse or promote products | ||
14 | * derived from this software without specific prior written permission. | ||
15 | * | ||
16 | * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS AND ANY | ||
17 | * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED | ||
18 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE | ||
19 | * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY | ||
20 | * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES | ||
21 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; | ||
22 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND | ||
23 | * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | ||
24 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS | ||
25 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | ||
26 | * | ||
27 | */ | ||
28 | using System; | ||
29 | using System.Collections.Generic; | ||
30 | using System.Text; | ||
31 | using libsecondlife; | ||
32 | using libsecondlife.Packets; | ||
33 | using OpenSim.RegionServer.Client; | ||
34 | |||
35 | namespace OpenSim.RegionServer.Simulator | ||
36 | { | ||
37 | partial class Avatar | ||
38 | { | ||
39 | public override void update() | ||
40 | { | ||
41 | if (!this.childAvatar) | ||
42 | { | ||
43 | if (this._physActor == null) | ||
44 | { | ||
45 | //HACKHACK: Note to work out why this entity does not have a physics actor | ||
46 | // and prehaps create one. | ||
47 | return; | ||
48 | } | ||
49 | libsecondlife.LLVector3 pos2 = new LLVector3(this._physActor.Position.X, this._physActor.Position.Y, this._physActor.Position.Z); | ||
50 | if (this.updateflag) | ||
51 | { | ||
52 | //need to send movement info | ||
53 | //so create the improvedterseobjectupdate packet | ||
54 | //use CreateTerseBlock() | ||
55 | ImprovedTerseObjectUpdatePacket.ObjectDataBlock terseBlock = CreateTerseBlock(); | ||
56 | ImprovedTerseObjectUpdatePacket terse = new ImprovedTerseObjectUpdatePacket(); | ||
57 | terse.RegionData.RegionHandle = m_world.m_regInfo.RegionHandle; | ||
58 | terse.RegionData.TimeDilation = 64096; | ||
59 | terse.ObjectData = new ImprovedTerseObjectUpdatePacket.ObjectDataBlock[1]; | ||
60 | terse.ObjectData[0] = terseBlock; | ||
61 | List<Avatar> avList = this.m_world.RequestAvatarList(); | ||
62 | foreach (Avatar client in avList) | ||
63 | { | ||
64 | client.SendPacketToViewer(terse); | ||
65 | } | ||
66 | |||
67 | updateflag = false; | ||
68 | //this._updateCount = 0; | ||
69 | } | ||
70 | else | ||
71 | { | ||
72 | |||
73 | if ((pos2 != this.positionLastFrame) || (this.movementflag == 16)) | ||
74 | { | ||
75 | _updateCount++; | ||
76 | if (((!PhysicsEngineFlying) && (_updateCount > 3)) || (PhysicsEngineFlying) && (_updateCount > 0)) | ||
77 | { | ||
78 | //It has been a while since last update was sent so lets send one. | ||
79 | ImprovedTerseObjectUpdatePacket.ObjectDataBlock terseBlock = CreateTerseBlock(); | ||
80 | ImprovedTerseObjectUpdatePacket terse = new ImprovedTerseObjectUpdatePacket(); | ||
81 | terse.RegionData.RegionHandle = m_world.m_regInfo.RegionHandle; | ||
82 | terse.RegionData.TimeDilation = 64096; | ||
83 | terse.ObjectData = new ImprovedTerseObjectUpdatePacket.ObjectDataBlock[1]; | ||
84 | terse.ObjectData[0] = terseBlock; | ||
85 | List<Avatar> avList = this.m_world.RequestAvatarList(); | ||
86 | foreach (Avatar client in avList) | ||
87 | { | ||
88 | client.SendPacketToViewer(terse); | ||
89 | } | ||
90 | _updateCount = 0; | ||
91 | } | ||
92 | |||
93 | if (this.movementflag == 16) | ||
94 | { | ||
95 | movementflag = 0; | ||
96 | } | ||
97 | } | ||
98 | |||
99 | } | ||
100 | |||
101 | if (positionFrameBeforeLast != pos2) | ||
102 | { | ||
103 | this.positionFrameBeforeLast = this.positionLastFrame; | ||
104 | this.positionLastFrame = pos2; | ||
105 | int tempRoundedX = (int)Math.Round(positionLastFrame.X); | ||
106 | int tempRoundedY = (int)Math.Round(positionLastFrame.Y); | ||
107 | if (this.positionRoundedX != tempRoundedX || this.positionRoundedY != tempRoundedY) | ||
108 | { | ||
109 | |||
110 | this.positionRoundedX = tempRoundedX; | ||
111 | this.positionRoundedY = tempRoundedY; | ||
112 | int currentParcelLocalID = m_world.parcelManager.getParcel(tempRoundedX, tempRoundedY).parcelData.localID; | ||
113 | if(currentParcelLocalID != this.positionParcelHoverLocalID) | ||
114 | { | ||
115 | |||
116 | Console.WriteLine("NEW PARCEL: " + m_world.parcelManager.getParcel(tempRoundedX, tempRoundedY).parcelData.parcelName); | ||
117 | m_world.parcelManager.getParcel(tempRoundedX, tempRoundedY).sendParcelProperties(this.parcelUpdateSequenceIncrement, false, 0,this.ControllingClient); | ||
118 | this.positionParcelHoverLocalID = currentParcelLocalID; | ||
119 | this.parcelUpdateSequenceIncrement++; | ||
120 | } | ||
121 | } | ||
122 | } | ||
123 | |||
124 | if (!this.ControllingClient.m_sandboxMode) | ||
125 | { | ||
126 | if (pos2.X < 0) | ||
127 | { | ||
128 | ControllingClient.CrossSimBorder(new LLVector3(this._physActor.Position.X, this._physActor.Position.Y, this._physActor.Position.Z)); | ||
129 | } | ||
130 | |||
131 | if (pos2.Y < 0) | ||
132 | { | ||
133 | ControllingClient.CrossSimBorder(new LLVector3(this._physActor.Position.X, this._physActor.Position.Y, this._physActor.Position.Z)); | ||
134 | } | ||
135 | |||
136 | if (pos2.X > 255) | ||
137 | { | ||
138 | ControllingClient.CrossSimBorder(new LLVector3(this._physActor.Position.X, this._physActor.Position.Y, this._physActor.Position.Z)); | ||
139 | } | ||
140 | |||
141 | if (pos2.Y > 255) | ||
142 | { | ||
143 | ControllingClient.CrossSimBorder(new LLVector3(this._physActor.Position.X, this._physActor.Position.Y, this._physActor.Position.Z)); | ||
144 | } | ||
145 | } | ||
146 | } | ||
147 | |||
148 | } | ||
149 | |||
150 | public void SendUpdateToOtherClient(Avatar remoteAvatar) | ||
151 | { | ||
152 | ObjectUpdatePacket objupdate = CreateUpdatePacket(); | ||
153 | remoteAvatar.SendPacketToViewer(objupdate); | ||
154 | } | ||
155 | |||
156 | public ObjectUpdatePacket CreateUpdatePacket() | ||
157 | { | ||
158 | System.Text.Encoding _enc = System.Text.Encoding.ASCII; | ||
159 | //send a objectupdate packet with information about the clients avatar | ||
160 | ObjectUpdatePacket objupdate = new ObjectUpdatePacket(); | ||
161 | objupdate.RegionData.RegionHandle = m_world.m_regInfo.RegionHandle; | ||
162 | objupdate.RegionData.TimeDilation = 64096; | ||
163 | objupdate.ObjectData = new libsecondlife.Packets.ObjectUpdatePacket.ObjectDataBlock[1]; | ||
164 | |||
165 | objupdate.ObjectData[0] = AvatarTemplate; | ||
166 | //give this avatar object a local id and assign the user a name | ||
167 | objupdate.ObjectData[0].ID = this.localid; | ||
168 | objupdate.ObjectData[0].FullID = ControllingClient.AgentID; | ||
169 | objupdate.ObjectData[0].NameValue = _enc.GetBytes("FirstName STRING RW SV " + firstname + "\nLastName STRING RW SV " + lastname + " \0"); | ||
170 | |||
171 | libsecondlife.LLVector3 pos2 = new LLVector3((float)this._physActor.Position.X, (float)this._physActor.Position.Y, (float)this._physActor.Position.Z); | ||
172 | |||
173 | byte[] pb = pos2.GetBytes(); | ||
174 | |||
175 | Array.Copy(pb, 0, objupdate.ObjectData[0].ObjectData, 16, pb.Length); | ||
176 | return objupdate; | ||
177 | } | ||
178 | |||
179 | public void SendInitialPosition() | ||
180 | { | ||
181 | System.Text.Encoding _enc = System.Text.Encoding.ASCII; | ||
182 | //send a objectupdate packet with information about the clients avatar | ||
183 | |||
184 | ObjectUpdatePacket objupdate = new ObjectUpdatePacket(); | ||
185 | objupdate.RegionData.RegionHandle = m_world.m_regInfo.RegionHandle; | ||
186 | objupdate.RegionData.TimeDilation = 64096; | ||
187 | objupdate.ObjectData = new libsecondlife.Packets.ObjectUpdatePacket.ObjectDataBlock[1]; | ||
188 | objupdate.ObjectData[0] = AvatarTemplate; | ||
189 | //give this avatar object a local id and assign the user a name | ||
190 | |||
191 | objupdate.ObjectData[0].ID = this.localid; | ||
192 | this.uuid = objupdate.ObjectData[0].FullID = ControllingClient.AgentID; | ||
193 | objupdate.ObjectData[0].NameValue = _enc.GetBytes("FirstName STRING RW SV " + firstname + "\nLastName STRING RW SV " + lastname + " \0"); | ||
194 | libsecondlife.LLVector3 pos2 = new LLVector3((float)this.Pos.X, (float)this.Pos.Y, (float)this.Pos.Z); | ||
195 | byte[] pb = pos2.GetBytes(); | ||
196 | Array.Copy(pb, 0, objupdate.ObjectData[0].ObjectData, 16, pb.Length); | ||
197 | m_world._localNumber++; | ||
198 | |||
199 | List<Avatar> avList = this.m_world.RequestAvatarList(); | ||
200 | foreach (Avatar client in avList) | ||
201 | { | ||
202 | client.SendPacketToViewer(objupdate); | ||
203 | if (client.ControllingClient.AgentID != this.ControllingClient.AgentID) | ||
204 | { | ||
205 | SendAppearanceToOtherAgent(client); | ||
206 | } | ||
207 | } | ||
208 | } | ||
209 | |||
210 | public void SendOurAppearance() | ||
211 | { | ||
212 | ControllingClient.SendAppearance(this.Wearables); | ||
213 | } | ||
214 | |||
215 | public void SendOurAppearance(ClientView OurClient) | ||
216 | { | ||
217 | //event handler for wearables request | ||
218 | this.SendOurAppearance(); | ||
219 | } | ||
220 | |||
221 | public void SendAppearanceToOtherAgent(Avatar avatarInfo) | ||
222 | { | ||
223 | AvatarAppearancePacket avp = new AvatarAppearancePacket(); | ||
224 | avp.VisualParam = new AvatarAppearancePacket.VisualParamBlock[218]; | ||
225 | avp.ObjectData.TextureEntry = this.avatarAppearanceTexture.ToBytes(); | ||
226 | |||
227 | AvatarAppearancePacket.VisualParamBlock avblock = null; | ||
228 | for (int i = 0; i < 218; i++) | ||
229 | { | ||
230 | avblock = new AvatarAppearancePacket.VisualParamBlock(); | ||
231 | avblock.ParamValue = visualParams[i]; | ||
232 | avp.VisualParam[i] = avblock; | ||
233 | } | ||
234 | |||
235 | avp.Sender.IsTrial = false; | ||
236 | avp.Sender.ID = ControllingClient.AgentID; | ||
237 | avatarInfo.SendPacketToViewer(avp); | ||
238 | } | ||
239 | |||
240 | public void SetAppearance(byte[] texture, AgentSetAppearancePacket.VisualParamBlock[] visualParam) | ||
241 | { | ||
242 | LLObject.TextureEntry tex = new LLObject.TextureEntry(texture, 0, texture.Length); | ||
243 | this.avatarAppearanceTexture = tex; | ||
244 | |||
245 | for (int i = 0; i < visualParam.Length; i++) | ||
246 | { | ||
247 | this.visualParams[i] = visualParam[i].ParamValue; | ||
248 | } | ||
249 | |||
250 | List<Avatar> avList = this.m_world.RequestAvatarList(); | ||
251 | foreach (Avatar client in avList) | ||
252 | { | ||
253 | if (client.ControllingClient.AgentID != this.ControllingClient.AgentID) | ||
254 | { | ||
255 | SendAppearanceToOtherAgent(client); | ||
256 | } | ||
257 | } | ||
258 | } | ||
259 | |||
260 | public ImprovedTerseObjectUpdatePacket.ObjectDataBlock CreateTerseBlock() | ||
261 | { | ||
262 | byte[] bytes = new byte[60]; | ||
263 | int i = 0; | ||
264 | ImprovedTerseObjectUpdatePacket.ObjectDataBlock dat = new ImprovedTerseObjectUpdatePacket.ObjectDataBlock(); | ||
265 | |||
266 | dat.TextureEntry = new byte[0];// AvatarTemplate.TextureEntry; | ||
267 | libsecondlife.LLVector3 pos2 = new LLVector3(0, 0, 0); | ||
268 | lock (m_world.LockPhysicsEngine) | ||
269 | { | ||
270 | pos2 = new LLVector3(this._physActor.Position.X, this._physActor.Position.Y, this._physActor.Position.Z); | ||
271 | } | ||
272 | |||
273 | uint ID = this.localid; | ||
274 | |||
275 | bytes[i++] = (byte)(ID % 256); | ||
276 | bytes[i++] = (byte)((ID >> 8) % 256); | ||
277 | bytes[i++] = (byte)((ID >> 16) % 256); | ||
278 | bytes[i++] = (byte)((ID >> 24) % 256); | ||
279 | bytes[i++] = 0; | ||
280 | bytes[i++] = 1; | ||
281 | i += 14; | ||
282 | bytes[i++] = 128; | ||
283 | bytes[i++] = 63; | ||
284 | |||
285 | byte[] pb = pos2.GetBytes(); | ||
286 | Array.Copy(pb, 0, bytes, i, pb.Length); | ||
287 | i += 12; | ||
288 | ushort InternVelocityX; | ||
289 | ushort InternVelocityY; | ||
290 | ushort InternVelocityZ; | ||
291 | Axiom.MathLib.Vector3 internDirec = new Axiom.MathLib.Vector3(0, 0, 0); | ||
292 | lock (m_world.LockPhysicsEngine) | ||
293 | { | ||
294 | internDirec = new Axiom.MathLib.Vector3(this._physActor.Velocity.X, this._physActor.Velocity.Y, this._physActor.Velocity.Z); | ||
295 | } | ||
296 | internDirec = internDirec / 128.0f; | ||
297 | internDirec.x += 1; | ||
298 | internDirec.y += 1; | ||
299 | internDirec.z += 1; | ||
300 | |||
301 | InternVelocityX = (ushort)(32768 * internDirec.x); | ||
302 | InternVelocityY = (ushort)(32768 * internDirec.y); | ||
303 | InternVelocityZ = (ushort)(32768 * internDirec.z); | ||
304 | |||
305 | ushort ac = 32767; | ||
306 | bytes[i++] = (byte)(InternVelocityX % 256); | ||
307 | bytes[i++] = (byte)((InternVelocityX >> 8) % 256); | ||
308 | bytes[i++] = (byte)(InternVelocityY % 256); | ||
309 | bytes[i++] = (byte)((InternVelocityY >> 8) % 256); | ||
310 | bytes[i++] = (byte)(InternVelocityZ % 256); | ||
311 | bytes[i++] = (byte)((InternVelocityZ >> 8) % 256); | ||
312 | |||
313 | //accel | ||
314 | bytes[i++] = (byte)(ac % 256); | ||
315 | bytes[i++] = (byte)((ac >> 8) % 256); | ||
316 | bytes[i++] = (byte)(ac % 256); | ||
317 | bytes[i++] = (byte)((ac >> 8) % 256); | ||
318 | bytes[i++] = (byte)(ac % 256); | ||
319 | bytes[i++] = (byte)((ac >> 8) % 256); | ||
320 | |||
321 | //rot | ||
322 | bytes[i++] = (byte)(ac % 256); | ||
323 | bytes[i++] = (byte)((ac >> 8) % 256); | ||
324 | bytes[i++] = (byte)(ac % 256); | ||
325 | bytes[i++] = (byte)((ac >> 8) % 256); | ||
326 | bytes[i++] = (byte)(ac % 256); | ||
327 | bytes[i++] = (byte)((ac >> 8) % 256); | ||
328 | bytes[i++] = (byte)(ac % 256); | ||
329 | bytes[i++] = (byte)((ac >> 8) % 256); | ||
330 | |||
331 | //rotation vel | ||
332 | bytes[i++] = (byte)(ac % 256); | ||
333 | bytes[i++] = (byte)((ac >> 8) % 256); | ||
334 | bytes[i++] = (byte)(ac % 256); | ||
335 | bytes[i++] = (byte)((ac >> 8) % 256); | ||
336 | bytes[i++] = (byte)(ac % 256); | ||
337 | bytes[i++] = (byte)((ac >> 8) % 256); | ||
338 | |||
339 | dat.Data = bytes; | ||
340 | return (dat); | ||
341 | } | ||
342 | |||
343 | // Sends animation update | ||
344 | public void SendAnimPack(LLUUID animID, int seq) | ||
345 | { | ||
346 | AvatarAnimationPacket ani = new AvatarAnimationPacket(); | ||
347 | ani.AnimationSourceList = new AvatarAnimationPacket.AnimationSourceListBlock[1]; | ||
348 | ani.AnimationSourceList[0] = new AvatarAnimationPacket.AnimationSourceListBlock(); | ||
349 | ani.AnimationSourceList[0].ObjectID = ControllingClient.AgentID; | ||
350 | ani.Sender = new AvatarAnimationPacket.SenderBlock(); | ||
351 | ani.Sender.ID = ControllingClient.AgentID; | ||
352 | ani.AnimationList = new AvatarAnimationPacket.AnimationListBlock[1]; | ||
353 | ani.AnimationList[0] = new AvatarAnimationPacket.AnimationListBlock(); | ||
354 | ani.AnimationList[0].AnimID = this.current_anim = animID; | ||
355 | ani.AnimationList[0].AnimSequenceID = this.anim_seq = seq; | ||
356 | |||
357 | List<Avatar> avList = this.m_world.RequestAvatarList(); | ||
358 | foreach (Avatar client in avList) | ||
359 | { | ||
360 | client.SendPacketToViewer(ani); | ||
361 | } | ||
362 | |||
363 | } | ||
364 | |||
365 | public void SendAnimPack() | ||
366 | { | ||
367 | this.SendAnimPack(this.current_anim, this.anim_seq); | ||
368 | } | ||
369 | |||
370 | } | ||
371 | } | ||