diff options
Diffstat (limited to 'OpenSim/Region/PhysicsModules/POS')
-rw-r--r-- | OpenSim/Region/PhysicsModules/POS/AssemblyInfo.cs | 62 | ||||
-rw-r--r-- | OpenSim/Region/PhysicsModules/POS/POSCharacter.cs | 341 | ||||
-rw-r--r-- | OpenSim/Region/PhysicsModules/POS/POSPrim.cs | 336 | ||||
-rw-r--r-- | OpenSim/Region/PhysicsModules/POS/POSScene.cs | 323 |
4 files changed, 1062 insertions, 0 deletions
diff --git a/OpenSim/Region/PhysicsModules/POS/AssemblyInfo.cs b/OpenSim/Region/PhysicsModules/POS/AssemblyInfo.cs new file mode 100644 index 0000000..e3a3e35 --- /dev/null +++ b/OpenSim/Region/PhysicsModules/POS/AssemblyInfo.cs | |||
@@ -0,0 +1,62 @@ | |||
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 | |||
28 | using System.Reflection; | ||
29 | using System.Runtime.InteropServices; | ||
30 | using Mono.Addins; | ||
31 | |||
32 | // Information about this assembly is defined by the following | ||
33 | // attributes. | ||
34 | // | ||
35 | // change them to the information which is associated with the assembly | ||
36 | // you compile. | ||
37 | |||
38 | [assembly : AssemblyTitle("POSPlugin")] | ||
39 | [assembly : AssemblyDescription("")] | ||
40 | [assembly : AssemblyConfiguration("")] | ||
41 | [assembly : AssemblyCompany("http://opensimulator.org")] | ||
42 | [assembly : AssemblyProduct("POSPlugin")] | ||
43 | [assembly : AssemblyCopyright("Copyright (c) OpenSimulator.org Developers")] | ||
44 | [assembly : AssemblyTrademark("")] | ||
45 | [assembly : AssemblyCulture("")] | ||
46 | |||
47 | // This sets the default COM visibility of types in the assembly to invisible. | ||
48 | // If you need to expose a type to COM, use [ComVisible(true)] on that type. | ||
49 | |||
50 | [assembly : ComVisible(false)] | ||
51 | |||
52 | // The assembly version has following format : | ||
53 | // | ||
54 | // Major.Minor.Build.Revision | ||
55 | // | ||
56 | // You can specify all values by your own or you can build default build and revision | ||
57 | // numbers with the '*' character (the default): | ||
58 | |||
59 | [assembly : AssemblyVersion("0.8.2.*")] | ||
60 | |||
61 | [assembly: Addin("OpenSim.Region.PhysicsModule.POS", OpenSim.VersionInfo.VersionNumber)] | ||
62 | [assembly: AddinDependency("OpenSim.Region.Framework", OpenSim.VersionInfo.VersionNumber)] | ||
diff --git a/OpenSim/Region/PhysicsModules/POS/POSCharacter.cs b/OpenSim/Region/PhysicsModules/POS/POSCharacter.cs new file mode 100644 index 0000000..32469d9 --- /dev/null +++ b/OpenSim/Region/PhysicsModules/POS/POSCharacter.cs | |||
@@ -0,0 +1,341 @@ | |||
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 | |||
28 | using System; | ||
29 | using System.Collections.Generic; | ||
30 | using Nini.Config; | ||
31 | using OpenMetaverse; | ||
32 | using OpenSim.Framework; | ||
33 | using OpenSim.Region.PhysicsModules.SharedBase; | ||
34 | |||
35 | namespace OpenSim.Region.PhysicsModule.POS | ||
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 | get { return false; } | ||
279 | set { return; } | ||
280 | } | ||
281 | |||
282 | public override float PIDTau | ||
283 | { | ||
284 | set { return; } | ||
285 | } | ||
286 | |||
287 | public override float PIDHoverHeight | ||
288 | { | ||
289 | set { return; } | ||
290 | } | ||
291 | |||
292 | public override bool PIDHoverActive | ||
293 | { | ||
294 | set { return; } | ||
295 | } | ||
296 | |||
297 | public override PIDHoverType PIDHoverType | ||
298 | { | ||
299 | set { return; } | ||
300 | } | ||
301 | |||
302 | public override float PIDHoverTau | ||
303 | { | ||
304 | set { return; } | ||
305 | } | ||
306 | |||
307 | public override Quaternion APIDTarget | ||
308 | { | ||
309 | set { return; } | ||
310 | } | ||
311 | |||
312 | public override bool APIDActive | ||
313 | { | ||
314 | set { return; } | ||
315 | } | ||
316 | |||
317 | public override float APIDStrength | ||
318 | { | ||
319 | set { return; } | ||
320 | } | ||
321 | |||
322 | public override float APIDDamping | ||
323 | { | ||
324 | set { return; } | ||
325 | } | ||
326 | |||
327 | |||
328 | public override void SubscribeEvents(int ms) | ||
329 | { | ||
330 | } | ||
331 | |||
332 | public override void UnSubscribeEvents() | ||
333 | { | ||
334 | } | ||
335 | |||
336 | public override bool SubscribedEvents() | ||
337 | { | ||
338 | return false; | ||
339 | } | ||
340 | } | ||
341 | } | ||
diff --git a/OpenSim/Region/PhysicsModules/POS/POSPrim.cs b/OpenSim/Region/PhysicsModules/POS/POSPrim.cs new file mode 100644 index 0000000..c190fab --- /dev/null +++ b/OpenSim/Region/PhysicsModules/POS/POSPrim.cs | |||
@@ -0,0 +1,336 @@ | |||
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 | |||
28 | using System; | ||
29 | using System.Collections.Generic; | ||
30 | using Nini.Config; | ||
31 | using OpenMetaverse; | ||
32 | using OpenSim.Framework; | ||
33 | using OpenSim.Region.PhysicsModules.SharedBase; | ||
34 | |||
35 | namespace OpenSim.Region.PhysicsModule.POS | ||
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 | get { return false; } | ||
274 | set { return; } | ||
275 | } | ||
276 | |||
277 | public override float PIDTau | ||
278 | { | ||
279 | set { return; } | ||
280 | } | ||
281 | |||
282 | public override float PIDHoverHeight | ||
283 | { | ||
284 | set { return; } | ||
285 | } | ||
286 | |||
287 | public override bool PIDHoverActive | ||
288 | { | ||
289 | set { return; } | ||
290 | } | ||
291 | |||
292 | public override PIDHoverType PIDHoverType | ||
293 | { | ||
294 | set { return; } | ||
295 | } | ||
296 | |||
297 | public override float PIDHoverTau | ||
298 | { | ||
299 | set { return; } | ||
300 | } | ||
301 | |||
302 | public override Quaternion APIDTarget | ||
303 | { | ||
304 | set { return; } | ||
305 | } | ||
306 | |||
307 | public override bool APIDActive | ||
308 | { | ||
309 | set { return; } | ||
310 | } | ||
311 | |||
312 | public override float APIDStrength | ||
313 | { | ||
314 | set { return; } | ||
315 | } | ||
316 | |||
317 | public override float APIDDamping | ||
318 | { | ||
319 | set { return; } | ||
320 | } | ||
321 | |||
322 | |||
323 | public override void SubscribeEvents(int ms) | ||
324 | { | ||
325 | } | ||
326 | |||
327 | public override void UnSubscribeEvents() | ||
328 | { | ||
329 | } | ||
330 | |||
331 | public override bool SubscribedEvents() | ||
332 | { | ||
333 | return false; | ||
334 | } | ||
335 | } | ||
336 | } | ||
diff --git a/OpenSim/Region/PhysicsModules/POS/POSScene.cs b/OpenSim/Region/PhysicsModules/POS/POSScene.cs new file mode 100644 index 0000000..e6bcbf2 --- /dev/null +++ b/OpenSim/Region/PhysicsModules/POS/POSScene.cs | |||
@@ -0,0 +1,323 @@ | |||
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 | |||
28 | using System; | ||
29 | using System.Collections.Generic; | ||
30 | using Nini.Config; | ||
31 | using OpenMetaverse; | ||
32 | using Mono.Addins; | ||
33 | using OpenSim.Framework; | ||
34 | using OpenSim.Region.PhysicsModules.SharedBase; | ||
35 | using OpenSim.Region.Framework.Scenes; | ||
36 | using OpenSim.Region.Framework.Interfaces; | ||
37 | |||
38 | namespace OpenSim.Region.PhysicsModule.POS | ||
39 | { | ||
40 | [Extension(Path = "/OpenSim/RegionModules", NodeName = "RegionModule", Id = "POSPhysicsScene")] | ||
41 | public class POSScene : PhysicsScene, INonSharedRegionModule | ||
42 | { | ||
43 | private List<POSCharacter> _characters = new List<POSCharacter>(); | ||
44 | private List<POSPrim> _prims = new List<POSPrim>(); | ||
45 | private float[] _heightMap; | ||
46 | private const float gravity = -9.8f; | ||
47 | |||
48 | private bool m_Enabled = false; | ||
49 | //protected internal string sceneIdentifier; | ||
50 | |||
51 | #region INonSharedRegionModule | ||
52 | public string Name | ||
53 | { | ||
54 | get { return "POS"; } | ||
55 | } | ||
56 | |||
57 | public Type ReplaceableInterface | ||
58 | { | ||
59 | get { return null; } | ||
60 | } | ||
61 | |||
62 | public void Initialise(IConfigSource source) | ||
63 | { | ||
64 | // TODO: Move this out of Startup | ||
65 | IConfig config = source.Configs["Startup"]; | ||
66 | if (config != null) | ||
67 | { | ||
68 | string physics = config.GetString("physics", string.Empty); | ||
69 | if (physics == Name) | ||
70 | m_Enabled = true; | ||
71 | } | ||
72 | |||
73 | } | ||
74 | |||
75 | public void Close() | ||
76 | { | ||
77 | } | ||
78 | |||
79 | public void AddRegion(Scene scene) | ||
80 | { | ||
81 | if (!m_Enabled) | ||
82 | return; | ||
83 | |||
84 | EngineType = Name; | ||
85 | PhysicsSceneName = EngineType + "/" + scene.RegionInfo.RegionName; | ||
86 | |||
87 | scene.RegisterModuleInterface<PhysicsScene>(this); | ||
88 | base.Initialise(scene.PhysicsRequestAsset, | ||
89 | (scene.Heightmap != null ? scene.Heightmap.GetFloatsSerialised() : new float[Constants.RegionSize * Constants.RegionSize]), | ||
90 | (float)scene.RegionInfo.RegionSettings.WaterHeight); | ||
91 | |||
92 | } | ||
93 | |||
94 | public void RemoveRegion(Scene scene) | ||
95 | { | ||
96 | if (!m_Enabled) | ||
97 | return; | ||
98 | } | ||
99 | |||
100 | public void RegionLoaded(Scene scene) | ||
101 | { | ||
102 | if (!m_Enabled) | ||
103 | return; | ||
104 | } | ||
105 | #endregion | ||
106 | |||
107 | public override void Dispose() | ||
108 | { | ||
109 | } | ||
110 | |||
111 | public override PhysicsActor AddAvatar( | ||
112 | string avName, Vector3 position, Vector3 velocity, Vector3 size, bool isFlying) | ||
113 | { | ||
114 | POSCharacter act = new POSCharacter(); | ||
115 | act.Position = position; | ||
116 | act.Flying = isFlying; | ||
117 | _characters.Add(act); | ||
118 | return act; | ||
119 | } | ||
120 | |||
121 | public override void RemovePrim(PhysicsActor prim) | ||
122 | { | ||
123 | POSPrim p = (POSPrim) prim; | ||
124 | if (_prims.Contains(p)) | ||
125 | { | ||
126 | _prims.Remove(p); | ||
127 | } | ||
128 | } | ||
129 | |||
130 | public override void RemoveAvatar(PhysicsActor character) | ||
131 | { | ||
132 | POSCharacter act = (POSCharacter) character; | ||
133 | if (_characters.Contains(act)) | ||
134 | { | ||
135 | _characters.Remove(act); | ||
136 | } | ||
137 | } | ||
138 | |||
139 | /* | ||
140 | public override PhysicsActor AddPrim(Vector3 position, Vector3 size, Quaternion rotation) | ||
141 | { | ||
142 | return null; | ||
143 | } | ||
144 | */ | ||
145 | |||
146 | public override PhysicsActor AddPrimShape(string primName, PrimitiveBaseShape pbs, Vector3 position, | ||
147 | Vector3 size, Quaternion rotation, bool isPhysical, uint localid) | ||
148 | { | ||
149 | POSPrim prim = new POSPrim(); | ||
150 | prim.Position = position; | ||
151 | prim.Orientation = rotation; | ||
152 | prim.Size = size; | ||
153 | _prims.Add(prim); | ||
154 | return prim; | ||
155 | } | ||
156 | |||
157 | private bool isColliding(POSCharacter c, POSPrim p) | ||
158 | { | ||
159 | Vector3 rotatedPos = new Vector3(c.Position.X - p.Position.X, c.Position.Y - p.Position.Y, | ||
160 | c.Position.Z - p.Position.Z) * Quaternion.Inverse(p.Orientation); | ||
161 | Vector3 avatarSize = new Vector3(c.Size.X, c.Size.Y, c.Size.Z) * Quaternion.Inverse(p.Orientation); | ||
162 | |||
163 | return (Math.Abs(rotatedPos.X) < (p.Size.X*0.5 + Math.Abs(avatarSize.X)) && | ||
164 | Math.Abs(rotatedPos.Y) < (p.Size.Y*0.5 + Math.Abs(avatarSize.Y)) && | ||
165 | Math.Abs(rotatedPos.Z) < (p.Size.Z*0.5 + Math.Abs(avatarSize.Z))); | ||
166 | } | ||
167 | |||
168 | private bool isCollidingWithPrim(POSCharacter c) | ||
169 | { | ||
170 | foreach (POSPrim p in _prims) | ||
171 | { | ||
172 | if (isColliding(c, p)) | ||
173 | { | ||
174 | return true; | ||
175 | } | ||
176 | } | ||
177 | |||
178 | return false; | ||
179 | } | ||
180 | |||
181 | public override void AddPhysicsActorTaint(PhysicsActor prim) | ||
182 | { | ||
183 | } | ||
184 | |||
185 | public override float Simulate(float timeStep) | ||
186 | { | ||
187 | float fps = 0; | ||
188 | for (int i = 0; i < _characters.Count; ++i) | ||
189 | { | ||
190 | fps++; | ||
191 | POSCharacter character = _characters[i]; | ||
192 | |||
193 | float oldposX = character.Position.X; | ||
194 | float oldposY = character.Position.Y; | ||
195 | float oldposZ = character.Position.Z; | ||
196 | |||
197 | if (!character.Flying) | ||
198 | { | ||
199 | character._target_velocity.Z += gravity * timeStep; | ||
200 | } | ||
201 | |||
202 | Vector3 characterPosition = character.Position; | ||
203 | |||
204 | characterPosition.X += character._target_velocity.X * timeStep; | ||
205 | characterPosition.Y += character._target_velocity.Y * timeStep; | ||
206 | |||
207 | characterPosition.X = Util.Clamp(character.Position.X, 0.01f, Constants.RegionSize - 0.01f); | ||
208 | characterPosition.Y = Util.Clamp(character.Position.Y, 0.01f, Constants.RegionSize - 0.01f); | ||
209 | |||
210 | bool forcedZ = false; | ||
211 | |||
212 | float terrainheight = _heightMap[(int)character.Position.Y * Constants.RegionSize + (int)character.Position.X]; | ||
213 | if (character.Position.Z + (character._target_velocity.Z * timeStep) < terrainheight + 2) | ||
214 | { | ||
215 | characterPosition.Z = terrainheight + character.Size.Z; | ||
216 | forcedZ = true; | ||
217 | } | ||
218 | else | ||
219 | { | ||
220 | characterPosition.Z += character._target_velocity.Z*timeStep; | ||
221 | } | ||
222 | |||
223 | /// this is it -- the magic you've all been waiting for! Ladies and gentlemen -- | ||
224 | /// Completely Bogus Collision Detection!!! | ||
225 | /// better known as the CBCD algorithm | ||
226 | |||
227 | if (isCollidingWithPrim(character)) | ||
228 | { | ||
229 | characterPosition.Z = oldposZ; // first try Z axis | ||
230 | if (isCollidingWithPrim(character)) | ||
231 | { | ||
232 | characterPosition.Z = oldposZ + character.Size.Z / 4.4f; // try harder | ||
233 | if (isCollidingWithPrim(character)) | ||
234 | { | ||
235 | characterPosition.Z = oldposZ + character.Size.Z / 2.2f; // try very hard | ||
236 | if (isCollidingWithPrim(character)) | ||
237 | { | ||
238 | characterPosition.X = oldposX; | ||
239 | characterPosition.Y = oldposY; | ||
240 | characterPosition.Z = oldposZ; | ||
241 | |||
242 | characterPosition.X += character._target_velocity.X * timeStep; | ||
243 | if (isCollidingWithPrim(character)) | ||
244 | { | ||
245 | characterPosition.X = oldposX; | ||
246 | } | ||
247 | |||
248 | characterPosition.Y += character._target_velocity.Y * timeStep; | ||
249 | if (isCollidingWithPrim(character)) | ||
250 | { | ||
251 | characterPosition.Y = oldposY; | ||
252 | } | ||
253 | } | ||
254 | else | ||
255 | { | ||
256 | forcedZ = true; | ||
257 | } | ||
258 | } | ||
259 | else | ||
260 | { | ||
261 | forcedZ = true; | ||
262 | } | ||
263 | } | ||
264 | else | ||
265 | { | ||
266 | forcedZ = true; | ||
267 | } | ||
268 | } | ||
269 | |||
270 | characterPosition.X = Util.Clamp(character.Position.X, 0.01f, Constants.RegionSize - 0.01f); | ||
271 | characterPosition.Y = Util.Clamp(character.Position.Y, 0.01f, Constants.RegionSize - 0.01f); | ||
272 | |||
273 | character.Position = characterPosition; | ||
274 | |||
275 | character._velocity.X = (character.Position.X - oldposX)/timeStep; | ||
276 | character._velocity.Y = (character.Position.Y - oldposY)/timeStep; | ||
277 | |||
278 | if (forcedZ) | ||
279 | { | ||
280 | character._velocity.Z = 0; | ||
281 | character._target_velocity.Z = 0; | ||
282 | ((PhysicsActor)character).IsColliding = true; | ||
283 | character.RequestPhysicsterseUpdate(); | ||
284 | } | ||
285 | else | ||
286 | { | ||
287 | ((PhysicsActor)character).IsColliding = false; | ||
288 | character._velocity.Z = (character.Position.Z - oldposZ)/timeStep; | ||
289 | } | ||
290 | } | ||
291 | return 1.0f; | ||
292 | } | ||
293 | |||
294 | public override void GetResults() | ||
295 | { | ||
296 | } | ||
297 | |||
298 | public override bool IsThreaded | ||
299 | { | ||
300 | // for now we won't be multithreaded | ||
301 | get { return (false); } | ||
302 | } | ||
303 | |||
304 | public override void SetTerrain(float[] heightMap) | ||
305 | { | ||
306 | _heightMap = heightMap; | ||
307 | } | ||
308 | |||
309 | public override void DeleteTerrain() | ||
310 | { | ||
311 | } | ||
312 | |||
313 | public override void SetWaterLevel(float baseheight) | ||
314 | { | ||
315 | } | ||
316 | |||
317 | public override Dictionary<uint, float> GetTopColliders() | ||
318 | { | ||
319 | Dictionary<uint, float> returncolliders = new Dictionary<uint, float>(); | ||
320 | return returncolliders; | ||
321 | } | ||
322 | } | ||
323 | } | ||