diff options
Today's work on Building support/tools. Think I am slowly getting there.
Diffstat (limited to '')
-rw-r--r-- | OpenSim/Region/Environment/Scenes/Primitive.cs | 130 |
1 files changed, 116 insertions, 14 deletions
diff --git a/OpenSim/Region/Environment/Scenes/Primitive.cs b/OpenSim/Region/Environment/Scenes/Primitive.cs index a767bd2..803bd28 100644 --- a/OpenSim/Region/Environment/Scenes/Primitive.cs +++ b/OpenSim/Region/Environment/Scenes/Primitive.cs | |||
@@ -42,7 +42,7 @@ namespace OpenSim.Region.Environment.Scenes | |||
42 | private PrimitiveBaseShape m_Shape; | 42 | private PrimitiveBaseShape m_Shape; |
43 | 43 | ||
44 | public SceneObject m_RootParent; | 44 | public SceneObject m_RootParent; |
45 | public bool isRootPrim; | 45 | public bool isRootPrim; |
46 | public EntityBase m_Parent; | 46 | public EntityBase m_Parent; |
47 | 47 | ||
48 | public override LLVector3 Pos | 48 | public override LLVector3 Pos |
@@ -60,7 +60,11 @@ namespace OpenSim.Region.Environment.Scenes | |||
60 | } | 60 | } |
61 | set | 61 | set |
62 | { | 62 | { |
63 | this.m_pos = m_Parent.Pos - value; //should we being subtracting the parent position | 63 | if (isRootPrim) |
64 | { | ||
65 | m_Parent.Pos = value; | ||
66 | } | ||
67 | this.m_pos = value - m_Parent.Pos; | ||
64 | } | 68 | } |
65 | 69 | ||
66 | } | 70 | } |
@@ -77,7 +81,19 @@ namespace OpenSim.Region.Environment.Scenes | |||
77 | } | 81 | } |
78 | } | 82 | } |
79 | 83 | ||
80 | public Primitive(ulong regionHandle, Scene world, ObjectAddPacket addPacket, LLUUID ownerID, uint localID, bool isRoot, EntityBase parent , SceneObject rootObject) | 84 | public LLVector3 Scale |
85 | { | ||
86 | set | ||
87 | { | ||
88 | this.m_Shape.Scale = value; | ||
89 | } | ||
90 | get | ||
91 | { | ||
92 | return this.m_Shape.Scale; | ||
93 | } | ||
94 | } | ||
95 | |||
96 | public Primitive(ulong regionHandle, Scene world, ObjectAddPacket addPacket, LLUUID ownerID, uint localID, bool isRoot, EntityBase parent, SceneObject rootObject) | ||
81 | { | 97 | { |
82 | m_regionHandle = regionHandle; | 98 | m_regionHandle = regionHandle; |
83 | m_world = world; | 99 | m_world = world; |
@@ -86,12 +102,13 @@ namespace OpenSim.Region.Environment.Scenes | |||
86 | this.isRootPrim = isRoot; | 102 | this.isRootPrim = isRoot; |
87 | this.m_RootParent = rootObject; | 103 | this.m_RootParent = rootObject; |
88 | this.CreateFromPacket(addPacket, ownerID, localID); | 104 | this.CreateFromPacket(addPacket, ownerID, localID); |
105 | this.rotation = Axiom.MathLib.Quaternion.Identity; | ||
89 | } | 106 | } |
90 | 107 | ||
91 | /// <summary> | 108 | /// <summary> |
92 | /// | 109 | /// |
93 | /// </summary> | 110 | /// </summary> |
94 | public override void update() | 111 | public override void update() |
95 | { | 112 | { |
96 | if (this.updateFlag == 1) // is a new prim just been created/reloaded or has major changes | 113 | if (this.updateFlag == 1) // is a new prim just been created/reloaded or has major changes |
97 | { | 114 | { |
@@ -104,7 +121,10 @@ namespace OpenSim.Region.Environment.Scenes | |||
104 | this.updateFlag = 0; | 121 | this.updateFlag = 0; |
105 | } | 122 | } |
106 | 123 | ||
107 | base.update(); | 124 | foreach (EntityBase child in children) |
125 | { | ||
126 | child.update(); | ||
127 | } | ||
108 | } | 128 | } |
109 | 129 | ||
110 | /// <summary> | 130 | /// <summary> |
@@ -150,9 +170,13 @@ namespace OpenSim.Region.Environment.Scenes | |||
150 | this.updateFlag = 1; | 170 | this.updateFlag = 1; |
151 | } | 171 | } |
152 | 172 | ||
173 | /// <summary> | ||
174 | /// | ||
175 | /// </summary> | ||
176 | /// <param name="linkObject"></param> | ||
153 | public void AddNewChildren(SceneObject linkObject) | 177 | public void AddNewChildren(SceneObject linkObject) |
154 | { | 178 | { |
155 | // Console.WriteLine("linking new prims " + linkObject.rootLocalID + " to me (" + this.LocalId + ")"); | 179 | // Console.WriteLine("linking new prims " + linkObject.rootLocalID + " to me (" + this.LocalId + ")"); |
156 | //TODO check permissions | 180 | //TODO check permissions |
157 | this.children.Add(linkObject.rootPrimitive); | 181 | this.children.Add(linkObject.rootPrimitive); |
158 | linkObject.rootPrimitive.SetNewParent(this, this.m_RootParent); | 182 | linkObject.rootPrimitive.SetNewParent(this, this.m_RootParent); |
@@ -161,30 +185,73 @@ namespace OpenSim.Region.Environment.Scenes | |||
161 | linkObject.DeleteAllChildren(); | 185 | linkObject.DeleteAllChildren(); |
162 | } | 186 | } |
163 | 187 | ||
188 | /// <summary> | ||
189 | /// | ||
190 | /// </summary> | ||
191 | /// <param name="newParent"></param> | ||
192 | /// <param name="rootParent"></param> | ||
164 | public void SetNewParent(Primitive newParent, SceneObject rootParent) | 193 | public void SetNewParent(Primitive newParent, SceneObject rootParent) |
165 | { | 194 | { |
166 | LLVector3 oldPos = new LLVector3(this.Pos.X, this.Pos.Y, this.Pos.Z); | 195 | LLVector3 oldPos = new LLVector3(this.Pos.X, this.Pos.Y, this.Pos.Z); |
167 | //Console.WriteLine("have a new parent and my old position is " + this.Pos.X + " , " + this.Pos.Y + " , " + this.Pos.Z); | ||
168 | this.isRootPrim = false; | 196 | this.isRootPrim = false; |
169 | this.m_Parent = newParent; | 197 | this.m_Parent = newParent; |
170 | this.ParentID = newParent.LocalId; | 198 | this.ParentID = newParent.LocalId; |
171 | this.SetRootParent(rootParent); | 199 | this.SetRootParent(rootParent); |
172 | // Console.WriteLine("have a new parent and its position is " + this.m_Parent.Pos.X + " , " + this.m_Parent.Pos.Y + " , " + this.m_Parent.Pos.Z); | ||
173 | this.Pos = oldPos; | 200 | this.Pos = oldPos; |
174 | // Console.WriteLine("have a new parent so my new offset position is " + this.Pos.X + " , " + this.Pos.Y + " , " + this.Pos.Z); | 201 | Axiom.MathLib.Vector3 axPos = new Axiom.MathLib.Vector3(this.m_pos.X, m_pos.Y, m_pos.Z); |
202 | axPos = this.m_Parent.rotation.Inverse() * axPos; | ||
203 | this.m_pos = new LLVector3(axPos.x, axPos.y, axPos.z); | ||
204 | this.rotation = this.rotation * this.m_Parent.rotation.Inverse(); | ||
175 | this.updateFlag = 1; | 205 | this.updateFlag = 1; |
176 | 206 | ||
177 | } | 207 | } |
178 | 208 | ||
209 | /// <summary> | ||
210 | /// | ||
211 | /// </summary> | ||
212 | /// <param name="newRoot"></param> | ||
179 | public void SetRootParent(SceneObject newRoot) | 213 | public void SetRootParent(SceneObject newRoot) |
180 | { | 214 | { |
181 | this.m_RootParent = newRoot; | 215 | this.m_RootParent = newRoot; |
216 | this.m_RootParent.AddChildToList(this); | ||
182 | foreach (Primitive child in children) | 217 | foreach (Primitive child in children) |
183 | { | 218 | { |
184 | child.SetRootParent(newRoot); | 219 | child.SetRootParent(newRoot); |
185 | } | 220 | } |
186 | } | 221 | } |
187 | 222 | ||
223 | public void AddOffsetToChildren(LLVector3 offset) | ||
224 | { | ||
225 | foreach (Primitive prim in this.children) | ||
226 | { | ||
227 | prim.m_pos += offset; | ||
228 | prim.updateFlag = 2; | ||
229 | } | ||
230 | } | ||
231 | |||
232 | #region Resizing/Scale | ||
233 | public void ResizeGoup(LLVector3 scale) | ||
234 | { | ||
235 | LLVector3 offset = (scale - this.m_Shape.Scale); | ||
236 | offset.X /= 2; | ||
237 | offset.Y /= 2; | ||
238 | offset.Z /= 2; | ||
239 | if (this.isRootPrim) | ||
240 | { | ||
241 | this.m_Parent.Pos += offset; | ||
242 | } | ||
243 | else | ||
244 | { | ||
245 | this.m_pos += offset; | ||
246 | } | ||
247 | |||
248 | this.AddOffsetToChildren(new LLVector3(-offset.X, -offset.Y, -offset.Z)); | ||
249 | this.m_Shape.Scale = scale; | ||
250 | |||
251 | this.updateFlag = 1; | ||
252 | } | ||
253 | #endregion | ||
254 | |||
188 | /// <summary> | 255 | /// <summary> |
189 | /// | 256 | /// |
190 | /// </summary> | 257 | /// </summary> |
@@ -192,14 +259,47 @@ namespace OpenSim.Region.Environment.Scenes | |||
192 | public void UpdatePosition(LLVector3 pos) | 259 | public void UpdatePosition(LLVector3 pos) |
193 | { | 260 | { |
194 | LLVector3 newPos = new LLVector3(pos.X, pos.Y, pos.Z); | 261 | LLVector3 newPos = new LLVector3(pos.X, pos.Y, pos.Z); |
195 | if (this.isRootPrim) | 262 | |
196 | { | ||
197 | this.m_Parent.Pos = newPos; | ||
198 | } | ||
199 | this.Pos = newPos; | 263 | this.Pos = newPos; |
200 | this.updateFlag = 2; | 264 | this.updateFlag = 2; |
201 | } | 265 | } |
202 | 266 | ||
267 | public void UpdateRotation(LLQuaternion rot) | ||
268 | { | ||
269 | this.rotation = new Axiom.MathLib.Quaternion(rot.W, rot.X, rot.Y, rot.Z); | ||
270 | this.updateFlag = 2; | ||
271 | } | ||
272 | |||
273 | public void UpdateGroupMouseRotation(LLVector3 pos, LLQuaternion rot) | ||
274 | { | ||
275 | this.rotation = new Axiom.MathLib.Quaternion(rot.W, rot.X, rot.Y, rot.Z); | ||
276 | this.Pos = pos; | ||
277 | this.updateFlag = 2; | ||
278 | } | ||
279 | |||
280 | public void UpdateShape(ObjectShapePacket.ObjectDataBlock shapeBlock) | ||
281 | { | ||
282 | this.m_Shape.PathBegin = shapeBlock.PathBegin; | ||
283 | this.m_Shape.PathEnd = shapeBlock.PathEnd; | ||
284 | this.m_Shape.PathScaleX = shapeBlock.PathScaleX; | ||
285 | this.m_Shape.PathScaleY = shapeBlock.PathScaleY; | ||
286 | this.m_Shape.PathShearX = shapeBlock.PathShearX; | ||
287 | this.m_Shape.PathShearY = shapeBlock.PathShearY; | ||
288 | this.m_Shape.PathSkew = shapeBlock.PathSkew; | ||
289 | this.m_Shape.ProfileBegin = shapeBlock.ProfileBegin; | ||
290 | this.m_Shape.ProfileEnd = shapeBlock.ProfileEnd; | ||
291 | this.m_Shape.PathCurve = shapeBlock.PathCurve; | ||
292 | this.m_Shape.ProfileCurve = shapeBlock.ProfileCurve; | ||
293 | this.m_Shape.ProfileHollow = shapeBlock.ProfileHollow; | ||
294 | this.m_Shape.PathRadiusOffset = shapeBlock.PathRadiusOffset; | ||
295 | this.m_Shape.PathRevolutions = shapeBlock.PathRevolutions; | ||
296 | this.m_Shape.PathTaperX = shapeBlock.PathTaperX; | ||
297 | this.m_Shape.PathTaperY = shapeBlock.PathTaperY; | ||
298 | this.m_Shape.PathTwist = shapeBlock.PathTwist; | ||
299 | this.m_Shape.PathTwistBegin = shapeBlock.PathTwistBegin; | ||
300 | this.updateFlag = 1; | ||
301 | } | ||
302 | |||
203 | #region Client Update Methods | 303 | #region Client Update Methods |
204 | 304 | ||
205 | /// <summary> | 305 | /// <summary> |
@@ -226,8 +326,10 @@ namespace OpenSim.Region.Environment.Scenes | |||
226 | { | 326 | { |
227 | LLVector3 lPos; | 327 | LLVector3 lPos; |
228 | lPos = this.Pos; | 328 | lPos = this.Pos; |
329 | LLQuaternion lRot; | ||
330 | lRot = new LLQuaternion(this.rotation.x, this.rotation.y, this.rotation.z, this.rotation.w); | ||
229 | 331 | ||
230 | remoteClient.SendPrimitiveToClient(this.m_regionHandle, 64096, this.LocalId, this.m_Shape, lPos, new LLUUID("00000000-0000-0000-9999-000000000005"), this.flags, this.uuid, this.OwnerID, this.Text, this.ParentID); | 332 | remoteClient.SendPrimitiveToClient(this.m_regionHandle, 64096, this.LocalId, this.m_Shape, lPos, lRot, new LLUUID("00000000-0000-0000-9999-000000000005"), this.flags, this.uuid, this.OwnerID, this.Text, this.ParentID); |
231 | } | 333 | } |
232 | 334 | ||
233 | /// <summary> | 335 | /// <summary> |