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