aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Framework/General/Types/PrimData.cs
diff options
context:
space:
mode:
authorMW2007-06-27 15:28:52 +0000
committerMW2007-06-27 15:28:52 +0000
commit646bbbc84b8010e0dacbeed5342cdb045f46cc49 (patch)
tree770b34d19855363c3c113ab9a0af9a56d821d887 /OpenSim/Framework/General/Types/PrimData.cs
downloadopensim-SC_OLD-646bbbc84b8010e0dacbeed5342cdb045f46cc49.zip
opensim-SC_OLD-646bbbc84b8010e0dacbeed5342cdb045f46cc49.tar.gz
opensim-SC_OLD-646bbbc84b8010e0dacbeed5342cdb045f46cc49.tar.bz2
opensim-SC_OLD-646bbbc84b8010e0dacbeed5342cdb045f46cc49.tar.xz
Some work on restructuring the namespaces / project names. Note this doesn't compile yet as not all the code has been changed to use the new namespaces. Am committing it now for feedback on the namespaces.
Diffstat (limited to 'OpenSim/Framework/General/Types/PrimData.cs')
-rw-r--r--OpenSim/Framework/General/Types/PrimData.cs230
1 files changed, 230 insertions, 0 deletions
diff --git a/OpenSim/Framework/General/Types/PrimData.cs b/OpenSim/Framework/General/Types/PrimData.cs
new file mode 100644
index 0000000..f84ae3e
--- /dev/null
+++ b/OpenSim/Framework/General/Types/PrimData.cs
@@ -0,0 +1,230 @@
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 libsecondlife;
32
33namespace OpenSim.Framework.Types
34{
35 public class PrimData
36 {
37 private const uint FULL_MASK_PERMISSIONS = 2147483647;
38
39 public LLUUID OwnerID;
40 public byte PCode;
41 public ushort PathBegin;
42 public ushort PathEnd;
43 public byte PathScaleX;
44 public byte PathScaleY;
45 public byte PathShearX;
46 public byte PathShearY;
47 public sbyte PathSkew;
48 public ushort ProfileBegin;
49 public ushort ProfileEnd;
50 public LLVector3 Scale;
51 public byte PathCurve;
52 public byte ProfileCurve;
53 public uint ParentID = 0;
54 public ushort ProfileHollow;
55 public sbyte PathRadiusOffset;
56 public byte PathRevolutions;
57 public sbyte PathTaperX;
58 public sbyte PathTaperY;
59 public sbyte PathTwist;
60 public sbyte PathTwistBegin;
61 public byte[] TextureEntry; // a LL textureEntry in byte[] format
62
63 public Int32 CreationDate;
64 public uint OwnerMask = FULL_MASK_PERMISSIONS;
65 public uint NextOwnerMask = FULL_MASK_PERMISSIONS;
66 public uint GroupMask = FULL_MASK_PERMISSIONS;
67 public uint EveryoneMask = FULL_MASK_PERMISSIONS;
68 public uint BaseMask = FULL_MASK_PERMISSIONS;
69
70 //following only used during prim storage
71 public LLVector3 Position;
72 public LLQuaternion Rotation = new LLQuaternion(0, 1, 0, 0);
73 public uint LocalID;
74 public LLUUID FullID;
75
76 public PrimData()
77 {
78
79 }
80
81 public PrimData(byte[] data)
82 {
83 int i = 0;
84
85 this.OwnerID = new LLUUID(data, i); i += 16;
86 this.PCode = data[i++];
87 this.PathBegin = (ushort)(data[i++] + (data[i++] << 8));
88 this.PathEnd = (ushort)(data[i++] + (data[i++] << 8));
89 this.PathScaleX = data[i++];
90 this.PathScaleY = data[i++];
91 this.PathShearX = data[i++];
92 this.PathShearY = data[i++];
93 this.PathSkew = (sbyte)data[i++];
94 this.ProfileBegin = (ushort)(data[i++] + (data[i++] << 8));
95 this.ProfileEnd = (ushort)(data[i++] + (data[i++] << 8));
96 this.Scale = new LLVector3(data, i); i += 12;
97 this.PathCurve = data[i++];
98 this.ProfileCurve = data[i++];
99 this.ParentID = (uint)(data[i++] + (data[i++] << 8) + (data[i++] << 16) + (data[i++] << 24));
100 this.ProfileHollow = (ushort)(data[i++] + (data[i++] << 8));
101 this.PathRadiusOffset = (sbyte)data[i++];
102 this.PathRevolutions = data[i++];
103 this.PathTaperX = (sbyte)data[i++];
104 this.PathTaperY = (sbyte)data[i++];
105 this.PathTwist = (sbyte)data[i++];
106 this.PathTwistBegin = (sbyte)data[i++];
107 ushort length = (ushort)(data[i++] + (data[i++] << 8));
108 this.TextureEntry = new byte[length];
109 Array.Copy(data, i, TextureEntry, 0, length); i += length;
110 this.CreationDate = (Int32)(data[i++] + (data[i++] << 8) + (data[i++] << 16) + (data[i++] << 24));
111 this.OwnerMask = (uint)(data[i++] + (data[i++] << 8) + (data[i++] << 16) + (data[i++] << 24));
112 this.NextOwnerMask = (uint)(data[i++] + (data[i++] << 8) + (data[i++] << 16) + (data[i++] << 24));
113 this.GroupMask = (uint)(data[i++] + (data[i++] << 8) + (data[i++] << 16) + (data[i++] << 24));
114 this.EveryoneMask = (uint)(data[i++] + (data[i++] << 8) + (data[i++] << 16) + (data[i++] << 24));
115 this.BaseMask = (uint)(data[i++] + (data[i++] << 8) + (data[i++] << 16) + (data[i++] << 24));
116 this.Position = new LLVector3(data, i); i += 12;
117 this.Rotation = new LLQuaternion(data, i, true); i += 12;
118 this.LocalID = (uint)(data[i++] + (data[i++] << 8) + (data[i++] << 16) + (data[i++] << 24));
119 this.FullID = new LLUUID(data, i); i += 16;
120
121 }
122
123 public byte[] ToBytes()
124 {
125 int i = 0;
126 byte[] bytes = new byte[126 + TextureEntry.Length];
127 Array.Copy(OwnerID.GetBytes(), 0, bytes, i, 16); i += 16;
128 bytes[i++] = this.PCode;
129 bytes[i++] = (byte)(this.PathBegin % 256);
130 bytes[i++] = (byte)((this.PathBegin >> 8) % 256);
131 bytes[i++] = (byte)(this.PathEnd % 256);
132 bytes[i++] = (byte)((this.PathEnd >> 8) % 256);
133 bytes[i++] = this.PathScaleX;
134 bytes[i++] = this.PathScaleY;
135 bytes[i++] = this.PathShearX;
136 bytes[i++] = this.PathShearY;
137 bytes[i++] = (byte)this.PathSkew;
138 bytes[i++] = (byte)(this.ProfileBegin % 256);
139 bytes[i++] = (byte)((this.ProfileBegin >> 8) % 256);
140 bytes[i++] = (byte)(this.ProfileEnd % 256);
141 bytes[i++] = (byte)((this.ProfileEnd >> 8) % 256);
142 Array.Copy(Scale.GetBytes(), 0, bytes, i, 12); i += 12;
143 bytes[i++] = this.PathCurve;
144 bytes[i++] = this.ProfileCurve;
145 bytes[i++] = (byte)(ParentID % 256);
146 bytes[i++] = (byte)((ParentID >> 8) % 256);
147 bytes[i++] = (byte)((ParentID >> 16) % 256);
148 bytes[i++] = (byte)((ParentID >> 24) % 256);
149 bytes[i++] = (byte)(this.ProfileHollow % 256);
150 bytes[i++] = (byte)((this.ProfileHollow >> 8) % 256);
151 bytes[i++] = ((byte)this.PathRadiusOffset);
152 bytes[i++] = this.PathRevolutions;
153 bytes[i++] = ((byte)this.PathTaperX);
154 bytes[i++] = ((byte)this.PathTaperY);
155 bytes[i++] = ((byte)this.PathTwist);
156 bytes[i++] = ((byte)this.PathTwistBegin);
157 bytes[i++] = (byte)(TextureEntry.Length % 256);
158 bytes[i++] = (byte)((TextureEntry.Length >> 8) % 256);
159 Array.Copy(TextureEntry, 0, bytes, i, TextureEntry.Length); i += TextureEntry.Length;
160 bytes[i++] = (byte)(this.CreationDate % 256);
161 bytes[i++] = (byte)((this.CreationDate >> 8) % 256);
162 bytes[i++] = (byte)((this.CreationDate >> 16) % 256);
163 bytes[i++] = (byte)((this.CreationDate >> 24) % 256);
164 bytes[i++] = (byte)(this.OwnerMask % 256);
165 bytes[i++] = (byte)((this.OwnerMask >> 8) % 256);
166 bytes[i++] = (byte)((this.OwnerMask >> 16) % 256);
167 bytes[i++] = (byte)((this.OwnerMask >> 24) % 256);
168 bytes[i++] = (byte)(this.NextOwnerMask % 256);
169 bytes[i++] = (byte)((this.NextOwnerMask >> 8) % 256);
170 bytes[i++] = (byte)((this.NextOwnerMask >> 16) % 256);
171 bytes[i++] = (byte)((this.NextOwnerMask >> 24) % 256);
172 bytes[i++] = (byte)(this.GroupMask % 256);
173 bytes[i++] = (byte)((this.GroupMask >> 8) % 256);
174 bytes[i++] = (byte)((this.GroupMask >> 16) % 256);
175 bytes[i++] = (byte)((this.GroupMask >> 24) % 256);
176 bytes[i++] = (byte)(this.EveryoneMask % 256);
177 bytes[i++] = (byte)((this.EveryoneMask >> 8) % 256);
178 bytes[i++] = (byte)((this.EveryoneMask >> 16) % 256);
179 bytes[i++] = (byte)((this.EveryoneMask >> 24) % 256);
180 bytes[i++] = (byte)(this.BaseMask % 256);
181 bytes[i++] = (byte)((this.BaseMask >> 8) % 256);
182 bytes[i++] = (byte)((this.BaseMask >> 16) % 256);
183 bytes[i++] = (byte)((this.BaseMask >> 24) % 256);
184 Array.Copy(this.Position.GetBytes(), 0, bytes, i, 12); i += 12;
185 if (this.Rotation == new LLQuaternion(0, 0, 0, 0))
186 {
187 this.Rotation = new LLQuaternion(0, 1, 0, 0);
188 }
189 Array.Copy(this.Rotation.GetBytes(), 0, bytes, i, 12); i += 12;
190 bytes[i++] = (byte)(this.LocalID % 256);
191 bytes[i++] = (byte)((this.LocalID >> 8) % 256);
192 bytes[i++] = (byte)((this.LocalID >> 16) % 256);
193 bytes[i++] = (byte)((this.LocalID >> 24) % 256);
194 Array.Copy(FullID.GetBytes(), 0, bytes, i, 16); i += 16;
195
196 return bytes;
197 }
198
199 public static PrimData DefaultCube()
200 {
201 PrimData primData = new PrimData();
202 primData.CreationDate = (Int32)(DateTime.UtcNow - new DateTime(1970, 1, 1)).TotalSeconds;
203 primData.FullID = LLUUID.Random();
204 primData.Scale = new LLVector3(0.5f, 0.5f, 0.5f);
205 primData.Rotation = new LLQuaternion(0, 0, 0, 1);
206 primData.PCode = 9;
207 primData.ParentID = 0;
208 primData.PathBegin = 0;
209 primData.PathEnd = 0;
210 primData.PathScaleX = 0;
211 primData.PathScaleY = 0;
212 primData.PathShearX = 0;
213 primData.PathShearY = 0;
214 primData.PathSkew = 0;
215 primData.ProfileBegin = 0;
216 primData.ProfileEnd = 0;
217 primData.PathCurve = 16;
218 primData.ProfileCurve = 1;
219 primData.ProfileHollow = 0;
220 primData.PathRadiusOffset = 0;
221 primData.PathRevolutions = 0;
222 primData.PathTaperX = 0;
223 primData.PathTaperY = 0;
224 primData.PathTwist = 0;
225 primData.PathTwistBegin = 0;
226
227 return primData;
228 }
229 }
230}