diff options
author | MW | 2007-05-26 14:55:17 +0000 |
---|---|---|
committer | MW | 2007-05-26 14:55:17 +0000 |
commit | 06387d0344b8fa84b790a9dd910fda8a0a1128bb (patch) | |
tree | faf19abd4c940e6c6fddf805beaee47b9b175e32 /OpenSim/OpenSim.World/Entity.cs | |
parent | Die WebFrontEnd, Die Grid class! (diff) | |
download | opensim-SC-06387d0344b8fa84b790a9dd910fda8a0a1128bb.zip opensim-SC-06387d0344b8fa84b790a9dd910fda8a0a1128bb.tar.gz opensim-SC-06387d0344b8fa84b790a9dd910fda8a0a1128bb.tar.bz2 opensim-SC-06387d0344b8fa84b790a9dd910fda8a0a1128bb.tar.xz |
Goodbye World
Diffstat (limited to 'OpenSim/OpenSim.World/Entity.cs')
-rw-r--r-- | OpenSim/OpenSim.World/Entity.cs | 124 |
1 files changed, 124 insertions, 0 deletions
diff --git a/OpenSim/OpenSim.World/Entity.cs b/OpenSim/OpenSim.World/Entity.cs new file mode 100644 index 0000000..96e039a --- /dev/null +++ b/OpenSim/OpenSim.World/Entity.cs | |||
@@ -0,0 +1,124 @@ | |||
1 | using System; | ||
2 | using System.Collections.Generic; | ||
3 | using System.Text; | ||
4 | using Axiom.MathLib; | ||
5 | using OpenSim.Physics.Manager; | ||
6 | using OpenSim.types; | ||
7 | using libsecondlife; | ||
8 | using OpenSim.RegionServer.world.scripting; | ||
9 | |||
10 | namespace OpenSim.world | ||
11 | { | ||
12 | public abstract class Entity : IScriptReadonlyEntity | ||
13 | { | ||
14 | public libsecondlife.LLUUID uuid; | ||
15 | public uint localid; | ||
16 | public LLVector3 velocity; | ||
17 | public Quaternion rotation; | ||
18 | protected List<Entity> children; | ||
19 | |||
20 | protected string m_name; | ||
21 | public virtual string Name | ||
22 | { | ||
23 | get { return m_name; } | ||
24 | } | ||
25 | |||
26 | protected LLVector3 m_pos; | ||
27 | protected PhysicsActor _physActor; | ||
28 | protected World m_world; | ||
29 | |||
30 | public virtual LLVector3 Pos | ||
31 | { | ||
32 | get | ||
33 | { | ||
34 | if (this._physActor != null) | ||
35 | { | ||
36 | m_pos.X = _physActor.Position.X; | ||
37 | m_pos.Y = _physActor.Position.Y; | ||
38 | m_pos.Z = _physActor.Position.Z; | ||
39 | } | ||
40 | |||
41 | return m_pos; | ||
42 | } | ||
43 | set | ||
44 | { | ||
45 | if (this._physActor != null) | ||
46 | { | ||
47 | try | ||
48 | { | ||
49 | lock (this.m_world.LockPhysicsEngine) | ||
50 | { | ||
51 | |||
52 | this._physActor.Position = new PhysicsVector(value.X, value.Y, value.Z); | ||
53 | } | ||
54 | } | ||
55 | catch (Exception e) | ||
56 | { | ||
57 | Console.WriteLine(e.Message); | ||
58 | } | ||
59 | } | ||
60 | |||
61 | m_pos = value; | ||
62 | } | ||
63 | } | ||
64 | |||
65 | /// <summary> | ||
66 | /// Creates a new Entity (should not occur on it's own) | ||
67 | /// </summary> | ||
68 | public Entity() | ||
69 | { | ||
70 | uuid = new libsecondlife.LLUUID(); | ||
71 | localid = 0; | ||
72 | m_pos = new LLVector3(); | ||
73 | velocity = new LLVector3(); | ||
74 | rotation = new Quaternion(); | ||
75 | m_name = "(basic entity)"; | ||
76 | children = new List<Entity>(); | ||
77 | } | ||
78 | |||
79 | public virtual void addForces() | ||
80 | { | ||
81 | foreach (Entity child in children) | ||
82 | { | ||
83 | child.addForces(); | ||
84 | } | ||
85 | } | ||
86 | |||
87 | /// <summary> | ||
88 | /// Performs any updates that need to be done at each frame. This function is overridable from it's children. | ||
89 | /// </summary> | ||
90 | public virtual void update() { | ||
91 | // Do any per-frame updates needed that are applicable to every type of entity | ||
92 | foreach (Entity child in children) | ||
93 | { | ||
94 | child.update(); | ||
95 | } | ||
96 | } | ||
97 | |||
98 | /// <summary> | ||
99 | /// Returns a mesh for this object and any dependents | ||
100 | /// </summary> | ||
101 | /// <returns>The mesh of this entity tree</returns> | ||
102 | public virtual Mesh getMesh() | ||
103 | { | ||
104 | Mesh mesh = new Mesh(); | ||
105 | |||
106 | foreach (Entity child in children) | ||
107 | { | ||
108 | mesh += child.getMesh(); | ||
109 | } | ||
110 | |||
111 | return mesh; | ||
112 | } | ||
113 | |||
114 | public virtual void BackUp() | ||
115 | { | ||
116 | |||
117 | } | ||
118 | |||
119 | public virtual void LandRenegerated() | ||
120 | { | ||
121 | |||
122 | } | ||
123 | } | ||
124 | } | ||