diff options
Diffstat (limited to 'OpenSim/Region/PhysicsModules/BasicPhysics')
4 files changed, 937 insertions, 0 deletions
diff --git a/OpenSim/Region/PhysicsModules/BasicPhysics/AssemblyInfo.cs b/OpenSim/Region/PhysicsModules/BasicPhysics/AssemblyInfo.cs new file mode 100644 index 0000000..1765ae0 --- /dev/null +++ b/OpenSim/Region/PhysicsModules/BasicPhysics/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("BasicPhysicsModule")] | ||
39 | [assembly : AssemblyDescription("")] | ||
40 | [assembly : AssemblyConfiguration("")] | ||
41 | [assembly : AssemblyCompany("http://opensimulator.org")] | ||
42 | [assembly : AssemblyProduct("BasicPhysicsModule")] | ||
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.BasicPhysics", OpenSim.VersionInfo.VersionNumber)] | ||
62 | [assembly: AddinDependency("OpenSim.Region.Framework", OpenSim.VersionInfo.VersionNumber)] | ||
diff --git a/OpenSim/Region/PhysicsModules/BasicPhysics/BasicPhysicsActor.cs b/OpenSim/Region/PhysicsModules/BasicPhysics/BasicPhysicsActor.cs new file mode 100644 index 0000000..e7b30ba --- /dev/null +++ b/OpenSim/Region/PhysicsModules/BasicPhysics/BasicPhysicsActor.cs | |||
@@ -0,0 +1,303 @@ | |||
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.BasicPhysics | ||
36 | { | ||
37 | public class BasicActor : PhysicsActor | ||
38 | { | ||
39 | public BasicActor(Vector3 size) | ||
40 | { | ||
41 | Size = size; | ||
42 | } | ||
43 | |||
44 | public override int PhysicsActorType | ||
45 | { | ||
46 | get { return (int) ActorTypes.Agent; } | ||
47 | set { return; } | ||
48 | } | ||
49 | |||
50 | public override Vector3 RotationalVelocity { get; set; } | ||
51 | |||
52 | public override bool SetAlwaysRun | ||
53 | { | ||
54 | get { return false; } | ||
55 | set { return; } | ||
56 | } | ||
57 | |||
58 | public override uint LocalID | ||
59 | { | ||
60 | set { return; } | ||
61 | } | ||
62 | |||
63 | public override bool Grabbed | ||
64 | { | ||
65 | set { return; } | ||
66 | } | ||
67 | |||
68 | public override bool Selected | ||
69 | { | ||
70 | set { return; } | ||
71 | } | ||
72 | |||
73 | public override float Buoyancy | ||
74 | { | ||
75 | get { return 0f; } | ||
76 | set { return; } | ||
77 | } | ||
78 | |||
79 | public override bool FloatOnWater | ||
80 | { | ||
81 | set { return; } | ||
82 | } | ||
83 | |||
84 | public override bool IsPhysical | ||
85 | { | ||
86 | get { return false; } | ||
87 | set { return; } | ||
88 | } | ||
89 | |||
90 | public override bool ThrottleUpdates | ||
91 | { | ||
92 | get { return false; } | ||
93 | set { return; } | ||
94 | } | ||
95 | |||
96 | public override bool Flying { get; set; } | ||
97 | |||
98 | public override bool IsColliding { get; set; } | ||
99 | |||
100 | public override bool CollidingGround | ||
101 | { | ||
102 | get { return false; } | ||
103 | set { return; } | ||
104 | } | ||
105 | |||
106 | public override bool CollidingObj | ||
107 | { | ||
108 | get { return false; } | ||
109 | set { return; } | ||
110 | } | ||
111 | |||
112 | public override bool Stopped | ||
113 | { | ||
114 | get { return false; } | ||
115 | } | ||
116 | |||
117 | public override Vector3 Position { get; set; } | ||
118 | |||
119 | public override Vector3 Size { get; set; } | ||
120 | |||
121 | public override PrimitiveBaseShape Shape | ||
122 | { | ||
123 | set { return; } | ||
124 | } | ||
125 | |||
126 | public override float Mass | ||
127 | { | ||
128 | get { return 0f; } | ||
129 | } | ||
130 | |||
131 | public override Vector3 Force | ||
132 | { | ||
133 | get { return Vector3.Zero; } | ||
134 | set { return; } | ||
135 | } | ||
136 | |||
137 | public override int VehicleType | ||
138 | { | ||
139 | get { return 0; } | ||
140 | set { return; } | ||
141 | } | ||
142 | |||
143 | public override void VehicleFloatParam(int param, float value) | ||
144 | { | ||
145 | |||
146 | } | ||
147 | |||
148 | public override void VehicleVectorParam(int param, Vector3 value) | ||
149 | { | ||
150 | |||
151 | } | ||
152 | |||
153 | public override void VehicleRotationParam(int param, Quaternion rotation) | ||
154 | { | ||
155 | |||
156 | } | ||
157 | |||
158 | public override void VehicleFlags(int param, bool remove) | ||
159 | { | ||
160 | |||
161 | } | ||
162 | |||
163 | public override void SetVolumeDetect(int param) | ||
164 | { | ||
165 | |||
166 | } | ||
167 | |||
168 | public override Vector3 CenterOfMass | ||
169 | { | ||
170 | get { return Vector3.Zero; } | ||
171 | } | ||
172 | |||
173 | public override Vector3 GeometricCenter | ||
174 | { | ||
175 | get { return Vector3.Zero; } | ||
176 | } | ||
177 | |||
178 | public override Vector3 Velocity { get; set; } | ||
179 | |||
180 | public override Vector3 Torque | ||
181 | { | ||
182 | get { return Vector3.Zero; } | ||
183 | set { return; } | ||
184 | } | ||
185 | |||
186 | public override float CollisionScore | ||
187 | { | ||
188 | get { return 0f; } | ||
189 | set { } | ||
190 | } | ||
191 | |||
192 | public override Quaternion Orientation | ||
193 | { | ||
194 | get { return Quaternion.Identity; } | ||
195 | set { } | ||
196 | } | ||
197 | |||
198 | public override Vector3 Acceleration { get; set; } | ||
199 | |||
200 | public override bool Kinematic | ||
201 | { | ||
202 | get { return true; } | ||
203 | set { } | ||
204 | } | ||
205 | |||
206 | public override void link(PhysicsActor obj) | ||
207 | { | ||
208 | } | ||
209 | |||
210 | public override void delink() | ||
211 | { | ||
212 | } | ||
213 | |||
214 | public override void LockAngularMotion(Vector3 axis) | ||
215 | { | ||
216 | } | ||
217 | |||
218 | public override void AddForce(Vector3 force, bool pushforce) | ||
219 | { | ||
220 | } | ||
221 | |||
222 | public override void AddAngularForce(Vector3 force, bool pushforce) | ||
223 | { | ||
224 | } | ||
225 | |||
226 | public override void SetMomentum(Vector3 momentum) | ||
227 | { | ||
228 | } | ||
229 | |||
230 | public override void CrossingFailure() | ||
231 | { | ||
232 | } | ||
233 | |||
234 | public override Vector3 PIDTarget | ||
235 | { | ||
236 | set { return; } | ||
237 | } | ||
238 | |||
239 | public override bool PIDActive | ||
240 | { | ||
241 | get { return false; } | ||
242 | set { return; } | ||
243 | } | ||
244 | |||
245 | public override float PIDTau | ||
246 | { | ||
247 | set { return; } | ||
248 | } | ||
249 | |||
250 | public override float PIDHoverHeight | ||
251 | { | ||
252 | set { return; } | ||
253 | } | ||
254 | |||
255 | public override bool PIDHoverActive | ||
256 | { | ||
257 | set { return; } | ||
258 | } | ||
259 | |||
260 | public override PIDHoverType PIDHoverType | ||
261 | { | ||
262 | set { return; } | ||
263 | } | ||
264 | |||
265 | public override float PIDHoverTau | ||
266 | { | ||
267 | set { return; } | ||
268 | } | ||
269 | |||
270 | public override Quaternion APIDTarget | ||
271 | { | ||
272 | set { return; } | ||
273 | } | ||
274 | |||
275 | public override bool APIDActive | ||
276 | { | ||
277 | set { return; } | ||
278 | } | ||
279 | |||
280 | public override float APIDStrength | ||
281 | { | ||
282 | set { return; } | ||
283 | } | ||
284 | |||
285 | public override float APIDDamping | ||
286 | { | ||
287 | set { return; } | ||
288 | } | ||
289 | |||
290 | public override void SubscribeEvents(int ms) | ||
291 | { | ||
292 | } | ||
293 | |||
294 | public override void UnSubscribeEvents() | ||
295 | { | ||
296 | } | ||
297 | |||
298 | public override bool SubscribedEvents() | ||
299 | { | ||
300 | return false; | ||
301 | } | ||
302 | } | ||
303 | } | ||
diff --git a/OpenSim/Region/PhysicsModules/BasicPhysics/BasicPhysicsPrim.cs b/OpenSim/Region/PhysicsModules/BasicPhysics/BasicPhysicsPrim.cs new file mode 100644 index 0000000..5383f1b --- /dev/null +++ b/OpenSim/Region/PhysicsModules/BasicPhysics/BasicPhysicsPrim.cs | |||
@@ -0,0 +1,316 @@ | |||
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.BasicPhysics | ||
36 | { | ||
37 | public class BasicPhysicsPrim : PhysicsActor | ||
38 | { | ||
39 | private Vector3 _size; | ||
40 | // private PrimitiveBaseShape _shape; | ||
41 | |||
42 | public BasicPhysicsPrim( | ||
43 | string name, uint localId, Vector3 position, Vector3 size, Quaternion orientation, PrimitiveBaseShape shape) | ||
44 | { | ||
45 | Name = name; | ||
46 | LocalID = localId; | ||
47 | Position = position; | ||
48 | Size = size; | ||
49 | Orientation = orientation; | ||
50 | Shape = shape; | ||
51 | } | ||
52 | |||
53 | public override int PhysicsActorType | ||
54 | { | ||
55 | get { return (int) ActorTypes.Agent; } | ||
56 | set { return; } | ||
57 | } | ||
58 | |||
59 | public override Vector3 RotationalVelocity { get; set; } | ||
60 | |||
61 | public override bool SetAlwaysRun | ||
62 | { | ||
63 | get { return false; } | ||
64 | set { return; } | ||
65 | } | ||
66 | |||
67 | public override uint LocalID | ||
68 | { | ||
69 | set { return; } | ||
70 | } | ||
71 | |||
72 | public override bool Grabbed | ||
73 | { | ||
74 | set { return; } | ||
75 | } | ||
76 | |||
77 | public override bool Selected | ||
78 | { | ||
79 | set { return; } | ||
80 | } | ||
81 | |||
82 | public override float Buoyancy | ||
83 | { | ||
84 | get { return 0f; } | ||
85 | set { return; } | ||
86 | } | ||
87 | |||
88 | public override bool FloatOnWater | ||
89 | { | ||
90 | set { return; } | ||
91 | } | ||
92 | |||
93 | public override bool IsPhysical | ||
94 | { | ||
95 | get { return false; } | ||
96 | set { return; } | ||
97 | } | ||
98 | |||
99 | public override bool ThrottleUpdates | ||
100 | { | ||
101 | get { return false; } | ||
102 | set { return; } | ||
103 | } | ||
104 | |||
105 | public override bool Flying { get; set; } | ||
106 | |||
107 | public override bool IsColliding { get; set; } | ||
108 | |||
109 | public override bool CollidingGround | ||
110 | { | ||
111 | get { return false; } | ||
112 | set { return; } | ||
113 | } | ||
114 | |||
115 | public override bool CollidingObj | ||
116 | { | ||
117 | get { return false; } | ||
118 | set { return; } | ||
119 | } | ||
120 | |||
121 | public override bool Stopped | ||
122 | { | ||
123 | get { return false; } | ||
124 | } | ||
125 | |||
126 | public override Vector3 Position { get; set; } | ||
127 | |||
128 | public override Vector3 Size | ||
129 | { | ||
130 | get { return _size; } | ||
131 | set { | ||
132 | _size = value; | ||
133 | _size.Z = _size.Z / 2.0f; | ||
134 | } | ||
135 | } | ||
136 | |||
137 | public override PrimitiveBaseShape Shape | ||
138 | { | ||
139 | // set { _shape = value; } | ||
140 | set {} | ||
141 | } | ||
142 | |||
143 | public override float Mass | ||
144 | { | ||
145 | get { return 0f; } | ||
146 | } | ||
147 | |||
148 | public override Vector3 Force | ||
149 | { | ||
150 | get { return Vector3.Zero; } | ||
151 | set { return; } | ||
152 | } | ||
153 | |||
154 | public override int VehicleType | ||
155 | { | ||
156 | get { return 0; } | ||
157 | set { return; } | ||
158 | } | ||
159 | |||
160 | public override void VehicleFloatParam(int param, float value) | ||
161 | { | ||
162 | |||
163 | } | ||
164 | |||
165 | public override void VehicleVectorParam(int param, Vector3 value) | ||
166 | { | ||
167 | |||
168 | } | ||
169 | |||
170 | public override void VehicleRotationParam(int param, Quaternion rotation) | ||
171 | { | ||
172 | |||
173 | } | ||
174 | |||
175 | public override void VehicleFlags(int param, bool remove) | ||
176 | { | ||
177 | |||
178 | } | ||
179 | |||
180 | public override void SetVolumeDetect(int param) | ||
181 | { | ||
182 | |||
183 | } | ||
184 | |||
185 | public override Vector3 CenterOfMass | ||
186 | { | ||
187 | get { return Vector3.Zero; } | ||
188 | } | ||
189 | |||
190 | public override Vector3 GeometricCenter | ||
191 | { | ||
192 | get { return Vector3.Zero; } | ||
193 | } | ||
194 | |||
195 | public override Vector3 Velocity { get; set; } | ||
196 | |||
197 | public override Vector3 Torque | ||
198 | { | ||
199 | get { return Vector3.Zero; } | ||
200 | set { return; } | ||
201 | } | ||
202 | |||
203 | public override float CollisionScore | ||
204 | { | ||
205 | get { return 0f; } | ||
206 | set { } | ||
207 | } | ||
208 | |||
209 | public override Quaternion Orientation { get; set; } | ||
210 | |||
211 | public override Vector3 Acceleration { get; set; } | ||
212 | |||
213 | public override bool Kinematic | ||
214 | { | ||
215 | get { return true; } | ||
216 | set { } | ||
217 | } | ||
218 | |||
219 | public override void link(PhysicsActor obj) | ||
220 | { | ||
221 | } | ||
222 | |||
223 | public override void delink() | ||
224 | { | ||
225 | } | ||
226 | |||
227 | public override void LockAngularMotion(Vector3 axis) | ||
228 | { | ||
229 | } | ||
230 | |||
231 | public override void AddForce(Vector3 force, bool pushforce) | ||
232 | { | ||
233 | } | ||
234 | |||
235 | public override void AddAngularForce(Vector3 force, bool pushforce) | ||
236 | { | ||
237 | } | ||
238 | |||
239 | public override void SetMomentum(Vector3 momentum) | ||
240 | { | ||
241 | } | ||
242 | |||
243 | public override void CrossingFailure() | ||
244 | { | ||
245 | } | ||
246 | |||
247 | public override Vector3 PIDTarget | ||
248 | { | ||
249 | set { return; } | ||
250 | } | ||
251 | |||
252 | public override bool PIDActive | ||
253 | { | ||
254 | get { return false; } | ||
255 | set { return; } | ||
256 | } | ||
257 | |||
258 | public override float PIDTau | ||
259 | { | ||
260 | set { return; } | ||
261 | } | ||
262 | |||
263 | public override float PIDHoverHeight | ||
264 | { | ||
265 | set { return; } | ||
266 | } | ||
267 | |||
268 | public override bool PIDHoverActive | ||
269 | { | ||
270 | set { return; } | ||
271 | } | ||
272 | |||
273 | public override PIDHoverType PIDHoverType | ||
274 | { | ||
275 | set { return; } | ||
276 | } | ||
277 | |||
278 | public override float PIDHoverTau | ||
279 | { | ||
280 | set { return; } | ||
281 | } | ||
282 | |||
283 | public override Quaternion APIDTarget | ||
284 | { | ||
285 | set { return; } | ||
286 | } | ||
287 | |||
288 | public override bool APIDActive | ||
289 | { | ||
290 | set { return; } | ||
291 | } | ||
292 | |||
293 | public override float APIDStrength | ||
294 | { | ||
295 | set { return; } | ||
296 | } | ||
297 | |||
298 | public override float APIDDamping | ||
299 | { | ||
300 | set { return; } | ||
301 | } | ||
302 | |||
303 | public override void SubscribeEvents(int ms) | ||
304 | { | ||
305 | } | ||
306 | |||
307 | public override void UnSubscribeEvents() | ||
308 | { | ||
309 | } | ||
310 | |||
311 | public override bool SubscribedEvents() | ||
312 | { | ||
313 | return false; | ||
314 | } | ||
315 | } | ||
316 | } | ||
diff --git a/OpenSim/Region/PhysicsModules/BasicPhysics/BasicPhysicsScene.cs b/OpenSim/Region/PhysicsModules/BasicPhysics/BasicPhysicsScene.cs new file mode 100644 index 0000000..ac2c1f3 --- /dev/null +++ b/OpenSim/Region/PhysicsModules/BasicPhysics/BasicPhysicsScene.cs | |||
@@ -0,0 +1,256 @@ | |||
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 Mono.Addins; | ||
32 | using OpenMetaverse; | ||
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.BasicPhysics | ||
39 | { | ||
40 | /// <summary> | ||
41 | /// This is an incomplete extremely basic physics implementation | ||
42 | /// </summary> | ||
43 | /// <remarks> | ||
44 | /// Not useful for anything at the moment apart from some regression testing in other components where some form | ||
45 | /// of physics plugin is needed. | ||
46 | /// </remarks> | ||
47 | [Extension(Path = "/OpenSim/RegionModules", NodeName = "RegionModule", Id = "BasicPhysicsScene")] | ||
48 | public class BasicScene : PhysicsScene, INonSharedRegionModule | ||
49 | { | ||
50 | private List<BasicActor> _actors = new List<BasicActor>(); | ||
51 | private List<BasicPhysicsPrim> _prims = new List<BasicPhysicsPrim>(); | ||
52 | private float[] _heightMap; | ||
53 | private Vector3 m_regionExtent; | ||
54 | |||
55 | private bool m_Enabled = false; | ||
56 | |||
57 | //protected internal string sceneIdentifier; | ||
58 | #region INonSharedRegionModule | ||
59 | public string Name | ||
60 | { | ||
61 | get { return "basicphysics"; } | ||
62 | } | ||
63 | |||
64 | public Type ReplaceableInterface | ||
65 | { | ||
66 | get { return null; } | ||
67 | } | ||
68 | |||
69 | public void Initialise(IConfigSource source) | ||
70 | { | ||
71 | // TODO: Move this out of Startup | ||
72 | IConfig config = source.Configs["Startup"]; | ||
73 | if (config != null) | ||
74 | { | ||
75 | string physics = config.GetString("physics", string.Empty); | ||
76 | if (physics == Name) | ||
77 | m_Enabled = true; | ||
78 | } | ||
79 | |||
80 | } | ||
81 | |||
82 | public void Close() | ||
83 | { | ||
84 | } | ||
85 | |||
86 | public void AddRegion(Scene scene) | ||
87 | { | ||
88 | if (!m_Enabled) | ||
89 | return; | ||
90 | |||
91 | EngineType = Name; | ||
92 | PhysicsSceneName = EngineType + "/" + scene.RegionInfo.RegionName; | ||
93 | |||
94 | scene.RegisterModuleInterface<PhysicsScene>(this); | ||
95 | m_regionExtent = new Vector3(scene.RegionInfo.RegionSizeX, scene.RegionInfo.RegionSizeY, scene.RegionInfo.RegionSizeZ); | ||
96 | base.Initialise(scene.PhysicsRequestAsset, | ||
97 | (scene.Heightmap != null ? scene.Heightmap.GetFloatsSerialised() : new float[scene.RegionInfo.RegionSizeX * scene.RegionInfo.RegionSizeY]), | ||
98 | (float)scene.RegionInfo.RegionSettings.WaterHeight); | ||
99 | |||
100 | } | ||
101 | |||
102 | public void RemoveRegion(Scene scene) | ||
103 | { | ||
104 | if (!m_Enabled) | ||
105 | return; | ||
106 | } | ||
107 | |||
108 | public void RegionLoaded(Scene scene) | ||
109 | { | ||
110 | if (!m_Enabled) | ||
111 | return; | ||
112 | } | ||
113 | #endregion | ||
114 | |||
115 | public override void Dispose() {} | ||
116 | |||
117 | public override PhysicsActor AddPrimShape(string primName, PrimitiveBaseShape pbs, Vector3 position, | ||
118 | Vector3 size, Quaternion rotation, bool isPhysical, uint localid) | ||
119 | { | ||
120 | BasicPhysicsPrim prim = new BasicPhysicsPrim(primName, localid, position, size, rotation, pbs); | ||
121 | prim.IsPhysical = isPhysical; | ||
122 | |||
123 | _prims.Add(prim); | ||
124 | |||
125 | return prim; | ||
126 | } | ||
127 | |||
128 | public override PhysicsActor AddAvatar(string avName, Vector3 position, Vector3 velocity, Vector3 size, bool isFlying) | ||
129 | { | ||
130 | BasicActor act = new BasicActor(size); | ||
131 | act.Position = position; | ||
132 | act.Velocity = velocity; | ||
133 | act.Flying = isFlying; | ||
134 | _actors.Add(act); | ||
135 | return act; | ||
136 | } | ||
137 | |||
138 | public override void RemovePrim(PhysicsActor actor) | ||
139 | { | ||
140 | BasicPhysicsPrim prim = (BasicPhysicsPrim)actor; | ||
141 | if (_prims.Contains(prim)) | ||
142 | _prims.Remove(prim); | ||
143 | } | ||
144 | |||
145 | public override void RemoveAvatar(PhysicsActor actor) | ||
146 | { | ||
147 | BasicActor act = (BasicActor)actor; | ||
148 | if (_actors.Contains(act)) | ||
149 | _actors.Remove(act); | ||
150 | } | ||
151 | |||
152 | public override void AddPhysicsActorTaint(PhysicsActor prim) | ||
153 | { | ||
154 | } | ||
155 | |||
156 | public override float Simulate(float timeStep) | ||
157 | { | ||
158 | // Console.WriteLine("Simulating"); | ||
159 | |||
160 | float fps = 0; | ||
161 | for (int i = 0; i < _actors.Count; ++i) | ||
162 | { | ||
163 | BasicActor actor = _actors[i]; | ||
164 | Vector3 actorPosition = actor.Position; | ||
165 | Vector3 actorVelocity = actor.Velocity; | ||
166 | |||
167 | //Console.WriteLine( | ||
168 | // "Processing actor {0}, starting pos {1}, starting vel {2}", i, actorPosition, actorVelocity); | ||
169 | |||
170 | actorPosition.X += actor.Velocity.X * timeStep; | ||
171 | actorPosition.Y += actor.Velocity.Y * timeStep; | ||
172 | |||
173 | if (actor.Position.Y < 0) | ||
174 | { | ||
175 | actorPosition.Y = 0.1F; | ||
176 | } | ||
177 | else if (actor.Position.Y >= m_regionExtent.Y) | ||
178 | { | ||
179 | actorPosition.Y = (m_regionExtent.Y - 0.1f); | ||
180 | } | ||
181 | |||
182 | if (actor.Position.X < 0) | ||
183 | { | ||
184 | actorPosition.X = 0.1F; | ||
185 | } | ||
186 | else if (actor.Position.X >= m_regionExtent.X) | ||
187 | { | ||
188 | actorPosition.X = (m_regionExtent.X - 0.1f); | ||
189 | } | ||
190 | |||
191 | float terrainHeight = 0; | ||
192 | if (_heightMap != null) | ||
193 | terrainHeight = _heightMap[(int)actor.Position.Y * (int)m_regionExtent.Y + (int)actor.Position.X]; | ||
194 | |||
195 | float height = terrainHeight + actor.Size.Z; | ||
196 | // Console.WriteLine("height {0}, actorPosition {1}", height, actorPosition); | ||
197 | |||
198 | if (actor.Flying) | ||
199 | { | ||
200 | if (actor.Position.Z + (actor.Velocity.Z * timeStep) < terrainHeight + 2) | ||
201 | { | ||
202 | actorPosition.Z = height; | ||
203 | actorVelocity.Z = 0; | ||
204 | actor.IsColliding = true; | ||
205 | } | ||
206 | else | ||
207 | { | ||
208 | actorPosition.Z += actor.Velocity.Z * timeStep; | ||
209 | actor.IsColliding = false; | ||
210 | } | ||
211 | } | ||
212 | else | ||
213 | { | ||
214 | actorPosition.Z = height; | ||
215 | actorVelocity.Z = 0; | ||
216 | actor.IsColliding = true; | ||
217 | } | ||
218 | |||
219 | actor.Position = actorPosition; | ||
220 | actor.Velocity = actorVelocity; | ||
221 | } | ||
222 | |||
223 | return 1.0f; | ||
224 | } | ||
225 | |||
226 | public override void GetResults() | ||
227 | { | ||
228 | } | ||
229 | |||
230 | public override bool IsThreaded | ||
231 | { | ||
232 | get { return (false); // for now we won't be multithreaded | ||
233 | } | ||
234 | } | ||
235 | |||
236 | public override void SetTerrain(float[] heightMap) | ||
237 | { | ||
238 | _heightMap = heightMap; | ||
239 | } | ||
240 | |||
241 | public override void DeleteTerrain() | ||
242 | { | ||
243 | } | ||
244 | |||
245 | public override void SetWaterLevel(float baseheight) | ||
246 | { | ||
247 | } | ||
248 | |||
249 | public override Dictionary<uint, float> GetTopColliders() | ||
250 | { | ||
251 | Dictionary<uint, float> returncolliders = new Dictionary<uint, float>(); | ||
252 | return returncolliders; | ||
253 | } | ||
254 | |||
255 | } | ||
256 | } | ||