aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/OpenSim.Region/World/Entities
diff options
context:
space:
mode:
Diffstat (limited to 'OpenSim/OpenSim.Region/World/Entities')
-rw-r--r--OpenSim/OpenSim.Region/World/Entities/Avatar/Avatar.Update.cs148
-rw-r--r--OpenSim/OpenSim.Region/World/Entities/Avatar/Avatar.cs225
-rw-r--r--OpenSim/OpenSim.Region/World/Entities/Avatar/AvatarAnimations.cs73
-rw-r--r--OpenSim/OpenSim.Region/World/Entities/Entity.cs165
-rw-r--r--OpenSim/OpenSim.Region/World/Entities/Primitive.cs525
-rw-r--r--OpenSim/OpenSim.Region/World/Entities/SceneObject.cs130
6 files changed, 1266 insertions, 0 deletions
diff --git a/OpenSim/OpenSim.Region/World/Entities/Avatar/Avatar.Update.cs b/OpenSim/OpenSim.Region/World/Entities/Avatar/Avatar.Update.cs
new file mode 100644
index 0000000..d373fdb
--- /dev/null
+++ b/OpenSim/OpenSim.Region/World/Entities/Avatar/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
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/World/Entities/Avatar/Avatar.cs b/OpenSim/OpenSim.Region/World/Entities/Avatar/Avatar.cs
new file mode 100644
index 0000000..c88e0cc
--- /dev/null
+++ b/OpenSim/OpenSim.Region/World/Entities/Avatar/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
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, World 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/World/Entities/Avatar/AvatarAnimations.cs b/OpenSim/OpenSim.Region/World/Entities/Avatar/AvatarAnimations.cs
new file mode 100644
index 0000000..585cf3c
--- /dev/null
+++ b/OpenSim/OpenSim.Region/World/Entities/Avatar/AvatarAnimations.cs
@@ -0,0 +1,73 @@
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
35{
36 public class AvatarAnimations
37 {
38
39 public Dictionary<string, LLUUID> AnimsLLUUID = new Dictionary<string, LLUUID>();
40 public Dictionary<LLUUID, string> AnimsNames = new Dictionary<LLUUID, string>();
41
42 public AvatarAnimations()
43 {
44 }
45
46 public void LoadAnims()
47 {
48 //OpenSim.Framework.Console.MainConsole.Instance.Verbose("Avatar.cs:LoadAnims() - Loading avatar animations");
49 XmlTextReader reader = new XmlTextReader("data/avataranimations.xml");
50
51 XmlDocument doc = new XmlDocument();
52 doc.Load(reader);
53 foreach (XmlNode nod in doc.DocumentElement.ChildNodes)
54 {
55
56 if ( nod.Attributes["name"] != null)
57 {
58 AnimsLLUUID.Add(nod.Attributes["name"].Value, nod.InnerText);
59 }
60
61 }
62
63 reader.Close();
64
65 // OpenSim.Framework.Console.MainConsole.Instance.Verbose("Loaded " + AnimsLLUUID.Count.ToString() + " animation(s)");
66
67 foreach (KeyValuePair<string, LLUUID> kp in OpenSim.Region.Avatar.Animations.AnimsLLUUID)
68 {
69 AnimsNames.Add(kp.Value, kp.Key);
70 }
71 }
72 }
73}
diff --git a/OpenSim/OpenSim.Region/World/Entities/Entity.cs b/OpenSim/OpenSim.Region/World/Entities/Entity.cs
new file mode 100644
index 0000000..1620c89
--- /dev/null
+++ b/OpenSim/OpenSim.Region/World/Entities/Entity.cs
@@ -0,0 +1,165 @@
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 OpenSim.Region.types;
34using libsecondlife;
35using OpenSim.Region.Scripting;
36
37namespace OpenSim.Region
38{
39 public abstract class Entity : IScriptReadonlyEntity
40 {
41 public libsecondlife.LLUUID uuid;
42 public uint localid;
43 public LLVector3 velocity;
44 public Quaternion rotation;
45 protected List<Entity> children;
46 protected LLVector3 m_pos;
47 protected PhysicsActor _physActor;
48 protected World m_world;
49 protected string m_name;
50
51 /// <summary>
52 ///
53 /// </summary>
54 public virtual string Name
55 {
56 get { return m_name; }
57 }
58
59 /// <summary>
60 ///
61 /// </summary>
62 public virtual LLVector3 Pos
63 {
64 get
65 {
66 if (this._physActor != null)
67 {
68 m_pos.X = _physActor.Position.X;
69 m_pos.Y = _physActor.Position.Y;
70 m_pos.Z = _physActor.Position.Z;
71 }
72
73 return m_pos;
74 }
75 set
76 {
77 if (this._physActor != null)
78 {
79 try
80 {
81 lock (this.m_world.SyncRoot)
82 {
83
84 this._physActor.Position = new PhysicsVector(value.X, value.Y, value.Z);
85 }
86 }
87 catch (Exception e)
88 {
89 Console.WriteLine(e.Message);
90 }
91 }
92
93 m_pos = value;
94 }
95 }
96
97 /// <summary>
98 /// Creates a new Entity (should not occur on it's own)
99 /// </summary>
100 public Entity()
101 {
102 uuid = new libsecondlife.LLUUID();
103 localid = 0;
104 m_pos = new LLVector3();
105 velocity = new LLVector3();
106 rotation = new Quaternion();
107 m_name = "(basic entity)";
108 children = new List<Entity>();
109 }
110
111 /// <summary>
112 ///
113 /// </summary>
114 public virtual void addForces()
115 {
116 foreach (Entity child in children)
117 {
118 child.addForces();
119 }
120 }
121
122 /// <summary>
123 /// Performs any updates that need to be done at each frame. This function is overridable from it's children.
124 /// </summary>
125 public virtual void update() {
126 // Do any per-frame updates needed that are applicable to every type of entity
127 foreach (Entity child in children)
128 {
129 child.update();
130 }
131 }
132
133 /// <summary>
134 /// Returns a mesh for this object and any dependents
135 /// </summary>
136 /// <returns>The mesh of this entity tree</returns>
137 public virtual Mesh getMesh()
138 {
139 Mesh mesh = new Mesh();
140
141 foreach (Entity child in children)
142 {
143 mesh += child.getMesh();
144 }
145
146 return mesh;
147 }
148
149 /// <summary>
150 /// Called at a set interval to inform entities that they should back themsleves up to the DB
151 /// </summary>
152 public virtual void BackUp()
153 {
154
155 }
156
157 /// <summary>
158 /// Infoms the entity that the land (heightmap) has changed
159 /// </summary>
160 public virtual void LandRenegerated()
161 {
162
163 }
164 }
165}
diff --git a/OpenSim/OpenSim.Region/World/Entities/Primitive.cs b/OpenSim/OpenSim.Region/World/Entities/Primitive.cs
new file mode 100644
index 0000000..0680eb3
--- /dev/null
+++ b/OpenSim/OpenSim.Region/World/Entities/Primitive.cs
@@ -0,0 +1,525 @@
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 OpenSim.Region.types;
33using libsecondlife;
34using libsecondlife.Packets;
35using OpenSim.Framework.Interfaces;
36using OpenSim.Physics.Manager;
37using OpenSim.Framework.Types;
38using OpenSim.Framework.Inventory;
39
40namespace OpenSim.Region
41{
42 public class Primitive : Entity
43 {
44 internal PrimData primData;
45 private LLVector3 positionLastFrame = new LLVector3(0, 0, 0);
46 // private Dictionary<uint, IClientAPI> m_clientThreads;
47 private ulong m_regionHandle;
48 private const uint FULL_MASK_PERMISSIONS = 2147483647;
49 private bool physicsEnabled = false;
50 private byte updateFlag = 0;
51
52 private Dictionary<LLUUID, InventoryItem> inventoryItems;
53
54 #region Properties
55
56 public LLVector3 Scale
57 {
58 set
59 {
60 this.primData.Scale = value;
61 //this.dirtyFlag = true;
62 }
63 get
64 {
65 return this.primData.Scale;
66 }
67 }
68
69 public PhysicsActor PhysActor
70 {
71 set
72 {
73 this._physActor = value;
74 }
75 }
76
77 public override LLVector3 Pos
78 {
79 get
80 {
81 return base.Pos;
82 }
83 set
84 {
85 base.Pos = value;
86 }
87 }
88 #endregion
89
90 /// <summary>
91 ///
92 /// </summary>
93 /// <param name="clientThreads"></param>
94 /// <param name="regionHandle"></param>
95 /// <param name="world"></param>
96 public Primitive(Dictionary<uint, IClientAPI> clientThreads, ulong regionHandle, World world)
97 {
98 // m_clientThreads = clientThreads;
99 m_regionHandle = regionHandle;
100 m_world = world;
101 inventoryItems = new Dictionary<LLUUID, InventoryItem>();
102 }
103
104 /// <summary>
105 ///
106 /// </summary>
107 /// <param name="clientThreads"></param>
108 /// <param name="regionHandle"></param>
109 /// <param name="world"></param>
110 /// <param name="owner"></param>
111 /// <param name="fullID"></param>
112 /// <param name="localID"></param>
113 public Primitive(Dictionary<uint, IClientAPI> clientThreads, ulong regionHandle, World world, LLUUID owner, LLUUID fullID, uint localID)
114 {
115 // m_clientThreads = clientThreads;
116 m_regionHandle = regionHandle;
117 m_world = world;
118 inventoryItems = new Dictionary<LLUUID, InventoryItem>();
119 this.primData = new PrimData();
120 this.primData.CreationDate = (Int32)(DateTime.UtcNow - new DateTime(1970, 1, 1)).TotalSeconds;
121 this.primData.OwnerID = owner;
122 this.primData.FullID = this.uuid = fullID;
123 this.primData.LocalID = this.localid = localID;
124 }
125
126 /// <summary>
127 /// Constructor to create a default cube
128 /// </summary>
129 /// <param name="clientThreads"></param>
130 /// <param name="regionHandle"></param>
131 /// <param name="world"></param>
132 /// <param name="owner"></param>
133 /// <param name="localID"></param>
134 /// <param name="position"></param>
135 public Primitive(Dictionary<uint, IClientAPI> clientThreads, ulong regionHandle, World world, LLUUID owner, uint localID, LLVector3 position)
136 {
137 //m_clientThreads = clientThreads;
138 m_regionHandle = regionHandle;
139 m_world = world;
140 inventoryItems = new Dictionary<LLUUID, InventoryItem>();
141 this.primData = PrimData.DefaultCube();
142 this.primData.OwnerID = owner;
143 this.primData.LocalID = this.localid = localID;
144 this.Pos = this.primData.Position = position;
145
146 this.updateFlag = 1;
147 }
148
149 /// <summary>
150 ///
151 /// </summary>
152 /// <returns></returns>
153 public byte[] GetByteArray()
154 {
155 byte[] result = null;
156 List<byte[]> dataArrays = new List<byte[]>();
157 dataArrays.Add(primData.ToBytes());
158 foreach (Entity child in children)
159 {
160 if (child is OpenSim.Region.Primitive)
161 {
162 dataArrays.Add(((OpenSim.Region.Primitive)child).GetByteArray());
163 }
164 }
165 byte[] primstart = Helpers.StringToField("<Prim>");
166 byte[] primend = Helpers.StringToField("</Prim>");
167 int totalLength = primstart.Length + primend.Length;
168 for (int i = 0; i < dataArrays.Count; i++)
169 {
170 totalLength += dataArrays[i].Length;
171 }
172
173 result = new byte[totalLength];
174 int arraypos = 0;
175 Array.Copy(primstart, 0, result, 0, primstart.Length);
176 arraypos += primstart.Length;
177 for (int i = 0; i < dataArrays.Count; i++)
178 {
179 Array.Copy(dataArrays[i], 0, result, arraypos, dataArrays[i].Length);
180 arraypos += dataArrays[i].Length;
181 }
182 Array.Copy(primend, 0, result, arraypos, primend.Length);
183
184 return result;
185 }
186
187 #region Overridden Methods
188
189 /// <summary>
190 ///
191 /// </summary>
192 public override void update()
193 {
194 if (this.updateFlag == 1) // is a new prim just been created/reloaded
195 {
196 this.SendFullUpdateToAllClients();
197 this.updateFlag = 0;
198 }
199 if (this.updateFlag == 2) //some change has been made so update the clients
200 {
201 this.SendTerseUpdateToALLClients();
202 this.updateFlag = 0;
203 }
204 }
205
206 /// <summary>
207 ///
208 /// </summary>
209 public override void BackUp()
210 {
211
212 }
213
214 #endregion
215
216 #region Packet handlers
217
218 /// <summary>
219 ///
220 /// </summary>
221 /// <param name="pos"></param>
222 public void UpdatePosition(LLVector3 pos)
223 {
224 this.Pos = new LLVector3(pos.X, pos.Y, pos.Z);
225 this.updateFlag = 2;
226 }
227
228 /// <summary>
229 ///
230 /// </summary>
231 /// <param name="addPacket"></param>
232 public void UpdateShape(ObjectShapePacket.ObjectDataBlock addPacket)
233 {
234 this.primData.PathBegin = addPacket.PathBegin;
235 this.primData.PathEnd = addPacket.PathEnd;
236 this.primData.PathScaleX = addPacket.PathScaleX;
237 this.primData.PathScaleY = addPacket.PathScaleY;
238 this.primData.PathShearX = addPacket.PathShearX;
239 this.primData.PathShearY = addPacket.PathShearY;
240 this.primData.PathSkew = addPacket.PathSkew;
241 this.primData.ProfileBegin = addPacket.ProfileBegin;
242 this.primData.ProfileEnd = addPacket.ProfileEnd;
243 this.primData.PathCurve = addPacket.PathCurve;
244 this.primData.ProfileCurve = addPacket.ProfileCurve;
245 this.primData.ProfileHollow = addPacket.ProfileHollow;
246 this.primData.PathRadiusOffset = addPacket.PathRadiusOffset;
247 this.primData.PathRevolutions = addPacket.PathRevolutions;
248 this.primData.PathTaperX = addPacket.PathTaperX;
249 this.primData.PathTaperY = addPacket.PathTaperY;
250 this.primData.PathTwist = addPacket.PathTwist;
251 this.primData.PathTwistBegin = addPacket.PathTwistBegin;
252 }
253
254 /// <summary>
255 ///
256 /// </summary>
257 /// <param name="tex"></param>
258 public void UpdateTexture(byte[] tex)
259 {
260 this.primData.Texture = tex;
261 }
262
263 /// <summary>
264 ///
265 /// </summary>
266 /// <param name="pack"></param>
267 public void UpdateObjectFlags(ObjectFlagUpdatePacket pack)
268 {
269
270 }
271
272 /// <summary>
273 ///
274 /// </summary>
275 /// <param name="prim"></param>
276 public void AssignToParent(Primitive prim)
277 {
278
279 }
280
281 #endregion
282
283 # region Inventory Methods
284 /// <summary>
285 ///
286 /// </summary>
287 /// <param name="item"></param>
288 /// <returns></returns>
289 public bool AddToInventory(InventoryItem item)
290 {
291 return false;
292 }
293
294 /// <summary>
295 ///
296 /// </summary>
297 /// <param name="itemID"></param>
298 /// <returns></returns>
299 public InventoryItem RemoveFromInventory(LLUUID itemID)
300 {
301 return null;
302 }
303
304 /// <summary>
305 ///
306 /// </summary>
307 /// <param name="simClient"></param>
308 /// <param name="packet"></param>
309 public void RequestInventoryInfo(IClientAPI simClient, RequestTaskInventoryPacket packet)
310 {
311
312 }
313
314 /// <summary>
315 ///
316 /// </summary>
317 /// <param name="simClient"></param>
318 /// <param name="xferID"></param>
319 public void RequestXferInventory(IClientAPI simClient, ulong xferID)
320 {
321 //will only currently work if the total size of the inventory data array is under about 1000 bytes
322 SendXferPacketPacket send = new SendXferPacketPacket();
323
324 send.XferID.ID = xferID;
325 send.XferID.Packet = 1 + 2147483648;
326 send.DataPacket.Data = this.ConvertInventoryToBytes();
327
328 simClient.OutPacket(send);
329 }
330
331 /// <summary>
332 ///
333 /// </summary>
334 /// <returns></returns>
335 public byte[] ConvertInventoryToBytes()
336 {
337 System.Text.Encoding enc = System.Text.Encoding.ASCII;
338 byte[] result = new byte[0];
339 List<byte[]> inventoryData = new List<byte[]>();
340 int totallength = 0;
341 foreach (InventoryItem invItem in inventoryItems.Values)
342 {
343 byte[] data = enc.GetBytes(invItem.ExportString());
344 inventoryData.Add(data);
345 totallength += data.Length;
346 }
347 //TODO: copy arrays into the single result array
348
349 return result;
350 }
351
352 /// <summary>
353 ///
354 /// </summary>
355 /// <param name="data"></param>
356 public void CreateInventoryFromBytes(byte[] data)
357 {
358
359 }
360
361 #endregion
362
363 #region Update viewers Methods
364
365 /// <summary>
366 ///
367 /// </summary>
368 /// <param name="remoteClient"></param>
369 public void SendFullUpdateForAllChildren(IClientAPI remoteClient)
370 {
371 this.SendFullUpdateToClient(remoteClient);
372 for (int i = 0; i < this.children.Count; i++)
373 {
374 if (this.children[i] is Primitive)
375 {
376 ((Primitive)this.children[i]).SendFullUpdateForAllChildren(remoteClient);
377 }
378 }
379 }
380
381 /// <summary>
382 ///
383 /// </summary>
384 /// <param name="remoteClient"></param>
385 public void SendFullUpdateToClient(IClientAPI remoteClient)
386 {
387 LLVector3 lPos;
388 if (this._physActor != null && this.physicsEnabled)
389 {
390 PhysicsVector pPos = this._physActor.Position;
391 lPos = new LLVector3(pPos.X, pPos.Y, pPos.Z);
392 }
393 else
394 {
395 lPos = this.Pos;
396 }
397
398 remoteClient.SendPrimitiveToClient(this.m_regionHandle, 64096, this.localid, this.primData, lPos, new LLUUID("00000000-0000-0000-5005-000000000005"));
399 }
400
401 /// <summary>
402 ///
403 /// </summary>
404 public void SendFullUpdateToAllClients()
405 {
406 List<Avatar> avatars = this.m_world.RequestAvatarList();
407 for (int i = 0; i < avatars.Count; i++)
408 {
409 this.SendFullUpdateToClient(avatars[i].ControllingClient);
410 }
411 }
412
413 /// <summary>
414 ///
415 /// </summary>
416 /// <param name="RemoteClient"></param>
417 public void SendTerseUpdateToClient(IClientAPI RemoteClient)
418 {
419 LLVector3 lPos;
420 Axiom.MathLib.Quaternion lRot;
421 if (this._physActor != null && this.physicsEnabled)
422 {
423 PhysicsVector pPos = this._physActor.Position;
424 lPos = new LLVector3(pPos.X, pPos.Y, pPos.Z);
425 lRot = this._physActor.Orientation;
426 }
427 else
428 {
429 lPos = this.Pos;
430 lRot = this.rotation;
431 }
432 }
433
434 /// <summary>
435 ///
436 /// </summary>
437 public void SendTerseUpdateToALLClients()
438 {
439 List<Avatar> avatars = this.m_world.RequestAvatarList();
440 for (int i = 0; i < avatars.Count; i++)
441 {
442 this.SendTerseUpdateToClient(avatars[i].ControllingClient);
443 }
444 }
445
446 #endregion
447
448 #region Create Methods
449
450 /// <summary>
451 ///
452 /// </summary>
453 /// <param name="addPacket"></param>
454 /// <param name="ownerID"></param>
455 /// <param name="localID"></param>
456 public void CreateFromPacket(ObjectAddPacket addPacket, LLUUID ownerID, uint localID)
457 {
458 PrimData PData = new PrimData();
459 this.primData = PData;
460 this.primData.CreationDate = (Int32)(DateTime.UtcNow - new DateTime(1970, 1, 1)).TotalSeconds;
461
462 PData.OwnerID = ownerID;
463 PData.PCode = addPacket.ObjectData.PCode;
464 PData.PathBegin = addPacket.ObjectData.PathBegin;
465 PData.PathEnd = addPacket.ObjectData.PathEnd;
466 PData.PathScaleX = addPacket.ObjectData.PathScaleX;
467 PData.PathScaleY = addPacket.ObjectData.PathScaleY;
468 PData.PathShearX = addPacket.ObjectData.PathShearX;
469 PData.PathShearY = addPacket.ObjectData.PathShearY;
470 PData.PathSkew = addPacket.ObjectData.PathSkew;
471 PData.ProfileBegin = addPacket.ObjectData.ProfileBegin;
472 PData.ProfileEnd = addPacket.ObjectData.ProfileEnd;
473 PData.Scale = addPacket.ObjectData.Scale;
474 PData.PathCurve = addPacket.ObjectData.PathCurve;
475 PData.ProfileCurve = addPacket.ObjectData.ProfileCurve;
476 PData.ParentID = 0;
477 PData.ProfileHollow = addPacket.ObjectData.ProfileHollow;
478 PData.PathRadiusOffset = addPacket.ObjectData.PathRadiusOffset;
479 PData.PathRevolutions = addPacket.ObjectData.PathRevolutions;
480 PData.PathTaperX = addPacket.ObjectData.PathTaperX;
481 PData.PathTaperY = addPacket.ObjectData.PathTaperY;
482 PData.PathTwist = addPacket.ObjectData.PathTwist;
483 PData.PathTwistBegin = addPacket.ObjectData.PathTwistBegin;
484 LLVector3 pos1 = addPacket.ObjectData.RayEnd;
485 this.primData.FullID = this.uuid = LLUUID.Random();
486 this.primData.LocalID = this.localid = (uint)(localID);
487 this.primData.Position = this.Pos = pos1;
488
489 this.updateFlag = 1;
490 }
491
492 /// <summary>
493 ///
494 /// </summary>
495 /// <param name="data"></param>
496 public void CreateFromBytes(byte[] data)
497 {
498
499 }
500
501 /// <summary>
502 ///
503 /// </summary>
504 /// <param name="primData"></param>
505 public void CreateFromPrimData(PrimData primData)
506 {
507 this.CreateFromPrimData(primData, primData.Position, primData.LocalID, false);
508 }
509
510 /// <summary>
511 ///
512 /// </summary>
513 /// <param name="primData"></param>
514 /// <param name="posi"></param>
515 /// <param name="localID"></param>
516 /// <param name="newprim"></param>
517 public void CreateFromPrimData(PrimData primData, LLVector3 posi, uint localID, bool newprim)
518 {
519
520 }
521
522 #endregion
523
524 }
525}
diff --git a/OpenSim/OpenSim.Region/World/Entities/SceneObject.cs b/OpenSim/OpenSim.Region/World/Entities/SceneObject.cs
new file mode 100644
index 0000000..6ded881
--- /dev/null
+++ b/OpenSim/OpenSim.Region/World/Entities/SceneObject.cs
@@ -0,0 +1,130 @@
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 OpenSim.Region.types;
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
40{
41 public class SceneObject : Entity
42 {
43 private LLUUID rootUUID;
44 //private Dictionary<LLUUID, Primitive> ChildPrimitives = new Dictionary<LLUUID, Primitive>();
45 protected Primitive rootPrimitive;
46 private World m_world;
47 protected ulong regionHandle;
48
49 /// <summary>
50 ///
51 /// </summary>
52 public SceneObject()
53 {
54
55 }
56
57 /// <summary>
58 ///
59 /// </summary>
60 /// <param name="addPacket"></param>
61 /// <param name="agentID"></param>
62 /// <param name="localID"></param>
63 public void CreateFromPacket(ObjectAddPacket addPacket, LLUUID agentID, uint localID)
64 {
65 this.rootPrimitive = new Primitive(null, this.regionHandle, this.m_world);
66 this.rootPrimitive.CreateFromPacket(addPacket, agentID, localID);
67 }
68
69 /// <summary>
70 ///
71 /// </summary>
72 /// <param name="data"></param>
73 public void CreateFromBytes(byte[] data)
74 {
75
76 }
77
78 /// <summary>
79 ///
80 /// </summary>
81 public override void update()
82 {
83
84 }
85
86 /// <summary>
87 ///
88 /// </summary>
89 public override void BackUp()
90 {
91
92 }
93
94 /// <summary>
95 ///
96 /// </summary>
97 /// <param name="client"></param>
98 public void GetProperites(IClientAPI client)
99 {
100 //needs changing
101 ObjectPropertiesPacket proper = new ObjectPropertiesPacket();
102 proper.ObjectData = new ObjectPropertiesPacket.ObjectDataBlock[1];
103 proper.ObjectData[0] = new ObjectPropertiesPacket.ObjectDataBlock();
104 proper.ObjectData[0].ItemID = LLUUID.Zero;
105 proper.ObjectData[0].CreationDate = (ulong)this.rootPrimitive.primData.CreationDate;
106 proper.ObjectData[0].CreatorID = this.rootPrimitive.primData.OwnerID;
107 proper.ObjectData[0].FolderID = LLUUID.Zero;
108 proper.ObjectData[0].FromTaskID = LLUUID.Zero;
109 proper.ObjectData[0].GroupID = LLUUID.Zero;
110 proper.ObjectData[0].InventorySerial = 0;
111 proper.ObjectData[0].LastOwnerID = LLUUID.Zero;
112 proper.ObjectData[0].ObjectID = this.uuid;
113 proper.ObjectData[0].OwnerID = this.rootPrimitive.primData.OwnerID;
114 proper.ObjectData[0].TouchName = new byte[0];
115 proper.ObjectData[0].TextureID = new byte[0];
116 proper.ObjectData[0].SitName = new byte[0];
117 proper.ObjectData[0].Name = new byte[0];
118 proper.ObjectData[0].Description = new byte[0];
119 proper.ObjectData[0].OwnerMask = this.rootPrimitive.primData.OwnerMask;
120 proper.ObjectData[0].NextOwnerMask = this.rootPrimitive.primData.NextOwnerMask;
121 proper.ObjectData[0].GroupMask = this.rootPrimitive.primData.GroupMask;
122 proper.ObjectData[0].EveryoneMask = this.rootPrimitive.primData.EveryoneMask;
123 proper.ObjectData[0].BaseMask = this.rootPrimitive.primData.BaseMask;
124
125 client.OutPacket(proper);
126
127 }
128
129 }
130}