aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/OpenSim.RegionServer/world/Primitive.cs
diff options
context:
space:
mode:
Diffstat (limited to 'OpenSim/OpenSim.RegionServer/world/Primitive.cs')
-rw-r--r--OpenSim/OpenSim.RegionServer/world/Primitive.cs597
1 files changed, 0 insertions, 597 deletions
diff --git a/OpenSim/OpenSim.RegionServer/world/Primitive.cs b/OpenSim/OpenSim.RegionServer/world/Primitive.cs
deleted file mode 100644
index 07d07db..0000000
--- a/OpenSim/OpenSim.RegionServer/world/Primitive.cs
+++ /dev/null
@@ -1,597 +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*/
28using System;
29using System.Collections.Generic;
30using System.Text;
31using OpenSim.types;
32using libsecondlife;
33using libsecondlife.Packets;
34using OpenSim.Framework.Interfaces;
35using OpenSim.Physics.Manager;
36using OpenSim.Framework.Types;
37
38namespace OpenSim.world
39{
40 public class Primitive : Entity
41 {
42 protected float mesh_cutbegin;
43 protected float mesh_cutend;
44 protected PrimData primData;
45 protected bool newPrimFlag = false;
46 protected bool updateFlag = false;
47 protected bool dirtyFlag = false;
48 private ObjectUpdatePacket OurPacket;
49 private bool physicsEnabled = false;
50 private bool physicstest = false;
51 private LLVector3 positionLastFrame = new LLVector3(0, 0, 0);
52 private Dictionary<uint, ClientView> m_clientThreads;
53 private ulong m_regionHandle;
54 private const uint FULL_MASK_PERMISSIONS = 2147483647;
55
56 public bool PhysicsEnabled
57 {
58 get
59 {
60 return physicsEnabled;
61 }
62 set
63 {
64 physicsEnabled = value;
65 }
66 }
67 public bool UpdateFlag
68 {
69 get
70 {
71 return updateFlag;
72 }
73 set
74 {
75 updateFlag = value;
76 }
77 }
78 public LLVector3 Scale
79 {
80 set
81 {
82 LLVector3 offset = (value - primData.Scale);
83 offset.X /= 2;
84 offset.Y /= 2;
85 offset.Z /= 2;
86
87 this.primData.Position += offset;
88 this.primData.Scale = value;
89
90 this.dirtyFlag = true;
91 }
92 get
93 {
94 return this.primData.Scale;
95 }
96 }
97 public PhysicsActor PhysActor
98 {
99 set
100 {
101 this._physActor = value;
102 }
103 }
104
105 public Primitive(Dictionary<uint, ClientView> clientThreads, ulong regionHandle, World world)
106 {
107 mesh_cutbegin = 0.0f;
108 mesh_cutend = 1.0f;
109
110 m_clientThreads = clientThreads;
111 m_regionHandle = regionHandle;
112 m_world = world;
113 }
114
115 public override Mesh getMesh()
116 {
117 Mesh mesh = new Mesh();
118 Triangle tri = new Triangle(
119 new Axiom.MathLib.Vector3(0.0f, 1.0f, 1.0f),
120 new Axiom.MathLib.Vector3(1.0f, 0.0f, 1.0f),
121 new Axiom.MathLib.Vector3(1.0f, 1.0f, 0.0f));
122
123 mesh.AddTri(tri);
124 mesh += base.getMesh();
125
126 return mesh;
127 }
128
129 public byte[] GetByteArray()
130 {
131 return this.primData.ToBytes();
132 }
133
134 public void GetProperites(ClientView client)
135 {
136 ObjectPropertiesPacket proper = new ObjectPropertiesPacket();
137 proper.ObjectData = new ObjectPropertiesPacket.ObjectDataBlock[1];
138 proper.ObjectData[0] = new ObjectPropertiesPacket.ObjectDataBlock();
139 proper.ObjectData[0].ItemID = LLUUID.Zero; // this.uuid;
140 proper.ObjectData[0].CreationDate = (ulong) this.primData.CreationDate;
141 proper.ObjectData[0].CreatorID = this.primData.OwnerID;
142 proper.ObjectData[0].FolderID = LLUUID.Zero;
143 proper.ObjectData[0].FromTaskID = LLUUID.Zero;
144 proper.ObjectData[0].GroupID = LLUUID.Zero;
145 proper.ObjectData[0].InventorySerial = 0;
146 proper.ObjectData[0].LastOwnerID = LLUUID.Zero;
147 proper.ObjectData[0].ObjectID = this.uuid;
148 proper.ObjectData[0].OwnerID = primData.OwnerID;
149 proper.ObjectData[0].TouchName = new byte[0];
150 proper.ObjectData[0].TextureID = new byte[0];
151 proper.ObjectData[0].SitName = new byte[0];
152 proper.ObjectData[0].Name = new byte[0];
153 proper.ObjectData[0].Description = new byte[0];
154 proper.ObjectData[0].OwnerMask = this.primData.OwnerMask;
155 proper.ObjectData[0].NextOwnerMask = this.primData.NextOwnerMask;
156 proper.ObjectData[0].GroupMask = this.primData.GroupMask;
157 proper.ObjectData[0].EveryoneMask = this.primData.EveryoneMask;
158 proper.ObjectData[0].BaseMask = this.primData.BaseMask;
159
160 client.OutPacket(proper);
161 }
162
163 public void UpdatePosition(LLVector3 pos)
164 {
165 this.Pos = pos;
166 if (this._physActor != null) // && this.physicsEnabled)
167 {
168 try
169 {
170 lock (m_world.LockPhysicsEngine)
171 {
172 this._physActor.Position = new PhysicsVector(pos.X, pos.Y, pos.Z);
173 }
174 }
175 catch (Exception e)
176 {
177 Console.WriteLine(e.Message);
178 }
179 }
180 this.updateFlag = true;
181 }
182
183 public override void update()
184 {
185 LLVector3 pos2 = new LLVector3(0, 0, 0);
186 if (this._physActor != null && this.physicsEnabled)
187 {
188
189 PhysicsVector pPos = this._physActor.Position;
190 pos2 = new LLVector3(pPos.X, pPos.Y, pPos.Z);
191 }
192 if (this.newPrimFlag)
193 {
194 foreach (ClientView client in m_clientThreads.Values)
195 {
196 client.OutPacket(OurPacket);
197 }
198 this.newPrimFlag = false;
199 }
200 else if (this.updateFlag)
201 {
202 ImprovedTerseObjectUpdatePacket terse = new ImprovedTerseObjectUpdatePacket();
203 terse.RegionData.RegionHandle = m_regionHandle; // FIXME
204 terse.RegionData.TimeDilation = 64096;
205 terse.ObjectData = new ImprovedTerseObjectUpdatePacket.ObjectDataBlock[1];
206 terse.ObjectData[0] = this.CreateImprovedBlock();
207 foreach (ClientView client in m_clientThreads.Values)
208 {
209 client.OutPacket(terse);
210 }
211 this.updateFlag = false;
212 }
213 else if (this.dirtyFlag)
214 {
215 foreach (ClientView client in m_clientThreads.Values)
216 {
217 UpdateClient(client);
218 }
219 this.dirtyFlag = false;
220 }
221 else
222 {
223 if (this._physActor != null && this.physicsEnabled)
224 {
225 if (pos2 != this.positionLastFrame)
226 {
227 ImprovedTerseObjectUpdatePacket terse = new ImprovedTerseObjectUpdatePacket();
228 terse.RegionData.RegionHandle = m_regionHandle; // FIXME
229 terse.RegionData.TimeDilation = 64096;
230 terse.ObjectData = new ImprovedTerseObjectUpdatePacket.ObjectDataBlock[1];
231 terse.ObjectData[0] = this.CreateImprovedBlock();
232 foreach (ClientView client in m_clientThreads.Values)
233 {
234 client.OutPacket(terse);
235 }
236 }
237 this.positionLastFrame = pos2;
238 }
239 }
240
241 if (this.physicstest)
242 {
243 LLVector3 pos = this.Pos;
244 pos.Z += 0.0001f;
245 this.UpdatePosition(pos);
246 this.physicstest = false;
247 }
248 }
249
250 public void UpdateClient(ClientView RemoteClient)
251 {
252
253 LLVector3 lPos;
254 if (this._physActor != null && this.physicsEnabled)
255 {
256 PhysicsVector pPos = this._physActor.Position;
257 lPos = new LLVector3(pPos.X, pPos.Y, pPos.Z);
258 }
259 else
260 {
261 lPos = this.Pos;
262 }
263 byte[] pb = lPos.GetBytes();
264 Array.Copy(pb, 0, OurPacket.ObjectData[0].ObjectData, 0, pb.Length);
265
266 // OurPacket should be update with the follwing in updateShape() rather than having to do it here
267 OurPacket.ObjectData[0].OwnerID = this.primData.OwnerID;
268 OurPacket.ObjectData[0].PCode = this.primData.PCode;
269 OurPacket.ObjectData[0].PathBegin = this.primData.PathBegin;
270 OurPacket.ObjectData[0].PathEnd = this.primData.PathEnd;
271 OurPacket.ObjectData[0].PathScaleX = this.primData.PathScaleX;
272 OurPacket.ObjectData[0].PathScaleY = this.primData.PathScaleY;
273 OurPacket.ObjectData[0].PathShearX = this.primData.PathShearX;
274 OurPacket.ObjectData[0].PathShearY = this.primData.PathShearY;
275 OurPacket.ObjectData[0].PathSkew = this.primData.PathSkew;
276 OurPacket.ObjectData[0].ProfileBegin = this.primData.ProfileBegin;
277 OurPacket.ObjectData[0].ProfileEnd = this.primData.ProfileEnd;
278 OurPacket.ObjectData[0].Scale = this.primData.Scale;
279 OurPacket.ObjectData[0].PathCurve = this.primData.PathCurve;
280 OurPacket.ObjectData[0].ProfileCurve = this.primData.ProfileCurve;
281 OurPacket.ObjectData[0].ParentID = this.primData.ParentID ;
282 OurPacket.ObjectData[0].ProfileHollow = this.primData.ProfileHollow;
283 //finish off copying rest of shape data
284 OurPacket.ObjectData[0].PathRadiusOffset = this.primData.PathRadiusOffset;
285 OurPacket.ObjectData[0].PathRevolutions = this.primData.PathRevolutions;
286 OurPacket.ObjectData[0].PathTaperX = this.primData.PathTaperX;
287 OurPacket.ObjectData[0].PathTaperY = this.primData.PathTaperY;
288 OurPacket.ObjectData[0].PathTwist = this.primData.PathTwist;
289 OurPacket.ObjectData[0].PathTwistBegin = this.primData.PathTwistBegin;
290
291 RemoteClient.OutPacket(OurPacket);
292 }
293
294 public void UpdateShape(ObjectShapePacket.ObjectDataBlock addPacket)
295 {
296 this.primData.PathBegin = addPacket.PathBegin;
297 this.primData.PathEnd = addPacket.PathEnd;
298 this.primData.PathScaleX = addPacket.PathScaleX;
299 this.primData.PathScaleY = addPacket.PathScaleY;
300 this.primData.PathShearX = addPacket.PathShearX;
301 this.primData.PathShearY = addPacket.PathShearY;
302 this.primData.PathSkew = addPacket.PathSkew;
303 this.primData.ProfileBegin = addPacket.ProfileBegin;
304 this.primData.ProfileEnd = addPacket.ProfileEnd;
305 this.primData.PathCurve = addPacket.PathCurve;
306 this.primData.ProfileCurve = addPacket.ProfileCurve;
307 this.primData.ProfileHollow = addPacket.ProfileHollow;
308 this.primData.PathRadiusOffset = addPacket.PathRadiusOffset;
309 this.primData.PathRevolutions = addPacket.PathRevolutions;
310 this.primData.PathTaperX = addPacket.PathTaperX;
311 this.primData.PathTaperY = addPacket.PathTaperY;
312 this.primData.PathTwist = addPacket.PathTwist;
313 this.primData.PathTwistBegin = addPacket.PathTwistBegin;
314 this.dirtyFlag = true;
315 }
316
317 public void UpdateTexture(byte[] tex)
318 {
319 this.OurPacket.ObjectData[0].TextureEntry = tex;
320 this.primData.Texture = tex;
321 this.dirtyFlag = true;
322 }
323
324 public void UpdateObjectFlags(ObjectFlagUpdatePacket pack)
325 {
326 if (this._physActor != null)
327 {
328 if (this._physActor.Kinematic == pack.AgentData.UsePhysics)
329 {
330 this._physActor.Kinematic = !pack.AgentData.UsePhysics; //if Usephysics = true, then Kinematic should = false
331 }
332 this.physicsEnabled = pack.AgentData.UsePhysics;
333 if (this._physActor.Kinematic == false)
334 {
335 LLVector3 pos = this.Pos;
336 this.UpdatePosition(pos);
337 pos.Z += 0.000001f;
338 this.UpdatePosition(pos);
339 this.physicstest = true;
340 }
341 else
342 {
343 PhysicsVector vec = this._physActor.Position;
344 LLVector3 pos = new LLVector3(vec.X, vec.Y, vec.Z);
345 this.Pos = pos;
346 this.updateFlag = true;
347 }
348 }
349 }
350
351 public void MakeParent(Primitive prim)
352 {
353 this.primData.ParentID = prim.localid;
354 this.Pos -= prim.Pos;
355 this.dirtyFlag = true;
356 }
357
358 public void CreateFromPacket(ObjectAddPacket addPacket, LLUUID ownerID, uint localID)
359 {
360 ObjectUpdatePacket objupdate = new ObjectUpdatePacket();
361 objupdate.RegionData.RegionHandle = m_regionHandle;
362 objupdate.RegionData.TimeDilation = 64096;
363
364 objupdate.ObjectData = new libsecondlife.Packets.ObjectUpdatePacket.ObjectDataBlock[1];
365 PrimData PData = new PrimData();
366 this.primData = PData;
367 this.primData.CreationDate = (Int32)(DateTime.UtcNow - new DateTime(1970, 1, 1)).TotalSeconds;
368
369 objupdate.ObjectData[0] = new ObjectUpdatePacket.ObjectDataBlock();
370 objupdate.ObjectData[0].PSBlock = new byte[0];
371 objupdate.ObjectData[0].ExtraParams = new byte[1];
372 objupdate.ObjectData[0].MediaURL = new byte[0];
373 objupdate.ObjectData[0].NameValue = new byte[0];
374 objupdate.ObjectData[0].Text = new byte[0];
375 objupdate.ObjectData[0].TextColor = new byte[4];
376 objupdate.ObjectData[0].JointAxisOrAnchor = new LLVector3(0, 0, 0);
377 objupdate.ObjectData[0].JointPivot = new LLVector3(0, 0, 0);
378 objupdate.ObjectData[0].Material = 3;
379 objupdate.ObjectData[0].UpdateFlags = 32 + 65536 + 131072 + 256 + 4 + 8 + 2048 + 524288 + 268435456;
380 objupdate.ObjectData[0].TextureAnim = new byte[0];
381 objupdate.ObjectData[0].Sound = LLUUID.Zero;
382 LLObject.TextureEntry ntex = new LLObject.TextureEntry(new LLUUID("00000000-0000-0000-5005-000000000005"));
383 this.primData.Texture = objupdate.ObjectData[0].TextureEntry = ntex.ToBytes();
384 objupdate.ObjectData[0].State = 0;
385 objupdate.ObjectData[0].Data = new byte[0];
386 PData.OwnerID = objupdate.ObjectData[0].OwnerID = ownerID;
387 PData.PCode = objupdate.ObjectData[0].PCode = addPacket.ObjectData.PCode;
388 PData.PathBegin = objupdate.ObjectData[0].PathBegin = addPacket.ObjectData.PathBegin;
389 PData.PathEnd = objupdate.ObjectData[0].PathEnd = addPacket.ObjectData.PathEnd;
390 PData.PathScaleX = objupdate.ObjectData[0].PathScaleX = addPacket.ObjectData.PathScaleX;
391 PData.PathScaleY = objupdate.ObjectData[0].PathScaleY = addPacket.ObjectData.PathScaleY;
392 PData.PathShearX = objupdate.ObjectData[0].PathShearX = addPacket.ObjectData.PathShearX;
393 PData.PathShearY = objupdate.ObjectData[0].PathShearY = addPacket.ObjectData.PathShearY;
394 PData.PathSkew = objupdate.ObjectData[0].PathSkew = addPacket.ObjectData.PathSkew;
395 PData.ProfileBegin = objupdate.ObjectData[0].ProfileBegin = addPacket.ObjectData.ProfileBegin;
396 PData.ProfileEnd = objupdate.ObjectData[0].ProfileEnd = addPacket.ObjectData.ProfileEnd;
397 PData.Scale = objupdate.ObjectData[0].Scale = addPacket.ObjectData.Scale;
398 PData.PathCurve = objupdate.ObjectData[0].PathCurve = addPacket.ObjectData.PathCurve;
399 PData.ProfileCurve = objupdate.ObjectData[0].ProfileCurve = addPacket.ObjectData.ProfileCurve;
400 PData.ParentID = objupdate.ObjectData[0].ParentID = 0;
401 PData.ProfileHollow = objupdate.ObjectData[0].ProfileHollow = addPacket.ObjectData.ProfileHollow;
402 PData.PathRadiusOffset = objupdate.ObjectData[0].PathRadiusOffset = addPacket.ObjectData.PathRadiusOffset;
403 PData.PathRevolutions = objupdate.ObjectData[0].PathRevolutions = addPacket.ObjectData.PathRevolutions;
404 PData.PathTaperX = objupdate.ObjectData[0].PathTaperX = addPacket.ObjectData.PathTaperX;
405 PData.PathTaperY = objupdate.ObjectData[0].PathTaperY = addPacket.ObjectData.PathTaperY;
406 PData.PathTwist = objupdate.ObjectData[0].PathTwist = addPacket.ObjectData.PathTwist;
407 PData.PathTwistBegin = objupdate.ObjectData[0].PathTwistBegin = addPacket.ObjectData.PathTwistBegin;
408
409 objupdate.ObjectData[0].ID = (uint)(localID);
410 objupdate.ObjectData[0].FullID = new LLUUID("edba7151-5857-acc5-b30b-f01efef" + (localID - 702000).ToString("00000"));
411 objupdate.ObjectData[0].ObjectData = new byte[60];
412 objupdate.ObjectData[0].ObjectData[46] = 128;
413 objupdate.ObjectData[0].ObjectData[47] = 63;
414 LLVector3 pos1 = addPacket.ObjectData.RayEnd;
415 //update position
416 byte[] pb = pos1.GetBytes();
417 Array.Copy(pb, 0, objupdate.ObjectData[0].ObjectData, 0, pb.Length);
418 this.newPrimFlag = true;
419 this.primData.FullID = this.uuid = objupdate.ObjectData[0].FullID;
420 this.localid = objupdate.ObjectData[0].ID;
421 this.primData.Position = this.Pos = pos1;
422 this.OurPacket = objupdate;
423 }
424
425 public void CreateFromStorage(PrimData store)
426 {
427 this.CreateFromStorage(store, store.Position, store.LocalID, false);
428 }
429
430 public void CreateFromStorage(PrimData store, LLVector3 posi, uint localID, bool newprim)
431 {
432 //need to clean this up as it shares a lot of code with CreateFromPacket()
433 ObjectUpdatePacket objupdate = new ObjectUpdatePacket();
434 objupdate.RegionData.RegionHandle = m_regionHandle;
435 objupdate.RegionData.TimeDilation = 64096;
436 objupdate.ObjectData = new libsecondlife.Packets.ObjectUpdatePacket.ObjectDataBlock[1];
437
438 this.primData = store;
439 objupdate.ObjectData[0] = new ObjectUpdatePacket.ObjectDataBlock();
440 objupdate.ObjectData[0].PSBlock = new byte[0];
441 objupdate.ObjectData[0].ExtraParams = new byte[1];
442 objupdate.ObjectData[0].MediaURL = new byte[0];
443 objupdate.ObjectData[0].NameValue = new byte[0];
444 objupdate.ObjectData[0].Text = new byte[0];
445 objupdate.ObjectData[0].TextColor = new byte[4];
446 objupdate.ObjectData[0].JointAxisOrAnchor = new LLVector3(0, 0, 0);
447 objupdate.ObjectData[0].JointPivot = new LLVector3(0, 0, 0);
448 objupdate.ObjectData[0].Material = 3;
449 objupdate.ObjectData[0].UpdateFlags = 32 + 65536 + 131072 + 256 + 4 + 8 + 2048 + 524288 + 268435456;
450 objupdate.ObjectData[0].TextureAnim = new byte[0];
451 objupdate.ObjectData[0].Sound = LLUUID.Zero;
452
453 if (store.Texture == null)
454 {
455 LLObject.TextureEntry ntex = new LLObject.TextureEntry(new LLUUID("00000000-0000-0000-5005-000000000005"));
456 objupdate.ObjectData[0].TextureEntry = ntex.ToBytes();
457 }
458 else
459 {
460 objupdate.ObjectData[0].TextureEntry = store.Texture;
461 }
462
463 objupdate.ObjectData[0].State = 0;
464 objupdate.ObjectData[0].Data = new byte[0];
465 objupdate.ObjectData[0].OwnerID = this.primData.OwnerID;
466 objupdate.ObjectData[0].PCode = this.primData.PCode;
467 objupdate.ObjectData[0].PathBegin = this.primData.PathBegin;
468 objupdate.ObjectData[0].PathEnd = this.primData.PathEnd;
469 objupdate.ObjectData[0].PathScaleX = this.primData.PathScaleX;
470 objupdate.ObjectData[0].PathScaleY = this.primData.PathScaleY;
471 objupdate.ObjectData[0].PathShearX = this.primData.PathShearX;
472 objupdate.ObjectData[0].PathShearY = this.primData.PathShearY;
473 objupdate.ObjectData[0].PathSkew = this.primData.PathSkew;
474 objupdate.ObjectData[0].ProfileBegin = this.primData.ProfileBegin;
475 objupdate.ObjectData[0].ProfileEnd = this.primData.ProfileEnd;
476 objupdate.ObjectData[0].Scale = this.primData.Scale;
477 objupdate.ObjectData[0].PathCurve = this.primData.PathCurve;
478 objupdate.ObjectData[0].ProfileCurve = this.primData.ProfileCurve;
479 objupdate.ObjectData[0].ParentID = 0;
480 objupdate.ObjectData[0].ProfileHollow = this.primData.ProfileHollow;
481 //finish off copying rest of shape data
482 objupdate.ObjectData[0].PathRadiusOffset = this.primData.PathRadiusOffset;
483 objupdate.ObjectData[0].PathRevolutions = this.primData.PathRevolutions;
484 objupdate.ObjectData[0].PathTaperX = this.primData.PathTaperX;
485 objupdate.ObjectData[0].PathTaperY = this.primData.PathTaperY;
486 objupdate.ObjectData[0].PathTwist = this.primData.PathTwist;
487 objupdate.ObjectData[0].PathTwistBegin = this.primData.PathTwistBegin;
488
489 objupdate.ObjectData[0].ID = localID; // (uint)store.LocalID;
490 objupdate.ObjectData[0].FullID = store.FullID;
491
492 objupdate.ObjectData[0].ObjectData = new byte[60];
493 objupdate.ObjectData[0].ObjectData[46] = 128;
494 objupdate.ObjectData[0].ObjectData[47] = 63;
495 LLVector3 pos1 = posi; // store.Position;
496 //update position
497 byte[] pb = pos1.GetBytes();
498 Array.Copy(pb, 0, objupdate.ObjectData[0].ObjectData, 0, pb.Length);
499
500 this.uuid = objupdate.ObjectData[0].FullID;
501 this.localid = objupdate.ObjectData[0].ID;
502 this.Pos = pos1;
503 this.OurPacket = objupdate;
504 if (newprim)
505 {
506 this.newPrimFlag = true;
507 }
508 }
509
510 public ImprovedTerseObjectUpdatePacket.ObjectDataBlock CreateImprovedBlock()
511 {
512 uint ID = this.localid;
513 byte[] bytes = new byte[60];
514
515 int i = 0;
516 ImprovedTerseObjectUpdatePacket.ObjectDataBlock dat = new ImprovedTerseObjectUpdatePacket.ObjectDataBlock();
517 //dat.TextureEntry = this.OurPacket.ObjectData[0].TextureEntry;
518 dat.TextureEntry = new byte[0];
519 bytes[i++] = (byte)(ID % 256);
520 bytes[i++] = (byte)((ID >> 8) % 256);
521 bytes[i++] = (byte)((ID >> 16) % 256);
522 bytes[i++] = (byte)((ID >> 24) % 256);
523 bytes[i++] = 0;
524 bytes[i++] = 0;
525
526 LLVector3 lPos;
527 Axiom.MathLib.Quaternion lRot;
528 if (this._physActor != null && this.physicsEnabled)
529 {
530 PhysicsVector pPos = this._physActor.Position;
531 lPos = new LLVector3(pPos.X, pPos.Y, pPos.Z);
532 lRot = this._physActor.Orientation;
533 }
534 else
535 {
536 lPos = this.Pos;
537 lRot = this.rotation;
538 }
539 byte[] pb = lPos.GetBytes();
540 Array.Copy(pb, 0, bytes, i, pb.Length);
541 i += 12;
542 ushort ac = 32767;
543
544 //vel
545 bytes[i++] = (byte)(ac % 256);
546 bytes[i++] = (byte)((ac >> 8) % 256);
547 bytes[i++] = (byte)(ac % 256);
548 bytes[i++] = (byte)((ac >> 8) % 256);
549 bytes[i++] = (byte)(ac % 256);
550 bytes[i++] = (byte)((ac >> 8) % 256);
551
552 //accel
553 bytes[i++] = (byte)(ac % 256);
554 bytes[i++] = (byte)((ac >> 8) % 256);
555 bytes[i++] = (byte)(ac % 256);
556 bytes[i++] = (byte)((ac >> 8) % 256);
557 bytes[i++] = (byte)(ac % 256);
558 bytes[i++] = (byte)((ac >> 8) % 256);
559
560 ushort rw, rx, ry, rz;
561 rw = (ushort)(32768 * (lRot.w + 1));
562 rx = (ushort)(32768 * (lRot.x + 1));
563 ry = (ushort)(32768 * (lRot.y + 1));
564 rz = (ushort)(32768 * (lRot.z + 1));
565
566 //rot
567 bytes[i++] = (byte)(rx % 256);
568 bytes[i++] = (byte)((rx >> 8) % 256);
569 bytes[i++] = (byte)(ry % 256);
570 bytes[i++] = (byte)((ry >> 8) % 256);
571 bytes[i++] = (byte)(rz % 256);
572 bytes[i++] = (byte)((rz >> 8) % 256);
573 bytes[i++] = (byte)(rw % 256);
574 bytes[i++] = (byte)((rw >> 8) % 256);
575
576 //rotation vel
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 dat.Data = bytes;
585 return dat;
586 }
587
588 public override void BackUp()
589 {
590 this.primData.FullID = this.uuid;
591 this.primData.LocalID = this.localid;
592 this.primData.Position = this.Pos;
593 this.primData.Rotation = new LLQuaternion(this.rotation.x, this.rotation.y, this.rotation.z, this.rotation.w);
594 this.m_world.localStorage.StorePrim(this.primData);
595 }
596 }
597}