aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region/Framework/Scenes/EntityBase.cs
diff options
context:
space:
mode:
Diffstat (limited to 'OpenSim/Region/Framework/Scenes/EntityBase.cs')
-rw-r--r--OpenSim/Region/Framework/Scenes/EntityBase.cs253
1 files changed, 253 insertions, 0 deletions
diff --git a/OpenSim/Region/Framework/Scenes/EntityBase.cs b/OpenSim/Region/Framework/Scenes/EntityBase.cs
new file mode 100644
index 0000000..5055e44
--- /dev/null
+++ b/OpenSim/Region/Framework/Scenes/EntityBase.cs
@@ -0,0 +1,253 @@
1/*
2 * Copyright (c) Contributors, http://opensimulator.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.Runtime.Serialization;
30using System.Security.Permissions;
31using OpenMetaverse;
32
33namespace OpenSim.Region.Framework.Scenes
34{
35 [Serializable]
36 public abstract class EntityBase : ISerializable
37 {
38 /// <summary>
39 /// The scene to which this entity belongs
40 /// </summary>
41 public Scene Scene
42 {
43 get { return m_scene; }
44 }
45 protected Scene m_scene;
46
47 protected UUID m_uuid;
48
49 public virtual UUID UUID
50 {
51 get { return m_uuid; }
52 set { m_uuid = value; }
53 }
54
55 protected string m_name;
56
57 /// <summary>
58 /// The name of this entity
59 /// </summary>
60 public virtual string Name
61 {
62 get { return m_name; }
63 set { m_name = value; }
64 }
65
66 /// <summary>
67 /// Signals whether this entity was in a scene but has since been removed from it.
68 /// </summary>
69 public bool IsDeleted
70 {
71 get { return m_isDeleted; }
72 }
73 protected bool m_isDeleted;
74
75 protected Vector3 m_pos;
76
77 /// <summary>
78 ///
79 /// </summary>
80 public virtual Vector3 AbsolutePosition
81 {
82 get { return m_pos; }
83 set { m_pos = value; }
84 }
85
86 protected Vector3 m_velocity;
87 protected Vector3 m_rotationalvelocity;
88
89 /// <summary>
90 /// Current velocity of the entity.
91 /// </summary>
92 public virtual Vector3 Velocity
93 {
94 get { return m_velocity; }
95 set { m_velocity = value; }
96 }
97
98 protected Quaternion m_rotation = new Quaternion(0f, 0f, 1f, 0f);
99
100 public virtual Quaternion Rotation
101 {
102 get { return m_rotation; }
103 set { m_rotation = value; }
104 }
105
106 protected uint m_localId;
107
108 public virtual uint LocalId
109 {
110 get { return m_localId; }
111 set { m_localId = value; }
112 }
113
114 /// <summary>
115 /// Creates a new Entity (should not occur on it's own)
116 /// </summary>
117 public EntityBase()
118 {
119 m_uuid = UUID.Zero;
120
121 m_pos = Vector3.Zero;
122 m_velocity = Vector3.Zero;
123 Rotation = Quaternion.Identity;
124 m_name = "(basic entity)";
125 m_rotationalvelocity = Vector3.Zero;
126 }
127
128 /// <summary>
129 ///
130 /// </summary>
131 public abstract void UpdateMovement();
132
133 /// <summary>
134 /// Performs any updates that need to be done at each frame, as opposed to immediately.
135 /// These included scheduled updates and updates that occur due to physics processing.
136 /// </summary>
137 public abstract void Update();
138
139 /// <summary>
140 /// Copies the entity
141 /// </summary>
142 /// <returns></returns>
143 public virtual EntityBase Copy()
144 {
145 return (EntityBase) MemberwiseClone();
146 }
147
148
149 public abstract void SetText(string text, Vector3 color, double alpha);
150
151 protected EntityBase(SerializationInfo info, StreamingContext context)
152 {
153 //System.Console.WriteLine("EntityBase Deserialize BGN");
154
155 if (info == null)
156 {
157 throw new ArgumentNullException("info");
158 }
159
160 m_uuid = new UUID((Guid)info.GetValue("m_uuid", typeof(Guid)));
161 m_name = (string)info.GetValue("m_name", typeof(string));
162
163 m_pos
164 = new Vector3(
165 (float)info.GetValue("m_pos.X", typeof(float)),
166 (float)info.GetValue("m_pos.Y", typeof(float)),
167 (float)info.GetValue("m_pos.Z", typeof(float)));
168
169 m_velocity
170 = new Vector3(
171 (float)info.GetValue("m_velocity.X", typeof(float)),
172 (float)info.GetValue("m_velocity.Y", typeof(float)),
173 (float)info.GetValue("m_velocity.Z", typeof(float)));
174
175 m_rotationalvelocity
176 = new Vector3(
177 (float)info.GetValue("m_rotationalvelocity.X", typeof(float)),
178 (float)info.GetValue("m_rotationalvelocity.Y", typeof(float)),
179 (float)info.GetValue("m_rotationalvelocity.Z", typeof(float)));
180
181 m_rotation
182 = new Quaternion(
183 (float)info.GetValue("m_rotation.X", typeof(float)),
184 (float)info.GetValue("m_rotation.Y", typeof(float)),
185 (float)info.GetValue("m_rotation.Z", typeof(float)),
186 (float)info.GetValue("m_rotation.W", typeof(float)));
187
188 m_localId = (uint)info.GetValue("m_localId", typeof(uint));
189
190 //System.Console.WriteLine("EntityBase Deserialize END");
191 }
192
193 [SecurityPermission(SecurityAction.LinkDemand,
194 Flags = SecurityPermissionFlag.SerializationFormatter)]
195 public virtual void GetObjectData(
196 SerializationInfo info, StreamingContext context)
197 {
198 if (info == null)
199 {
200 throw new ArgumentNullException("info");
201 }
202
203 info.AddValue("m_uuid", m_uuid.Guid);
204 info.AddValue("m_name", m_name);
205
206 // Vector3
207 info.AddValue("m_pos.X", m_pos.X);
208 info.AddValue("m_pos.Y", m_pos.Y);
209 info.AddValue("m_pos.Z", m_pos.Z);
210
211 // Vector3
212 info.AddValue("m_velocity.X", m_velocity.X);
213 info.AddValue("m_velocity.Y", m_velocity.Y);
214 info.AddValue("m_velocity.Z", m_velocity.Z);
215
216 // Vector3
217 info.AddValue("m_rotationalvelocity.X", m_rotationalvelocity.X);
218 info.AddValue("m_rotationalvelocity.Y", m_rotationalvelocity.Y);
219 info.AddValue("m_rotationalvelocity.Z", m_rotationalvelocity.Z);
220
221 // Quaternion
222 info.AddValue("m_rotation.X", m_rotation.X);
223 info.AddValue("m_rotation.Y", m_rotation.Y);
224 info.AddValue("m_rotation.Z", m_rotation.Z);
225 info.AddValue("m_rotation.W", m_rotation.W);
226
227 info.AddValue("m_localId", m_localId);
228 }
229 }
230
231 //Nested Classes
232 public class EntityIntersection
233 {
234 public Vector3 ipoint = new Vector3(0, 0, 0);
235 public Vector3 normal = new Vector3(0, 0, 0);
236 public Vector3 AAfaceNormal = new Vector3(0, 0, 0);
237 public int face = -1;
238 public bool HitTF = false;
239 public SceneObjectPart obj;
240 public float distance = 0;
241
242 public EntityIntersection()
243 {
244 }
245
246 public EntityIntersection(Vector3 _ipoint, Vector3 _normal, bool _HitTF)
247 {
248 ipoint = _ipoint;
249 normal = _normal;
250 HitTF = _HitTF;
251 }
252 }
253}