aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region/Physics/POSPlugin
diff options
context:
space:
mode:
Diffstat (limited to 'OpenSim/Region/Physics/POSPlugin')
-rw-r--r--OpenSim/Region/Physics/POSPlugin/AssemblyInfo.cs58
-rw-r--r--OpenSim/Region/Physics/POSPlugin/POSCharacter.cs340
-rw-r--r--OpenSim/Region/Physics/POSPlugin/POSPlugin.cs64
-rw-r--r--OpenSim/Region/Physics/POSPlugin/POSPrim.cs335
-rw-r--r--OpenSim/Region/Physics/POSPlugin/POSScene.cs270
5 files changed, 0 insertions, 1067 deletions
diff --git a/OpenSim/Region/Physics/POSPlugin/AssemblyInfo.cs b/OpenSim/Region/Physics/POSPlugin/AssemblyInfo.cs
deleted file mode 100644
index d07df02..0000000
--- a/OpenSim/Region/Physics/POSPlugin/AssemblyInfo.cs
+++ /dev/null
@@ -1,58 +0,0 @@
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 OpenSimulator 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.Reflection;
29using System.Runtime.InteropServices;
30
31// Information about this assembly is defined by the following
32// attributes.
33//
34// change them to the information which is associated with the assembly
35// you compile.
36
37[assembly : AssemblyTitle("POSPlugin")]
38[assembly : AssemblyDescription("")]
39[assembly : AssemblyConfiguration("")]
40[assembly : AssemblyCompany("http://opensimulator.org")]
41[assembly : AssemblyProduct("POSPlugin")]
42[assembly : AssemblyCopyright("Copyright (c) OpenSimulator.org Developers")]
43[assembly : AssemblyTrademark("")]
44[assembly : AssemblyCulture("")]
45
46// This sets the default COM visibility of types in the assembly to invisible.
47// If you need to expose a type to COM, use [ComVisible(true)] on that type.
48
49[assembly : ComVisible(false)]
50
51// The assembly version has following format :
52//
53// Major.Minor.Build.Revision
54//
55// You can specify all values by your own or you can build default build and revision
56// numbers with the '*' character (the default):
57
58[assembly : AssemblyVersion("0.7.5.*")]
diff --git a/OpenSim/Region/Physics/POSPlugin/POSCharacter.cs b/OpenSim/Region/Physics/POSPlugin/POSCharacter.cs
deleted file mode 100644
index ae534ea..0000000
--- a/OpenSim/Region/Physics/POSPlugin/POSCharacter.cs
+++ /dev/null
@@ -1,340 +0,0 @@
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 OpenSimulator 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 Nini.Config;
31using OpenMetaverse;
32using OpenSim.Framework;
33using OpenSim.Region.Physics.Manager;
34
35namespace OpenSim.Region.Physics.POSPlugin
36{
37 public class POSCharacter : PhysicsActor
38 {
39 private Vector3 _position;
40 public Vector3 _velocity;
41 public Vector3 _target_velocity = Vector3.Zero;
42 public Vector3 _size = Vector3.Zero;
43 private Vector3 _acceleration;
44 private Vector3 m_rotationalVelocity = Vector3.Zero;
45 private bool flying;
46 private bool isColliding;
47
48 public POSCharacter()
49 {
50 }
51
52 public override int PhysicsActorType
53 {
54 get { return (int) ActorTypes.Agent; }
55 set { return; }
56 }
57
58 public override Vector3 RotationalVelocity
59 {
60 get { return m_rotationalVelocity; }
61 set { m_rotationalVelocity = value; }
62 }
63
64 public override bool SetAlwaysRun
65 {
66 get { return false; }
67 set { return; }
68 }
69
70 public override uint LocalID
71 {
72 set { return; }
73 }
74
75 public override bool Grabbed
76 {
77 set { return; }
78 }
79
80 public override bool Selected
81 {
82 set { return; }
83 }
84
85 public override float Buoyancy
86 {
87 get { return 0f; }
88 set { return; }
89 }
90
91 public override bool FloatOnWater
92 {
93 set { return; }
94 }
95
96 public override bool IsPhysical
97 {
98 get { return false; }
99 set { return; }
100 }
101
102 public override bool ThrottleUpdates
103 {
104 get { return false; }
105 set { return; }
106 }
107
108 public override bool Flying
109 {
110 get { return flying; }
111 set { flying = value; }
112 }
113
114 public override bool IsColliding
115 {
116 get { return isColliding; }
117 set { isColliding = value; }
118 }
119
120 public override bool CollidingGround
121 {
122 get { return false; }
123 set { return; }
124 }
125
126 public override bool CollidingObj
127 {
128 get { return false; }
129 set { return; }
130 }
131
132 public override bool Stopped
133 {
134 get { return false; }
135 }
136
137 public override Vector3 Position
138 {
139 get { return _position; }
140 set { _position = value; }
141 }
142
143 public override Vector3 Size
144 {
145 get { return _size; }
146 set
147 {
148 _size = value;
149 _size.Z = _size.Z / 2.0f;
150 }
151 }
152
153 public override float Mass
154 {
155 get { return 0f; }
156 }
157
158 public override Vector3 Force
159 {
160 get { return Vector3.Zero; }
161 set { return; }
162 }
163
164 public override int VehicleType
165 {
166 get { return 0; }
167 set { return; }
168 }
169
170 public override void VehicleFloatParam(int param, float value)
171 {
172
173 }
174
175 public override void VehicleVectorParam(int param, Vector3 value)
176 {
177
178 }
179
180 public override void VehicleRotationParam(int param, Quaternion rotation)
181 {
182
183 }
184
185 public override void VehicleFlags(int param, bool remove) { }
186
187 public override void SetVolumeDetect(int param)
188 {
189
190 }
191
192 public override Vector3 CenterOfMass
193 {
194 get { return Vector3.Zero; }
195 }
196
197 public override Vector3 GeometricCenter
198 {
199 get { return Vector3.Zero; }
200 }
201
202 public override PrimitiveBaseShape Shape
203 {
204 set { return; }
205 }
206
207 public override Vector3 Velocity
208 {
209 get { return _velocity; }
210 set { _target_velocity = value; }
211 }
212
213 public override Vector3 Torque
214 {
215 get { return Vector3.Zero; }
216 set { return; }
217 }
218
219 public override float CollisionScore
220 {
221 get { return 0f; }
222 set { }
223 }
224
225 public override Quaternion Orientation
226 {
227 get { return Quaternion.Identity; }
228 set { }
229 }
230
231 public override Vector3 Acceleration
232 {
233 get { return _acceleration; }
234 set { _acceleration = value; }
235 }
236
237 public override bool Kinematic
238 {
239 get { return true; }
240 set { }
241 }
242
243 public override void link(PhysicsActor obj)
244 {
245 }
246
247 public override void delink()
248 {
249 }
250
251 public override void LockAngularMotion(Vector3 axis)
252 {
253 }
254
255 public override void AddForce(Vector3 force, bool pushforce)
256 {
257 }
258
259 public override void AddAngularForce(Vector3 force, bool pushforce)
260 {
261 }
262
263 public override void SetMomentum(Vector3 momentum)
264 {
265 }
266
267 public override void CrossingFailure()
268 {
269 }
270
271 public override Vector3 PIDTarget
272 {
273 set { return; }
274 }
275
276 public override bool PIDActive
277 {
278 set { return; }
279 }
280
281 public override float PIDTau
282 {
283 set { return; }
284 }
285
286 public override float PIDHoverHeight
287 {
288 set { return; }
289 }
290
291 public override bool PIDHoverActive
292 {
293 set { return; }
294 }
295
296 public override PIDHoverType PIDHoverType
297 {
298 set { return; }
299 }
300
301 public override float PIDHoverTau
302 {
303 set { return; }
304 }
305
306 public override Quaternion APIDTarget
307 {
308 set { return; }
309 }
310
311 public override bool APIDActive
312 {
313 set { return; }
314 }
315
316 public override float APIDStrength
317 {
318 set { return; }
319 }
320
321 public override float APIDDamping
322 {
323 set { return; }
324 }
325
326
327 public override void SubscribeEvents(int ms)
328 {
329 }
330
331 public override void UnSubscribeEvents()
332 {
333 }
334
335 public override bool SubscribedEvents()
336 {
337 return false;
338 }
339 }
340}
diff --git a/OpenSim/Region/Physics/POSPlugin/POSPlugin.cs b/OpenSim/Region/Physics/POSPlugin/POSPlugin.cs
deleted file mode 100644
index e6b42e6..0000000
--- a/OpenSim/Region/Physics/POSPlugin/POSPlugin.cs
+++ /dev/null
@@ -1,64 +0,0 @@
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 OpenSimulator 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 Nini.Config;
31using OpenSim.Framework;
32using OpenSim.Region.Physics.Manager;
33
34namespace OpenSim.Region.Physics.POSPlugin
35{
36 /// <summary>
37 /// for now will be a very POS physics engine
38 /// </summary>
39 public class POSPlugin : IPhysicsPlugin
40 {
41 public POSPlugin()
42 {
43 }
44
45 public bool Init()
46 {
47 return true;
48 }
49
50 public PhysicsScene GetScene(string sceneIdentifier)
51 {
52 return new POSScene(sceneIdentifier);
53 }
54
55 public string GetName()
56 {
57 return ("POS");
58 }
59
60 public void Dispose()
61 {
62 }
63 }
64}
diff --git a/OpenSim/Region/Physics/POSPlugin/POSPrim.cs b/OpenSim/Region/Physics/POSPlugin/POSPrim.cs
deleted file mode 100644
index e4fd7eb..0000000
--- a/OpenSim/Region/Physics/POSPlugin/POSPrim.cs
+++ /dev/null
@@ -1,335 +0,0 @@
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 OpenSimulator 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 Nini.Config;
31using OpenMetaverse;
32using OpenSim.Framework;
33using OpenSim.Region.Physics.Manager;
34
35namespace OpenSim.Region.Physics.POSPlugin
36{
37 public class POSPrim : PhysicsActor
38 {
39 private Vector3 _position;
40 private Vector3 _velocity;
41 private Vector3 _acceleration;
42 private Vector3 _size;
43 private Vector3 m_rotationalVelocity = Vector3.Zero;
44 private Quaternion _orientation;
45 private bool iscolliding;
46
47 public POSPrim()
48 {
49 }
50
51 public override int PhysicsActorType
52 {
53 get { return (int) ActorTypes.Prim; }
54 set { return; }
55 }
56
57 public override Vector3 RotationalVelocity
58 {
59 get { return m_rotationalVelocity; }
60 set { m_rotationalVelocity = value; }
61 }
62
63 public override bool IsPhysical
64 {
65 get { return false; }
66 set { return; }
67 }
68
69 public override bool ThrottleUpdates
70 {
71 get { return false; }
72 set { return; }
73 }
74
75 public override bool IsColliding
76 {
77 get { return iscolliding; }
78 set { iscolliding = value; }
79 }
80
81 public override bool CollidingGround
82 {
83 get { return false; }
84 set { return; }
85 }
86
87 public override bool CollidingObj
88 {
89 get { return false; }
90 set { return; }
91 }
92
93 public override bool Stopped
94 {
95 get { return false; }
96 }
97
98 public override Vector3 Position
99 {
100 get { return _position; }
101 set { _position = value; }
102 }
103
104 public override Vector3 Size
105 {
106 get { return _size; }
107 set { _size = value; }
108 }
109
110 public override float Mass
111 {
112 get { return 0f; }
113 }
114
115 public override Vector3 Force
116 {
117 get { return Vector3.Zero; }
118 set { return; }
119 }
120
121 public override int VehicleType
122 {
123 get { return 0; }
124 set { return; }
125 }
126
127 public override void VehicleFloatParam(int param, float value)
128 {
129
130 }
131
132 public override void VehicleVectorParam(int param, Vector3 value)
133 {
134
135 }
136
137 public override void VehicleRotationParam(int param, Quaternion rotation)
138 {
139
140 }
141
142 public override void VehicleFlags(int param, bool remove) { }
143
144 public override void SetVolumeDetect(int param)
145 {
146
147 }
148
149 public override Vector3 CenterOfMass
150 {
151 get { return Vector3.Zero; }
152 }
153
154 public override Vector3 GeometricCenter
155 {
156 get { return Vector3.Zero; }
157 }
158
159 public override PrimitiveBaseShape Shape
160 {
161 set { return; }
162 }
163
164 public override float Buoyancy
165 {
166 get { return 0f; }
167 set { return; }
168 }
169
170 public override bool FloatOnWater
171 {
172 set { return; }
173 }
174
175 public override Vector3 Velocity
176 {
177 get { return _velocity; }
178 set { _velocity = value; }
179 }
180
181 public override float CollisionScore
182 {
183 get { return 0f; }
184 set { }
185 }
186
187 public override Quaternion Orientation
188 {
189 get { return _orientation; }
190 set { _orientation = value; }
191 }
192
193 public override Vector3 Acceleration
194 {
195 get { return _acceleration; }
196 set { _acceleration = value; }
197 }
198
199 public override bool Kinematic
200 {
201 get { return true; }
202 set { }
203 }
204
205 public override void AddForce(Vector3 force, bool pushforce)
206 {
207 }
208
209 public override void AddAngularForce(Vector3 force, bool pushforce)
210 {
211 }
212
213 public override Vector3 Torque
214 {
215 get { return Vector3.Zero; }
216 set { return; }
217 }
218
219 public override void SetMomentum(Vector3 momentum)
220 {
221 }
222
223 public override bool Flying
224 {
225 get { return false; }
226 set { }
227 }
228
229 public override bool SetAlwaysRun
230 {
231 get { return false; }
232 set { return; }
233 }
234
235 public override uint LocalID
236 {
237 set { return; }
238 }
239
240 public override bool Grabbed
241 {
242 set { return; }
243 }
244
245 public override void link(PhysicsActor obj)
246 {
247 }
248
249 public override void delink()
250 {
251 }
252
253 public override void LockAngularMotion(Vector3 axis)
254 {
255 }
256
257 public override bool Selected
258 {
259 set { return; }
260 }
261
262 public override void CrossingFailure()
263 {
264 }
265
266 public override Vector3 PIDTarget
267 {
268 set { return; }
269 }
270
271 public override bool PIDActive
272 {
273 set { return; }
274 }
275
276 public override float PIDTau
277 {
278 set { return; }
279 }
280
281 public override float PIDHoverHeight
282 {
283 set { return; }
284 }
285
286 public override bool PIDHoverActive
287 {
288 set { return; }
289 }
290
291 public override PIDHoverType PIDHoverType
292 {
293 set { return; }
294 }
295
296 public override float PIDHoverTau
297 {
298 set { return; }
299 }
300
301 public override Quaternion APIDTarget
302 {
303 set { return; }
304 }
305
306 public override bool APIDActive
307 {
308 set { return; }
309 }
310
311 public override float APIDStrength
312 {
313 set { return; }
314 }
315
316 public override float APIDDamping
317 {
318 set { return; }
319 }
320
321
322 public override void SubscribeEvents(int ms)
323 {
324 }
325
326 public override void UnSubscribeEvents()
327 {
328 }
329
330 public override bool SubscribedEvents()
331 {
332 return false;
333 }
334 }
335}
diff --git a/OpenSim/Region/Physics/POSPlugin/POSScene.cs b/OpenSim/Region/Physics/POSPlugin/POSScene.cs
deleted file mode 100644
index 2f24a50..0000000
--- a/OpenSim/Region/Physics/POSPlugin/POSScene.cs
+++ /dev/null
@@ -1,270 +0,0 @@
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 OpenSimulator 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 Nini.Config;
31using OpenMetaverse;
32using OpenSim.Framework;
33using OpenSim.Region.Physics.Manager;
34
35namespace OpenSim.Region.Physics.POSPlugin
36{
37 public class POSScene : PhysicsScene
38 {
39 private List<POSCharacter> _characters = new List<POSCharacter>();
40 private List<POSPrim> _prims = new List<POSPrim>();
41 private float[] _heightMap;
42 private const float gravity = -9.8f;
43
44 //protected internal string sceneIdentifier;
45
46 public POSScene(String _sceneIdentifier)
47 {
48 //sceneIdentifier = _sceneIdentifier;
49 }
50
51 public override void Initialise(IMesher meshmerizer, IConfigSource config)
52 {
53 }
54
55 public override void Dispose()
56 {
57 }
58
59 public override PhysicsActor AddAvatar(string avName, Vector3 position, Vector3 size, bool isFlying)
60 {
61 POSCharacter act = new POSCharacter();
62 act.Position = position;
63 act.Flying = isFlying;
64 _characters.Add(act);
65 return act;
66 }
67
68 public override void RemovePrim(PhysicsActor prim)
69 {
70 POSPrim p = (POSPrim) prim;
71 if (_prims.Contains(p))
72 {
73 _prims.Remove(p);
74 }
75 }
76
77 public override void RemoveAvatar(PhysicsActor character)
78 {
79 POSCharacter act = (POSCharacter) character;
80 if (_characters.Contains(act))
81 {
82 _characters.Remove(act);
83 }
84 }
85
86/*
87 public override PhysicsActor AddPrim(Vector3 position, Vector3 size, Quaternion rotation)
88 {
89 return null;
90 }
91*/
92
93 public override PhysicsActor AddPrimShape(string primName, PrimitiveBaseShape pbs, Vector3 position,
94 Vector3 size, Quaternion rotation, bool isPhysical, uint localid)
95 {
96 POSPrim prim = new POSPrim();
97 prim.Position = position;
98 prim.Orientation = rotation;
99 prim.Size = size;
100 _prims.Add(prim);
101 return prim;
102 }
103
104 private bool isColliding(POSCharacter c, POSPrim p)
105 {
106 Vector3 rotatedPos = new Vector3(c.Position.X - p.Position.X, c.Position.Y - p.Position.Y,
107 c.Position.Z - p.Position.Z) * Quaternion.Inverse(p.Orientation);
108 Vector3 avatarSize = new Vector3(c.Size.X, c.Size.Y, c.Size.Z) * Quaternion.Inverse(p.Orientation);
109
110 return (Math.Abs(rotatedPos.X) < (p.Size.X*0.5 + Math.Abs(avatarSize.X)) &&
111 Math.Abs(rotatedPos.Y) < (p.Size.Y*0.5 + Math.Abs(avatarSize.Y)) &&
112 Math.Abs(rotatedPos.Z) < (p.Size.Z*0.5 + Math.Abs(avatarSize.Z)));
113 }
114
115 private bool isCollidingWithPrim(POSCharacter c)
116 {
117 foreach (POSPrim p in _prims)
118 {
119 if (isColliding(c, p))
120 {
121 return true;
122 }
123 }
124
125 return false;
126 }
127
128 public override void AddPhysicsActorTaint(PhysicsActor prim)
129 {
130 }
131
132 public override float Simulate(float timeStep)
133 {
134 float fps = 0;
135 for (int i = 0; i < _characters.Count; ++i)
136 {
137 fps++;
138 POSCharacter character = _characters[i];
139
140 float oldposX = character.Position.X;
141 float oldposY = character.Position.Y;
142 float oldposZ = character.Position.Z;
143
144 if (!character.Flying)
145 {
146 character._target_velocity.Z += gravity * timeStep;
147 }
148
149 Vector3 characterPosition = character.Position;
150
151 characterPosition.X += character._target_velocity.X * timeStep;
152 characterPosition.Y += character._target_velocity.Y * timeStep;
153
154 characterPosition.X = Util.Clamp(character.Position.X, 0.01f, Constants.RegionSize - 0.01f);
155 characterPosition.Y = Util.Clamp(character.Position.Y, 0.01f, Constants.RegionSize - 0.01f);
156
157 bool forcedZ = false;
158
159 float terrainheight = _heightMap[(int)character.Position.Y * Constants.RegionSize + (int)character.Position.X];
160 if (character.Position.Z + (character._target_velocity.Z * timeStep) < terrainheight + 2)
161 {
162 characterPosition.Z = terrainheight + character.Size.Z;
163 forcedZ = true;
164 }
165 else
166 {
167 characterPosition.Z += character._target_velocity.Z*timeStep;
168 }
169
170 /// this is it -- the magic you've all been waiting for! Ladies and gentlemen --
171 /// Completely Bogus Collision Detection!!!
172 /// better known as the CBCD algorithm
173
174 if (isCollidingWithPrim(character))
175 {
176 characterPosition.Z = oldposZ; // first try Z axis
177 if (isCollidingWithPrim(character))
178 {
179 characterPosition.Z = oldposZ + character.Size.Z / 4.4f; // try harder
180 if (isCollidingWithPrim(character))
181 {
182 characterPosition.Z = oldposZ + character.Size.Z / 2.2f; // try very hard
183 if (isCollidingWithPrim(character))
184 {
185 characterPosition.X = oldposX;
186 characterPosition.Y = oldposY;
187 characterPosition.Z = oldposZ;
188
189 characterPosition.X += character._target_velocity.X * timeStep;
190 if (isCollidingWithPrim(character))
191 {
192 characterPosition.X = oldposX;
193 }
194
195 characterPosition.Y += character._target_velocity.Y * timeStep;
196 if (isCollidingWithPrim(character))
197 {
198 characterPosition.Y = oldposY;
199 }
200 }
201 else
202 {
203 forcedZ = true;
204 }
205 }
206 else
207 {
208 forcedZ = true;
209 }
210 }
211 else
212 {
213 forcedZ = true;
214 }
215 }
216
217 characterPosition.X = Util.Clamp(character.Position.X, 0.01f, Constants.RegionSize - 0.01f);
218 characterPosition.Y = Util.Clamp(character.Position.Y, 0.01f, Constants.RegionSize - 0.01f);
219
220 character.Position = characterPosition;
221
222 character._velocity.X = (character.Position.X - oldposX)/timeStep;
223 character._velocity.Y = (character.Position.Y - oldposY)/timeStep;
224
225 if (forcedZ)
226 {
227 character._velocity.Z = 0;
228 character._target_velocity.Z = 0;
229 ((PhysicsActor)character).IsColliding = true;
230 character.RequestPhysicsterseUpdate();
231 }
232 else
233 {
234 ((PhysicsActor)character).IsColliding = false;
235 character._velocity.Z = (character.Position.Z - oldposZ)/timeStep;
236 }
237 }
238 return fps;
239 }
240
241 public override void GetResults()
242 {
243 }
244
245 public override bool IsThreaded
246 {
247 // for now we won't be multithreaded
248 get { return (false); }
249 }
250
251 public override void SetTerrain(float[] heightMap)
252 {
253 _heightMap = heightMap;
254 }
255
256 public override void DeleteTerrain()
257 {
258 }
259
260 public override void SetWaterLevel(float baseheight)
261 {
262 }
263
264 public override Dictionary<uint, float> GetTopColliders()
265 {
266 Dictionary<uint, float> returncolliders = new Dictionary<uint, float>();
267 return returncolliders;
268 }
269 }
270}