aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region/Environment/Scenes/SceneObject.cs
diff options
context:
space:
mode:
Diffstat (limited to 'OpenSim/Region/Environment/Scenes/SceneObject.cs')
-rw-r--r--OpenSim/Region/Environment/Scenes/SceneObject.cs246
1 files changed, 246 insertions, 0 deletions
diff --git a/OpenSim/Region/Environment/Scenes/SceneObject.cs b/OpenSim/Region/Environment/Scenes/SceneObject.cs
new file mode 100644
index 0000000..ecd2dee
--- /dev/null
+++ b/OpenSim/Region/Environment/Scenes/SceneObject.cs
@@ -0,0 +1,246 @@
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.Collections.Generic;
29using System.Text;
30using libsecondlife;
31using libsecondlife.Packets;
32using OpenSim.Framework.Interfaces;
33using OpenSim.Physics.Manager;
34
35namespace OpenSim.Region.Environment.Scenes
36{
37 public class SceneObject : EntityBase
38 {
39 private Encoding enc = Encoding.ASCII;
40 private Dictionary<LLUUID, Primitive> ChildPrimitives = new Dictionary<LLUUID, Primitive>(); //list of all primitive id's that are part of this group
41 public Primitive rootPrimitive;
42 private new Scene m_world;
43 protected ulong m_regionHandle;
44
45 private bool physicsEnabled = false;
46 private PhysicsScene m_PhysScene;
47 private PhysicsActor m_PhysActor;
48
49 public LLUUID rootUUID
50 {
51 get
52 {
53 this.uuid = this.rootPrimitive.uuid;
54 return this.uuid;
55 }
56 }
57
58 public uint rootLocalID
59 {
60 get
61 {
62 this.m_localId = this.rootPrimitive.LocalId;
63 return this.LocalId;
64 }
65 }
66
67 /// <summary>
68 ///
69 /// </summary>
70 public SceneObject(ulong regionHandle, Scene world, ObjectAddPacket addPacket, LLUUID ownerID, uint localID)
71 {
72 m_regionHandle = regionHandle;
73 m_world = world;
74 this.Pos = addPacket.ObjectData.RayEnd;
75 this.CreateRootFromPacket(addPacket, ownerID, localID);
76 }
77
78 /// <summary>
79 ///
80 /// </summary>
81 /// <remarks>Need a null constructor for duplication</remarks>
82 public SceneObject()
83 {
84
85 }
86
87 /// <summary>
88 ///
89 /// </summary>
90 /// <param name="addPacket"></param>
91 /// <param name="agentID"></param>
92 /// <param name="localID"></param>
93 public void CreateRootFromPacket(ObjectAddPacket addPacket, LLUUID agentID, uint localID)
94 {
95 this.rootPrimitive = new Primitive( this.m_regionHandle, this.m_world, addPacket, agentID, localID, true, this, this);
96 this.children.Add(rootPrimitive);
97 this.ChildPrimitives.Add(this.rootUUID, this.rootPrimitive);
98 }
99
100 /// <summary>
101 ///
102 /// </summary>
103 /// <param name="data"></param>
104 public void CreateFromBytes(byte[] data)
105 {
106
107 }
108
109 /// <summary>
110 ///
111 /// </summary>
112 /// <returns>A complete copy of the object</returns>
113 public SceneObject Copy()
114 {
115 SceneObject dupe = new SceneObject();
116
117 Primitive newRoot = this.rootPrimitive.Copy((EntityBase)dupe, dupe);
118
119 foreach (EntityBase child in this.children)
120 {
121 EntityBase newChild = child.Copy();
122 dupe.children.Add(newChild);
123 }
124
125 return dupe;
126 }
127
128 /// <summary>
129 ///
130 /// </summary>
131 public void DeleteAllChildren()
132 {
133 this.children.Clear();
134 this.ChildPrimitives.Clear();
135 this.rootPrimitive = null;
136 }
137
138 /// <summary>
139 ///
140 /// </summary>
141 /// <param name="primObject"></param>
142 public void AddNewChildPrims(SceneObject primObject)
143 {
144 this.rootPrimitive.AddNewChildren(primObject);
145 }
146
147 public void AddChildToList(Primitive prim)
148 {
149 if (!this.ChildPrimitives.ContainsKey(prim.uuid))
150 {
151 this.ChildPrimitives.Add(prim.uuid, prim);
152 }
153 }
154 /// <summary>
155 ///
156 /// </summary>
157 /// <param name="primID"></param>
158 /// <returns></returns>
159 public Primitive HasChildPrim(LLUUID primID)
160 {
161 if (this.ChildPrimitives.ContainsKey(primID))
162 {
163 return this.ChildPrimitives[primID];
164 }
165
166 return null;
167 }
168
169 /// <summary>
170 ///
171 /// </summary>
172 /// <param name="localID"></param>
173 /// <returns></returns>
174 public Primitive HasChildPrim(uint localID)
175 {
176 Primitive returnPrim = null;
177 foreach (Primitive prim in this.ChildPrimitives.Values)
178 {
179 if (prim.LocalId == localID)
180 {
181 returnPrim = prim;
182 break;
183 }
184 }
185 return returnPrim;
186 }
187
188 public void SendAllChildPrimsToClient(IClientAPI client)
189 {
190 this.rootPrimitive.SendFullUpdateForAllChildren(client);
191 }
192
193 /// <summary>
194 ///
195 /// </summary>
196 public override void BackUp()
197 {
198
199 }
200
201 /// <summary>
202 ///
203 /// </summary>
204 /// <param name="offset"></param>
205 /// <param name="pos"></param>
206 /// <param name="remoteClient"></param>
207 public void GrapMovement(LLVector3 offset, LLVector3 pos, IClientAPI remoteClient)
208 {
209 this.rootPrimitive.Pos = pos ;
210 this.rootPrimitive.SendTerseUpdateForAllChildren(remoteClient);
211 }
212
213 /// <summary>
214 ///
215 /// </summary>
216 /// <param name="client"></param>
217 public void GetProperites(IClientAPI client)
218 {
219 ObjectPropertiesPacket proper = new ObjectPropertiesPacket();
220 proper.ObjectData = new ObjectPropertiesPacket.ObjectDataBlock[1];
221 proper.ObjectData[0] = new ObjectPropertiesPacket.ObjectDataBlock();
222 proper.ObjectData[0].ItemID = LLUUID.Zero;
223 proper.ObjectData[0].CreationDate = (ulong)this.rootPrimitive.CreationDate;
224 proper.ObjectData[0].CreatorID = this.rootPrimitive.CreatorID;
225 proper.ObjectData[0].FolderID = LLUUID.Zero;
226 proper.ObjectData[0].FromTaskID = LLUUID.Zero;
227 proper.ObjectData[0].GroupID = LLUUID.Zero;
228 proper.ObjectData[0].InventorySerial = 0;
229 proper.ObjectData[0].LastOwnerID = this.rootPrimitive.LastOwnerID;
230 proper.ObjectData[0].ObjectID = this.rootUUID;
231 proper.ObjectData[0].OwnerID = this.rootPrimitive.OwnerID;
232 proper.ObjectData[0].TouchName = enc.GetBytes(this.rootPrimitive.TouchName + "\0");
233 proper.ObjectData[0].TextureID = new byte[0];
234 proper.ObjectData[0].SitName = enc.GetBytes(this.rootPrimitive.SitName +"\0") ;
235 proper.ObjectData[0].Name = enc.GetBytes(this.rootPrimitive.Name +"\0");
236 proper.ObjectData[0].Description = enc.GetBytes(this.rootPrimitive.Description +"\0");
237 proper.ObjectData[0].OwnerMask = this.rootPrimitive.OwnerMask;
238 proper.ObjectData[0].NextOwnerMask = this.rootPrimitive.NextOwnerMask;
239 proper.ObjectData[0].GroupMask = this.rootPrimitive.GroupMask;
240 proper.ObjectData[0].EveryoneMask = this.rootPrimitive.EveryoneMask;
241 proper.ObjectData[0].BaseMask = this.rootPrimitive.BaseMask;
242
243 client.OutPacket(proper);
244 }
245 }
246}