aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim
diff options
context:
space:
mode:
authorJeff Ames2010-02-22 13:16:40 +0900
committerJeff Ames2010-02-22 13:16:40 +0900
commit300f4c58a646daa233a370e46f257bf65453aea8 (patch)
treec9c37fb0999607aec8b2adee352bc2b82e2c0ce5 /OpenSim
parentFormatting cleanup. (diff)
downloadopensim-SC_OLD-300f4c58a646daa233a370e46f257bf65453aea8.zip
opensim-SC_OLD-300f4c58a646daa233a370e46f257bf65453aea8.tar.gz
opensim-SC_OLD-300f4c58a646daa233a370e46f257bf65453aea8.tar.bz2
opensim-SC_OLD-300f4c58a646daa233a370e46f257bf65453aea8.tar.xz
Separate PhysX classes into separate files.
Diffstat (limited to 'OpenSim')
-rw-r--r--OpenSim/Region/Physics/PhysXPlugin/PhysXCharacter.cs353
-rw-r--r--OpenSim/Region/Physics/PhysXPlugin/PhysXPlugin.cs771
-rw-r--r--OpenSim/Region/Physics/PhysXPlugin/PhysXPrim.cs345
-rw-r--r--OpenSim/Region/Physics/PhysXPlugin/PhysXScene.cs183
4 files changed, 882 insertions, 770 deletions
diff --git a/OpenSim/Region/Physics/PhysXPlugin/PhysXCharacter.cs b/OpenSim/Region/Physics/PhysXPlugin/PhysXCharacter.cs
new file mode 100644
index 0000000..92261cd
--- /dev/null
+++ b/OpenSim/Region/Physics/PhysXPlugin/PhysXCharacter.cs
@@ -0,0 +1,353 @@
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;
33using PhysXWrapper;
34using Quaternion=OpenMetaverse.Quaternion;
35using System.Reflection;
36using log4net;
37using OpenMetaverse;
38
39namespace OpenSim.Region.Physics.PhysXPlugin
40{
41 public class PhysXCharacter : PhysicsActor
42 {
43 private Vector3 _position;
44 private Vector3 _velocity;
45 private Vector3 m_rotationalVelocity = Vector3.Zero;
46 private Vector3 _acceleration;
47 private NxCharacter _character;
48 private bool flying;
49 private bool iscolliding = false;
50 private float gravityAccel;
51
52 public PhysXCharacter(NxCharacter character)
53 {
54 _character = character;
55 }
56
57 public override int PhysicsActorType
58 {
59 get { return (int) ActorTypes.Agent; }
60 set { return; }
61 }
62
63 public override bool SetAlwaysRun
64 {
65 get { return false; }
66 set { return; }
67 }
68
69 public override uint LocalID
70 {
71 set { return; }
72 }
73
74 public override bool Grabbed
75 {
76 set { return; }
77 }
78
79 public override bool Selected
80 {
81 set { return; }
82 }
83
84 public override float Buoyancy
85 {
86 get { return 0f; }
87 set { return; }
88 }
89
90 public override bool FloatOnWater
91 {
92 set { return; }
93 }
94
95 public override bool IsPhysical
96 {
97 get { return false; }
98 set { return; }
99 }
100
101 public override bool ThrottleUpdates
102 {
103 get { return false; }
104 set { return; }
105 }
106
107 public override bool Flying
108 {
109 get { return flying; }
110 set { flying = value; }
111 }
112
113 public override bool IsColliding
114 {
115 get { return iscolliding; }
116 set { iscolliding = value; }
117 }
118
119 public override bool CollidingGround
120 {
121 get { return false; }
122 set { return; }
123 }
124
125 public override bool CollidingObj
126 {
127 get { return false; }
128 set { return; }
129 }
130
131 public override Vector3 RotationalVelocity
132 {
133 get { return m_rotationalVelocity; }
134 set { m_rotationalVelocity = value; }
135 }
136
137 public override bool Stopped
138 {
139 get { return false; }
140 }
141
142 public override Vector3 Position
143 {
144 get { return _position; }
145 set
146 {
147 _position = value;
148 Vec3 ps = new Vec3();
149 ps.X = value.X;
150 ps.Y = value.Y;
151 ps.Z = value.Z;
152 _character.Position = ps;
153 }
154 }
155
156 public override Vector3 Size
157 {
158 get { return Vector3.Zero; }
159 set { }
160 }
161
162 public override float Mass
163 {
164 get { return 0f; }
165 }
166
167 public override Vector3 Force
168 {
169 get { return Vector3.Zero; }
170 set { return; }
171 }
172
173 public override int VehicleType
174 {
175 get { return 0; }
176 set { return; }
177 }
178
179 public override void VehicleFloatParam(int param, float value)
180 {
181 }
182
183 public override void VehicleVectorParam(int param, Vector3 value)
184 {
185 }
186
187 public override void VehicleRotationParam(int param, Quaternion rotation)
188 {
189 }
190
191 public override void VehicleFlags(int param, bool remove)
192 {
193 }
194
195 public override void SetVolumeDetect(int param)
196 {
197 }
198
199 public override Vector3 CenterOfMass
200 {
201 get { return Vector3.Zero; }
202 }
203
204 public override Vector3 GeometricCenter
205 {
206 get { return Vector3.Zero; }
207 }
208
209 public override Vector3 Velocity
210 {
211 get { return _velocity; }
212 set { _velocity = value; }
213 }
214
215 public override float CollisionScore
216 {
217 get { return 0f; }
218 set { }
219 }
220
221 public override bool Kinematic
222 {
223 get { return false; }
224 set { }
225 }
226
227 public override Quaternion Orientation
228 {
229 get { return Quaternion.Identity; }
230 set { }
231 }
232
233 public override Vector3 Acceleration
234 {
235 get { return _acceleration; }
236 }
237
238 public void SetAcceleration(Vector3 accel)
239 {
240 _acceleration = accel;
241 }
242
243 public override void AddForce(Vector3 force, bool pushforce)
244 {
245 }
246
247 public override Vector3 Torque
248 {
249 get { return Vector3.Zero; }
250 set { return; }
251 }
252
253 public override void AddAngularForce(Vector3 force, bool pushforce)
254 {
255 }
256
257 public override void link(PhysicsActor obj)
258 {
259 }
260
261 public override void delink()
262 {
263 }
264
265 public override void LockAngularMotion(Vector3 axis)
266 {
267 }
268
269 public override void SetMomentum(Vector3 momentum)
270 {
271 }
272
273 public void Move(float timeStep)
274 {
275 Vec3 vec = new Vec3();
276 vec.X = _velocity.X*timeStep;
277 vec.Y = _velocity.Y*timeStep;
278 if (flying)
279 {
280 vec.Z = (_velocity.Z)*timeStep;
281 }
282 else
283 {
284 gravityAccel += -9.8f;
285 vec.Z = (gravityAccel + _velocity.Z)*timeStep;
286 }
287 int res = _character.Move(vec);
288 if (res == 1)
289 {
290 gravityAccel = 0;
291 }
292 }
293
294 public override PrimitiveBaseShape Shape
295 {
296 set { return; }
297 }
298
299 public void UpdatePosition()
300 {
301 Vec3 vec = _character.Position;
302 _position.X = vec.X;
303 _position.Y = vec.Y;
304 _position.Z = vec.Z;
305 }
306
307 public override void CrossingFailure()
308 {
309 }
310
311 public override Vector3 PIDTarget { set { return; } }
312 public override bool PIDActive { set { return; } }
313 public override float PIDTau { set { return; } }
314
315 public override float PIDHoverHeight { set { return; } }
316 public override bool PIDHoverActive { set { return; } }
317 public override PIDHoverType PIDHoverType { set { return; } }
318 public override float PIDHoverTau { set { return; } }
319
320 public override Quaternion APIDTarget
321 {
322 set { return; }
323 }
324
325 public override bool APIDActive
326 {
327 set { return; }
328 }
329
330 public override float APIDStrength
331 {
332 set { return; }
333 }
334
335 public override float APIDDamping
336 {
337 set { return; }
338 }
339
340 public override void SubscribeEvents(int ms)
341 {
342
343 }
344 public override void UnSubscribeEvents()
345 {
346
347 }
348 public override bool SubscribedEvents()
349 {
350 return false;
351 }
352 }
353}
diff --git a/OpenSim/Region/Physics/PhysXPlugin/PhysXPlugin.cs b/OpenSim/Region/Physics/PhysXPlugin/PhysXPlugin.cs
index dd2c686..ca7a4f8 100644
--- a/OpenSim/Region/Physics/PhysXPlugin/PhysXPlugin.cs
+++ b/OpenSim/Region/Physics/PhysXPlugin/PhysXPlugin.cs
@@ -1,4 +1,4 @@
1/*/* 1/*
2 * Copyright (c) Contributors, http://opensimulator.org/ 2 * Copyright (c) Contributors, http://opensimulator.org/
3 * See CONTRIBUTORS.TXT for a full list of copyright holders. 3 * See CONTRIBUTORS.TXT for a full list of copyright holders.
4 * 4 *
@@ -73,773 +73,4 @@ namespace OpenSim.Region.Physics.PhysXPlugin
73 { 73 {
74 } 74 }
75 } 75 }
76
77 public class PhysXScene : PhysicsScene
78 {
79 private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
80 private List<PhysXCharacter> _characters = new List<PhysXCharacter>();
81 private List<PhysXPrim> _prims = new List<PhysXPrim>();
82 private float[] _heightMap = null;
83 private NxPhysicsSDK mySdk;
84 private NxScene scene;
85
86 // protected internal string sceneIdentifier;
87 public PhysXScene(string _sceneIdentifier)
88 {
89 //sceneIdentifier = _sceneIdentifier;
90
91 mySdk = NxPhysicsSDK.CreateSDK();
92 m_log.Info("Sdk created - now creating scene");
93 scene = mySdk.CreateScene();
94 }
95
96 public override void Initialise(IMesher meshmerizer, IConfigSource config)
97 {
98 // Does nothing right now
99 }
100 public override void Dispose()
101 {
102
103 }
104
105 public override void SetWaterLevel(float baseheight)
106 {
107
108 }
109
110 public override PhysicsActor AddAvatar(string avName, Vector3 position, Vector3 size, bool isFlying)
111 {
112 Vec3 pos = new Vec3();
113 pos.X = position.X;
114 pos.Y = position.Y;
115 pos.Z = position.Z;
116 PhysXCharacter act = new PhysXCharacter(scene.AddCharacter(pos));
117 act.Flying = isFlying;
118 act.Position = position;
119 _characters.Add(act);
120 return act;
121 }
122
123 public override void RemovePrim(PhysicsActor prim)
124 {
125 }
126
127 public override void RemoveAvatar(PhysicsActor actor)
128 {
129 }
130
131 private PhysicsActor AddPrim(Vector3 position, Vector3 size, Quaternion rotation)
132 {
133 Vec3 pos = new Vec3();
134 pos.X = position.X;
135 pos.Y = position.Y;
136 pos.Z = position.Z;
137 Vec3 siz = new Vec3();
138 siz.X = size.X;
139 siz.Y = size.Y;
140 siz.Z = size.Z;
141 PhysXPrim act = new PhysXPrim(scene.AddNewBox(pos, siz));
142 _prims.Add(act);
143 return act;
144 }
145
146 public override PhysicsActor AddPrimShape(string primName, PrimitiveBaseShape pbs, Vector3 position,
147 Vector3 size, Quaternion rotation) //To be removed
148 {
149 return AddPrimShape(primName, pbs, position, size, rotation, false);
150 }
151
152 public override PhysicsActor AddPrimShape(string primName, PrimitiveBaseShape pbs, Vector3 position,
153 Vector3 size, Quaternion rotation, bool isPhysical)
154 {
155 return AddPrim(position, size, rotation);
156 }
157
158 public override void AddPhysicsActorTaint(PhysicsActor prim)
159 {
160 }
161
162 public override float Simulate(float timeStep)
163 {
164 float fps = 0f;
165 try
166 {
167 foreach (PhysXCharacter actor in _characters)
168 {
169 actor.Move(timeStep);
170 }
171 scene.Simulate(timeStep);
172 scene.FetchResults();
173 scene.UpdateControllers();
174
175 foreach (PhysXCharacter actor in _characters)
176 {
177 actor.UpdatePosition();
178 }
179 }
180 catch (Exception e)
181 {
182 m_log.Error(e.Message);
183 }
184 return fps;
185 }
186
187 public override void GetResults()
188 {
189 }
190
191 public override bool IsThreaded
192 {
193 get { return (false); // for now we won't be multithreaded
194 }
195 }
196
197 public override void SetTerrain(float[] heightMap)
198 {
199 if (_heightMap != null)
200 {
201 m_log.Debug("PhysX - deleting old terrain");
202 scene.DeleteTerrain();
203 }
204 _heightMap = heightMap;
205 scene.AddTerrain(heightMap);
206 }
207
208 public override void DeleteTerrain()
209 {
210 scene.DeleteTerrain();
211 }
212
213 public override Dictionary<uint, float> GetTopColliders()
214 {
215 Dictionary<uint, float> returncolliders = new Dictionary<uint, float>();
216 return returncolliders;
217 }
218
219 }
220
221 public class PhysXCharacter : PhysicsActor
222 {
223 private Vector3 _position;
224 private Vector3 _velocity;
225 private Vector3 m_rotationalVelocity = Vector3.Zero;
226 private Vector3 _acceleration;
227 private NxCharacter _character;
228 private bool flying;
229 private bool iscolliding = false;
230 private float gravityAccel;
231
232 public PhysXCharacter(NxCharacter character)
233 {
234 _character = character;
235 }
236
237 public override int PhysicsActorType
238 {
239 get { return (int) ActorTypes.Agent; }
240 set { return; }
241 }
242
243 public override bool SetAlwaysRun
244 {
245 get { return false; }
246 set { return; }
247 }
248
249 public override uint LocalID
250 {
251 set { return; }
252 }
253
254 public override bool Grabbed
255 {
256 set { return; }
257 }
258
259 public override bool Selected
260 {
261 set { return; }
262 }
263
264 public override float Buoyancy
265 {
266 get { return 0f; }
267 set { return; }
268 }
269
270 public override bool FloatOnWater
271 {
272 set { return; }
273 }
274
275 public override bool IsPhysical
276 {
277 get { return false; }
278 set { return; }
279 }
280
281 public override bool ThrottleUpdates
282 {
283 get { return false; }
284 set { return; }
285 }
286
287 public override bool Flying
288 {
289 get { return flying; }
290 set { flying = value; }
291 }
292
293 public override bool IsColliding
294 {
295 get { return iscolliding; }
296 set { iscolliding = value; }
297 }
298
299 public override bool CollidingGround
300 {
301 get { return false; }
302 set { return; }
303 }
304
305 public override bool CollidingObj
306 {
307 get { return false; }
308 set { return; }
309 }
310
311 public override Vector3 RotationalVelocity
312 {
313 get { return m_rotationalVelocity; }
314 set { m_rotationalVelocity = value; }
315 }
316
317 public override bool Stopped
318 {
319 get { return false; }
320 }
321
322 public override Vector3 Position
323 {
324 get { return _position; }
325 set
326 {
327 _position = value;
328 Vec3 ps = new Vec3();
329 ps.X = value.X;
330 ps.Y = value.Y;
331 ps.Z = value.Z;
332 _character.Position = ps;
333 }
334 }
335
336 public override Vector3 Size
337 {
338 get { return Vector3.Zero; }
339 set { }
340 }
341
342 public override float Mass
343 {
344 get { return 0f; }
345 }
346
347 public override Vector3 Force
348 {
349 get { return Vector3.Zero; }
350 set { return; }
351 }
352
353 public override int VehicleType
354 {
355 get { return 0; }
356 set { return; }
357 }
358
359 public override void VehicleFloatParam(int param, float value)
360 {
361
362 }
363
364 public override void VehicleVectorParam(int param, Vector3 value)
365 {
366
367 }
368
369 public override void VehicleRotationParam(int param, Quaternion rotation)
370 {
371
372 }
373
374 public override void VehicleFlags(int param, bool remove) { }
375
376 public override void SetVolumeDetect(int param)
377 {
378
379 }
380
381
382 public override Vector3 CenterOfMass
383 {
384 get { return Vector3.Zero; }
385 }
386
387 public override Vector3 GeometricCenter
388 {
389 get { return Vector3.Zero; }
390 }
391
392 public override Vector3 Velocity
393 {
394 get { return _velocity; }
395 set { _velocity = value; }
396 }
397
398 public override float CollisionScore
399 {
400 get { return 0f; }
401 set { }
402 }
403
404 public override bool Kinematic
405 {
406 get { return false; }
407 set { }
408 }
409
410 public override Quaternion Orientation
411 {
412 get { return Quaternion.Identity; }
413 set { }
414 }
415
416 public override Vector3 Acceleration
417 {
418 get { return _acceleration; }
419 }
420
421 public void SetAcceleration(Vector3 accel)
422 {
423 _acceleration = accel;
424 }
425
426 public override void AddForce(Vector3 force, bool pushforce)
427 {
428 }
429 public override Vector3 Torque
430 {
431 get { return Vector3.Zero; }
432 set { return; }
433 }
434 public override void AddAngularForce(Vector3 force, bool pushforce)
435 {
436 }
437
438 public override void link(PhysicsActor obj)
439 {
440
441 }
442
443 public override void delink()
444 {
445
446 }
447
448 public override void LockAngularMotion(Vector3 axis)
449 {
450
451 }
452
453 public override void SetMomentum(Vector3 momentum)
454 {
455 }
456
457 public void Move(float timeStep)
458 {
459 Vec3 vec = new Vec3();
460 vec.X = _velocity.X*timeStep;
461 vec.Y = _velocity.Y*timeStep;
462 if (flying)
463 {
464 vec.Z = (_velocity.Z)*timeStep;
465 }
466 else
467 {
468 gravityAccel += -9.8f;
469 vec.Z = (gravityAccel + _velocity.Z)*timeStep;
470 }
471 int res = _character.Move(vec);
472 if (res == 1)
473 {
474 gravityAccel = 0;
475 }
476 }
477
478 public override PrimitiveBaseShape Shape
479 {
480 set { return; }
481 }
482
483 public void UpdatePosition()
484 {
485 Vec3 vec = _character.Position;
486 _position.X = vec.X;
487 _position.Y = vec.Y;
488 _position.Z = vec.Z;
489 }
490 public override void CrossingFailure()
491 {
492
493 }
494
495 public override Vector3 PIDTarget { set { return; } }
496 public override bool PIDActive { set { return; } }
497 public override float PIDTau { set { return; } }
498
499 public override float PIDHoverHeight { set { return; } }
500 public override bool PIDHoverActive { set { return; } }
501 public override PIDHoverType PIDHoverType { set { return; } }
502 public override float PIDHoverTau { set { return; } }
503
504 public override Quaternion APIDTarget
505 {
506 set { return; }
507 }
508
509 public override bool APIDActive
510 {
511 set { return; }
512 }
513
514 public override float APIDStrength
515 {
516 set { return; }
517 }
518
519 public override float APIDDamping
520 {
521 set { return; }
522 }
523
524
525
526 public override void SubscribeEvents(int ms)
527 {
528
529 }
530 public override void UnSubscribeEvents()
531 {
532
533 }
534 public override bool SubscribedEvents()
535 {
536 return false;
537 }
538 }
539
540
541 public class PhysXPrim : PhysicsActor
542 {
543 private Vector3 _velocity;
544 private Vector3 _acceleration;
545 private Vector3 m_rotationalVelocity;
546 private NxActor _prim;
547
548 public PhysXPrim(NxActor prim)
549 {
550 _velocity = Vector3.Zero;
551 _acceleration = Vector3.Zero;
552 _prim = prim;
553 }
554
555 public override int PhysicsActorType
556 {
557 get { return (int) ActorTypes.Prim; }
558 set { return; }
559 }
560
561 public override bool IsPhysical
562 {
563 get { return false; }
564 set { return; }
565 }
566
567 public override bool SetAlwaysRun
568 {
569 get { return false; }
570 set { return; }
571 }
572
573 public override uint LocalID
574 {
575 set { return; }
576 }
577
578 public override bool Grabbed
579 {
580 set { return; }
581 }
582
583 public override bool Selected
584 {
585 set { return; }
586 }
587
588 public override float Buoyancy
589 {
590 get { return 0f; }
591 set { return; }
592 }
593
594 public override bool FloatOnWater
595 {
596 set { return; }
597 }
598
599 public override bool ThrottleUpdates
600 {
601 get { return false; }
602 set { return; }
603 }
604
605 public override Vector3 RotationalVelocity
606 {
607 get { return m_rotationalVelocity; }
608 set { m_rotationalVelocity = value; }
609 }
610
611 public override bool Flying
612 {
613 get { return false; //no flying prims for you
614 }
615 set { }
616 }
617
618 public override bool IsColliding
619 {
620 get { return false; }
621 set { }
622 }
623
624 public override bool CollidingGround
625 {
626 get { return false; }
627 set { return; }
628 }
629
630 public override bool CollidingObj
631 {
632 get { return false; }
633 set { return; }
634 }
635
636 public override bool Stopped
637 {
638 get { return false; }
639 }
640
641 public override Vector3 Position
642 {
643 get
644 {
645 Vector3 pos = Vector3.Zero;
646 Vec3 vec = _prim.Position;
647 pos.X = vec.X;
648 pos.Y = vec.Y;
649 pos.Z = vec.Z;
650 return pos;
651 }
652 set
653 {
654 Vector3 vec = value;
655 Vec3 pos = new Vec3();
656 pos.X = vec.X;
657 pos.Y = vec.Y;
658 pos.Z = vec.Z;
659 _prim.Position = pos;
660 }
661 }
662
663 public override PrimitiveBaseShape Shape
664 {
665 set { return; }
666 }
667
668 public override Vector3 Velocity
669 {
670 get { return _velocity; }
671 set { _velocity = value; }
672 }
673
674 public override Vector3 Torque
675 {
676 get { return Vector3.Zero; }
677 set { return; }
678 }
679
680 public override float CollisionScore
681 {
682 get { return 0f; }
683 set { }
684 }
685
686 public override bool Kinematic
687 {
688 get { return _prim.Kinematic; }
689 set { _prim.Kinematic = value; }
690 }
691
692 public override Quaternion Orientation
693 {
694 get
695 {
696 Quaternion res;
697 PhysXWrapper.Quaternion quat = _prim.GetOrientation();
698 res.W = quat.W;
699 res.X = quat.X;
700 res.Y = quat.Y;
701 res.Z = quat.Z;
702 return res;
703 }
704 set { }
705 }
706
707 public override Vector3 Acceleration
708 {
709 get { return _acceleration; }
710 }
711
712 public void SetAcceleration(Vector3 accel)
713 {
714 _acceleration = accel;
715 }
716
717 public override void AddForce(Vector3 force, bool pushforce)
718 {
719 }
720
721 public override void AddAngularForce(Vector3 force, bool pushforce)
722 {
723 }
724
725 public override void SetMomentum(Vector3 momentum)
726 {
727 }
728
729 public override Vector3 Size
730 {
731 get { return Vector3.Zero; }
732 set { }
733 }
734
735 public override void link(PhysicsActor obj)
736 {
737 }
738
739 public override void delink()
740 {
741 }
742
743 public override void LockAngularMotion(Vector3 axis)
744 {
745
746 }
747
748 public override float Mass
749 {
750 get { return 0f; }
751 }
752
753 public override Vector3 Force
754 {
755 get { return Vector3.Zero; }
756 set { return; }
757 }
758
759 public override int VehicleType
760 {
761 get { return 0; }
762 set { return; }
763 }
764
765 public override void VehicleFloatParam(int param, float value)
766 {
767
768 }
769
770 public override void VehicleVectorParam(int param, Vector3 value)
771 {
772
773 }
774
775 public override void VehicleRotationParam(int param, Quaternion rotation)
776 {
777
778 }
779
780 public override void VehicleFlags(int param, bool remove) { }
781
782 public override void SetVolumeDetect(int param)
783 {
784
785 }
786
787 public override Vector3 CenterOfMass
788 {
789 get { return Vector3.Zero; }
790 }
791
792 public override Vector3 GeometricCenter
793 {
794 get { return Vector3.Zero; }
795 }
796
797 public override void CrossingFailure()
798 {
799 }
800
801 public override Vector3 PIDTarget { set { return; } }
802 public override bool PIDActive { set { return; } }
803 public override float PIDTau { set { return; } }
804
805 public override float PIDHoverHeight { set { return; } }
806 public override bool PIDHoverActive { set { return; } }
807 public override PIDHoverType PIDHoverType { set { return; } }
808 public override float PIDHoverTau { set { return; } }
809
810 public override Quaternion APIDTarget
811 {
812 set { return; }
813 }
814
815 public override bool APIDActive
816 {
817 set { return; }
818 }
819
820 public override float APIDStrength
821 {
822 set { return; }
823 }
824
825 public override float APIDDamping
826 {
827 set { return; }
828 }
829
830
831
832 public override void SubscribeEvents(int ms)
833 {
834
835 }
836 public override void UnSubscribeEvents()
837 {
838
839 }
840 public override bool SubscribedEvents()
841 {
842 return false;
843 }
844 }
845} 76}
diff --git a/OpenSim/Region/Physics/PhysXPlugin/PhysXPrim.cs b/OpenSim/Region/Physics/PhysXPlugin/PhysXPrim.cs
new file mode 100644
index 0000000..c0e24fd
--- /dev/null
+++ b/OpenSim/Region/Physics/PhysXPlugin/PhysXPrim.cs
@@ -0,0 +1,345 @@
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;
33using PhysXWrapper;
34using Quaternion=OpenMetaverse.Quaternion;
35using System.Reflection;
36using log4net;
37using OpenMetaverse;
38
39namespace OpenSim.Region.Physics.PhysXPlugin
40{
41 public class PhysXPrim : PhysicsActor
42 {
43 private Vector3 _velocity;
44 private Vector3 _acceleration;
45 private Vector3 m_rotationalVelocity;
46 private NxActor _prim;
47
48 public PhysXPrim(NxActor prim)
49 {
50 _velocity = Vector3.Zero;
51 _acceleration = Vector3.Zero;
52 _prim = prim;
53 }
54
55 public override int PhysicsActorType
56 {
57 get { return (int) ActorTypes.Prim; }
58 set { return; }
59 }
60
61 public override bool IsPhysical
62 {
63 get { return false; }
64 set { return; }
65 }
66
67 public override bool SetAlwaysRun
68 {
69 get { return false; }
70 set { return; }
71 }
72
73 public override uint LocalID
74 {
75 set { return; }
76 }
77
78 public override bool Grabbed
79 {
80 set { return; }
81 }
82
83 public override bool Selected
84 {
85 set { return; }
86 }
87
88 public override float Buoyancy
89 {
90 get { return 0f; }
91 set { return; }
92 }
93
94 public override bool FloatOnWater
95 {
96 set { return; }
97 }
98
99 public override bool ThrottleUpdates
100 {
101 get { return false; }
102 set { return; }
103 }
104
105 public override Vector3 RotationalVelocity
106 {
107 get { return m_rotationalVelocity; }
108 set { m_rotationalVelocity = value; }
109 }
110
111 public override bool Flying
112 {
113 get { return false; //no flying prims for you
114 }
115 set { }
116 }
117
118 public override bool IsColliding
119 {
120 get { return false; }
121 set { }
122 }
123
124 public override bool CollidingGround
125 {
126 get { return false; }
127 set { return; }
128 }
129
130 public override bool CollidingObj
131 {
132 get { return false; }
133 set { return; }
134 }
135
136 public override bool Stopped
137 {
138 get { return false; }
139 }
140
141 public override Vector3 Position
142 {
143 get
144 {
145 Vector3 pos = Vector3.Zero;
146 Vec3 vec = _prim.Position;
147 pos.X = vec.X;
148 pos.Y = vec.Y;
149 pos.Z = vec.Z;
150 return pos;
151 }
152 set
153 {
154 Vector3 vec = value;
155 Vec3 pos = new Vec3();
156 pos.X = vec.X;
157 pos.Y = vec.Y;
158 pos.Z = vec.Z;
159 _prim.Position = pos;
160 }
161 }
162
163 public override PrimitiveBaseShape Shape
164 {
165 set { return; }
166 }
167
168 public override Vector3 Velocity
169 {
170 get { return _velocity; }
171 set { _velocity = value; }
172 }
173
174 public override Vector3 Torque
175 {
176 get { return Vector3.Zero; }
177 set { return; }
178 }
179
180 public override float CollisionScore
181 {
182 get { return 0f; }
183 set { }
184 }
185
186 public override bool Kinematic
187 {
188 get { return _prim.Kinematic; }
189 set { _prim.Kinematic = value; }
190 }
191
192 public override Quaternion Orientation
193 {
194 get
195 {
196 Quaternion res;
197 PhysXWrapper.Quaternion quat = _prim.GetOrientation();
198 res.W = quat.W;
199 res.X = quat.X;
200 res.Y = quat.Y;
201 res.Z = quat.Z;
202 return res;
203 }
204 set { }
205 }
206
207 public override Vector3 Acceleration
208 {
209 get { return _acceleration; }
210 }
211
212 public void SetAcceleration(Vector3 accel)
213 {
214 _acceleration = accel;
215 }
216
217 public override void AddForce(Vector3 force, bool pushforce)
218 {
219 }
220
221 public override void AddAngularForce(Vector3 force, bool pushforce)
222 {
223 }
224
225 public override void SetMomentum(Vector3 momentum)
226 {
227 }
228
229 public override Vector3 Size
230 {
231 get { return Vector3.Zero; }
232 set { }
233 }
234
235 public override void link(PhysicsActor obj)
236 {
237 }
238
239 public override void delink()
240 {
241 }
242
243 public override void LockAngularMotion(Vector3 axis)
244 {
245
246 }
247
248 public override float Mass
249 {
250 get { return 0f; }
251 }
252
253 public override Vector3 Force
254 {
255 get { return Vector3.Zero; }
256 set { return; }
257 }
258
259 public override int VehicleType
260 {
261 get { return 0; }
262 set { return; }
263 }
264
265 public override void VehicleFloatParam(int param, float value)
266 {
267
268 }
269
270 public override void VehicleVectorParam(int param, Vector3 value)
271 {
272
273 }
274
275 public override void VehicleRotationParam(int param, Quaternion rotation)
276 {
277
278 }
279
280 public override void VehicleFlags(int param, bool remove) { }
281
282 public override void SetVolumeDetect(int param)
283 {
284
285 }
286
287 public override Vector3 CenterOfMass
288 {
289 get { return Vector3.Zero; }
290 }
291
292 public override Vector3 GeometricCenter
293 {
294 get { return Vector3.Zero; }
295 }
296
297 public override void CrossingFailure()
298 {
299 }
300
301 public override Vector3 PIDTarget { set { return; } }
302 public override bool PIDActive { set { return; } }
303 public override float PIDTau { set { return; } }
304
305 public override float PIDHoverHeight { set { return; } }
306 public override bool PIDHoverActive { set { return; } }
307 public override PIDHoverType PIDHoverType { set { return; } }
308 public override float PIDHoverTau { set { return; } }
309
310 public override Quaternion APIDTarget
311 {
312 set { return; }
313 }
314
315 public override bool APIDActive
316 {
317 set { return; }
318 }
319
320 public override float APIDStrength
321 {
322 set { return; }
323 }
324
325 public override float APIDDamping
326 {
327 set { return; }
328 }
329
330
331
332 public override void SubscribeEvents(int ms)
333 {
334
335 }
336 public override void UnSubscribeEvents()
337 {
338
339 }
340 public override bool SubscribedEvents()
341 {
342 return false;
343 }
344 }
345}
diff --git a/OpenSim/Region/Physics/PhysXPlugin/PhysXScene.cs b/OpenSim/Region/Physics/PhysXPlugin/PhysXScene.cs
new file mode 100644
index 0000000..4de4b01
--- /dev/null
+++ b/OpenSim/Region/Physics/PhysXPlugin/PhysXScene.cs
@@ -0,0 +1,183 @@
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;
33using PhysXWrapper;
34using Quaternion=OpenMetaverse.Quaternion;
35using System.Reflection;
36using log4net;
37using OpenMetaverse;
38
39namespace OpenSim.Region.Physics.PhysXPlugin
40{
41 public class PhysXScene : PhysicsScene
42 {
43 private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
44 private List<PhysXCharacter> _characters = new List<PhysXCharacter>();
45 private List<PhysXPrim> _prims = new List<PhysXPrim>();
46 private float[] _heightMap = null;
47 private NxPhysicsSDK mySdk;
48 private NxScene scene;
49
50 // protected internal string sceneIdentifier;
51 public PhysXScene(string _sceneIdentifier)
52 {
53 //sceneIdentifier = _sceneIdentifier;
54
55 mySdk = NxPhysicsSDK.CreateSDK();
56 m_log.Info("Sdk created - now creating scene");
57 scene = mySdk.CreateScene();
58 }
59
60 public override void Initialise(IMesher meshmerizer, IConfigSource config)
61 {
62 // Does nothing right now
63 }
64 public override void Dispose()
65 {
66
67 }
68
69 public override void SetWaterLevel(float baseheight)
70 {
71
72 }
73
74 public override PhysicsActor AddAvatar(string avName, Vector3 position, Vector3 size, bool isFlying)
75 {
76 Vec3 pos = new Vec3();
77 pos.X = position.X;
78 pos.Y = position.Y;
79 pos.Z = position.Z;
80 PhysXCharacter act = new PhysXCharacter(scene.AddCharacter(pos));
81 act.Flying = isFlying;
82 act.Position = position;
83 _characters.Add(act);
84 return act;
85 }
86
87 public override void RemovePrim(PhysicsActor prim)
88 {
89 }
90
91 public override void RemoveAvatar(PhysicsActor actor)
92 {
93 }
94
95 private PhysicsActor AddPrim(Vector3 position, Vector3 size, Quaternion rotation)
96 {
97 Vec3 pos = new Vec3();
98 pos.X = position.X;
99 pos.Y = position.Y;
100 pos.Z = position.Z;
101 Vec3 siz = new Vec3();
102 siz.X = size.X;
103 siz.Y = size.Y;
104 siz.Z = size.Z;
105 PhysXPrim act = new PhysXPrim(scene.AddNewBox(pos, siz));
106 _prims.Add(act);
107 return act;
108 }
109
110 public override PhysicsActor AddPrimShape(string primName, PrimitiveBaseShape pbs, Vector3 position,
111 Vector3 size, Quaternion rotation) //To be removed
112 {
113 return AddPrimShape(primName, pbs, position, size, rotation, false);
114 }
115
116 public override PhysicsActor AddPrimShape(string primName, PrimitiveBaseShape pbs, Vector3 position,
117 Vector3 size, Quaternion rotation, bool isPhysical)
118 {
119 return AddPrim(position, size, rotation);
120 }
121
122 public override void AddPhysicsActorTaint(PhysicsActor prim)
123 {
124 }
125
126 public override float Simulate(float timeStep)
127 {
128 float fps = 0f;
129 try
130 {
131 foreach (PhysXCharacter actor in _characters)
132 {
133 actor.Move(timeStep);
134 }
135 scene.Simulate(timeStep);
136 scene.FetchResults();
137 scene.UpdateControllers();
138
139 foreach (PhysXCharacter actor in _characters)
140 {
141 actor.UpdatePosition();
142 }
143 }
144 catch (Exception e)
145 {
146 m_log.Error(e.Message);
147 }
148 return fps;
149 }
150
151 public override void GetResults()
152 {
153 }
154
155 public override bool IsThreaded
156 {
157 // for now we won't be multithreaded
158 get { return (false); }
159 }
160
161 public override void SetTerrain(float[] heightMap)
162 {
163 if (_heightMap != null)
164 {
165 m_log.Debug("PhysX - deleting old terrain");
166 scene.DeleteTerrain();
167 }
168 _heightMap = heightMap;
169 scene.AddTerrain(heightMap);
170 }
171
172 public override void DeleteTerrain()
173 {
174 scene.DeleteTerrain();
175 }
176
177 public override Dictionary<uint, float> GetTopColliders()
178 {
179 Dictionary<uint, float> returncolliders = new Dictionary<uint, float>();
180 return returncolliders;
181 }
182 }
183}