aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/OpenSim.Region/Scenes/Entities
diff options
context:
space:
mode:
authorMW2007-06-14 12:49:28 +0000
committerMW2007-06-14 12:49:28 +0000
commit841ae288e4e9ad841d2b5226cccd1a17c22b9168 (patch)
tree7f22e9befb5fc463210a9ea14348cfba8e752fab /OpenSim/OpenSim.Region/Scenes/Entities
parenttrying to clean up the namespaces. (diff)
downloadopensim-SC-841ae288e4e9ad841d2b5226cccd1a17c22b9168.zip
opensim-SC-841ae288e4e9ad841d2b5226cccd1a17c22b9168.tar.gz
opensim-SC-841ae288e4e9ad841d2b5226cccd1a17c22b9168.tar.bz2
opensim-SC-841ae288e4e9ad841d2b5226cccd1a17c22b9168.tar.xz
trying to clean up the namespaces.
Diffstat (limited to 'OpenSim/OpenSim.Region/Scenes/Entities')
-rw-r--r--OpenSim/OpenSim.Region/Scenes/Entities/Avatar.Animations.cs76
-rw-r--r--OpenSim/OpenSim.Region/Scenes/Entities/Avatar.Update.cs148
-rw-r--r--OpenSim/OpenSim.Region/Scenes/Entities/Avatar.cs225
-rw-r--r--OpenSim/OpenSim.Region/Scenes/Entities/Entity.cs148
-rw-r--r--OpenSim/OpenSim.Region/Scenes/Entities/Primitive.cs541
-rw-r--r--OpenSim/OpenSim.Region/Scenes/Entities/SceneObject.cs128
6 files changed, 1266 insertions, 0 deletions
diff --git a/OpenSim/OpenSim.Region/Scenes/Entities/Avatar.Animations.cs b/OpenSim/OpenSim.Region/Scenes/Entities/Avatar.Animations.cs
new file mode 100644
index 0000000..1963a8a
--- /dev/null
+++ b/OpenSim/OpenSim.Region/Scenes/Entities/Avatar.Animations.cs
@@ -0,0 +1,76 @@
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;
32using System.Xml;
33
34namespace OpenSim.Region.Scenes
35{
36 partial class Avatar
37 {
38 public class AvatarAnimations
39 {
40
41 public Dictionary<string, LLUUID> AnimsLLUUID = new Dictionary<string, LLUUID>();
42 public Dictionary<LLUUID, string> AnimsNames = new Dictionary<LLUUID, string>();
43
44 public AvatarAnimations()
45 {
46 }
47
48 public void LoadAnims()
49 {
50 //OpenSim.Framework.Console.MainConsole.Instance.Verbose("Avatar.cs:LoadAnims() - Loading avatar animations");
51 XmlTextReader reader = new XmlTextReader("data/avataranimations.xml");
52
53 XmlDocument doc = new XmlDocument();
54 doc.Load(reader);
55 foreach (XmlNode nod in doc.DocumentElement.ChildNodes)
56 {
57
58 if (nod.Attributes["name"] != null)
59 {
60 AnimsLLUUID.Add(nod.Attributes["name"].Value, nod.InnerText);
61 }
62
63 }
64
65 reader.Close();
66
67 // OpenSim.Framework.Console.MainConsole.Instance.Verbose("Loaded " + AnimsLLUUID.Count.ToString() + " animation(s)");
68
69 foreach (KeyValuePair<string, LLUUID> kp in OpenSim.Region.Scenes.Avatar.Animations.AnimsLLUUID)
70 {
71 AnimsNames.Add(kp.Value, kp.Key);
72 }
73 }
74 }
75 }
76}
diff --git a/OpenSim/OpenSim.Region/Scenes/Entities/Avatar.Update.cs b/OpenSim/OpenSim.Region/Scenes/Entities/Avatar.Update.cs
new file mode 100644
index 0000000..d5c25f3
--- /dev/null
+++ b/OpenSim/OpenSim.Region/Scenes/Entities/Avatar.Update.cs
@@ -0,0 +1,148 @@
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;
32using libsecondlife.Packets;
33using OpenSim.Physics.Manager;
34using OpenSim.Framework.Interfaces;
35
36namespace OpenSim.Region.Scenes
37{
38 partial class Avatar
39 {
40 /// <summary>
41 ///
42 /// </summary>
43 public override void update()
44 {
45
46
47 }
48
49 /// <summary>
50 ///
51 /// </summary>
52 /// <param name="remoteAvatar"></param>
53 public void SendUpdateToOtherClient(Avatar remoteAvatar)
54 {
55
56 }
57
58 /// <summary>
59 ///
60 /// </summary>
61 /// <returns></returns>
62 public ObjectUpdatePacket CreateUpdatePacket()
63 {
64 return null;
65 }
66
67 /// <summary>
68 ///
69 /// </summary>
70 public void SendInitialPosition()
71 {
72 this.ControllingClient.SendAvatarData(m_regionInfo, this.firstname, this.lastname, this.uuid, this.localid, new LLVector3(128, 128, 60));
73 }
74
75 /// <summary>
76 ///
77 /// </summary>
78 public void SendOurAppearance()
79 {
80
81 }
82
83 /// <summary>
84 ///
85 /// </summary>
86 /// <param name="OurClient"></param>
87 public void SendOurAppearance(IClientAPI OurClient)
88 {
89 this.ControllingClient.SendWearables(this.Wearables);
90 }
91
92 /// <summary>
93 ///
94 /// </summary>
95 /// <param name="avatarInfo"></param>
96 public void SendAppearanceToOtherAgent(Avatar avatarInfo)
97 {
98
99 }
100
101 /// <summary>
102 ///
103 /// </summary>
104 /// <param name="texture"></param>
105 /// <param name="visualParam"></param>
106 public void SetAppearance(byte[] texture, AgentSetAppearancePacket.VisualParamBlock[] visualParam)
107 {
108
109 }
110
111 /// <summary>
112 ///
113 /// </summary>
114 public void StopMovement()
115 {
116
117 }
118
119 /// <summary>
120 /// Very likely to be deleted soon!
121 /// </summary>
122 /// <returns></returns>
123 public ImprovedTerseObjectUpdatePacket.ObjectDataBlock CreateTerseBlock()
124 {
125 return null;
126 }
127
128 /// <summary>
129 ///
130 /// </summary>
131 /// <param name="animID"></param>
132 /// <param name="seq"></param>
133 public void SendAnimPack(LLUUID animID, int seq)
134 {
135
136
137 }
138
139 /// <summary>
140 ///
141 /// </summary>
142 public void SendAnimPack()
143 {
144
145 }
146
147 }
148}
diff --git a/OpenSim/OpenSim.Region/Scenes/Entities/Avatar.cs b/OpenSim/OpenSim.Region/Scenes/Entities/Avatar.cs
new file mode 100644
index 0000000..6ae4319
--- /dev/null
+++ b/OpenSim/OpenSim.Region/Scenes/Entities/Avatar.cs
@@ -0,0 +1,225 @@
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.IO;
31using System.Text;
32using libsecondlife;
33using libsecondlife.Packets;
34using OpenSim.Physics.Manager;
35using OpenSim.Framework.Inventory;
36using OpenSim.Framework.Interfaces;
37using OpenSim.Framework.Types;
38using Axiom.MathLib;
39
40namespace OpenSim.Region.Scenes
41{
42 public partial class Avatar : Entity
43 {
44 public static bool PhysicsEngineFlying = false;
45 public static AvatarAnimations Animations;
46 public string firstname;
47 public string lastname;
48 public IClientAPI ControllingClient;
49 public LLUUID current_anim;
50 public int anim_seq;
51 private static libsecondlife.Packets.ObjectUpdatePacket.ObjectDataBlock AvatarTemplate;
52 private bool updateflag = false;
53 private byte movementflag = 0;
54 private List<NewForce> forcesList = new List<NewForce>();
55 private short _updateCount = 0;
56 private Axiom.MathLib.Quaternion bodyRot;
57 private LLObject.TextureEntry avatarAppearanceTexture = null;
58 private byte[] visualParams;
59 private AvatarWearable[] Wearables;
60 private LLVector3 positionLastFrame = new LLVector3(0, 0, 0);
61 private ulong m_regionHandle;
62 private Dictionary<uint, IClientAPI> m_clientThreads;
63 private bool childAvatar = false;
64
65 protected RegionInfo m_regionInfo;
66 /// <summary>
67 ///
68 /// </summary>
69 /// <param name="theClient"></param>
70 /// <param name="world"></param>
71 /// <param name="clientThreads"></param>
72 /// <param name="regionDat"></param>
73 public Avatar(IClientAPI theClient, Scene world, Dictionary<uint, IClientAPI> clientThreads, RegionInfo reginfo)
74 {
75
76 m_world = world;
77 m_clientThreads = clientThreads;
78 this.uuid = theClient.AgentId;
79
80 m_regionInfo = reginfo;
81 OpenSim.Framework.Console.MainConsole.Instance.WriteLine(OpenSim.Framework.Console.LogPriority.LOW, "Avatar.cs - Loading details from grid (DUMMY)");
82 ControllingClient = theClient;
83 this.firstname = ControllingClient.FirstName;
84 this.lastname = ControllingClient.LastName;
85 localid = this.m_world.NextLocalId;
86 Pos = ControllingClient.StartPos;
87 visualParams = new byte[218];
88 for (int i = 0; i < 218; i++)
89 {
90 visualParams[i] = 100;
91 }
92
93 Wearables = AvatarWearable.DefaultWearables;
94
95 this.avatarAppearanceTexture = new LLObject.TextureEntry(new LLUUID("00000000-0000-0000-5005-000000000005"));
96
97 //register for events
98 ControllingClient.OnRequestWearables += new GenericCall(this.SendOurAppearance);
99 //ControllingClient.OnSetAppearance += new SetAppearance(this.SetAppearance);
100 ControllingClient.OnCompleteMovementToRegion += new GenericCall2(this.CompleteMovement);
101 ControllingClient.OnCompleteMovementToRegion += new GenericCall2(this.SendInitialPosition);
102 /* ControllingClient.OnAgentUpdate += new GenericCall3(this.HandleAgentUpdate);
103 ControllingClient.OnStartAnim += new StartAnim(this.SendAnimPack);
104 ControllingClient.OnChildAgentStatus += new StatusChange(this.ChildStatusChange);
105 ControllingClient.OnStopMovement += new GenericCall2(this.StopMovement);
106 */
107 }
108
109 /// <summary>
110 ///
111 /// </summary>
112 public PhysicsActor PhysActor
113 {
114 set
115 {
116 this._physActor = value;
117 }
118 get
119 {
120 return _physActor;
121 }
122 }
123
124 /// <summary>
125 ///
126 /// </summary>
127 /// <param name="status"></param>
128 public void ChildStatusChange(bool status)
129 {
130
131 }
132
133 /// <summary>
134 ///
135 /// </summary>
136 public override void addForces()
137 {
138
139 }
140
141 /// <summary>
142 /// likely to removed very soon
143 /// </summary>
144 /// <param name="name"></param>
145 public static void SetupTemplate(string name)
146 {
147
148 }
149
150 /// <summary>
151 /// likely to removed very soon
152 /// </summary>
153 /// <param name="objdata"></param>
154 protected static void SetDefaultPacketValues(ObjectUpdatePacket.ObjectDataBlock objdata)
155 {
156
157
158
159 }
160
161 /// <summary>
162 ///
163 /// </summary>
164 public void CompleteMovement()
165 {
166 this.ControllingClient.MoveAgentIntoRegion(m_regionInfo);
167 }
168
169 /// <summary>
170 ///
171 /// </summary>
172 /// <param name="pack"></param>
173 public void HandleAgentUpdate(Packet pack)
174 {
175 this.HandleUpdate((AgentUpdatePacket)pack);
176 }
177
178 /// <summary>
179 ///
180 /// </summary>
181 /// <param name="pack"></param>
182 public void HandleUpdate(AgentUpdatePacket pack)
183 {
184
185 }
186
187 /// <summary>
188 ///
189 /// </summary>
190 public void SendRegionHandshake()
191 {
192
193 }
194
195 /// <summary>
196 ///
197 /// </summary>
198 public static void LoadAnims()
199 {
200
201 }
202
203 /// <summary>
204 ///
205 /// </summary>
206 public override void LandRenegerated()
207 {
208
209 }
210
211
212 public class NewForce
213 {
214 public float X;
215 public float Y;
216 public float Z;
217
218 public NewForce()
219 {
220
221 }
222 }
223 }
224
225}
diff --git a/OpenSim/OpenSim.Region/Scenes/Entities/Entity.cs b/OpenSim/OpenSim.Region/Scenes/Entities/Entity.cs
new file mode 100644
index 0000000..d4c981a
--- /dev/null
+++ b/OpenSim/OpenSim.Region/Scenes/Entities/Entity.cs
@@ -0,0 +1,148 @@
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 Axiom.MathLib;
32using OpenSim.Physics.Manager;
33using libsecondlife;
34using OpenSim.Region.Scripting;
35
36namespace OpenSim.Region.Scenes
37{
38 public abstract class Entity : IScriptReadonlyEntity
39 {
40 public libsecondlife.LLUUID uuid;
41 public uint localid;
42 public LLVector3 velocity;
43 public Quaternion rotation;
44 protected List<Entity> children;
45 protected LLVector3 m_pos;
46 protected PhysicsActor _physActor;
47 protected Scene m_world;
48 protected string m_name;
49
50 /// <summary>
51 ///
52 /// </summary>
53 public virtual string Name
54 {
55 get { return m_name; }
56 }
57
58 /// <summary>
59 ///
60 /// </summary>
61 public virtual LLVector3 Pos
62 {
63 get
64 {
65 if (this._physActor != null)
66 {
67 m_pos.X = _physActor.Position.X;
68 m_pos.Y = _physActor.Position.Y;
69 m_pos.Z = _physActor.Position.Z;
70 }
71
72 return m_pos;
73 }
74 set
75 {
76 if (this._physActor != null)
77 {
78 try
79 {
80 lock (this.m_world.SyncRoot)
81 {
82
83 this._physActor.Position = new PhysicsVector(value.X, value.Y, value.Z);
84 }
85 }
86 catch (Exception e)
87 {
88 Console.WriteLine(e.Message);
89 }
90 }
91
92 m_pos = value;
93 }
94 }
95
96 /// <summary>
97 /// Creates a new Entity (should not occur on it's own)
98 /// </summary>
99 public Entity()
100 {
101 uuid = new libsecondlife.LLUUID();
102 localid = 0;
103 m_pos = new LLVector3();
104 velocity = new LLVector3();
105 rotation = new Quaternion();
106 m_name = "(basic entity)";
107 children = new List<Entity>();
108 }
109
110 /// <summary>
111 ///
112 /// </summary>
113 public virtual void addForces()
114 {
115 foreach (Entity child in children)
116 {
117 child.addForces();
118 }
119 }
120
121 /// <summary>
122 /// Performs any updates that need to be done at each frame. This function is overridable from it's children.
123 /// </summary>
124 public virtual void update() {
125 // Do any per-frame updates needed that are applicable to every type of entity
126 foreach (Entity child in children)
127 {
128 child.update();
129 }
130 }
131
132 /// <summary>
133 /// Called at a set interval to inform entities that they should back themsleves up to the DB
134 /// </summary>
135 public virtual void BackUp()
136 {
137
138 }
139
140 /// <summary>
141 /// Infoms the entity that the land (heightmap) has changed
142 /// </summary>
143 public virtual void LandRenegerated()
144 {
145
146 }
147 }
148}
diff --git a/OpenSim/OpenSim.Region/Scenes/Entities/Primitive.cs b/OpenSim/OpenSim.Region/Scenes/Entities/Primitive.cs
new file mode 100644
index 0000000..9bccfd3
--- /dev/null
+++ b/OpenSim/OpenSim.Region/Scenes/Entities/Primitive.cs
@@ -0,0 +1,541 @@
1
2/*
3* Copyright (c) Contributors, http://www.openmetaverse.org/
4* See CONTRIBUTORS.TXT for a full list of copyright holders.
5*
6* Redistribution and use in source and binary forms, with or without
7* modification, are permitted provided that the following conditions are met:
8* * Redistributions of source code must retain the above copyright
9* notice, this list of conditions and the following disclaimer.
10* * Redistributions in binary form must reproduce the above copyright
11* notice, this list of conditions and the following disclaimer in the
12* documentation and/or other materials provided with the distribution.
13* * Neither the name of the OpenSim Project nor the
14* names of its contributors may be used to endorse or promote products
15* derived from this software without specific prior written permission.
16*
17* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS AND ANY
18* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
19* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
20* DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
21* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
22* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
23* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
24* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
25* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
26* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27*
28*/
29using System;
30using System.Collections.Generic;
31using System.Text;
32using libsecondlife;
33using libsecondlife.Packets;
34using OpenSim.Framework.Interfaces;
35using OpenSim.Physics.Manager;
36using OpenSim.Framework.Types;
37using OpenSim.Framework.Inventory;
38
39namespace OpenSim.Region.Scenes
40{
41 public class Primitive : Entity
42 {
43 internal PrimData primData;
44 private LLVector3 positionLastFrame = new LLVector3(0, 0, 0);
45 // private Dictionary<uint, IClientAPI> m_clientThreads;
46 private ulong m_regionHandle;
47 private const uint FULL_MASK_PERMISSIONS = 2147483647;
48 private bool physicsEnabled = false;
49 private byte updateFlag = 0;
50
51 private Dictionary<LLUUID, InventoryItem> inventoryItems;
52
53 #region Properties
54
55 public LLVector3 Scale
56 {
57 set
58 {
59 this.primData.Scale = value;
60 //this.dirtyFlag = true;
61 }
62 get
63 {
64 return this.primData.Scale;
65 }
66 }
67
68 public PhysicsActor PhysActor
69 {
70 set
71 {
72 this._physActor = value;
73 }
74 }
75
76 public override LLVector3 Pos
77 {
78 get
79 {
80 return base.Pos;
81 }
82 set
83 {
84 base.Pos = value;
85 }
86 }
87 #endregion
88
89 /// <summary>
90 ///
91 /// </summary>
92 /// <param name="clientThreads"></param>
93 /// <param name="regionHandle"></param>
94 /// <param name="world"></param>
95 public Primitive( ulong regionHandle, Scene world)
96 {
97 // m_clientThreads = clientThreads;
98 m_regionHandle = regionHandle;
99 m_world = world;
100 inventoryItems = new Dictionary<LLUUID, InventoryItem>();
101 }
102
103 /// <summary>
104 ///
105 /// </summary>
106 /// <param name="regionHandle"></param>
107 /// <param name="world"></param>
108 /// <param name="addPacket"></param>
109 /// <param name="ownerID"></param>
110 /// <param name="localID"></param>
111 public Primitive(ulong regionHandle, Scene world, ObjectAddPacket addPacket, LLUUID ownerID, uint localID)
112 {
113 // m_clientThreads = clientThreads;
114 m_regionHandle = regionHandle;
115 m_world = world;
116 inventoryItems = new Dictionary<LLUUID, InventoryItem>();
117 this.CreateFromPacket(addPacket, ownerID, localID);
118 }
119
120 /// <summary>
121 ///
122 /// </summary>
123 /// <param name="clientThreads"></param>
124 /// <param name="regionHandle"></param>
125 /// <param name="world"></param>
126 /// <param name="owner"></param>
127 /// <param name="fullID"></param>
128 /// <param name="localID"></param>
129 public Primitive( ulong regionHandle, Scene world, LLUUID owner, LLUUID fullID, uint localID)
130 {
131 // m_clientThreads = clientThreads;
132 m_regionHandle = regionHandle;
133 m_world = world;
134 inventoryItems = new Dictionary<LLUUID, InventoryItem>();
135 this.primData = new PrimData();
136 this.primData.CreationDate = (Int32)(DateTime.UtcNow - new DateTime(1970, 1, 1)).TotalSeconds;
137 this.primData.OwnerID = owner;
138 this.primData.FullID = this.uuid = fullID;
139 this.primData.LocalID = this.localid = localID;
140 }
141
142 /// <summary>
143 /// Constructor to create a default cube
144 /// </summary>
145 /// <param name="clientThreads"></param>
146 /// <param name="regionHandle"></param>
147 /// <param name="world"></param>
148 /// <param name="owner"></param>
149 /// <param name="localID"></param>
150 /// <param name="position"></param>
151 public Primitive( ulong regionHandle, Scene world, LLUUID owner, uint localID, LLVector3 position)
152 {
153 //m_clientThreads = clientThreads;
154 m_regionHandle = regionHandle;
155 m_world = world;
156 inventoryItems = new Dictionary<LLUUID, InventoryItem>();
157 this.primData = PrimData.DefaultCube();
158 this.primData.OwnerID = owner;
159 this.primData.LocalID = this.localid = localID;
160 this.Pos = this.primData.Position = position;
161
162 this.updateFlag = 1;
163 }
164
165 /// <summary>
166 ///
167 /// </summary>
168 /// <returns></returns>
169 public byte[] GetByteArray()
170 {
171 byte[] result = null;
172 List<byte[]> dataArrays = new List<byte[]>();
173 dataArrays.Add(primData.ToBytes());
174 foreach (Entity child in children)
175 {
176 if (child is OpenSim.Region.Scenes.Primitive)
177 {
178 dataArrays.Add(((OpenSim.Region.Scenes.Primitive)child).GetByteArray());
179 }
180 }
181 byte[] primstart = Helpers.StringToField("<Prim>");
182 byte[] primend = Helpers.StringToField("</Prim>");
183 int totalLength = primstart.Length + primend.Length;
184 for (int i = 0; i < dataArrays.Count; i++)
185 {
186 totalLength += dataArrays[i].Length;
187 }
188
189 result = new byte[totalLength];
190 int arraypos = 0;
191 Array.Copy(primstart, 0, result, 0, primstart.Length);
192 arraypos += primstart.Length;
193 for (int i = 0; i < dataArrays.Count; i++)
194 {
195 Array.Copy(dataArrays[i], 0, result, arraypos, dataArrays[i].Length);
196 arraypos += dataArrays[i].Length;
197 }
198 Array.Copy(primend, 0, result, arraypos, primend.Length);
199
200 return result;
201 }
202
203 #region Overridden Methods
204
205 /// <summary>
206 ///
207 /// </summary>
208 public override void update()
209 {
210 if (this.updateFlag == 1) // is a new prim just been created/reloaded
211 {
212 this.SendFullUpdateToAllClients();
213 this.updateFlag = 0;
214 }
215 if (this.updateFlag == 2) //some change has been made so update the clients
216 {
217 this.SendTerseUpdateToALLClients();
218 this.updateFlag = 0;
219 }
220 }
221
222 /// <summary>
223 ///
224 /// </summary>
225 public override void BackUp()
226 {
227
228 }
229
230 #endregion
231
232 #region Packet handlers
233
234 /// <summary>
235 ///
236 /// </summary>
237 /// <param name="pos"></param>
238 public void UpdatePosition(LLVector3 pos)
239 {
240 this.Pos = new LLVector3(pos.X, pos.Y, pos.Z);
241 this.updateFlag = 2;
242 }
243
244 /// <summary>
245 ///
246 /// </summary>
247 /// <param name="addPacket"></param>
248 public void UpdateShape(ObjectShapePacket.ObjectDataBlock updatePacket)
249 {
250 this.primData.PathBegin = updatePacket.PathBegin;
251 this.primData.PathEnd = updatePacket.PathEnd;
252 this.primData.PathScaleX = updatePacket.PathScaleX;
253 this.primData.PathScaleY = updatePacket.PathScaleY;
254 this.primData.PathShearX = updatePacket.PathShearX;
255 this.primData.PathShearY = updatePacket.PathShearY;
256 this.primData.PathSkew = updatePacket.PathSkew;
257 this.primData.ProfileBegin = updatePacket.ProfileBegin;
258 this.primData.ProfileEnd = updatePacket.ProfileEnd;
259 this.primData.PathCurve = updatePacket.PathCurve;
260 this.primData.ProfileCurve = updatePacket.ProfileCurve;
261 this.primData.ProfileHollow = updatePacket.ProfileHollow;
262 this.primData.PathRadiusOffset = updatePacket.PathRadiusOffset;
263 this.primData.PathRevolutions = updatePacket.PathRevolutions;
264 this.primData.PathTaperX = updatePacket.PathTaperX;
265 this.primData.PathTaperY = updatePacket.PathTaperY;
266 this.primData.PathTwist = updatePacket.PathTwist;
267 this.primData.PathTwistBegin = updatePacket.PathTwistBegin;
268 }
269
270 /// <summary>
271 ///
272 /// </summary>
273 /// <param name="tex"></param>
274 public void UpdateTexture(byte[] tex)
275 {
276 this.primData.Texture = tex;
277 }
278
279 /// <summary>
280 ///
281 /// </summary>
282 /// <param name="pack"></param>
283 public void UpdateObjectFlags(ObjectFlagUpdatePacket pack)
284 {
285
286 }
287
288 /// <summary>
289 ///
290 /// </summary>
291 /// <param name="prim"></param>
292 public void AssignToParent(Primitive prim)
293 {
294
295 }
296
297 #endregion
298
299 # region Inventory Methods
300 /// <summary>
301 ///
302 /// </summary>
303 /// <param name="item"></param>
304 /// <returns></returns>
305 public bool AddToInventory(InventoryItem item)
306 {
307 return false;
308 }
309
310 /// <summary>
311 ///
312 /// </summary>
313 /// <param name="itemID"></param>
314 /// <returns></returns>
315 public InventoryItem RemoveFromInventory(LLUUID itemID)
316 {
317 return null;
318 }
319
320 /// <summary>
321 ///
322 /// </summary>
323 /// <param name="simClient"></param>
324 /// <param name="packet"></param>
325 public void RequestInventoryInfo(IClientAPI simClient, RequestTaskInventoryPacket packet)
326 {
327
328 }
329
330 /// <summary>
331 ///
332 /// </summary>
333 /// <param name="simClient"></param>
334 /// <param name="xferID"></param>
335 public void RequestXferInventory(IClientAPI simClient, ulong xferID)
336 {
337 //will only currently work if the total size of the inventory data array is under about 1000 bytes
338 SendXferPacketPacket send = new SendXferPacketPacket();
339
340 send.XferID.ID = xferID;
341 send.XferID.Packet = 1 + 2147483648;
342 send.DataPacket.Data = this.ConvertInventoryToBytes();
343
344 simClient.OutPacket(send);
345 }
346
347 /// <summary>
348 ///
349 /// </summary>
350 /// <returns></returns>
351 public byte[] ConvertInventoryToBytes()
352 {
353 System.Text.Encoding enc = System.Text.Encoding.ASCII;
354 byte[] result = new byte[0];
355 List<byte[]> inventoryData = new List<byte[]>();
356 int totallength = 0;
357 foreach (InventoryItem invItem in inventoryItems.Values)
358 {
359 byte[] data = enc.GetBytes(invItem.ExportString());
360 inventoryData.Add(data);
361 totallength += data.Length;
362 }
363 //TODO: copy arrays into the single result array
364
365 return result;
366 }
367
368 /// <summary>
369 ///
370 /// </summary>
371 /// <param name="data"></param>
372 public void CreateInventoryFromBytes(byte[] data)
373 {
374
375 }
376
377 #endregion
378
379 #region Update viewers Methods
380
381 /// <summary>
382 ///
383 /// </summary>
384 /// <param name="remoteClient"></param>
385 public void SendFullUpdateForAllChildren(IClientAPI remoteClient)
386 {
387 this.SendFullUpdateToClient(remoteClient);
388 for (int i = 0; i < this.children.Count; i++)
389 {
390 if (this.children[i] is Primitive)
391 {
392 ((Primitive)this.children[i]).SendFullUpdateForAllChildren(remoteClient);
393 }
394 }
395 }
396
397 /// <summary>
398 ///
399 /// </summary>
400 /// <param name="remoteClient"></param>
401 public void SendFullUpdateToClient(IClientAPI remoteClient)
402 {
403 LLVector3 lPos;
404 if (this._physActor != null && this.physicsEnabled)
405 {
406 PhysicsVector pPos = this._physActor.Position;
407 lPos = new LLVector3(pPos.X, pPos.Y, pPos.Z);
408 }
409 else
410 {
411 lPos = this.Pos;
412 }
413
414 remoteClient.SendPrimitiveToClient(this.m_regionHandle, 64096, this.localid, this.primData, lPos, new LLUUID("00000000-0000-0000-5005-000000000005"));
415 }
416
417 /// <summary>
418 ///
419 /// </summary>
420 public void SendFullUpdateToAllClients()
421 {
422 List<Avatar> avatars = this.m_world.RequestAvatarList();
423 for (int i = 0; i < avatars.Count; i++)
424 {
425 this.SendFullUpdateToClient(avatars[i].ControllingClient);
426 }
427 }
428
429 /// <summary>
430 ///
431 /// </summary>
432 /// <param name="RemoteClient"></param>
433 public void SendTerseUpdateToClient(IClientAPI RemoteClient)
434 {
435 LLVector3 lPos;
436 Axiom.MathLib.Quaternion lRot;
437 if (this._physActor != null && this.physicsEnabled)
438 {
439 PhysicsVector pPos = this._physActor.Position;
440 lPos = new LLVector3(pPos.X, pPos.Y, pPos.Z);
441 lRot = this._physActor.Orientation;
442 }
443 else
444 {
445 lPos = this.Pos;
446 lRot = this.rotation;
447 }
448 }
449
450 /// <summary>
451 ///
452 /// </summary>
453 public void SendTerseUpdateToALLClients()
454 {
455 List<Avatar> avatars = this.m_world.RequestAvatarList();
456 for (int i = 0; i < avatars.Count; i++)
457 {
458 this.SendTerseUpdateToClient(avatars[i].ControllingClient);
459 }
460 }
461
462 #endregion
463
464 #region Create Methods
465
466 /// <summary>
467 ///
468 /// </summary>
469 /// <param name="addPacket"></param>
470 /// <param name="ownerID"></param>
471 /// <param name="localID"></param>
472 public void CreateFromPacket(ObjectAddPacket addPacket, LLUUID ownerID, uint localID)
473 {
474 PrimData PData = new PrimData();
475 this.primData = PData;
476 this.primData.CreationDate = (Int32)(DateTime.UtcNow - new DateTime(1970, 1, 1)).TotalSeconds;
477
478 PData.OwnerID = ownerID;
479 PData.PCode = addPacket.ObjectData.PCode;
480 PData.PathBegin = addPacket.ObjectData.PathBegin;
481 PData.PathEnd = addPacket.ObjectData.PathEnd;
482 PData.PathScaleX = addPacket.ObjectData.PathScaleX;
483 PData.PathScaleY = addPacket.ObjectData.PathScaleY;
484 PData.PathShearX = addPacket.ObjectData.PathShearX;
485 PData.PathShearY = addPacket.ObjectData.PathShearY;
486 PData.PathSkew = addPacket.ObjectData.PathSkew;
487 PData.ProfileBegin = addPacket.ObjectData.ProfileBegin;
488 PData.ProfileEnd = addPacket.ObjectData.ProfileEnd;
489 PData.Scale = addPacket.ObjectData.Scale;
490 PData.PathCurve = addPacket.ObjectData.PathCurve;
491 PData.ProfileCurve = addPacket.ObjectData.ProfileCurve;
492 PData.ParentID = 0;
493 PData.ProfileHollow = addPacket.ObjectData.ProfileHollow;
494 PData.PathRadiusOffset = addPacket.ObjectData.PathRadiusOffset;
495 PData.PathRevolutions = addPacket.ObjectData.PathRevolutions;
496 PData.PathTaperX = addPacket.ObjectData.PathTaperX;
497 PData.PathTaperY = addPacket.ObjectData.PathTaperY;
498 PData.PathTwist = addPacket.ObjectData.PathTwist;
499 PData.PathTwistBegin = addPacket.ObjectData.PathTwistBegin;
500 LLVector3 pos1 = addPacket.ObjectData.RayEnd;
501 this.primData.FullID = this.uuid = LLUUID.Random();
502 this.primData.LocalID = this.localid = (uint)(localID);
503 this.primData.Position = this.Pos = pos1;
504
505 this.updateFlag = 1;
506 }
507
508 /// <summary>
509 ///
510 /// </summary>
511 /// <param name="data"></param>
512 public void CreateFromBytes(byte[] data)
513 {
514
515 }
516
517 /// <summary>
518 ///
519 /// </summary>
520 /// <param name="primData"></param>
521 public void CreateFromPrimData(PrimData primData)
522 {
523 this.CreateFromPrimData(primData, primData.Position, primData.LocalID, false);
524 }
525
526 /// <summary>
527 ///
528 /// </summary>
529 /// <param name="primData"></param>
530 /// <param name="posi"></param>
531 /// <param name="localID"></param>
532 /// <param name="newprim"></param>
533 public void CreateFromPrimData(PrimData primData, LLVector3 posi, uint localID, bool newprim)
534 {
535
536 }
537
538 #endregion
539
540 }
541}
diff --git a/OpenSim/OpenSim.Region/Scenes/Entities/SceneObject.cs b/OpenSim/OpenSim.Region/Scenes/Entities/SceneObject.cs
new file mode 100644
index 0000000..5df87bf
--- /dev/null
+++ b/OpenSim/OpenSim.Region/Scenes/Entities/SceneObject.cs
@@ -0,0 +1,128 @@
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;
32using libsecondlife.Packets;
33using OpenSim.Framework.Interfaces;
34using OpenSim.Physics.Manager;
35using OpenSim.Framework.Types;
36using OpenSim.Framework.Inventory;
37
38namespace OpenSim.Region.Scenes
39{
40 public class SceneObject : Entity
41 {
42 private LLUUID rootUUID;
43 //private Dictionary<LLUUID, Primitive> ChildPrimitives = new Dictionary<LLUUID, Primitive>();
44 protected Primitive rootPrimitive;
45 private Scene m_world;
46 protected ulong regionHandle;
47
48 /// <summary>
49 ///
50 /// </summary>
51 public SceneObject()
52 {
53
54 }
55
56 /// <summary>
57 ///
58 /// </summary>
59 /// <param name="addPacket"></param>
60 /// <param name="agentID"></param>
61 /// <param name="localID"></param>
62 public void CreateFromPacket(ObjectAddPacket addPacket, LLUUID agentID, uint localID)
63 {
64 this.rootPrimitive = new Primitive( this.regionHandle, this.m_world, addPacket, agentID, localID);
65 }
66
67 /// <summary>
68 ///
69 /// </summary>
70 /// <param name="data"></param>
71 public void CreateFromBytes(byte[] data)
72 {
73
74 }
75
76 /// <summary>
77 ///
78 /// </summary>
79 public override void update()
80 {
81
82 }
83
84 /// <summary>
85 ///
86 /// </summary>
87 public override void BackUp()
88 {
89
90 }
91
92 /// <summary>
93 ///
94 /// </summary>
95 /// <param name="client"></param>
96 public void GetProperites(IClientAPI client)
97 {
98 //needs changing
99 ObjectPropertiesPacket proper = new ObjectPropertiesPacket();
100 proper.ObjectData = new ObjectPropertiesPacket.ObjectDataBlock[1];
101 proper.ObjectData[0] = new ObjectPropertiesPacket.ObjectDataBlock();
102 proper.ObjectData[0].ItemID = LLUUID.Zero;
103 proper.ObjectData[0].CreationDate = (ulong)this.rootPrimitive.primData.CreationDate;
104 proper.ObjectData[0].CreatorID = this.rootPrimitive.primData.OwnerID;
105 proper.ObjectData[0].FolderID = LLUUID.Zero;
106 proper.ObjectData[0].FromTaskID = LLUUID.Zero;
107 proper.ObjectData[0].GroupID = LLUUID.Zero;
108 proper.ObjectData[0].InventorySerial = 0;
109 proper.ObjectData[0].LastOwnerID = LLUUID.Zero;
110 proper.ObjectData[0].ObjectID = this.uuid;
111 proper.ObjectData[0].OwnerID = this.rootPrimitive.primData.OwnerID;
112 proper.ObjectData[0].TouchName = new byte[0];
113 proper.ObjectData[0].TextureID = new byte[0];
114 proper.ObjectData[0].SitName = new byte[0];
115 proper.ObjectData[0].Name = new byte[0];
116 proper.ObjectData[0].Description = new byte[0];
117 proper.ObjectData[0].OwnerMask = this.rootPrimitive.primData.OwnerMask;
118 proper.ObjectData[0].NextOwnerMask = this.rootPrimitive.primData.NextOwnerMask;
119 proper.ObjectData[0].GroupMask = this.rootPrimitive.primData.GroupMask;
120 proper.ObjectData[0].EveryoneMask = this.rootPrimitive.primData.EveryoneMask;
121 proper.ObjectData[0].BaseMask = this.rootPrimitive.primData.BaseMask;
122
123 client.OutPacket(proper);
124
125 }
126
127 }
128}