aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim.Physics/OdePlugin/OdePlugin.cs
diff options
context:
space:
mode:
authorgareth2007-03-25 01:23:34 +0000
committergareth2007-03-25 01:23:34 +0000
commita31f7e21e9feb72e76f485923616866178e47ba0 (patch)
tree4852f18e2b80988f2cfadaebe5054b7e70428157 /OpenSim.Physics/OdePlugin/OdePlugin.cs
parent.pdb files shouldn't reside in SVN. (diff)
downloadopensim-SC_OLD-a31f7e21e9feb72e76f485923616866178e47ba0.zip
opensim-SC_OLD-a31f7e21e9feb72e76f485923616866178e47ba0.tar.gz
opensim-SC_OLD-a31f7e21e9feb72e76f485923616866178e47ba0.tar.bz2
opensim-SC_OLD-a31f7e21e9feb72e76f485923616866178e47ba0.tar.xz
Added skeleton ODE plugin
Diffstat (limited to 'OpenSim.Physics/OdePlugin/OdePlugin.cs')
-rw-r--r--OpenSim.Physics/OdePlugin/OdePlugin.cs357
1 files changed, 357 insertions, 0 deletions
diff --git a/OpenSim.Physics/OdePlugin/OdePlugin.cs b/OpenSim.Physics/OdePlugin/OdePlugin.cs
new file mode 100644
index 0000000..cb96533
--- /dev/null
+++ b/OpenSim.Physics/OdePlugin/OdePlugin.cs
@@ -0,0 +1,357 @@
1/*
2* Copyright (c) OpenSim project, http://sim.opensecondlife.org/
3*
4* Redistribution and use in source and binary forms, with or without
5* modification, are permitted provided that the following conditions are met:
6* * Redistributions of source code must retain the above copyright
7* notice, this list of conditions and the following disclaimer.
8* * Redistributions in binary form must reproduce the above copyright
9* notice, this list of conditions and the following disclaimer in the
10* documentation and/or other materials provided with the distribution.
11* * Neither the name of the <organization> nor the
12* names of its contributors may be used to endorse or promote products
13* derived from this software without specific prior written permission.
14*
15* THIS SOFTWARE IS PROVIDED BY <copyright holder> ``AS IS'' AND ANY
16* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
17* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
18* DISCLAIMED. IN NO EVENT SHALL <copyright holder> BE LIABLE FOR ANY
19* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
20* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
21* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
22* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
23* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
24* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
25*
26*/
27using System;
28using System.Collections.Generic;
29using OpenSim.Physics.Manager;
30
31namespace OpenSim.Physics.OdePlugin
32{
33 /// <summary>
34 /// ODE plugin
35 /// </summary>
36 public class OdePlugin : IPhysicsPlugin
37 {
38 private OdeScene _mScene;
39
40 public OdePlugin()
41 {
42
43 }
44
45 public bool Init()
46 {
47 return true;
48 }
49
50 public PhysicsScene GetScene()
51 {
52 if(_mScene == null)
53 {
54 _mScene = new OdeScene();
55 }
56 return(_mScene);
57 }
58
59 public string GetName()
60 {
61 return("OpenDynamicsEngine");
62 }
63
64 public void Dispose()
65 {
66
67 }
68 }
69
70 public class OdeScene :PhysicsScene
71 {
72
73 public OdeScene()
74 {
75
76 }
77
78 public override PhysicsActor AddAvatar(PhysicsVector position)
79 {
80 PhysicsVector pos = new PhysicsVector();
81 pos.X = position.X;
82 pos.Y = position.Y;
83 pos.Z = position.Z;
84 return new OdeCharacter();
85 }
86
87 public override PhysicsActor AddPrim(PhysicsVector position, PhysicsVector size)
88 {
89 PhysicsVector pos = new PhysicsVector();
90 pos.X = position.X;
91 pos.Y = position.Y;
92 pos.Z = position.Z;
93 PhysicsVector siz = new PhysicsVector();
94 siz.X = size.X;
95 siz.Y = size.Y;
96 siz.Z = size.Z;
97 return new OdePrim();
98 }
99
100 public override void Simulate(float timeStep)
101 {
102
103 }
104
105 public override void GetResults()
106 {
107
108 }
109
110 public override bool IsThreaded
111 {
112 get
113 {
114 return(false); // for now we won't be multithreaded
115 }
116 }
117
118 public override void SetTerrain(float[] heightMap)
119 {
120 }
121 }
122
123 public class OdeCharacter : PhysicsActor
124 {
125 private PhysicsVector _position;
126 private PhysicsVector _velocity;
127 private PhysicsVector _acceleration;
128 private bool flying;
129 private float gravityAccel;
130
131 public OdeCharacter()
132 {
133 _velocity = new PhysicsVector();
134 _position = new PhysicsVector();
135 _acceleration = new PhysicsVector();
136 }
137
138 public override bool Flying
139 {
140 get
141 {
142 return flying;
143 }
144 set
145 {
146 flying = value;
147 }
148 }
149
150 public override PhysicsVector Position
151 {
152 get
153 {
154 return _position;
155 }
156 set
157 {
158 _position = value;
159 }
160 }
161
162 public override PhysicsVector Velocity
163 {
164 get
165 {
166 return _velocity;
167 }
168 set
169 {
170 _velocity = value;
171 }
172 }
173
174 public override bool Kinematic
175 {
176 get
177 {
178 return false;
179 }
180 set
181 {
182
183 }
184 }
185
186 public override Axiom.MathLib.Quaternion Orientation
187 {
188 get
189 {
190 return Axiom.MathLib.Quaternion.Identity;
191 }
192 set
193 {
194
195 }
196 }
197
198 public override PhysicsVector Acceleration
199 {
200 get
201 {
202 return _acceleration;
203 }
204
205 }
206 public void SetAcceleration (PhysicsVector accel)
207 {
208 this._acceleration = accel;
209 }
210
211 public override void AddForce(PhysicsVector force)
212 {
213
214 }
215
216 public override void SetMomentum(PhysicsVector momentum)
217 {
218
219 }
220
221 public void Move(float timeStep)
222 {
223 PhysicsVector vec = new PhysicsVector();
224 vec.X = this._velocity.X * timeStep;
225 vec.Y = this._velocity.Y * timeStep;
226 if(flying)
227 {
228 vec.Z = ( this._velocity.Z) * timeStep;
229 }
230 else
231 {
232 gravityAccel+= -9.8f;
233 vec.Z = (gravityAccel + this._velocity.Z) * timeStep;
234 }
235 //int res = this._character.Move(vec);
236 //if(res == 1)
237 //{
238 // gravityAccel = 0;
239 //}
240 }
241
242 public void UpdatePosition()
243 {
244 }
245 }
246
247 public class OdePrim : PhysicsActor
248 {
249 private PhysicsVector _position;
250 private PhysicsVector _velocity;
251 private PhysicsVector _acceleration;
252
253 public OdePrim()
254 {
255 _velocity = new PhysicsVector();
256 _position = new PhysicsVector();
257 _acceleration = new PhysicsVector();
258 }
259 public override bool Flying
260 {
261 get
262 {
263 return false; //no flying prims for you
264 }
265 set
266 {
267
268 }
269 }
270 public override PhysicsVector Position
271 {
272 get
273 {
274 PhysicsVector pos = new PhysicsVector();
275 //PhysicsVector vec = this._prim.Position;
276 //pos.X = vec.X;
277 //pos.Y = vec.Y;
278 //pos.Z = vec.Z;
279 return pos;
280
281 }
282 set
283 {
284 /*PhysicsVector vec = value;
285 PhysicsVector pos = new PhysicsVector();
286 pos.X = vec.X;
287 pos.Y = vec.Y;
288 pos.Z = vec.Z;
289 this._prim.Position = pos;*/
290 }
291 }
292
293 public override PhysicsVector Velocity
294 {
295 get
296 {
297 return _velocity;
298 }
299 set
300 {
301 _velocity = value;
302 }
303 }
304
305 public override bool Kinematic
306 {
307 get
308 {
309 return false;
310 //return this._prim.Kinematic;
311 }
312 set
313 {
314 //this._prim.Kinematic = value;
315 }
316 }
317
318 public override Axiom.MathLib.Quaternion Orientation
319 {
320 get
321 {
322 Axiom.MathLib.Quaternion res = new Axiom.MathLib.Quaternion();
323 return res;
324 }
325 set
326 {
327
328 }
329 }
330
331 public override PhysicsVector Acceleration
332 {
333 get
334 {
335 return _acceleration;
336 }
337
338 }
339 public void SetAcceleration (PhysicsVector accel)
340 {
341 this._acceleration = accel;
342 }
343
344 public override void AddForce(PhysicsVector force)
345 {
346
347 }
348
349 public override void SetMomentum(PhysicsVector momentum)
350 {
351
352 }
353
354
355 }
356
357}