aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/Common/OpenSim.Framework/Types/PrimData.cs
diff options
context:
space:
mode:
Diffstat (limited to 'Common/OpenSim.Framework/Types/PrimData.cs')
-rw-r--r--Common/OpenSim.Framework/Types/PrimData.cs173
1 files changed, 173 insertions, 0 deletions
diff --git a/Common/OpenSim.Framework/Types/PrimData.cs b/Common/OpenSim.Framework/Types/PrimData.cs
new file mode 100644
index 0000000..68e2a22
--- /dev/null
+++ b/Common/OpenSim.Framework/Types/PrimData.cs
@@ -0,0 +1,173 @@
1using System;
2using System.Collections.Generic;
3using System.Text;
4using libsecondlife;
5
6namespace OpenSim.Framework.Types
7{
8 public class PrimData
9 {
10 private const uint FULL_MASK_PERMISSIONS = 2147483647;
11
12 public LLUUID OwnerID;
13 public byte PCode;
14 public ushort PathBegin;
15 public ushort PathEnd;
16 public byte PathScaleX;
17 public byte PathScaleY;
18 public byte PathShearX;
19 public byte PathShearY;
20 public sbyte PathSkew;
21 public ushort ProfileBegin;
22 public ushort ProfileEnd;
23 public LLVector3 Scale;
24 public byte PathCurve;
25 public byte ProfileCurve;
26 public uint ParentID = 0;
27 public ushort ProfileHollow;
28 public sbyte PathRadiusOffset;
29 public byte PathRevolutions;
30 public sbyte PathTaperX;
31 public sbyte PathTaperY;
32 public sbyte PathTwist;
33 public sbyte PathTwistBegin;
34 public byte[] Texture;
35
36
37 public Int32 CreationDate;
38 public uint OwnerMask = FULL_MASK_PERMISSIONS;
39 public uint NextOwnerMask = FULL_MASK_PERMISSIONS;
40 public uint GroupMask = FULL_MASK_PERMISSIONS;
41 public uint EveryoneMask = FULL_MASK_PERMISSIONS;
42 public uint BaseMask = FULL_MASK_PERMISSIONS;
43
44 //following only used during prim storage
45 public LLVector3 Position;
46 public LLQuaternion Rotation = new LLQuaternion(0,1,0,0);
47 public uint LocalID;
48 public LLUUID FullID;
49
50 public PrimData()
51 {
52
53 }
54
55 public PrimData(byte[] data)
56 {
57 int i =0;
58
59 this.OwnerID = new LLUUID(data, i); i += 16;
60 this.PCode = data[i++];
61 this.PathBegin = (ushort)(data[i++] + (data[i++] << 8));
62 this.PathEnd = (ushort)(data[i++] + (data[i++] << 8));
63 this.PathScaleX = data[i++];
64 this.PathScaleY = data[i++];
65 this.PathShearX = data[i++];
66 this.PathShearY = data[i++];
67 this.PathSkew = (sbyte)data[i++];
68 this.ProfileBegin = (ushort)(data[i++] + (data[i++] << 8));
69 this.ProfileEnd = (ushort)(data[i++] + (data[i++] << 8));
70 this.Scale = new LLVector3(data, i); i += 12;
71 this.PathCurve = data[i++];
72 this.ProfileCurve = data[i++];
73 this.ParentID = (uint)(data[i++] + (data[i++] << 8) + (data[i++] << 16) + (data[i++] << 24));
74 this.ProfileHollow = (ushort)(data[i++] + (data[i++] << 8));
75 this.PathRadiusOffset = (sbyte)data[i++];
76 this.PathRevolutions = data[i++];
77 this.PathTaperX = (sbyte)data[i++];
78 this.PathTaperY =(sbyte) data[i++];
79 this.PathTwist = (sbyte) data[i++];
80 this.PathTwistBegin = (sbyte) data[i++];
81 ushort length = (ushort)(data[i++] + (data[i++] << 8));
82 this.Texture = new byte[length];
83 Array.Copy(data, i, Texture, 0, length); i += length;
84 this.CreationDate = (Int32)(data[i++] + (data[i++] << 8) + (data[i++] << 16) + (data[i++] << 24));
85 this.OwnerMask = (uint)(data[i++] + (data[i++] << 8) + (data[i++] << 16) + (data[i++] << 24));
86 this.NextOwnerMask = (uint)(data[i++] + (data[i++] << 8) + (data[i++] << 16) + (data[i++] << 24));
87 this.GroupMask = (uint)(data[i++] + (data[i++] << 8) + (data[i++] << 16) + (data[i++] << 24));
88 this.EveryoneMask = (uint)(data[i++] + (data[i++] << 8) + (data[i++] << 16) + (data[i++] << 24));
89 this.BaseMask = (uint)(data[i++] + (data[i++] << 8) + (data[i++] << 16) + (data[i++] << 24));
90 this.Position = new LLVector3(data, i); i += 12;
91 this.Rotation = new LLQuaternion(data,i, true); i += 12;
92 this.LocalID = (uint)(data[i++] + (data[i++] << 8) + (data[i++] << 16) + (data[i++] << 24));
93 this.FullID = new LLUUID(data, i); i += 16;
94
95 }
96
97 public byte[] ToBytes()
98 {
99 int i = 0;
100 byte[] bytes = new byte[126 + Texture.Length];
101 Array.Copy(OwnerID.GetBytes(), 0, bytes, i, 16); i += 16;
102 bytes[i++] = this.PCode;
103 bytes[i++] = (byte)(this.PathBegin % 256);
104 bytes[i++] = (byte)((this.PathBegin >> 8) % 256);
105 bytes[i++] = (byte)(this.PathEnd % 256);
106 bytes[i++] = (byte)((this.PathEnd >> 8) % 256);
107 bytes[i++] = this.PathScaleX;
108 bytes[i++] = this.PathScaleY;
109 bytes[i++] = this.PathShearX;
110 bytes[i++] = this.PathShearY;
111 bytes[i++] = (byte)this.PathSkew;
112 bytes[i++] = (byte)(this.ProfileBegin % 256);
113 bytes[i++] = (byte)((this.ProfileBegin >> 8) % 256);
114 bytes[i++] = (byte)(this.ProfileEnd % 256);
115 bytes[i++] = (byte)((this.ProfileEnd >> 8) % 256);
116 Array.Copy(Scale.GetBytes(), 0, bytes, i, 12); i += 12;
117 bytes[i++] = this.PathCurve;
118 bytes[i++] = this.ProfileCurve;
119 bytes[i++] = (byte)(ParentID % 256);
120 bytes[i++] = (byte)((ParentID >> 8) % 256);
121 bytes[i++] = (byte)((ParentID >> 16) % 256);
122 bytes[i++] = (byte)((ParentID >> 24) % 256);
123 bytes[i++] = (byte)(this.ProfileHollow %256);
124 bytes[i++] = (byte)((this.ProfileHollow >> 8)% 256);
125 bytes[i++] = ((byte)this.PathRadiusOffset);
126 bytes[i++] = this.PathRevolutions;
127 bytes[i++] = ((byte) this.PathTaperX);
128 bytes[i++] = ((byte) this.PathTaperY);
129 bytes[i++] = ((byte) this.PathTwist);
130 bytes[i++] = ((byte) this.PathTwistBegin);
131 bytes[i++] = (byte)(Texture.Length % 256);
132 bytes[i++] = (byte)((Texture.Length >> 8) % 256);
133 Array.Copy(Texture, 0, bytes, i, Texture.Length); i += Texture.Length;
134 bytes[i++] = (byte)(this.CreationDate % 256);
135 bytes[i++] = (byte)((this.CreationDate >> 8) % 256);
136 bytes[i++] = (byte)((this.CreationDate >> 16) % 256);
137 bytes[i++] = (byte)((this.CreationDate >> 24) % 256);
138 bytes[i++] = (byte)(this.OwnerMask % 256);
139 bytes[i++] = (byte)((this.OwnerMask >> 8) % 256);
140 bytes[i++] = (byte)((this.OwnerMask >> 16) % 256);
141 bytes[i++] = (byte)((this.OwnerMask >> 24) % 256);
142 bytes[i++] = (byte)(this.NextOwnerMask % 256);
143 bytes[i++] = (byte)((this.NextOwnerMask >> 8) % 256);
144 bytes[i++] = (byte)((this.NextOwnerMask >> 16) % 256);
145 bytes[i++] = (byte)((this.NextOwnerMask >> 24) % 256);
146 bytes[i++] = (byte)(this.GroupMask % 256);
147 bytes[i++] = (byte)((this.GroupMask >> 8) % 256);
148 bytes[i++] = (byte)((this.GroupMask >> 16) % 256);
149 bytes[i++] = (byte)((this.GroupMask >> 24) % 256);
150 bytes[i++] = (byte)(this.EveryoneMask % 256);
151 bytes[i++] = (byte)((this.EveryoneMask >> 8) % 256);
152 bytes[i++] = (byte)((this.EveryoneMask >> 16) % 256);
153 bytes[i++] = (byte)((this.EveryoneMask >> 24) % 256);
154 bytes[i++] = (byte)(this.BaseMask % 256);
155 bytes[i++] = (byte)((this.BaseMask >> 8) % 256);
156 bytes[i++] = (byte)((this.BaseMask >> 16) % 256);
157 bytes[i++] = (byte)((this.BaseMask >> 24) % 256);
158 Array.Copy(this.Position.GetBytes(), 0, bytes, i, 12); i += 12;
159 if (this.Rotation == new LLQuaternion(0,0,0,0))
160 {
161 this.Rotation = new LLQuaternion(0, 1, 0, 0);
162 }
163 Array.Copy(this.Rotation.GetBytes(), 0, bytes, i, 12); i += 12;
164 bytes[i++] = (byte)(this.LocalID % 256);
165 bytes[i++] = (byte)((this.LocalID >> 8) % 256);
166 bytes[i++] = (byte)((this.LocalID >> 16) % 256);
167 bytes[i++] = (byte)((this.LocalID >> 24) % 256);
168 Array.Copy(FullID.GetBytes(), 0, bytes, i, 16); i += 16;
169
170 return bytes;
171 }
172 }
173}