diff options
Diffstat (limited to 'OpenSim/OpenSim.RegionServer/Simulator/Primitive2.cs')
-rw-r--r-- | OpenSim/OpenSim.RegionServer/Simulator/Primitive2.cs | 519 |
1 files changed, 0 insertions, 519 deletions
diff --git a/OpenSim/OpenSim.RegionServer/Simulator/Primitive2.cs b/OpenSim/OpenSim.RegionServer/Simulator/Primitive2.cs deleted file mode 100644 index 0286e54..0000000 --- a/OpenSim/OpenSim.RegionServer/Simulator/Primitive2.cs +++ /dev/null | |||
@@ -1,519 +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 OpenSim.RegionServer.Types; | ||
32 | using libsecondlife; | ||
33 | using libsecondlife.Packets; | ||
34 | using OpenSim.Framework.Interfaces; | ||
35 | using OpenSim.Physics.Manager; | ||
36 | using OpenSim.Framework.Types; | ||
37 | using OpenSim.Framework.Inventory; | ||
38 | using OpenSim.RegionServer.Client; | ||
39 | |||
40 | namespace OpenSim.RegionServer.Simulator | ||
41 | { | ||
42 | public class Primitive2 : Entity | ||
43 | { | ||
44 | protected PrimData primData; | ||
45 | //private ObjectUpdatePacket OurPacket; | ||
46 | private LLVector3 positionLastFrame = new LLVector3(0, 0, 0); | ||
47 | private Dictionary<uint, ClientView> m_clientThreads; | ||
48 | private ulong m_regionHandle; | ||
49 | private const uint FULL_MASK_PERMISSIONS = 2147483647; | ||
50 | private bool physicsEnabled = false; | ||
51 | |||
52 | private Dictionary<LLUUID, InventoryItem> inventoryItems; | ||
53 | |||
54 | #region Properties | ||
55 | |||
56 | public LLVector3 Scale | ||
57 | { | ||
58 | set | ||
59 | { | ||
60 | this.primData.Scale = value; | ||
61 | //this.dirtyFlag = true; | ||
62 | } | ||
63 | get | ||
64 | { | ||
65 | return this.primData.Scale; | ||
66 | } | ||
67 | } | ||
68 | |||
69 | public PhysicsActor PhysActor | ||
70 | { | ||
71 | set | ||
72 | { | ||
73 | this._physActor = value; | ||
74 | } | ||
75 | } | ||
76 | public override LLVector3 Pos | ||
77 | { | ||
78 | get | ||
79 | { | ||
80 | return base.Pos; | ||
81 | } | ||
82 | set | ||
83 | { | ||
84 | base.Pos = value; | ||
85 | } | ||
86 | } | ||
87 | #endregion | ||
88 | |||
89 | public Primitive2(Dictionary<uint, ClientView> clientThreads, ulong regionHandle, World world) | ||
90 | { | ||
91 | m_clientThreads = clientThreads; | ||
92 | m_regionHandle = regionHandle; | ||
93 | m_world = world; | ||
94 | inventoryItems = new Dictionary<LLUUID, InventoryItem>(); | ||
95 | } | ||
96 | |||
97 | public Primitive2(Dictionary<uint, ClientView> clientThreads, ulong regionHandle, World world, LLUUID owner) | ||
98 | { | ||
99 | m_clientThreads = clientThreads; | ||
100 | m_regionHandle = regionHandle; | ||
101 | m_world = world; | ||
102 | inventoryItems = new Dictionary<LLUUID, InventoryItem>(); | ||
103 | this.primData = new PrimData(); | ||
104 | this.primData.CreationDate = (Int32)(DateTime.UtcNow - new DateTime(1970, 1, 1)).TotalSeconds; | ||
105 | this.primData.OwnerID = owner; | ||
106 | } | ||
107 | |||
108 | public byte[] GetByteArray() | ||
109 | { | ||
110 | byte[] result = null; | ||
111 | List<byte[]> dataArrays = new List<byte[]>(); | ||
112 | dataArrays.Add(primData.ToBytes()); | ||
113 | foreach (Entity child in children) | ||
114 | { | ||
115 | if (child is OpenSim.RegionServer.Simulator.Primitive2) | ||
116 | { | ||
117 | dataArrays.Add(((OpenSim.RegionServer.Simulator.Primitive2)child).GetByteArray()); | ||
118 | } | ||
119 | } | ||
120 | byte[] primstart = Helpers.StringToField("<Prim>"); | ||
121 | byte[] primend = Helpers.StringToField("</Prim>"); | ||
122 | int totalLength = primstart.Length + primend.Length; | ||
123 | for (int i = 0; i < dataArrays.Count; i++) | ||
124 | { | ||
125 | totalLength += dataArrays[i].Length; | ||
126 | } | ||
127 | |||
128 | result = new byte[totalLength]; | ||
129 | int arraypos = 0; | ||
130 | Array.Copy(primstart, 0, result, 0, primstart.Length); | ||
131 | arraypos += primstart.Length; | ||
132 | for (int i = 0; i < dataArrays.Count; i++) | ||
133 | { | ||
134 | Array.Copy(dataArrays[i], 0, result, arraypos, dataArrays[i].Length); | ||
135 | arraypos += dataArrays[i].Length; | ||
136 | } | ||
137 | Array.Copy(primend, 0, result, arraypos, primend.Length); | ||
138 | |||
139 | return result; | ||
140 | } | ||
141 | |||
142 | #region Overridden Methods | ||
143 | |||
144 | public override void update() | ||
145 | { | ||
146 | LLVector3 pos2 = new LLVector3(0, 0, 0); | ||
147 | } | ||
148 | |||
149 | public override void BackUp() | ||
150 | { | ||
151 | |||
152 | } | ||
153 | |||
154 | #endregion | ||
155 | |||
156 | #region Packet handlers | ||
157 | |||
158 | public void UpdatePosition(LLVector3 pos) | ||
159 | { | ||
160 | |||
161 | } | ||
162 | |||
163 | public void UpdateShape(ObjectShapePacket.ObjectDataBlock addPacket) | ||
164 | { | ||
165 | this.primData.PathBegin = addPacket.PathBegin; | ||
166 | this.primData.PathEnd = addPacket.PathEnd; | ||
167 | this.primData.PathScaleX = addPacket.PathScaleX; | ||
168 | this.primData.PathScaleY = addPacket.PathScaleY; | ||
169 | this.primData.PathShearX = addPacket.PathShearX; | ||
170 | this.primData.PathShearY = addPacket.PathShearY; | ||
171 | this.primData.PathSkew = addPacket.PathSkew; | ||
172 | this.primData.ProfileBegin = addPacket.ProfileBegin; | ||
173 | this.primData.ProfileEnd = addPacket.ProfileEnd; | ||
174 | this.primData.PathCurve = addPacket.PathCurve; | ||
175 | this.primData.ProfileCurve = addPacket.ProfileCurve; | ||
176 | this.primData.ProfileHollow = addPacket.ProfileHollow; | ||
177 | this.primData.PathRadiusOffset = addPacket.PathRadiusOffset; | ||
178 | this.primData.PathRevolutions = addPacket.PathRevolutions; | ||
179 | this.primData.PathTaperX = addPacket.PathTaperX; | ||
180 | this.primData.PathTaperY = addPacket.PathTaperY; | ||
181 | this.primData.PathTwist = addPacket.PathTwist; | ||
182 | this.primData.PathTwistBegin = addPacket.PathTwistBegin; | ||
183 | } | ||
184 | |||
185 | public void UpdateTexture(byte[] tex) | ||
186 | { | ||
187 | this.primData.Texture = tex; | ||
188 | //this.dirtyFlag = true; | ||
189 | } | ||
190 | |||
191 | public void UpdateObjectFlags(ObjectFlagUpdatePacket pack) | ||
192 | { | ||
193 | |||
194 | } | ||
195 | |||
196 | public void AssignToParent(Primitive prim) | ||
197 | { | ||
198 | |||
199 | } | ||
200 | |||
201 | public void GetProperites(ClientView client) | ||
202 | { | ||
203 | ObjectPropertiesPacket proper = new ObjectPropertiesPacket(); | ||
204 | proper.ObjectData = new ObjectPropertiesPacket.ObjectDataBlock[1]; | ||
205 | proper.ObjectData[0] = new ObjectPropertiesPacket.ObjectDataBlock(); | ||
206 | proper.ObjectData[0].ItemID = LLUUID.Zero; | ||
207 | proper.ObjectData[0].CreationDate = (ulong)this.primData.CreationDate; | ||
208 | proper.ObjectData[0].CreatorID = this.primData.OwnerID; | ||
209 | proper.ObjectData[0].FolderID = LLUUID.Zero; | ||
210 | proper.ObjectData[0].FromTaskID = LLUUID.Zero; | ||
211 | proper.ObjectData[0].GroupID = LLUUID.Zero; | ||
212 | proper.ObjectData[0].InventorySerial = 0; | ||
213 | proper.ObjectData[0].LastOwnerID = LLUUID.Zero; | ||
214 | proper.ObjectData[0].ObjectID = this.uuid; | ||
215 | proper.ObjectData[0].OwnerID = primData.OwnerID; | ||
216 | proper.ObjectData[0].TouchName = new byte[0]; | ||
217 | proper.ObjectData[0].TextureID = new byte[0]; | ||
218 | proper.ObjectData[0].SitName = new byte[0]; | ||
219 | proper.ObjectData[0].Name = new byte[0]; | ||
220 | proper.ObjectData[0].Description = new byte[0]; | ||
221 | proper.ObjectData[0].OwnerMask = this.primData.OwnerMask; | ||
222 | proper.ObjectData[0].NextOwnerMask = this.primData.NextOwnerMask; | ||
223 | proper.ObjectData[0].GroupMask = this.primData.GroupMask; | ||
224 | proper.ObjectData[0].EveryoneMask = this.primData.EveryoneMask; | ||
225 | proper.ObjectData[0].BaseMask = this.primData.BaseMask; | ||
226 | |||
227 | client.OutPacket(proper); | ||
228 | } | ||
229 | |||
230 | #endregion | ||
231 | |||
232 | # region Inventory Methods | ||
233 | |||
234 | public bool AddToInventory(InventoryItem item) | ||
235 | { | ||
236 | return false; | ||
237 | } | ||
238 | |||
239 | public InventoryItem RemoveFromInventory(LLUUID itemID) | ||
240 | { | ||
241 | return null; | ||
242 | } | ||
243 | |||
244 | public void RequestInventoryInfo(ClientView simClient, RequestTaskInventoryPacket packet) | ||
245 | { | ||
246 | |||
247 | } | ||
248 | |||
249 | public void RequestXferInventory(ClientView simClient, ulong xferID) | ||
250 | { | ||
251 | //will only currently work if the total size of the inventory data array is under about 1000 bytes | ||
252 | SendXferPacketPacket send = new SendXferPacketPacket(); | ||
253 | |||
254 | send.XferID.ID = xferID; | ||
255 | send.XferID.Packet = 1 + 2147483648; | ||
256 | send.DataPacket.Data = this.ConvertInventoryToBytes(); | ||
257 | |||
258 | simClient.OutPacket(send); | ||
259 | } | ||
260 | |||
261 | public byte[] ConvertInventoryToBytes() | ||
262 | { | ||
263 | System.Text.Encoding enc = System.Text.Encoding.ASCII; | ||
264 | byte[] result = new byte[0]; | ||
265 | List<byte[]> inventoryData = new List<byte[]>(); | ||
266 | int totallength = 0; | ||
267 | foreach (InventoryItem invItem in inventoryItems.Values) | ||
268 | { | ||
269 | byte[] data = enc.GetBytes(invItem.ExportString()); | ||
270 | inventoryData.Add(data); | ||
271 | totallength += data.Length; | ||
272 | } | ||
273 | //TODO: copy arrays into the single result array | ||
274 | |||
275 | return result; | ||
276 | } | ||
277 | |||
278 | public void CreateInventoryFromBytes(byte[] data) | ||
279 | { | ||
280 | |||
281 | } | ||
282 | |||
283 | #endregion | ||
284 | |||
285 | #region Update viewers Methods | ||
286 | |||
287 | //should change these mehtods, so that outgoing packets are sent through the avatar class | ||
288 | public void SendFullUpdateToClient(ClientView remoteClient) | ||
289 | { | ||
290 | LLVector3 lPos; | ||
291 | if (this._physActor != null && this.physicsEnabled) | ||
292 | { | ||
293 | PhysicsVector pPos = this._physActor.Position; | ||
294 | lPos = new LLVector3(pPos.X, pPos.Y, pPos.Z); | ||
295 | } | ||
296 | else | ||
297 | { | ||
298 | lPos = this.Pos; | ||
299 | } | ||
300 | |||
301 | ObjectUpdatePacket outPacket = new ObjectUpdatePacket(); | ||
302 | outPacket.ObjectData = new ObjectUpdatePacket.ObjectDataBlock[1]; | ||
303 | outPacket.ObjectData[0] = this.CreateUpdateBlock(); | ||
304 | byte[] pb = lPos.GetBytes(); | ||
305 | Array.Copy(pb, 0, outPacket.ObjectData[0].ObjectData, 0, pb.Length); | ||
306 | |||
307 | remoteClient.OutPacket(outPacket); | ||
308 | } | ||
309 | |||
310 | public void SendFullUpdateToAllClients() | ||
311 | { | ||
312 | |||
313 | } | ||
314 | |||
315 | public void SendTerseUpdateToClient(ClientView RemoteClient) | ||
316 | { | ||
317 | |||
318 | } | ||
319 | |||
320 | public void SendTerseUpdateToALLClients() | ||
321 | { | ||
322 | |||
323 | } | ||
324 | |||
325 | #endregion | ||
326 | |||
327 | #region Create Methods | ||
328 | |||
329 | public void CreateFromPacket(ObjectAddPacket addPacket, LLUUID ownerID, uint localID) | ||
330 | { | ||
331 | PrimData PData = new PrimData(); | ||
332 | this.primData = PData; | ||
333 | this.primData.CreationDate = (Int32)(DateTime.UtcNow - new DateTime(1970, 1, 1)).TotalSeconds; | ||
334 | |||
335 | PData.OwnerID = ownerID; | ||
336 | PData.PCode = addPacket.ObjectData.PCode; | ||
337 | PData.PathBegin = addPacket.ObjectData.PathBegin; | ||
338 | PData.PathEnd = addPacket.ObjectData.PathEnd; | ||
339 | PData.PathScaleX = addPacket.ObjectData.PathScaleX; | ||
340 | PData.PathScaleY = addPacket.ObjectData.PathScaleY; | ||
341 | PData.PathShearX = addPacket.ObjectData.PathShearX; | ||
342 | PData.PathShearY = addPacket.ObjectData.PathShearY; | ||
343 | PData.PathSkew = addPacket.ObjectData.PathSkew; | ||
344 | PData.ProfileBegin = addPacket.ObjectData.ProfileBegin; | ||
345 | PData.ProfileEnd = addPacket.ObjectData.ProfileEnd; | ||
346 | PData.Scale = addPacket.ObjectData.Scale; | ||
347 | PData.PathCurve = addPacket.ObjectData.PathCurve; | ||
348 | PData.ProfileCurve = addPacket.ObjectData.ProfileCurve; | ||
349 | PData.ParentID = 0; | ||
350 | PData.ProfileHollow = addPacket.ObjectData.ProfileHollow; | ||
351 | PData.PathRadiusOffset = addPacket.ObjectData.PathRadiusOffset; | ||
352 | PData.PathRevolutions = addPacket.ObjectData.PathRevolutions; | ||
353 | PData.PathTaperX = addPacket.ObjectData.PathTaperX; | ||
354 | PData.PathTaperY = addPacket.ObjectData.PathTaperY; | ||
355 | PData.PathTwist = addPacket.ObjectData.PathTwist; | ||
356 | PData.PathTwistBegin = addPacket.ObjectData.PathTwistBegin; | ||
357 | LLVector3 pos1 = addPacket.ObjectData.RayEnd; | ||
358 | this.primData.FullID = this.uuid = LLUUID.Random(); | ||
359 | this.localid = (uint)(localID); | ||
360 | this.primData.Position = this.Pos = pos1; | ||
361 | } | ||
362 | |||
363 | public void CreateFromBytes(byte[] data) | ||
364 | { | ||
365 | |||
366 | } | ||
367 | |||
368 | public void CreateFromPrimData(PrimData primData) | ||
369 | { | ||
370 | this.CreateFromPrimData(primData, primData.Position, primData.LocalID, false); | ||
371 | } | ||
372 | |||
373 | public void CreateFromPrimData(PrimData primData, LLVector3 posi, uint localID, bool newprim) | ||
374 | { | ||
375 | |||
376 | } | ||
377 | |||
378 | #endregion | ||
379 | |||
380 | #region Packet Update Methods | ||
381 | protected void SetDefaultPacketValues(ObjectUpdatePacket.ObjectDataBlock objdata) | ||
382 | { | ||
383 | objdata.PSBlock = new byte[0]; | ||
384 | objdata.ExtraParams = new byte[1]; | ||
385 | objdata.MediaURL = new byte[0]; | ||
386 | objdata.NameValue = new byte[0]; | ||
387 | objdata.Text = new byte[0]; | ||
388 | objdata.TextColor = new byte[4]; | ||
389 | objdata.JointAxisOrAnchor = new LLVector3(0, 0, 0); | ||
390 | objdata.JointPivot = new LLVector3(0, 0, 0); | ||
391 | objdata.Material = 3; | ||
392 | objdata.TextureAnim = new byte[0]; | ||
393 | objdata.Sound = LLUUID.Zero; | ||
394 | LLObject.TextureEntry ntex = new LLObject.TextureEntry(new LLUUID("00000000-0000-0000-5005-000000000005")); | ||
395 | this.primData.Texture = objdata.TextureEntry = ntex.ToBytes(); | ||
396 | objdata.State = 0; | ||
397 | objdata.Data = new byte[0]; | ||
398 | |||
399 | objdata.ObjectData = new byte[60]; | ||
400 | objdata.ObjectData[46] = 128; | ||
401 | objdata.ObjectData[47] = 63; | ||
402 | } | ||
403 | |||
404 | protected void SetPacketShapeData(ObjectUpdatePacket.ObjectDataBlock objectData) | ||
405 | { | ||
406 | objectData.OwnerID = this.primData.OwnerID; | ||
407 | objectData.PCode = this.primData.PCode; | ||
408 | objectData.PathBegin = this.primData.PathBegin; | ||
409 | objectData.PathEnd = this.primData.PathEnd; | ||
410 | objectData.PathScaleX = this.primData.PathScaleX; | ||
411 | objectData.PathScaleY = this.primData.PathScaleY; | ||
412 | objectData.PathShearX = this.primData.PathShearX; | ||
413 | objectData.PathShearY = this.primData.PathShearY; | ||
414 | objectData.PathSkew = this.primData.PathSkew; | ||
415 | objectData.ProfileBegin = this.primData.ProfileBegin; | ||
416 | objectData.ProfileEnd = this.primData.ProfileEnd; | ||
417 | objectData.Scale = this.primData.Scale; | ||
418 | objectData.PathCurve = this.primData.PathCurve; | ||
419 | objectData.ProfileCurve = this.primData.ProfileCurve; | ||
420 | objectData.ParentID = this.primData.ParentID; | ||
421 | objectData.ProfileHollow = this.primData.ProfileHollow; | ||
422 | objectData.PathRadiusOffset = this.primData.PathRadiusOffset; | ||
423 | objectData.PathRevolutions = this.primData.PathRevolutions; | ||
424 | objectData.PathTaperX = this.primData.PathTaperX; | ||
425 | objectData.PathTaperY = this.primData.PathTaperY; | ||
426 | objectData.PathTwist = this.primData.PathTwist; | ||
427 | objectData.PathTwistBegin = this.primData.PathTwistBegin; | ||
428 | } | ||
429 | |||
430 | #endregion | ||
431 | protected ObjectUpdatePacket.ObjectDataBlock CreateUpdateBlock() | ||
432 | { | ||
433 | ObjectUpdatePacket.ObjectDataBlock objupdate = new ObjectUpdatePacket.ObjectDataBlock(); | ||
434 | this.SetDefaultPacketValues(objupdate); | ||
435 | objupdate.UpdateFlags = 32 + 65536 + 131072 + 256 + 4 + 8 + 2048 + 524288 + 268435456; | ||
436 | this.SetPacketShapeData(objupdate); | ||
437 | byte[] pb = this.Pos.GetBytes(); | ||
438 | Array.Copy(pb, 0, objupdate.ObjectData, 0, pb.Length); | ||
439 | return objupdate; | ||
440 | } | ||
441 | |||
442 | protected ImprovedTerseObjectUpdatePacket.ObjectDataBlock CreateImprovedBlock() | ||
443 | { | ||
444 | uint ID = this.localid; | ||
445 | byte[] bytes = new byte[60]; | ||
446 | |||
447 | int i = 0; | ||
448 | ImprovedTerseObjectUpdatePacket.ObjectDataBlock dat = new ImprovedTerseObjectUpdatePacket.ObjectDataBlock(); | ||
449 | dat.TextureEntry = new byte[0]; | ||
450 | bytes[i++] = (byte)(ID % 256); | ||
451 | bytes[i++] = (byte)((ID >> 8) % 256); | ||
452 | bytes[i++] = (byte)((ID >> 16) % 256); | ||
453 | bytes[i++] = (byte)((ID >> 24) % 256); | ||
454 | bytes[i++] = 0; | ||
455 | bytes[i++] = 0; | ||
456 | |||
457 | LLVector3 lPos; | ||
458 | Axiom.MathLib.Quaternion lRot; | ||
459 | if (this._physActor != null && this.physicsEnabled) | ||
460 | { | ||
461 | PhysicsVector pPos = this._physActor.Position; | ||
462 | lPos = new LLVector3(pPos.X, pPos.Y, pPos.Z); | ||
463 | lRot = this._physActor.Orientation; | ||
464 | } | ||
465 | else | ||
466 | { | ||
467 | lPos = this.Pos; | ||
468 | lRot = this.rotation; | ||
469 | } | ||
470 | byte[] pb = lPos.GetBytes(); | ||
471 | Array.Copy(pb, 0, bytes, i, pb.Length); | ||
472 | i += 12; | ||
473 | ushort ac = 32767; | ||
474 | |||
475 | //vel | ||
476 | bytes[i++] = (byte)(ac % 256); | ||
477 | bytes[i++] = (byte)((ac >> 8) % 256); | ||
478 | bytes[i++] = (byte)(ac % 256); | ||
479 | bytes[i++] = (byte)((ac >> 8) % 256); | ||
480 | bytes[i++] = (byte)(ac % 256); | ||
481 | bytes[i++] = (byte)((ac >> 8) % 256); | ||
482 | |||
483 | //accel | ||
484 | bytes[i++] = (byte)(ac % 256); | ||
485 | bytes[i++] = (byte)((ac >> 8) % 256); | ||
486 | bytes[i++] = (byte)(ac % 256); | ||
487 | bytes[i++] = (byte)((ac >> 8) % 256); | ||
488 | bytes[i++] = (byte)(ac % 256); | ||
489 | bytes[i++] = (byte)((ac >> 8) % 256); | ||
490 | |||
491 | ushort rw, rx, ry, rz; | ||
492 | rw = (ushort)(32768 * (lRot.w + 1)); | ||
493 | rx = (ushort)(32768 * (lRot.x + 1)); | ||
494 | ry = (ushort)(32768 * (lRot.y + 1)); | ||
495 | rz = (ushort)(32768 * (lRot.z + 1)); | ||
496 | |||
497 | //rot | ||
498 | bytes[i++] = (byte)(rx % 256); | ||
499 | bytes[i++] = (byte)((rx >> 8) % 256); | ||
500 | bytes[i++] = (byte)(ry % 256); | ||
501 | bytes[i++] = (byte)((ry >> 8) % 256); | ||
502 | bytes[i++] = (byte)(rz % 256); | ||
503 | bytes[i++] = (byte)((rz >> 8) % 256); | ||
504 | bytes[i++] = (byte)(rw % 256); | ||
505 | bytes[i++] = (byte)((rw >> 8) % 256); | ||
506 | |||
507 | //rotation vel | ||
508 | bytes[i++] = (byte)(ac % 256); | ||
509 | bytes[i++] = (byte)((ac >> 8) % 256); | ||
510 | bytes[i++] = (byte)(ac % 256); | ||
511 | bytes[i++] = (byte)((ac >> 8) % 256); | ||
512 | bytes[i++] = (byte)(ac % 256); | ||
513 | bytes[i++] = (byte)((ac >> 8) % 256); | ||
514 | |||
515 | dat.Data = bytes; | ||
516 | return dat; | ||
517 | } | ||
518 | } | ||
519 | } | ||