aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region/Environment/Scenes/AllNewSceneObjectPart.cs
diff options
context:
space:
mode:
Diffstat (limited to 'OpenSim/Region/Environment/Scenes/AllNewSceneObjectPart.cs')
-rw-r--r--OpenSim/Region/Environment/Scenes/AllNewSceneObjectPart.cs258
1 files changed, 258 insertions, 0 deletions
diff --git a/OpenSim/Region/Environment/Scenes/AllNewSceneObjectPart.cs b/OpenSim/Region/Environment/Scenes/AllNewSceneObjectPart.cs
new file mode 100644
index 0000000..21659c4
--- /dev/null
+++ b/OpenSim/Region/Environment/Scenes/AllNewSceneObjectPart.cs
@@ -0,0 +1,258 @@
1using System.Collections.Generic;
2using System.Text;
3using System;
4using Axiom.Math;
5using libsecondlife;
6using libsecondlife.Packets;
7using OpenSim.Framework.Interfaces;
8using OpenSim.Framework.Types;
9
10namespace OpenSim.Region.Environment.Scenes
11{
12 public enum UpdateType
13 {
14 OutGoingOffset,
15 InComingNewPosition,
16 SinglePositionEdit,
17 ResizeOffset,
18 SingleRotationEdit
19 }
20
21 public delegate LLVector3 HandleUpdate(ref LLVector3 pos, UpdateType updateType, AllNewSceneObjectPart objectPart);
22
23 public class AllNewSceneObjectPart
24 {
25 private const uint FULL_MASK_PERMISSIONS = 2147483647;
26
27 private ulong m_regionHandle;
28 private uint m_flags = 32 + 65536 + 131072 + 256 + 4 + 8 + 2048 + 524288 + 268435456 + 128;
29 //private Dictionary<LLUUID, InventoryItem> inventoryItems;
30
31 public string SitName = "";
32 public string TouchName = "";
33 public string Text = "";
34
35 public LLUUID CreatorID;
36 public LLUUID OwnerID;
37 public LLUUID LastOwnerID;
38 public Int32 CreationDate;
39
40 public LLUUID uuid;
41 public uint m_localID;
42
43 public uint ParentID = 0;
44
45 public uint OwnerMask = FULL_MASK_PERMISSIONS;
46 public uint NextOwnerMask = FULL_MASK_PERMISSIONS;
47 public uint GroupMask = FULL_MASK_PERMISSIONS;
48 public uint EveryoneMask = FULL_MASK_PERMISSIONS;
49 public uint BaseMask = FULL_MASK_PERMISSIONS;
50
51 protected PrimitiveBaseShape m_Shape;
52
53 protected AllNewSceneObjectGroup m_parentGroup;
54
55 public HandleUpdate UpdateHandler;
56
57 #region Properties
58 protected string m_name;
59 /// <summary>
60 ///
61 /// </summary>
62 public virtual string Name
63 {
64 get { return m_name; }
65 set { m_name = value; }
66 }
67
68 protected LLVector3 m_offset;
69 public LLVector3 OffsetPosition
70 {
71 get
72 {
73 return m_offset;
74 }
75 set
76 {
77 m_offset = value;
78 }
79 }
80
81 protected LLQuaternion m_rotationOffset;
82 public LLQuaternion RotationOffset
83 {
84 get
85 {
86 return m_rotationOffset;
87 }
88 set
89 {
90 m_rotationOffset = value;
91 }
92 }
93
94 private string m_description = "";
95 public string Description
96 {
97 get
98 {
99 return this.m_description;
100 }
101 set
102 {
103 this.m_description = value;
104 }
105 }
106
107 public PrimitiveBaseShape Shape
108 {
109 get
110 {
111 return this.m_Shape;
112 }
113 }
114
115 public LLVector3 Scale
116 {
117 set
118 {
119 this.m_Shape.Scale = value;
120 }
121 get
122 {
123 return this.m_Shape.Scale;
124 }
125 }
126 #endregion
127
128 #region Constructors
129 public AllNewSceneObjectPart(ulong regionHandle, AllNewSceneObjectGroup parent, LLUUID ownerID, uint localID, PrimitiveBaseShape shape, LLVector3 position)
130 {
131 this.m_regionHandle = regionHandle;
132 this.m_parentGroup = parent;
133
134 this.CreationDate = (Int32)(DateTime.UtcNow - new DateTime(1970, 1, 1)).TotalSeconds;
135 this.OwnerID = ownerID;
136 this.CreatorID = this.OwnerID;
137 this.LastOwnerID = LLUUID.Zero;
138 this.uuid = LLUUID.Random();
139 this.m_localID = (uint)(localID);
140 this.m_Shape = shape;
141
142 this.UpdateHandler(ref position, UpdateType.InComingNewPosition, this);
143 this.OffsetPosition = position;
144 }
145 #endregion
146
147 #region Shape
148 /// <summary>
149 ///
150 /// </summary>
151 /// <param name="shapeBlock"></param>
152 public void UpdateShape(ObjectShapePacket.ObjectDataBlock shapeBlock)
153 {
154 this.m_Shape.PathBegin = shapeBlock.PathBegin;
155 this.m_Shape.PathEnd = shapeBlock.PathEnd;
156 this.m_Shape.PathScaleX = shapeBlock.PathScaleX;
157 this.m_Shape.PathScaleY = shapeBlock.PathScaleY;
158 this.m_Shape.PathShearX = shapeBlock.PathShearX;
159 this.m_Shape.PathShearY = shapeBlock.PathShearY;
160 this.m_Shape.PathSkew = shapeBlock.PathSkew;
161 this.m_Shape.ProfileBegin = shapeBlock.ProfileBegin;
162 this.m_Shape.ProfileEnd = shapeBlock.ProfileEnd;
163 this.m_Shape.PathCurve = shapeBlock.PathCurve;
164 this.m_Shape.ProfileCurve = shapeBlock.ProfileCurve;
165 this.m_Shape.ProfileHollow = shapeBlock.ProfileHollow;
166 this.m_Shape.PathRadiusOffset = shapeBlock.PathRadiusOffset;
167 this.m_Shape.PathRevolutions = shapeBlock.PathRevolutions;
168 this.m_Shape.PathTaperX = shapeBlock.PathTaperX;
169 this.m_Shape.PathTaperY = shapeBlock.PathTaperY;
170 this.m_Shape.PathTwist = shapeBlock.PathTwist;
171 this.m_Shape.PathTwistBegin = shapeBlock.PathTwistBegin;
172 }
173 #endregion
174
175 #region Texture
176 /// <summary>
177 ///
178 /// </summary>
179 /// <param name="textureEntry"></param>
180 public void UpdateTextureEntry(byte[] textureEntry)
181 {
182 this.m_Shape.TextureEntry = textureEntry;
183 }
184 #endregion
185
186 #region Position
187 /// <summary>
188 ///
189 /// </summary>
190 /// <param name="pos"></param>
191 public void UpdateGroupPosition(LLVector3 pos)
192 {
193 LLVector3 newPos = new LLVector3(pos.X, pos.Y, pos.Z);
194 this.UpdateHandler(ref newPos, UpdateType.InComingNewPosition, this);
195 this.OffsetPosition = newPos;
196 }
197
198 public void UpdateSinglePosition(LLVector3 pos)
199 {
200 LLVector3 newPos = new LLVector3(pos.X, pos.Y, pos.Z);
201 this.UpdateHandler(ref newPos, UpdateType.SinglePositionEdit, this);
202 this.OffsetPosition = newPos;
203 }
204 #endregion
205
206 #region rotation
207 public void UpdateGroupRotation(LLQuaternion rot)
208 {
209 this.RotationOffset = new LLQuaternion(rot.X, rot.Y, rot.Z, rot.W);
210 }
211
212 /// <summary>
213 ///
214 /// </summary>
215 /// <param name="pos"></param>
216 /// <param name="rot"></param>
217 public void UpdateGroupMouseRotation(LLVector3 pos, LLQuaternion rot)
218 {
219 this.RotationOffset = new LLQuaternion(rot.X, rot.Y, rot.Z, rot.W);
220 this.UpdateHandler(ref pos, UpdateType.InComingNewPosition, this);
221 this.OffsetPosition = pos;
222 }
223
224 /// <summary>
225 ///
226 /// </summary>
227 /// <param name="rot"></param>
228 public void UpdateSingleRotation(LLQuaternion rot)
229 {
230 //Console.WriteLine("updating single prim rotation");
231 Axiom.Math.Quaternion axRot = new Quaternion(rot.W, rot.X, rot.Y, rot.Z);
232 Axiom.Math.Quaternion oldParentRot = new Quaternion(this.RotationOffset.W, this.RotationOffset.X, this.RotationOffset.Y, this.RotationOffset.Z);
233 this.RotationOffset = new LLQuaternion(axRot.x, axRot.y, axRot.z, axRot.w);
234
235 LLVector3 offset = this.OffsetPosition;
236 this.UpdateHandler(ref offset, UpdateType.SingleRotationEdit, this);
237 }
238 #endregion
239
240 #region Resizing/Scale
241 /// <summary>
242 ///
243 /// </summary>
244 /// <param name="scale"></param>
245 public void ResizeGoup(LLVector3 scale)
246 {
247 LLVector3 offset = (scale - this.m_Shape.Scale);
248 offset.X /= 2;
249 offset.Y /= 2;
250 offset.Z /= 2;
251
252 this.UpdateHandler(ref offset, UpdateType.ResizeOffset, this);
253 this.OffsetPosition += offset;
254 this.m_Shape.Scale = scale;
255 }
256 #endregion
257 }
258}