diff options
author | mingchen | 2007-06-07 14:23:19 +0000 |
---|---|---|
committer | mingchen | 2007-06-07 14:23:19 +0000 |
commit | f88a4777f9e9b23795aed5a7f364a93a73e9ed15 (patch) | |
tree | 7acf567aed35932ae0bcc5410698379bbb6087c0 /OpenSim/OpenSim.RegionServer/world/Avatar.Update.cs | |
parent | *When avatar crosses parcel, it updates successfully in the viewer (diff) | |
download | opensim-SC-f88a4777f9e9b23795aed5a7f364a93a73e9ed15.zip opensim-SC-f88a4777f9e9b23795aed5a7f364a93a73e9ed15.tar.gz opensim-SC-f88a4777f9e9b23795aed5a7f364a93a73e9ed15.tar.bz2 opensim-SC-f88a4777f9e9b23795aed5a7f364a93a73e9ed15.tar.xz |
*Cleaned up namespaces, filenames, etc in OpenSim.RegionServer
NOTES:
*ClientView is now in the namespace OpenSim.RegionServer.Client
*Scripting is now in the namespace OpenSim.RegionServer.scripting
*Other various cleaning
Diffstat (limited to 'OpenSim/OpenSim.RegionServer/world/Avatar.Update.cs')
-rw-r--r-- | OpenSim/OpenSim.RegionServer/world/Avatar.Update.cs | 370 |
1 files changed, 0 insertions, 370 deletions
diff --git a/OpenSim/OpenSim.RegionServer/world/Avatar.Update.cs b/OpenSim/OpenSim.RegionServer/world/Avatar.Update.cs deleted file mode 100644 index 7712905..0000000 --- a/OpenSim/OpenSim.RegionServer/world/Avatar.Update.cs +++ /dev/null | |||
@@ -1,370 +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 | |||
34 | namespace OpenSim.world | ||
35 | { | ||
36 | partial class Avatar | ||
37 | { | ||
38 | public override void update() | ||
39 | { | ||
40 | if (!this.childAvatar) | ||
41 | { | ||
42 | if (this._physActor == null) | ||
43 | { | ||
44 | //HACKHACK: Note to work out why this entity does not have a physics actor | ||
45 | // and prehaps create one. | ||
46 | return; | ||
47 | } | ||
48 | libsecondlife.LLVector3 pos2 = new LLVector3(this._physActor.Position.X, this._physActor.Position.Y, this._physActor.Position.Z); | ||
49 | if (this.updateflag) | ||
50 | { | ||
51 | //need to send movement info | ||
52 | //so create the improvedterseobjectupdate packet | ||
53 | //use CreateTerseBlock() | ||
54 | ImprovedTerseObjectUpdatePacket.ObjectDataBlock terseBlock = CreateTerseBlock(); | ||
55 | ImprovedTerseObjectUpdatePacket terse = new ImprovedTerseObjectUpdatePacket(); | ||
56 | terse.RegionData.RegionHandle = m_regionHandle; // FIXME | ||
57 | terse.RegionData.TimeDilation = 64096; | ||
58 | terse.ObjectData = new ImprovedTerseObjectUpdatePacket.ObjectDataBlock[1]; | ||
59 | terse.ObjectData[0] = terseBlock; | ||
60 | List<Avatar> avList = this.m_world.RequestAvatarList(); | ||
61 | foreach (Avatar client in avList) | ||
62 | { | ||
63 | client.SendPacketToViewer(terse); | ||
64 | } | ||
65 | |||
66 | updateflag = false; | ||
67 | //this._updateCount = 0; | ||
68 | } | ||
69 | else | ||
70 | { | ||
71 | |||
72 | if ((pos2 != this.positionLastFrame) || (this.movementflag == 16)) | ||
73 | { | ||
74 | _updateCount++; | ||
75 | if (((!PhysicsEngineFlying) && (_updateCount > 3)) || (PhysicsEngineFlying) && (_updateCount > 0)) | ||
76 | { | ||
77 | //It has been a while since last update was sent so lets send one. | ||
78 | ImprovedTerseObjectUpdatePacket.ObjectDataBlock terseBlock = CreateTerseBlock(); | ||
79 | ImprovedTerseObjectUpdatePacket terse = new ImprovedTerseObjectUpdatePacket(); | ||
80 | terse.RegionData.RegionHandle = m_regionHandle; // FIXME | ||
81 | terse.RegionData.TimeDilation = 64096; | ||
82 | terse.ObjectData = new ImprovedTerseObjectUpdatePacket.ObjectDataBlock[1]; | ||
83 | terse.ObjectData[0] = terseBlock; | ||
84 | List<Avatar> avList = this.m_world.RequestAvatarList(); | ||
85 | foreach (Avatar client in avList) | ||
86 | { | ||
87 | client.SendPacketToViewer(terse); | ||
88 | } | ||
89 | _updateCount = 0; | ||
90 | } | ||
91 | |||
92 | if (this.movementflag == 16) | ||
93 | { | ||
94 | movementflag = 0; | ||
95 | } | ||
96 | } | ||
97 | |||
98 | } | ||
99 | |||
100 | if (positionFrameBeforeLast != pos2) | ||
101 | { | ||
102 | this.positionFrameBeforeLast = this.positionLastFrame; | ||
103 | this.positionLastFrame = pos2; | ||
104 | int tempRoundedX = (int)Math.Round(positionLastFrame.X); | ||
105 | int tempRoundedY = (int)Math.Round(positionLastFrame.Y); | ||
106 | if (this.positionRoundedX != tempRoundedX || this.positionRoundedY != tempRoundedY) | ||
107 | { | ||
108 | |||
109 | this.positionRoundedX = tempRoundedX; | ||
110 | this.positionRoundedY = tempRoundedY; | ||
111 | int currentParcelLocalID = m_world.parcelManager.getParcel(tempRoundedX, tempRoundedY).parcelData.localID; | ||
112 | if(currentParcelLocalID != this.positionParcelHoverLocalID) | ||
113 | { | ||
114 | |||
115 | Console.WriteLine("NEW PARCEL: " + m_world.parcelManager.getParcel(tempRoundedX, tempRoundedY).parcelData.parcelName); | ||
116 | m_world.parcelManager.getParcel(tempRoundedX, tempRoundedY).sendParcelProperties(this.parcelUpdateSequenceIncrement, false, 0,this.ControllingClient); | ||
117 | this.positionParcelHoverLocalID = currentParcelLocalID; | ||
118 | this.parcelUpdateSequenceIncrement++; | ||
119 | } | ||
120 | } | ||
121 | } | ||
122 | |||
123 | if (!this.ControllingClient.m_sandboxMode) | ||
124 | { | ||
125 | if (pos2.X < 0) | ||
126 | { | ||
127 | ControllingClient.CrossSimBorder(new LLVector3(this._physActor.Position.X, this._physActor.Position.Y, this._physActor.Position.Z)); | ||
128 | } | ||
129 | |||
130 | if (pos2.Y < 0) | ||
131 | { | ||
132 | ControllingClient.CrossSimBorder(new LLVector3(this._physActor.Position.X, this._physActor.Position.Y, this._physActor.Position.Z)); | ||
133 | } | ||
134 | |||
135 | if (pos2.X > 255) | ||
136 | { | ||
137 | ControllingClient.CrossSimBorder(new LLVector3(this._physActor.Position.X, this._physActor.Position.Y, this._physActor.Position.Z)); | ||
138 | } | ||
139 | |||
140 | if (pos2.Y > 255) | ||
141 | { | ||
142 | ControllingClient.CrossSimBorder(new LLVector3(this._physActor.Position.X, this._physActor.Position.Y, this._physActor.Position.Z)); | ||
143 | } | ||
144 | } | ||
145 | } | ||
146 | |||
147 | } | ||
148 | |||
149 | public void SendUpdateToOtherClient(Avatar remoteAvatar) | ||
150 | { | ||
151 | ObjectUpdatePacket objupdate = CreateUpdatePacket(); | ||
152 | remoteAvatar.SendPacketToViewer(objupdate); | ||
153 | } | ||
154 | |||
155 | public ObjectUpdatePacket CreateUpdatePacket() | ||
156 | { | ||
157 | System.Text.Encoding _enc = System.Text.Encoding.ASCII; | ||
158 | //send a objectupdate packet with information about the clients avatar | ||
159 | ObjectUpdatePacket objupdate = new ObjectUpdatePacket(); | ||
160 | objupdate.RegionData.RegionHandle = m_regionHandle; | ||
161 | objupdate.RegionData.TimeDilation = 64096; | ||
162 | objupdate.ObjectData = new libsecondlife.Packets.ObjectUpdatePacket.ObjectDataBlock[1]; | ||
163 | |||
164 | objupdate.ObjectData[0] = AvatarTemplate; | ||
165 | //give this avatar object a local id and assign the user a name | ||
166 | objupdate.ObjectData[0].ID = this.localid; | ||
167 | objupdate.ObjectData[0].FullID = ControllingClient.AgentID; | ||
168 | objupdate.ObjectData[0].NameValue = _enc.GetBytes("FirstName STRING RW SV " + firstname + "\nLastName STRING RW SV " + lastname + " \0"); | ||
169 | |||
170 | libsecondlife.LLVector3 pos2 = new LLVector3((float)this._physActor.Position.X, (float)this._physActor.Position.Y, (float)this._physActor.Position.Z); | ||
171 | |||
172 | byte[] pb = pos2.GetBytes(); | ||
173 | |||
174 | Array.Copy(pb, 0, objupdate.ObjectData[0].ObjectData, 16, pb.Length); | ||
175 | return objupdate; | ||
176 | } | ||
177 | |||
178 | public void SendInitialPosition() | ||
179 | { | ||
180 | System.Text.Encoding _enc = System.Text.Encoding.ASCII; | ||
181 | //send a objectupdate packet with information about the clients avatar | ||
182 | |||
183 | ObjectUpdatePacket objupdate = new ObjectUpdatePacket(); | ||
184 | objupdate.RegionData.RegionHandle = m_regionHandle; | ||
185 | objupdate.RegionData.TimeDilation = 64096; | ||
186 | objupdate.ObjectData = new libsecondlife.Packets.ObjectUpdatePacket.ObjectDataBlock[1]; | ||
187 | objupdate.ObjectData[0] = AvatarTemplate; | ||
188 | //give this avatar object a local id and assign the user a name | ||
189 | |||
190 | objupdate.ObjectData[0].ID = this.localid; | ||
191 | this.uuid = objupdate.ObjectData[0].FullID = ControllingClient.AgentID; | ||
192 | objupdate.ObjectData[0].NameValue = _enc.GetBytes("FirstName STRING RW SV " + firstname + "\nLastName STRING RW SV " + lastname + " \0"); | ||
193 | libsecondlife.LLVector3 pos2 = new LLVector3((float)this.Pos.X, (float)this.Pos.Y, (float)this.Pos.Z); | ||
194 | byte[] pb = pos2.GetBytes(); | ||
195 | Array.Copy(pb, 0, objupdate.ObjectData[0].ObjectData, 16, pb.Length); | ||
196 | m_world._localNumber++; | ||
197 | |||
198 | List<Avatar> avList = this.m_world.RequestAvatarList(); | ||
199 | foreach (Avatar client in avList) | ||
200 | { | ||
201 | client.SendPacketToViewer(objupdate); | ||
202 | if (client.ControllingClient.AgentID != this.ControllingClient.AgentID) | ||
203 | { | ||
204 | SendAppearanceToOtherAgent(client); | ||
205 | } | ||
206 | } | ||
207 | } | ||
208 | |||
209 | public void SendOurAppearance() | ||
210 | { | ||
211 | ControllingClient.SendAppearance(this.Wearables); | ||
212 | } | ||
213 | |||
214 | public void SendOurAppearance(ClientView OurClient) | ||
215 | { | ||
216 | //event handler for wearables request | ||
217 | this.SendOurAppearance(); | ||
218 | } | ||
219 | |||
220 | public void SendAppearanceToOtherAgent(Avatar avatarInfo) | ||
221 | { | ||
222 | AvatarAppearancePacket avp = new AvatarAppearancePacket(); | ||
223 | avp.VisualParam = new AvatarAppearancePacket.VisualParamBlock[218]; | ||
224 | avp.ObjectData.TextureEntry = this.avatarAppearanceTexture.ToBytes(); | ||
225 | |||
226 | AvatarAppearancePacket.VisualParamBlock avblock = null; | ||
227 | for (int i = 0; i < 218; i++) | ||
228 | { | ||
229 | avblock = new AvatarAppearancePacket.VisualParamBlock(); | ||
230 | avblock.ParamValue = visualParams[i]; | ||
231 | avp.VisualParam[i] = avblock; | ||
232 | } | ||
233 | |||
234 | avp.Sender.IsTrial = false; | ||
235 | avp.Sender.ID = ControllingClient.AgentID; | ||
236 | avatarInfo.SendPacketToViewer(avp); | ||
237 | } | ||
238 | |||
239 | public void SetAppearance(byte[] texture, AgentSetAppearancePacket.VisualParamBlock[] visualParam) | ||
240 | { | ||
241 | LLObject.TextureEntry tex = new LLObject.TextureEntry(texture, 0, texture.Length); | ||
242 | this.avatarAppearanceTexture = tex; | ||
243 | |||
244 | for (int i = 0; i < visualParam.Length; i++) | ||
245 | { | ||
246 | this.visualParams[i] = visualParam[i].ParamValue; | ||
247 | } | ||
248 | |||
249 | List<Avatar> avList = this.m_world.RequestAvatarList(); | ||
250 | foreach (Avatar client in avList) | ||
251 | { | ||
252 | if (client.ControllingClient.AgentID != this.ControllingClient.AgentID) | ||
253 | { | ||
254 | SendAppearanceToOtherAgent(client); | ||
255 | } | ||
256 | } | ||
257 | } | ||
258 | |||
259 | public ImprovedTerseObjectUpdatePacket.ObjectDataBlock CreateTerseBlock() | ||
260 | { | ||
261 | byte[] bytes = new byte[60]; | ||
262 | int i = 0; | ||
263 | ImprovedTerseObjectUpdatePacket.ObjectDataBlock dat = new ImprovedTerseObjectUpdatePacket.ObjectDataBlock(); | ||
264 | |||
265 | dat.TextureEntry = new byte[0];// AvatarTemplate.TextureEntry; | ||
266 | libsecondlife.LLVector3 pos2 = new LLVector3(0, 0, 0); | ||
267 | lock (m_world.LockPhysicsEngine) | ||
268 | { | ||
269 | pos2 = new LLVector3(this._physActor.Position.X, this._physActor.Position.Y, this._physActor.Position.Z); | ||
270 | } | ||
271 | |||
272 | uint ID = this.localid; | ||
273 | |||
274 | bytes[i++] = (byte)(ID % 256); | ||
275 | bytes[i++] = (byte)((ID >> 8) % 256); | ||
276 | bytes[i++] = (byte)((ID >> 16) % 256); | ||
277 | bytes[i++] = (byte)((ID >> 24) % 256); | ||
278 | bytes[i++] = 0; | ||
279 | bytes[i++] = 1; | ||
280 | i += 14; | ||
281 | bytes[i++] = 128; | ||
282 | bytes[i++] = 63; | ||
283 | |||
284 | byte[] pb = pos2.GetBytes(); | ||
285 | Array.Copy(pb, 0, bytes, i, pb.Length); | ||
286 | i += 12; | ||
287 | ushort InternVelocityX; | ||
288 | ushort InternVelocityY; | ||
289 | ushort InternVelocityZ; | ||
290 | Axiom.MathLib.Vector3 internDirec = new Axiom.MathLib.Vector3(0, 0, 0); | ||
291 | lock (m_world.LockPhysicsEngine) | ||
292 | { | ||
293 | internDirec = new Axiom.MathLib.Vector3(this._physActor.Velocity.X, this._physActor.Velocity.Y, this._physActor.Velocity.Z); | ||
294 | } | ||
295 | internDirec = internDirec / 128.0f; | ||
296 | internDirec.x += 1; | ||
297 | internDirec.y += 1; | ||
298 | internDirec.z += 1; | ||
299 | |||
300 | InternVelocityX = (ushort)(32768 * internDirec.x); | ||
301 | InternVelocityY = (ushort)(32768 * internDirec.y); | ||
302 | InternVelocityZ = (ushort)(32768 * internDirec.z); | ||
303 | |||
304 | ushort ac = 32767; | ||
305 | bytes[i++] = (byte)(InternVelocityX % 256); | ||
306 | bytes[i++] = (byte)((InternVelocityX >> 8) % 256); | ||
307 | bytes[i++] = (byte)(InternVelocityY % 256); | ||
308 | bytes[i++] = (byte)((InternVelocityY >> 8) % 256); | ||
309 | bytes[i++] = (byte)(InternVelocityZ % 256); | ||
310 | bytes[i++] = (byte)((InternVelocityZ >> 8) % 256); | ||
311 | |||
312 | //accel | ||
313 | bytes[i++] = (byte)(ac % 256); | ||
314 | bytes[i++] = (byte)((ac >> 8) % 256); | ||
315 | bytes[i++] = (byte)(ac % 256); | ||
316 | bytes[i++] = (byte)((ac >> 8) % 256); | ||
317 | bytes[i++] = (byte)(ac % 256); | ||
318 | bytes[i++] = (byte)((ac >> 8) % 256); | ||
319 | |||
320 | //rot | ||
321 | bytes[i++] = (byte)(ac % 256); | ||
322 | bytes[i++] = (byte)((ac >> 8) % 256); | ||
323 | bytes[i++] = (byte)(ac % 256); | ||
324 | bytes[i++] = (byte)((ac >> 8) % 256); | ||
325 | bytes[i++] = (byte)(ac % 256); | ||
326 | bytes[i++] = (byte)((ac >> 8) % 256); | ||
327 | bytes[i++] = (byte)(ac % 256); | ||
328 | bytes[i++] = (byte)((ac >> 8) % 256); | ||
329 | |||
330 | //rotation vel | ||
331 | bytes[i++] = (byte)(ac % 256); | ||
332 | bytes[i++] = (byte)((ac >> 8) % 256); | ||
333 | bytes[i++] = (byte)(ac % 256); | ||
334 | bytes[i++] = (byte)((ac >> 8) % 256); | ||
335 | bytes[i++] = (byte)(ac % 256); | ||
336 | bytes[i++] = (byte)((ac >> 8) % 256); | ||
337 | |||
338 | dat.Data = bytes; | ||
339 | return (dat); | ||
340 | } | ||
341 | |||
342 | // Sends animation update | ||
343 | public void SendAnimPack(LLUUID animID, int seq) | ||
344 | { | ||
345 | AvatarAnimationPacket ani = new AvatarAnimationPacket(); | ||
346 | ani.AnimationSourceList = new AvatarAnimationPacket.AnimationSourceListBlock[1]; | ||
347 | ani.AnimationSourceList[0] = new AvatarAnimationPacket.AnimationSourceListBlock(); | ||
348 | ani.AnimationSourceList[0].ObjectID = ControllingClient.AgentID; | ||
349 | ani.Sender = new AvatarAnimationPacket.SenderBlock(); | ||
350 | ani.Sender.ID = ControllingClient.AgentID; | ||
351 | ani.AnimationList = new AvatarAnimationPacket.AnimationListBlock[1]; | ||
352 | ani.AnimationList[0] = new AvatarAnimationPacket.AnimationListBlock(); | ||
353 | ani.AnimationList[0].AnimID = this.current_anim = animID; | ||
354 | ani.AnimationList[0].AnimSequenceID = this.anim_seq = seq; | ||
355 | |||
356 | List<Avatar> avList = this.m_world.RequestAvatarList(); | ||
357 | foreach (Avatar client in avList) | ||
358 | { | ||
359 | client.SendPacketToViewer(ani); | ||
360 | } | ||
361 | |||
362 | } | ||
363 | |||
364 | public void SendAnimPack() | ||
365 | { | ||
366 | this.SendAnimPack(this.current_anim, this.anim_seq); | ||
367 | } | ||
368 | |||
369 | } | ||
370 | } | ||