From 2a3c79df83e800d5dfe75a1a3b140ed81da2b1d6 Mon Sep 17 00:00:00 2001
From: Sean Dague
Date: Mon, 16 Jul 2007 15:40:11 +0000
Subject: changed to native line ending encoding
---
.../Physics/BasicPhysicsPlugin/AssemblyInfo.cs | 112 +-
.../BasicPhysicsPlugin/BasicPhysicsPlugin.cs | 602 +++++------
.../Region/Physics/BulletXPlugin/AssemblyInfo.cs | 112 +-
.../Region/Physics/BulletXPlugin/BulletXPlugin.cs | 1068 ++++++++++----------
OpenSim/Region/Physics/Manager/AssemblyInfo.cs | 112 +-
OpenSim/Region/Physics/Manager/PhysicsActor.cs | 334 +++---
OpenSim/Region/Physics/Manager/PhysicsManager.cs | 230 ++---
OpenSim/Region/Physics/Manager/PhysicsScene.cs | 220 ++--
OpenSim/Region/Physics/Manager/PhysicsVector.cs | 110 +-
OpenSim/Region/Physics/OdePlugin/AssemblyInfo.cs | 112 +-
OpenSim/Region/Physics/OdePlugin/OdePlugin.cs | 914 ++++++++---------
OpenSim/Region/Physics/PhysXPlugin/AssemblyInfo.cs | 112 +-
OpenSim/Region/Physics/PhysXPlugin/PhysXPlugin.cs | 850 ++++++++--------
13 files changed, 2444 insertions(+), 2444 deletions(-)
(limited to 'OpenSim/Region/Physics')
diff --git a/OpenSim/Region/Physics/BasicPhysicsPlugin/AssemblyInfo.cs b/OpenSim/Region/Physics/BasicPhysicsPlugin/AssemblyInfo.cs
index ce567a9..ecf8e68 100644
--- a/OpenSim/Region/Physics/BasicPhysicsPlugin/AssemblyInfo.cs
+++ b/OpenSim/Region/Physics/BasicPhysicsPlugin/AssemblyInfo.cs
@@ -1,56 +1,56 @@
-/*
-* Copyright (c) Contributors, http://www.openmetaverse.org/
-* See CONTRIBUTORS.TXT for a full list of copyright holders.
-*
-* Redistribution and use in source and binary forms, with or without
-* modification, are permitted provided that the following conditions are met:
-* * Redistributions of source code must retain the above copyright
-* notice, this list of conditions and the following disclaimer.
-* * Redistributions in binary form must reproduce the above copyright
-* notice, this list of conditions and the following disclaimer in the
-* documentation and/or other materials provided with the distribution.
-* * Neither the name of the OpenSim Project nor the
-* names of its contributors may be used to endorse or promote products
-* derived from this software without specific prior written permission.
-*
-* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS AND ANY
-* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
-* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
-* DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
-* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
-* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
-* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
-* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
-* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-*
-*/
-using System.Reflection;
-using System.Runtime.InteropServices;
-// Information about this assembly is defined by the following
-// attributes.
-//
-// change them to the information which is associated with the assembly
-// you compile.
-
-[assembly: AssemblyTitle("PhysXplugin")]
-[assembly: AssemblyDescription("")]
-[assembly: AssemblyConfiguration("")]
-[assembly: AssemblyCompany("")]
-[assembly: AssemblyProduct("PhysXplugin")]
-[assembly: AssemblyCopyright("")]
-[assembly: AssemblyTrademark("")]
-[assembly: AssemblyCulture("")]
-
-// This sets the default COM visibility of types in the assembly to invisible.
-// If you need to expose a type to COM, use [ComVisible(true)] on that type.
-[assembly: ComVisible(false)]
-
-// The assembly version has following format :
-//
-// Major.Minor.Build.Revision
-//
-// You can specify all values by your own or you can build default build and revision
-// numbers with the '*' character (the default):
-
-[assembly: AssemblyVersion("1.0.*")]
+/*
+* Copyright (c) Contributors, http://www.openmetaverse.org/
+* See CONTRIBUTORS.TXT for a full list of copyright holders.
+*
+* Redistribution and use in source and binary forms, with or without
+* modification, are permitted provided that the following conditions are met:
+* * Redistributions of source code must retain the above copyright
+* notice, this list of conditions and the following disclaimer.
+* * Redistributions in binary form must reproduce the above copyright
+* notice, this list of conditions and the following disclaimer in the
+* documentation and/or other materials provided with the distribution.
+* * Neither the name of the OpenSim Project nor the
+* names of its contributors may be used to endorse or promote products
+* derived from this software without specific prior written permission.
+*
+* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS AND ANY
+* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+* DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
+* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+*
+*/
+using System.Reflection;
+using System.Runtime.InteropServices;
+// Information about this assembly is defined by the following
+// attributes.
+//
+// change them to the information which is associated with the assembly
+// you compile.
+
+[assembly: AssemblyTitle("PhysXplugin")]
+[assembly: AssemblyDescription("")]
+[assembly: AssemblyConfiguration("")]
+[assembly: AssemblyCompany("")]
+[assembly: AssemblyProduct("PhysXplugin")]
+[assembly: AssemblyCopyright("")]
+[assembly: AssemblyTrademark("")]
+[assembly: AssemblyCulture("")]
+
+// This sets the default COM visibility of types in the assembly to invisible.
+// If you need to expose a type to COM, use [ComVisible(true)] on that type.
+[assembly: ComVisible(false)]
+
+// The assembly version has following format :
+//
+// Major.Minor.Build.Revision
+//
+// You can specify all values by your own or you can build default build and revision
+// numbers with the '*' character (the default):
+
+[assembly: AssemblyVersion("1.0.*")]
diff --git a/OpenSim/Region/Physics/BasicPhysicsPlugin/BasicPhysicsPlugin.cs b/OpenSim/Region/Physics/BasicPhysicsPlugin/BasicPhysicsPlugin.cs
index f133045..ec406f1 100644
--- a/OpenSim/Region/Physics/BasicPhysicsPlugin/BasicPhysicsPlugin.cs
+++ b/OpenSim/Region/Physics/BasicPhysicsPlugin/BasicPhysicsPlugin.cs
@@ -1,301 +1,301 @@
-/*
-* Copyright (c) Contributors, http://www.openmetaverse.org/
-* See CONTRIBUTORS.TXT for a full list of copyright holders.
-*
-* Redistribution and use in source and binary forms, with or without
-* modification, are permitted provided that the following conditions are met:
-* * Redistributions of source code must retain the above copyright
-* notice, this list of conditions and the following disclaimer.
-* * Redistributions in binary form must reproduce the above copyright
-* notice, this list of conditions and the following disclaimer in the
-* documentation and/or other materials provided with the distribution.
-* * Neither the name of the OpenSim Project nor the
-* names of its contributors may be used to endorse or promote products
-* derived from this software without specific prior written permission.
-*
-* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS AND ANY
-* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
-* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
-* DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
-* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
-* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
-* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
-* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
-* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-*
-*/
-using System.Collections.Generic;
-using Axiom.Math;
-using OpenSim.Physics.Manager;
-
-namespace OpenSim.Region.Physics.BasicPhysicsPlugin
-{
- ///
- /// Will be the PhysX plugin but for now will be a very basic physics engine
- ///
- public class BasicPhysicsPlugin : IPhysicsPlugin
- {
- private BasicScene _mScene;
-
- public BasicPhysicsPlugin()
- {
-
- }
-
- public bool Init()
- {
- return true;
- }
-
- public PhysicsScene GetScene()
- {
- return new BasicScene();
- }
-
- public string GetName()
- {
- return("basicphysics");
- }
-
- public void Dispose()
- {
-
- }
- }
-
- public class BasicScene :PhysicsScene
- {
- private List _actors = new List();
- private float[] _heightMap;
-
- public BasicScene()
- {
-
- }
-
- public override PhysicsActor AddAvatar(PhysicsVector position)
- {
- BasicActor act = new BasicActor();
- act.Position = position;
- _actors.Add(act);
- return act;
- }
-
- public override void RemoveAvatar(PhysicsActor actor)
- {
- BasicActor act = (BasicActor)actor;
- if(_actors.Contains(act))
- {
- _actors.Remove(act);
- }
-
- }
-
- public override PhysicsActor AddPrim(PhysicsVector position, PhysicsVector size)
- {
- return null;
- }
-
- public override void Simulate(float timeStep)
- {
- foreach (BasicActor actor in _actors)
- {
- if ((actor.Position.Y > 0 && actor.Position.Y < 256) && (actor.Position.X > 0 && actor.Position.X < 256))
- {
- float height = _heightMap[(int)actor.Position.Y * 256 + (int)actor.Position.X] + 1.2f;
- actor.Position.X = actor.Position.X + (actor.Velocity.X * timeStep);
- actor.Position.Y = actor.Position.Y + (actor.Velocity.Y * timeStep);
- if (actor.Flying)
- {
- if (actor.Position.Z + (actor.Velocity.Z * timeStep) <
- _heightMap[(int)actor.Position.Y * 256 + (int)actor.Position.X] + 2)
- {
- actor.Position.Z = height;
- actor.Velocity.Z = 0;
- }
- else
- {
- actor.Position.Z = actor.Position.Z + (actor.Velocity.Z * timeStep);
- }
- }
- else
- {
- actor.Position.Z = height;
- actor.Velocity.Z = 0;
- }
- }
- else
- {
- if (actor.Position.Y < 0)
- {
- actor.Position.Y = 0;
- }
- else if (actor.Position.Y > 256)
- {
- actor.Position.Y = 256;
- }
-
- if (actor.Position.X < 0)
- {
- actor.Position.X = 0;
- }
- if (actor.Position.X > 256)
- {
- actor.Position.X = 256;
- }
- }
- //}
-
-
-
- // This code needs sorting out - border crossings etc
-/* if(actor.Position.X<0)
- {
- ControllingClient.CrossSimBorder(new LLVector3(this.Position.X,this.Position.Y,this.Position.Z));
- actor.Position.X = 0;
- actor.Velocity.X = 0;
- }
- if(actor.Position.Y < 0)
- {
- ControllingClient.CrossSimBorder(new LLVector3(this.Position.X,this.Position.Y,this.Position.Z));
- actor.Position.Y = 0;
- actor.Velocity.Y = 0;
- }
- if(actor.Position.X > 255)
- {
- ControllingClient.CrossSimBorder(new LLVector3(this.Position.X,this.Position.Y,this.Position.Z));
- actor.Position.X = 255;
- actor.Velocity.X = 0;
- }
- if(actor.Position.Y > 255)
- {
- ControllingClient.CrossSimBorder(new LLVector3(this.Position.X,this.Position.Y,this.Position.Z));
- actor.Position.Y = 255;
- actor.Velocity.X = 0;
- }*/
- }
- }
-
- public override void GetResults()
- {
-
- }
-
- public override bool IsThreaded
- {
- get
- {
- return(false); // for now we won't be multithreaded
- }
- }
-
- public override void SetTerrain(float[] heightMap)
- {
- this._heightMap = heightMap;
- }
-
- public override void DeleteTerrain()
- {
-
- }
- }
-
- public class BasicActor : PhysicsActor
- {
- private PhysicsVector _position;
- private PhysicsVector _velocity;
- private PhysicsVector _acceleration;
- private bool flying;
- public BasicActor()
- {
- _velocity = new PhysicsVector();
- _position = new PhysicsVector();
- _acceleration = new PhysicsVector();
- }
-
- public override bool Flying
- {
- get
- {
- return flying;
- }
- set
- {
- flying= value;
- }
- }
-
- public override PhysicsVector Position
- {
- get
- {
- return _position;
- }
- set
- {
- _position = value;
- }
- }
-
- public override PhysicsVector Velocity
- {
- get
- {
- return _velocity;
- }
- set
- {
- _velocity = value;
- }
- }
-
- public override Quaternion Orientation
- {
- get
- {
- return Quaternion.Identity;
- }
- set
- {
-
- }
- }
-
- public override PhysicsVector Acceleration
- {
- get
- {
- return _acceleration;
- }
-
- }
-
- public override bool Kinematic
- {
- get
- {
- return true;
- }
- set
- {
-
- }
- }
- public void SetAcceleration (PhysicsVector accel)
- {
- this._acceleration = accel;
- }
-
- public override void AddForce(PhysicsVector force)
- {
-
- }
-
- public override void SetMomentum(PhysicsVector momentum)
- {
-
- }
- }
-
-}
+/*
+* Copyright (c) Contributors, http://www.openmetaverse.org/
+* See CONTRIBUTORS.TXT for a full list of copyright holders.
+*
+* Redistribution and use in source and binary forms, with or without
+* modification, are permitted provided that the following conditions are met:
+* * Redistributions of source code must retain the above copyright
+* notice, this list of conditions and the following disclaimer.
+* * Redistributions in binary form must reproduce the above copyright
+* notice, this list of conditions and the following disclaimer in the
+* documentation and/or other materials provided with the distribution.
+* * Neither the name of the OpenSim Project nor the
+* names of its contributors may be used to endorse or promote products
+* derived from this software without specific prior written permission.
+*
+* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS AND ANY
+* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+* DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
+* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+*
+*/
+using System.Collections.Generic;
+using Axiom.Math;
+using OpenSim.Physics.Manager;
+
+namespace OpenSim.Region.Physics.BasicPhysicsPlugin
+{
+ ///
+ /// Will be the PhysX plugin but for now will be a very basic physics engine
+ ///
+ public class BasicPhysicsPlugin : IPhysicsPlugin
+ {
+ private BasicScene _mScene;
+
+ public BasicPhysicsPlugin()
+ {
+
+ }
+
+ public bool Init()
+ {
+ return true;
+ }
+
+ public PhysicsScene GetScene()
+ {
+ return new BasicScene();
+ }
+
+ public string GetName()
+ {
+ return("basicphysics");
+ }
+
+ public void Dispose()
+ {
+
+ }
+ }
+
+ public class BasicScene :PhysicsScene
+ {
+ private List _actors = new List();
+ private float[] _heightMap;
+
+ public BasicScene()
+ {
+
+ }
+
+ public override PhysicsActor AddAvatar(PhysicsVector position)
+ {
+ BasicActor act = new BasicActor();
+ act.Position = position;
+ _actors.Add(act);
+ return act;
+ }
+
+ public override void RemoveAvatar(PhysicsActor actor)
+ {
+ BasicActor act = (BasicActor)actor;
+ if(_actors.Contains(act))
+ {
+ _actors.Remove(act);
+ }
+
+ }
+
+ public override PhysicsActor AddPrim(PhysicsVector position, PhysicsVector size)
+ {
+ return null;
+ }
+
+ public override void Simulate(float timeStep)
+ {
+ foreach (BasicActor actor in _actors)
+ {
+ if ((actor.Position.Y > 0 && actor.Position.Y < 256) && (actor.Position.X > 0 && actor.Position.X < 256))
+ {
+ float height = _heightMap[(int)actor.Position.Y * 256 + (int)actor.Position.X] + 1.2f;
+ actor.Position.X = actor.Position.X + (actor.Velocity.X * timeStep);
+ actor.Position.Y = actor.Position.Y + (actor.Velocity.Y * timeStep);
+ if (actor.Flying)
+ {
+ if (actor.Position.Z + (actor.Velocity.Z * timeStep) <
+ _heightMap[(int)actor.Position.Y * 256 + (int)actor.Position.X] + 2)
+ {
+ actor.Position.Z = height;
+ actor.Velocity.Z = 0;
+ }
+ else
+ {
+ actor.Position.Z = actor.Position.Z + (actor.Velocity.Z * timeStep);
+ }
+ }
+ else
+ {
+ actor.Position.Z = height;
+ actor.Velocity.Z = 0;
+ }
+ }
+ else
+ {
+ if (actor.Position.Y < 0)
+ {
+ actor.Position.Y = 0;
+ }
+ else if (actor.Position.Y > 256)
+ {
+ actor.Position.Y = 256;
+ }
+
+ if (actor.Position.X < 0)
+ {
+ actor.Position.X = 0;
+ }
+ if (actor.Position.X > 256)
+ {
+ actor.Position.X = 256;
+ }
+ }
+ //}
+
+
+
+ // This code needs sorting out - border crossings etc
+/* if(actor.Position.X<0)
+ {
+ ControllingClient.CrossSimBorder(new LLVector3(this.Position.X,this.Position.Y,this.Position.Z));
+ actor.Position.X = 0;
+ actor.Velocity.X = 0;
+ }
+ if(actor.Position.Y < 0)
+ {
+ ControllingClient.CrossSimBorder(new LLVector3(this.Position.X,this.Position.Y,this.Position.Z));
+ actor.Position.Y = 0;
+ actor.Velocity.Y = 0;
+ }
+ if(actor.Position.X > 255)
+ {
+ ControllingClient.CrossSimBorder(new LLVector3(this.Position.X,this.Position.Y,this.Position.Z));
+ actor.Position.X = 255;
+ actor.Velocity.X = 0;
+ }
+ if(actor.Position.Y > 255)
+ {
+ ControllingClient.CrossSimBorder(new LLVector3(this.Position.X,this.Position.Y,this.Position.Z));
+ actor.Position.Y = 255;
+ actor.Velocity.X = 0;
+ }*/
+ }
+ }
+
+ public override void GetResults()
+ {
+
+ }
+
+ public override bool IsThreaded
+ {
+ get
+ {
+ return(false); // for now we won't be multithreaded
+ }
+ }
+
+ public override void SetTerrain(float[] heightMap)
+ {
+ this._heightMap = heightMap;
+ }
+
+ public override void DeleteTerrain()
+ {
+
+ }
+ }
+
+ public class BasicActor : PhysicsActor
+ {
+ private PhysicsVector _position;
+ private PhysicsVector _velocity;
+ private PhysicsVector _acceleration;
+ private bool flying;
+ public BasicActor()
+ {
+ _velocity = new PhysicsVector();
+ _position = new PhysicsVector();
+ _acceleration = new PhysicsVector();
+ }
+
+ public override bool Flying
+ {
+ get
+ {
+ return flying;
+ }
+ set
+ {
+ flying= value;
+ }
+ }
+
+ public override PhysicsVector Position
+ {
+ get
+ {
+ return _position;
+ }
+ set
+ {
+ _position = value;
+ }
+ }
+
+ public override PhysicsVector Velocity
+ {
+ get
+ {
+ return _velocity;
+ }
+ set
+ {
+ _velocity = value;
+ }
+ }
+
+ public override Quaternion Orientation
+ {
+ get
+ {
+ return Quaternion.Identity;
+ }
+ set
+ {
+
+ }
+ }
+
+ public override PhysicsVector Acceleration
+ {
+ get
+ {
+ return _acceleration;
+ }
+
+ }
+
+ public override bool Kinematic
+ {
+ get
+ {
+ return true;
+ }
+ set
+ {
+
+ }
+ }
+ public void SetAcceleration (PhysicsVector accel)
+ {
+ this._acceleration = accel;
+ }
+
+ public override void AddForce(PhysicsVector force)
+ {
+
+ }
+
+ public override void SetMomentum(PhysicsVector momentum)
+ {
+
+ }
+ }
+
+}
diff --git a/OpenSim/Region/Physics/BulletXPlugin/AssemblyInfo.cs b/OpenSim/Region/Physics/BulletXPlugin/AssemblyInfo.cs
index bda35f7..42ccdff 100644
--- a/OpenSim/Region/Physics/BulletXPlugin/AssemblyInfo.cs
+++ b/OpenSim/Region/Physics/BulletXPlugin/AssemblyInfo.cs
@@ -1,56 +1,56 @@
-/*
-* Copyright (c) Contributors, http://www.openmetaverse.org/
-* See CONTRIBUTORS.TXT for a full list of copyright holders.
-*
-* Redistribution and use in source and binary forms, with or without
-* modification, are permitted provided that the following conditions are met:
-* * Redistributions of source code must retain the above copyright
-* notice, this list of conditions and the following disclaimer.
-* * Redistributions in binary form must reproduce the above copyright
-* notice, this list of conditions and the following disclaimer in the
-* documentation and/or other materials provided with the distribution.
-* * Neither the name of the OpenSim Project nor the
-* names of its contributors may be used to endorse or promote products
-* derived from this software without specific prior written permission.
-*
-* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS AND ANY
-* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
-* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
-* DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
-* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
-* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
-* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
-* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
-* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-*
-*/
-using System.Reflection;
-using System.Runtime.InteropServices;
-// Information about this assembly is defined by the following
-// attributes.
-//
-// change them to the information which is associated with the assembly
-// you compile.
-
-[assembly: AssemblyTitle("BulletXPlugin")]
-[assembly: AssemblyDescription("")]
-[assembly: AssemblyConfiguration("")]
-[assembly: AssemblyCompany("")]
-[assembly: AssemblyProduct("BulletXPlugin")]
-[assembly: AssemblyCopyright("")]
-[assembly: AssemblyTrademark("")]
-[assembly: AssemblyCulture("")]
-
-// This sets the default COM visibility of types in the assembly to invisible.
-// If you need to expose a type to COM, use [ComVisible(true)] on that type.
-[assembly: ComVisible(false)]
-
-// The assembly version has following format :
-//
-// Major.Minor.Build.Revision
-//
-// You can specify all values by your own or you can build default build and revision
-// numbers with the '*' character (the default):
-
-[assembly: AssemblyVersion("1.0.0.0")]
+/*
+* Copyright (c) Contributors, http://www.openmetaverse.org/
+* See CONTRIBUTORS.TXT for a full list of copyright holders.
+*
+* Redistribution and use in source and binary forms, with or without
+* modification, are permitted provided that the following conditions are met:
+* * Redistributions of source code must retain the above copyright
+* notice, this list of conditions and the following disclaimer.
+* * Redistributions in binary form must reproduce the above copyright
+* notice, this list of conditions and the following disclaimer in the
+* documentation and/or other materials provided with the distribution.
+* * Neither the name of the OpenSim Project nor the
+* names of its contributors may be used to endorse or promote products
+* derived from this software without specific prior written permission.
+*
+* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS AND ANY
+* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+* DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
+* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+*
+*/
+using System.Reflection;
+using System.Runtime.InteropServices;
+// Information about this assembly is defined by the following
+// attributes.
+//
+// change them to the information which is associated with the assembly
+// you compile.
+
+[assembly: AssemblyTitle("BulletXPlugin")]
+[assembly: AssemblyDescription("")]
+[assembly: AssemblyConfiguration("")]
+[assembly: AssemblyCompany("")]
+[assembly: AssemblyProduct("BulletXPlugin")]
+[assembly: AssemblyCopyright("")]
+[assembly: AssemblyTrademark("")]
+[assembly: AssemblyCulture("")]
+
+// This sets the default COM visibility of types in the assembly to invisible.
+// If you need to expose a type to COM, use [ComVisible(true)] on that type.
+[assembly: ComVisible(false)]
+
+// The assembly version has following format :
+//
+// Major.Minor.Build.Revision
+//
+// You can specify all values by your own or you can build default build and revision
+// numbers with the '*' character (the default):
+
+[assembly: AssemblyVersion("1.0.0.0")]
diff --git a/OpenSim/Region/Physics/BulletXPlugin/BulletXPlugin.cs b/OpenSim/Region/Physics/BulletXPlugin/BulletXPlugin.cs
index 1ca5efe..383dbc0 100644
--- a/OpenSim/Region/Physics/BulletXPlugin/BulletXPlugin.cs
+++ b/OpenSim/Region/Physics/BulletXPlugin/BulletXPlugin.cs
@@ -1,534 +1,534 @@
-/*
-* Copyright (c) Contributors, http://www.openmetaverse.org/
-* See CONTRIBUTORS.TXT for a full list of copyright holders.
-*
-* Redistribution and use in source and binary forms, with or without
-* modification, are permitted provided that the following conditions are met:
-* * Redistributions of source code must retain the above copyright
-* notice, this list of conditions and the following disclaimer.
-* * Redistributions in binary form must reproduce the above copyright
-* notice, this list of conditions and the following disclaimer in the
-* documentation and/or other materials provided with the distribution.
-* * Neither the name of the OpenSim Project nor the
-* names of its contributors may be used to endorse or promote products
-* derived from this software without specific prior written permission.
-*
-* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS AND ANY
-* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
-* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
-* DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
-* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
-* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
-* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
-* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
-* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-*
-*/
-#region References
-using System;
-using System.Collections.Generic;
-using OpenSim.Physics.Manager;
-using Axiom.Math;
-//Specific References for BulletXPlugin
-using MonoXnaCompactMaths;
-using XnaDevRu.BulletX;
-using XnaDevRu.BulletX.Dynamics;
-#endregion
-
-namespace OpenSim.Region.Physics.BulletXPlugin
-{
- ///
- /// This Class converts objects and types for BulletX
- ///
- public class BulletXConversions
- {
- public static MonoXnaCompactMaths.Vector3 PhysicsVectorToXnaVector3(PhysicsVector physicsVector)
- {
- return new MonoXnaCompactMaths.Vector3(physicsVector.X, physicsVector.Y, physicsVector.Z);
- }
- public static void PhysicsVectorToXnaVector3(PhysicsVector physicsVector, out MonoXnaCompactMaths.Vector3 XnaVector3)
- {
- XnaVector3.X = physicsVector.X;
- XnaVector3.Y = physicsVector.Y;
- XnaVector3.Z = physicsVector.Z;
- }
- public static PhysicsVector XnaVector3ToPhysicsVector(MonoXnaCompactMaths.Vector3 xnaVector3)
- {
- return new PhysicsVector(xnaVector3.X, xnaVector3.Y, xnaVector3.Z);
- }
- /*public static void XnaVector3ToPhysicsVector(MonoXnaCompactMaths.Vector3 xnaVector3, out PhysicsVector physicsVector)
- {
- xnaVector3.X = physicsVector.X;
- xnaVector3.Y = physicsVector.Y;
- xnaVector3.Z = physicsVector.Z;
- }*/
- #region Axiom and Xna
- /////
- ///// BTW maybe some conversions will be a simply converion that it doesn't require this class, but i don't know
- /////
- /////
- /////
- //public static MonoXnaCompactMaths.Vector3 Vector3AxiomToXna(Axiom.Math.Vector3 AxiomVector3)
- //{
- // return new MonoXnaCompactMaths.Vector3(AxiomVector3.x, AxiomVector3.y, AxiomVector3.z);
- //}
- #endregion
- }
- ///
- /// PhysicsPlugin Class for BulletX
- ///
- public class BulletXPlugin : IPhysicsPlugin
- {
- private BulletXScene _mScene;
-
- public BulletXPlugin()
- {
- }
- public bool Init()
- {
- return true;
- }
- public PhysicsScene GetScene()
- {
- if (_mScene == null)
- {
- _mScene = new BulletXScene();
- }
- return (_mScene);
- }
- public string GetName()
- {
- return ("BulletXEngine");
- }
- public void Dispose()
- {
- }
- }
- ///
- /// PhysicsScene Class for BulletX
- ///
- public class BulletXScene : PhysicsScene
- {
- public DiscreteDynamicsWorld ddWorld;
- private CollisionDispatcher cDispatcher;
- private OverlappingPairCache opCache;
- private SequentialImpulseConstraintSolver sicSolver;
-
- private const int minXY = 0;
- private const int minZ = 0;
- private const int maxXY = 256;
- private const int maxZ = 4096;
- private const int maxHandles = 32766; //Why? I don't know
- private static float gravity = 9.8f;
- private static float heightLevel0 = 77.0f;
- private static float heightLevel1 = 200.0f;
- private static float lowGravityFactor = 0.2f;
-
- private float[] _heightmap;
- private List _characters = new List();
-
- public static float Gravity { get { return gravity; } }
- public static float HeightLevel0 { get { return heightLevel0; } }
- public static float HeightLevel1 { get { return heightLevel1; } }
- public static float LowGravityFactor { get { return lowGravityFactor; } }
-
- public BulletXScene()
- {
- cDispatcher = new CollisionDispatcher();
- MonoXnaCompactMaths.Vector3 worldMinDim = new MonoXnaCompactMaths.Vector3((float)minXY, (float)minXY, (float)minZ);
- MonoXnaCompactMaths.Vector3 worldMaxDim = new MonoXnaCompactMaths.Vector3((float)maxXY, (float)maxXY, (float)maxZ);
- opCache = new AxisSweep3(worldMinDim, worldMaxDim, maxHandles);
- sicSolver = new SequentialImpulseConstraintSolver();
-
- ddWorld = new DiscreteDynamicsWorld(cDispatcher, opCache, sicSolver);
- ddWorld.Gravity = new MonoXnaCompactMaths.Vector3(0, 0, -gravity);
-
- this._heightmap = new float[65536];
- }
-
- public override PhysicsActor AddAvatar(PhysicsVector position)
- {
- PhysicsVector pos = new PhysicsVector();
- pos.X = position.X;
- pos.Y = position.Y;
- pos.Z = position.Z + 20;
- BulletXCharacter newAv = new BulletXCharacter(this, pos);
- this._characters.Add(newAv);
- return newAv;
- }
-
- public override void RemoveAvatar(PhysicsActor actor)
- {
-
- }
-
- public override PhysicsActor AddPrim(PhysicsVector position, PhysicsVector size)
- {
- PhysicsVector pos = new PhysicsVector();
- pos.X = position.X;
- pos.Y = position.Y;
- pos.Z = position.Z;
- PhysicsVector siz = new PhysicsVector();
- siz.X = size.X;
- siz.Y = size.Y;
- siz.Z = size.Z;
- return new BulletXPrim();
- }
-
- public override void Simulate(float timeStep)
- {
- foreach (BulletXCharacter actor in _characters)
- {
- actor.Move(timeStep);
-
- }
- ddWorld.StepSimulation(timeStep, 0, timeStep);
- foreach (BulletXCharacter actor in _characters)
- {
- actor.ValidateHeight(this._heightmap[
- (int)Math.Round(actor.RigidBodyHorizontalPosition.x) * 256
- + (int)Math.Round(actor.RigidBodyHorizontalPosition.y)]);
- }
- foreach (BulletXCharacter actor in _characters)
- {
- actor.UpdatePosition();
- }
-
- }
-
- public override void GetResults()
- {
-
- }
-
- public override bool IsThreaded
- {
- get
- {
- return (false); // for now we won't be multithreaded
- }
- }
-
- public override void SetTerrain(float[] heightMap)
- {
- //As the same as ODE, heightmap (x,y) must be swapped for BulletX
- for (int i = 0; i < 65536; i++)
- {
- // this._heightmap[i] = (double)heightMap[i];
- // dbm (danx0r) -- heightmap x,y must be swapped for Ode (should fix ODE, but for now...)
- int x = i & 0xff;
- int y = i >> 8;
- this._heightmap[i] = heightMap[x * 256 + y];
- }
- }
-
- public override void DeleteTerrain()
- {
-
- }
- }
- ///
- /// PhysicsActor Character Class for BulletX
- ///
- public class BulletXCharacter : PhysicsActor
- {
- private PhysicsVector _position;
- private PhysicsVector _velocity;
- private PhysicsVector _acceleration;
- private bool flying;
- private RigidBody rigidBody;
- public Axiom.Math.Vector2 RigidBodyHorizontalPosition
- {
- get
- {
- return new Axiom.Math.Vector2(this.rigidBody.CenterOfMassPosition.X, this.rigidBody.CenterOfMassPosition.Y);
- }
- }
- public BulletXCharacter(BulletXScene parent_scene, PhysicsVector pos)
- {
- _velocity = new PhysicsVector();
- _position = pos;
- _acceleration = new PhysicsVector();
- float _mass = 50.0f; //This depends of avatar's dimensions
- Matrix _startTransform = Matrix.Identity;
- _startTransform.Translation = BulletXConversions.PhysicsVectorToXnaVector3(pos);
- Matrix _centerOfMassOffset = Matrix.Identity;
- CollisionShape _collisionShape = new BoxShape(new MonoXnaCompactMaths.Vector3(0.5f, 0.5f, 1.60f));
- DefaultMotionState _motionState = new DefaultMotionState(_startTransform, _centerOfMassOffset);
- MonoXnaCompactMaths.Vector3 _localInertia = new MonoXnaCompactMaths.Vector3();
- _collisionShape.CalculateLocalInertia(_mass, out _localInertia); //Always when mass > 0
-
- //The next values might change
- float _linearDamping = 0.0f;
- float _angularDamping = 0.0f;
- float _friction = 0.5f;
- float _restitution = 0.0f;
-
- rigidBody = new RigidBody(_mass, _motionState, _collisionShape, _localInertia, _linearDamping, _angularDamping, _friction, _restitution);
- rigidBody.ActivationState = ActivationState.DisableDeactivation;
-
- parent_scene.ddWorld.AddRigidBody(rigidBody);
- }
-
- public override bool Flying
- {
- get
- {
- return flying;
- }
- set
- {
- flying = value;
- }
- }
-
- public override PhysicsVector Position
- {
- get
- {
- return _position;
- }
- set
- {
- _position = value;
- }
- }
-
- public override PhysicsVector Velocity
- {
- get
- {
- return _velocity;
- }
- set
- {
- _velocity = value;
- }
- }
-
- public override bool Kinematic
- {
- get
- {
- return false;
- }
- set
- {
-
- }
- }
-
- public override Axiom.Math.Quaternion Orientation
- {
- get
- {
- return Axiom.Math.Quaternion.Identity;
- }
- set
- {
-
- }
- }
-
- public override PhysicsVector Acceleration
- {
- get
- {
- return _acceleration;
- }
-
- }
- public void SetAcceleration(PhysicsVector accel)
- {
- this._acceleration = accel;
- }
-
- public override void AddForce(PhysicsVector force)
- {
-
- }
-
- public override void SetMomentum(PhysicsVector momentum)
- {
-
- }
-
- public void Move(float timeStep)
- {
- MonoXnaCompactMaths.Vector3 vec = new MonoXnaCompactMaths.Vector3();
- //if (this._velocity.X == 0.0f)
- // vec.X = this.rigidBody.LinearVelocity.X; //current velocity
- //else
- vec.X = this._velocity.X; //overrides current velocity
-
- //if (this._velocity.Y == 0.0f)
- // vec.Y = this.rigidBody.LinearVelocity.Y; //current velocity
- //else
- vec.Y = this._velocity.Y; //overrides current velocity
-
- float nextZVelocity;
- //if (this._velocity.Z == 0.0f)
- // nextZVelocity = this.rigidBody.LinearVelocity.Z; //current velocity
- //else
- nextZVelocity = this._velocity.Z; //overrides current velocity
-
- if (flying)
- {
- //Antigravity with movement
- if (this._position.Z <= BulletXScene.HeightLevel0)
- {
- vec.Z = nextZVelocity + BulletXScene.Gravity * timeStep;
- }
- //Lowgravity with movement
- else if((this._position.Z > BulletXScene.HeightLevel0)
- && (this._position.Z <= BulletXScene.HeightLevel1))
- {
- vec.Z = nextZVelocity + BulletXScene.Gravity * timeStep * (1.0f - BulletXScene.LowGravityFactor);
- }
- //Lowgravity with...
- else if (this._position.Z > BulletXScene.HeightLevel1)
- {
- if(nextZVelocity > 0) //no movement
- vec.Z = BulletXScene.Gravity * timeStep * (1.0f - BulletXScene.LowGravityFactor);
- else
- vec.Z = nextZVelocity + BulletXScene.Gravity * timeStep * (1.0f - BulletXScene.LowGravityFactor);
-
- }
- }
- else
- {
- vec.Z = nextZVelocity;
- }
- rigidBody.LinearVelocity = vec;
- }
-
- public void UpdatePosition()
- {
- this._position = BulletXConversions.XnaVector3ToPhysicsVector(rigidBody.CenterOfMassPosition);
- }
-
- //This validation is very basic
- internal void ValidateHeight(float heighmapPositionValue)
- {
- if (rigidBody.CenterOfMassPosition.Z < heighmapPositionValue)
- {
- Matrix m = rigidBody.WorldTransform;
- MonoXnaCompactMaths.Vector3 v3 = m.Translation;
- v3.Z = heighmapPositionValue;
- m.Translation = v3;
- rigidBody.WorldTransform = m;
- }
- }
- }
- ///
- /// PhysicsActor Prim Class for BulletX
- ///
- public class BulletXPrim : PhysicsActor
- {
- private PhysicsVector _position;
- private PhysicsVector _velocity;
- private PhysicsVector _acceleration;
-
- public BulletXPrim()
- {
- _velocity = new PhysicsVector();
- _position = new PhysicsVector();
- _acceleration = new PhysicsVector();
- }
- public override bool Flying
- {
- get
- {
- return false; //no flying prims for you
- }
- set
- {
-
- }
- }
- public override PhysicsVector Position
- {
- get
- {
- PhysicsVector pos = new PhysicsVector();
- // PhysicsVector vec = this._prim.Position;
- //pos.X = vec.X;
- //pos.Y = vec.Y;
- //pos.Z = vec.Z;
- return pos;
-
- }
- set
- {
- /*PhysicsVector vec = value;
- PhysicsVector pos = new PhysicsVector();
- pos.X = vec.X;
- pos.Y = vec.Y;
- pos.Z = vec.Z;
- this._prim.Position = pos;*/
- }
- }
-
- public override PhysicsVector Velocity
- {
- get
- {
- return _velocity;
- }
- set
- {
- _velocity = value;
- }
- }
-
- public override bool Kinematic
- {
- get
- {
- return false;
- //return this._prim.Kinematic;
- }
- set
- {
- //this._prim.Kinematic = value;
- }
- }
-
- public override Axiom.Math.Quaternion Orientation
- {
- get
- {
- Axiom.Math.Quaternion res = new Axiom.Math.Quaternion();
- return res;
- }
- set
- {
-
- }
- }
-
- public override PhysicsVector Acceleration
- {
- get
- {
- return _acceleration;
- }
-
- }
- public void SetAcceleration(PhysicsVector accel)
- {
- this._acceleration = accel;
- }
-
- public override void AddForce(PhysicsVector force)
- {
-
- }
-
- public override void SetMomentum(PhysicsVector momentum)
- {
-
- }
- }
-}
+/*
+* Copyright (c) Contributors, http://www.openmetaverse.org/
+* See CONTRIBUTORS.TXT for a full list of copyright holders.
+*
+* Redistribution and use in source and binary forms, with or without
+* modification, are permitted provided that the following conditions are met:
+* * Redistributions of source code must retain the above copyright
+* notice, this list of conditions and the following disclaimer.
+* * Redistributions in binary form must reproduce the above copyright
+* notice, this list of conditions and the following disclaimer in the
+* documentation and/or other materials provided with the distribution.
+* * Neither the name of the OpenSim Project nor the
+* names of its contributors may be used to endorse or promote products
+* derived from this software without specific prior written permission.
+*
+* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS AND ANY
+* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+* DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
+* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+*
+*/
+#region References
+using System;
+using System.Collections.Generic;
+using OpenSim.Physics.Manager;
+using Axiom.Math;
+//Specific References for BulletXPlugin
+using MonoXnaCompactMaths;
+using XnaDevRu.BulletX;
+using XnaDevRu.BulletX.Dynamics;
+#endregion
+
+namespace OpenSim.Region.Physics.BulletXPlugin
+{
+ ///
+ /// This Class converts objects and types for BulletX
+ ///
+ public class BulletXConversions
+ {
+ public static MonoXnaCompactMaths.Vector3 PhysicsVectorToXnaVector3(PhysicsVector physicsVector)
+ {
+ return new MonoXnaCompactMaths.Vector3(physicsVector.X, physicsVector.Y, physicsVector.Z);
+ }
+ public static void PhysicsVectorToXnaVector3(PhysicsVector physicsVector, out MonoXnaCompactMaths.Vector3 XnaVector3)
+ {
+ XnaVector3.X = physicsVector.X;
+ XnaVector3.Y = physicsVector.Y;
+ XnaVector3.Z = physicsVector.Z;
+ }
+ public static PhysicsVector XnaVector3ToPhysicsVector(MonoXnaCompactMaths.Vector3 xnaVector3)
+ {
+ return new PhysicsVector(xnaVector3.X, xnaVector3.Y, xnaVector3.Z);
+ }
+ /*public static void XnaVector3ToPhysicsVector(MonoXnaCompactMaths.Vector3 xnaVector3, out PhysicsVector physicsVector)
+ {
+ xnaVector3.X = physicsVector.X;
+ xnaVector3.Y = physicsVector.Y;
+ xnaVector3.Z = physicsVector.Z;
+ }*/
+ #region Axiom and Xna
+ /////
+ ///// BTW maybe some conversions will be a simply converion that it doesn't require this class, but i don't know
+ /////
+ /////
+ /////
+ //public static MonoXnaCompactMaths.Vector3 Vector3AxiomToXna(Axiom.Math.Vector3 AxiomVector3)
+ //{
+ // return new MonoXnaCompactMaths.Vector3(AxiomVector3.x, AxiomVector3.y, AxiomVector3.z);
+ //}
+ #endregion
+ }
+ ///
+ /// PhysicsPlugin Class for BulletX
+ ///
+ public class BulletXPlugin : IPhysicsPlugin
+ {
+ private BulletXScene _mScene;
+
+ public BulletXPlugin()
+ {
+ }
+ public bool Init()
+ {
+ return true;
+ }
+ public PhysicsScene GetScene()
+ {
+ if (_mScene == null)
+ {
+ _mScene = new BulletXScene();
+ }
+ return (_mScene);
+ }
+ public string GetName()
+ {
+ return ("BulletXEngine");
+ }
+ public void Dispose()
+ {
+ }
+ }
+ ///
+ /// PhysicsScene Class for BulletX
+ ///
+ public class BulletXScene : PhysicsScene
+ {
+ public DiscreteDynamicsWorld ddWorld;
+ private CollisionDispatcher cDispatcher;
+ private OverlappingPairCache opCache;
+ private SequentialImpulseConstraintSolver sicSolver;
+
+ private const int minXY = 0;
+ private const int minZ = 0;
+ private const int maxXY = 256;
+ private const int maxZ = 4096;
+ private const int maxHandles = 32766; //Why? I don't know
+ private static float gravity = 9.8f;
+ private static float heightLevel0 = 77.0f;
+ private static float heightLevel1 = 200.0f;
+ private static float lowGravityFactor = 0.2f;
+
+ private float[] _heightmap;
+ private List _characters = new List();
+
+ public static float Gravity { get { return gravity; } }
+ public static float HeightLevel0 { get { return heightLevel0; } }
+ public static float HeightLevel1 { get { return heightLevel1; } }
+ public static float LowGravityFactor { get { return lowGravityFactor; } }
+
+ public BulletXScene()
+ {
+ cDispatcher = new CollisionDispatcher();
+ MonoXnaCompactMaths.Vector3 worldMinDim = new MonoXnaCompactMaths.Vector3((float)minXY, (float)minXY, (float)minZ);
+ MonoXnaCompactMaths.Vector3 worldMaxDim = new MonoXnaCompactMaths.Vector3((float)maxXY, (float)maxXY, (float)maxZ);
+ opCache = new AxisSweep3(worldMinDim, worldMaxDim, maxHandles);
+ sicSolver = new SequentialImpulseConstraintSolver();
+
+ ddWorld = new DiscreteDynamicsWorld(cDispatcher, opCache, sicSolver);
+ ddWorld.Gravity = new MonoXnaCompactMaths.Vector3(0, 0, -gravity);
+
+ this._heightmap = new float[65536];
+ }
+
+ public override PhysicsActor AddAvatar(PhysicsVector position)
+ {
+ PhysicsVector pos = new PhysicsVector();
+ pos.X = position.X;
+ pos.Y = position.Y;
+ pos.Z = position.Z + 20;
+ BulletXCharacter newAv = new BulletXCharacter(this, pos);
+ this._characters.Add(newAv);
+ return newAv;
+ }
+
+ public override void RemoveAvatar(PhysicsActor actor)
+ {
+
+ }
+
+ public override PhysicsActor AddPrim(PhysicsVector position, PhysicsVector size)
+ {
+ PhysicsVector pos = new PhysicsVector();
+ pos.X = position.X;
+ pos.Y = position.Y;
+ pos.Z = position.Z;
+ PhysicsVector siz = new PhysicsVector();
+ siz.X = size.X;
+ siz.Y = size.Y;
+ siz.Z = size.Z;
+ return new BulletXPrim();
+ }
+
+ public override void Simulate(float timeStep)
+ {
+ foreach (BulletXCharacter actor in _characters)
+ {
+ actor.Move(timeStep);
+
+ }
+ ddWorld.StepSimulation(timeStep, 0, timeStep);
+ foreach (BulletXCharacter actor in _characters)
+ {
+ actor.ValidateHeight(this._heightmap[
+ (int)Math.Round(actor.RigidBodyHorizontalPosition.x) * 256
+ + (int)Math.Round(actor.RigidBodyHorizontalPosition.y)]);
+ }
+ foreach (BulletXCharacter actor in _characters)
+ {
+ actor.UpdatePosition();
+ }
+
+ }
+
+ public override void GetResults()
+ {
+
+ }
+
+ public override bool IsThreaded
+ {
+ get
+ {
+ return (false); // for now we won't be multithreaded
+ }
+ }
+
+ public override void SetTerrain(float[] heightMap)
+ {
+ //As the same as ODE, heightmap (x,y) must be swapped for BulletX
+ for (int i = 0; i < 65536; i++)
+ {
+ // this._heightmap[i] = (double)heightMap[i];
+ // dbm (danx0r) -- heightmap x,y must be swapped for Ode (should fix ODE, but for now...)
+ int x = i & 0xff;
+ int y = i >> 8;
+ this._heightmap[i] = heightMap[x * 256 + y];
+ }
+ }
+
+ public override void DeleteTerrain()
+ {
+
+ }
+ }
+ ///
+ /// PhysicsActor Character Class for BulletX
+ ///
+ public class BulletXCharacter : PhysicsActor
+ {
+ private PhysicsVector _position;
+ private PhysicsVector _velocity;
+ private PhysicsVector _acceleration;
+ private bool flying;
+ private RigidBody rigidBody;
+ public Axiom.Math.Vector2 RigidBodyHorizontalPosition
+ {
+ get
+ {
+ return new Axiom.Math.Vector2(this.rigidBody.CenterOfMassPosition.X, this.rigidBody.CenterOfMassPosition.Y);
+ }
+ }
+ public BulletXCharacter(BulletXScene parent_scene, PhysicsVector pos)
+ {
+ _velocity = new PhysicsVector();
+ _position = pos;
+ _acceleration = new PhysicsVector();
+ float _mass = 50.0f; //This depends of avatar's dimensions
+ Matrix _startTransform = Matrix.Identity;
+ _startTransform.Translation = BulletXConversions.PhysicsVectorToXnaVector3(pos);
+ Matrix _centerOfMassOffset = Matrix.Identity;
+ CollisionShape _collisionShape = new BoxShape(new MonoXnaCompactMaths.Vector3(0.5f, 0.5f, 1.60f));
+ DefaultMotionState _motionState = new DefaultMotionState(_startTransform, _centerOfMassOffset);
+ MonoXnaCompactMaths.Vector3 _localInertia = new MonoXnaCompactMaths.Vector3();
+ _collisionShape.CalculateLocalInertia(_mass, out _localInertia); //Always when mass > 0
+
+ //The next values might change
+ float _linearDamping = 0.0f;
+ float _angularDamping = 0.0f;
+ float _friction = 0.5f;
+ float _restitution = 0.0f;
+
+ rigidBody = new RigidBody(_mass, _motionState, _collisionShape, _localInertia, _linearDamping, _angularDamping, _friction, _restitution);
+ rigidBody.ActivationState = ActivationState.DisableDeactivation;
+
+ parent_scene.ddWorld.AddRigidBody(rigidBody);
+ }
+
+ public override bool Flying
+ {
+ get
+ {
+ return flying;
+ }
+ set
+ {
+ flying = value;
+ }
+ }
+
+ public override PhysicsVector Position
+ {
+ get
+ {
+ return _position;
+ }
+ set
+ {
+ _position = value;
+ }
+ }
+
+ public override PhysicsVector Velocity
+ {
+ get
+ {
+ return _velocity;
+ }
+ set
+ {
+ _velocity = value;
+ }
+ }
+
+ public override bool Kinematic
+ {
+ get
+ {
+ return false;
+ }
+ set
+ {
+
+ }
+ }
+
+ public override Axiom.Math.Quaternion Orientation
+ {
+ get
+ {
+ return Axiom.Math.Quaternion.Identity;
+ }
+ set
+ {
+
+ }
+ }
+
+ public override PhysicsVector Acceleration
+ {
+ get
+ {
+ return _acceleration;
+ }
+
+ }
+ public void SetAcceleration(PhysicsVector accel)
+ {
+ this._acceleration = accel;
+ }
+
+ public override void AddForce(PhysicsVector force)
+ {
+
+ }
+
+ public override void SetMomentum(PhysicsVector momentum)
+ {
+
+ }
+
+ public void Move(float timeStep)
+ {
+ MonoXnaCompactMaths.Vector3 vec = new MonoXnaCompactMaths.Vector3();
+ //if (this._velocity.X == 0.0f)
+ // vec.X = this.rigidBody.LinearVelocity.X; //current velocity
+ //else
+ vec.X = this._velocity.X; //overrides current velocity
+
+ //if (this._velocity.Y == 0.0f)
+ // vec.Y = this.rigidBody.LinearVelocity.Y; //current velocity
+ //else
+ vec.Y = this._velocity.Y; //overrides current velocity
+
+ float nextZVelocity;
+ //if (this._velocity.Z == 0.0f)
+ // nextZVelocity = this.rigidBody.LinearVelocity.Z; //current velocity
+ //else
+ nextZVelocity = this._velocity.Z; //overrides current velocity
+
+ if (flying)
+ {
+ //Antigravity with movement
+ if (this._position.Z <= BulletXScene.HeightLevel0)
+ {
+ vec.Z = nextZVelocity + BulletXScene.Gravity * timeStep;
+ }
+ //Lowgravity with movement
+ else if((this._position.Z > BulletXScene.HeightLevel0)
+ && (this._position.Z <= BulletXScene.HeightLevel1))
+ {
+ vec.Z = nextZVelocity + BulletXScene.Gravity * timeStep * (1.0f - BulletXScene.LowGravityFactor);
+ }
+ //Lowgravity with...
+ else if (this._position.Z > BulletXScene.HeightLevel1)
+ {
+ if(nextZVelocity > 0) //no movement
+ vec.Z = BulletXScene.Gravity * timeStep * (1.0f - BulletXScene.LowGravityFactor);
+ else
+ vec.Z = nextZVelocity + BulletXScene.Gravity * timeStep * (1.0f - BulletXScene.LowGravityFactor);
+
+ }
+ }
+ else
+ {
+ vec.Z = nextZVelocity;
+ }
+ rigidBody.LinearVelocity = vec;
+ }
+
+ public void UpdatePosition()
+ {
+ this._position = BulletXConversions.XnaVector3ToPhysicsVector(rigidBody.CenterOfMassPosition);
+ }
+
+ //This validation is very basic
+ internal void ValidateHeight(float heighmapPositionValue)
+ {
+ if (rigidBody.CenterOfMassPosition.Z < heighmapPositionValue)
+ {
+ Matrix m = rigidBody.WorldTransform;
+ MonoXnaCompactMaths.Vector3 v3 = m.Translation;
+ v3.Z = heighmapPositionValue;
+ m.Translation = v3;
+ rigidBody.WorldTransform = m;
+ }
+ }
+ }
+ ///
+ /// PhysicsActor Prim Class for BulletX
+ ///
+ public class BulletXPrim : PhysicsActor
+ {
+ private PhysicsVector _position;
+ private PhysicsVector _velocity;
+ private PhysicsVector _acceleration;
+
+ public BulletXPrim()
+ {
+ _velocity = new PhysicsVector();
+ _position = new PhysicsVector();
+ _acceleration = new PhysicsVector();
+ }
+ public override bool Flying
+ {
+ get
+ {
+ return false; //no flying prims for you
+ }
+ set
+ {
+
+ }
+ }
+ public override PhysicsVector Position
+ {
+ get
+ {
+ PhysicsVector pos = new PhysicsVector();
+ // PhysicsVector vec = this._prim.Position;
+ //pos.X = vec.X;
+ //pos.Y = vec.Y;
+ //pos.Z = vec.Z;
+ return pos;
+
+ }
+ set
+ {
+ /*PhysicsVector vec = value;
+ PhysicsVector pos = new PhysicsVector();
+ pos.X = vec.X;
+ pos.Y = vec.Y;
+ pos.Z = vec.Z;
+ this._prim.Position = pos;*/
+ }
+ }
+
+ public override PhysicsVector Velocity
+ {
+ get
+ {
+ return _velocity;
+ }
+ set
+ {
+ _velocity = value;
+ }
+ }
+
+ public override bool Kinematic
+ {
+ get
+ {
+ return false;
+ //return this._prim.Kinematic;
+ }
+ set
+ {
+ //this._prim.Kinematic = value;
+ }
+ }
+
+ public override Axiom.Math.Quaternion Orientation
+ {
+ get
+ {
+ Axiom.Math.Quaternion res = new Axiom.Math.Quaternion();
+ return res;
+ }
+ set
+ {
+
+ }
+ }
+
+ public override PhysicsVector Acceleration
+ {
+ get
+ {
+ return _acceleration;
+ }
+
+ }
+ public void SetAcceleration(PhysicsVector accel)
+ {
+ this._acceleration = accel;
+ }
+
+ public override void AddForce(PhysicsVector force)
+ {
+
+ }
+
+ public override void SetMomentum(PhysicsVector momentum)
+ {
+
+ }
+ }
+}
diff --git a/OpenSim/Region/Physics/Manager/AssemblyInfo.cs b/OpenSim/Region/Physics/Manager/AssemblyInfo.cs
index 9415db9..27b467f 100644
--- a/OpenSim/Region/Physics/Manager/AssemblyInfo.cs
+++ b/OpenSim/Region/Physics/Manager/AssemblyInfo.cs
@@ -1,56 +1,56 @@
-/*
-* Copyright (c) Contributors, http://www.openmetaverse.org/
-* See CONTRIBUTORS.TXT for a full list of copyright holders.
-*
-* Redistribution and use in source and binary forms, with or without
-* modification, are permitted provided that the following conditions are met:
-* * Redistributions of source code must retain the above copyright
-* notice, this list of conditions and the following disclaimer.
-* * Redistributions in binary form must reproduce the above copyright
-* notice, this list of conditions and the following disclaimer in the
-* documentation and/or other materials provided with the distribution.
-* * Neither the name of the OpenSim Project nor the
-* names of its contributors may be used to endorse or promote products
-* derived from this software without specific prior written permission.
-*
-* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS AND ANY
-* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
-* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
-* DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
-* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
-* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
-* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
-* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
-* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-*
-*/
-using System.Reflection;
-using System.Runtime.InteropServices;
-// Information about this assembly is defined by the following
-// attributes.
-//
-// change them to the information which is associated with the assembly
-// you compile.
-
-[assembly: AssemblyTitle("PhysicsManager")]
-[assembly: AssemblyDescription("")]
-[assembly: AssemblyConfiguration("")]
-[assembly: AssemblyCompany("")]
-[assembly: AssemblyProduct("PhysicsManager")]
-[assembly: AssemblyCopyright("")]
-[assembly: AssemblyTrademark("")]
-[assembly: AssemblyCulture("")]
-
-// This sets the default COM visibility of types in the assembly to invisible.
-// If you need to expose a type to COM, use [ComVisible(true)] on that type.
-[assembly: ComVisible(false)]
-
-// The assembly version has following format :
-//
-// Major.Minor.Build.Revision
-//
-// You can specify all values by your own or you can build default build and revision
-// numbers with the '*' character (the default):
-
-[assembly: AssemblyVersion("1.0.*")]
+/*
+* Copyright (c) Contributors, http://www.openmetaverse.org/
+* See CONTRIBUTORS.TXT for a full list of copyright holders.
+*
+* Redistribution and use in source and binary forms, with or without
+* modification, are permitted provided that the following conditions are met:
+* * Redistributions of source code must retain the above copyright
+* notice, this list of conditions and the following disclaimer.
+* * Redistributions in binary form must reproduce the above copyright
+* notice, this list of conditions and the following disclaimer in the
+* documentation and/or other materials provided with the distribution.
+* * Neither the name of the OpenSim Project nor the
+* names of its contributors may be used to endorse or promote products
+* derived from this software without specific prior written permission.
+*
+* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS AND ANY
+* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+* DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
+* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+*
+*/
+using System.Reflection;
+using System.Runtime.InteropServices;
+// Information about this assembly is defined by the following
+// attributes.
+//
+// change them to the information which is associated with the assembly
+// you compile.
+
+[assembly: AssemblyTitle("PhysicsManager")]
+[assembly: AssemblyDescription("")]
+[assembly: AssemblyConfiguration("")]
+[assembly: AssemblyCompany("")]
+[assembly: AssemblyProduct("PhysicsManager")]
+[assembly: AssemblyCopyright("")]
+[assembly: AssemblyTrademark("")]
+[assembly: AssemblyCulture("")]
+
+// This sets the default COM visibility of types in the assembly to invisible.
+// If you need to expose a type to COM, use [ComVisible(true)] on that type.
+[assembly: ComVisible(false)]
+
+// The assembly version has following format :
+//
+// Major.Minor.Build.Revision
+//
+// You can specify all values by your own or you can build default build and revision
+// numbers with the '*' character (the default):
+
+[assembly: AssemblyVersion("1.0.*")]
diff --git a/OpenSim/Region/Physics/Manager/PhysicsActor.cs b/OpenSim/Region/Physics/Manager/PhysicsActor.cs
index da3b560..2c2c8dd 100644
--- a/OpenSim/Region/Physics/Manager/PhysicsActor.cs
+++ b/OpenSim/Region/Physics/Manager/PhysicsActor.cs
@@ -1,167 +1,167 @@
-/*
-* Copyright (c) Contributors, http://www.openmetaverse.org/
-* See CONTRIBUTORS.TXT for a full list of copyright holders.
-*
-* Redistribution and use in source and binary forms, with or without
-* modification, are permitted provided that the following conditions are met:
-* * Redistributions of source code must retain the above copyright
-* notice, this list of conditions and the following disclaimer.
-* * Redistributions in binary form must reproduce the above copyright
-* notice, this list of conditions and the following disclaimer in the
-* documentation and/or other materials provided with the distribution.
-* * Neither the name of the OpenSim Project nor the
-* names of its contributors may be used to endorse or promote products
-* derived from this software without specific prior written permission.
-*
-* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS AND ANY
-* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
-* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
-* DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
-* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
-* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
-* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
-* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
-* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-*
-*/
-using Axiom.Math;
-
-namespace OpenSim.Physics.Manager
-{
- public delegate void PositionUpdate(PhysicsVector position);
- public delegate void VelocityUpdate(PhysicsVector velocity);
- public delegate void OrientationUpdate(Quaternion orientation);
-
- public abstract class PhysicsActor
- {
- public event PositionUpdate OnPositionUpdate;
- public event VelocityUpdate OnVelocityUpdate;
- public event OrientationUpdate OnOrientationUpdate;
-
- public static PhysicsActor Null
- {
- get
- {
- return new NullPhysicsActor();
- }
- }
-
- public abstract PhysicsVector Position
- {
- get;
- set;
- }
-
- public abstract PhysicsVector Velocity
- {
- get;
- set;
- }
-
- public abstract PhysicsVector Acceleration
- {
- get;
- }
-
- public abstract Quaternion Orientation
- {
- get;
- set;
- }
-
- public abstract bool Flying
- {
- get;
- set;
- }
-
- public abstract bool Kinematic
- {
- get;
- set;
- }
-
- public abstract void AddForce(PhysicsVector force);
-
- public abstract void SetMomentum(PhysicsVector momentum);
- }
-
- public class NullPhysicsActor : PhysicsActor
- {
- public override PhysicsVector Position
- {
- get
- {
- return PhysicsVector.Zero;
- }
- set
- {
- return;
- }
- }
-
- public override PhysicsVector Velocity
- {
- get
- {
- return PhysicsVector.Zero;
- }
- set
- {
- return;
- }
- }
-
- public override Quaternion Orientation
- {
- get
- {
- return Quaternion.Identity;
- }
- set
- {
-
- }
- }
-
- public override PhysicsVector Acceleration
- {
- get { return PhysicsVector.Zero; }
- }
-
- public override bool Flying
- {
- get
- {
- return false;
- }
- set
- {
- return;
- }
- }
-
- public override bool Kinematic
- {
- get
- {
- return true;
- }
- set
- {
- return;
- }
- }
-
- public override void AddForce(PhysicsVector force)
- {
- return;
- }
-
- public override void SetMomentum(PhysicsVector momentum)
- {
- return;
- }
- }
-}
+/*
+* Copyright (c) Contributors, http://www.openmetaverse.org/
+* See CONTRIBUTORS.TXT for a full list of copyright holders.
+*
+* Redistribution and use in source and binary forms, with or without
+* modification, are permitted provided that the following conditions are met:
+* * Redistributions of source code must retain the above copyright
+* notice, this list of conditions and the following disclaimer.
+* * Redistributions in binary form must reproduce the above copyright
+* notice, this list of conditions and the following disclaimer in the
+* documentation and/or other materials provided with the distribution.
+* * Neither the name of the OpenSim Project nor the
+* names of its contributors may be used to endorse or promote products
+* derived from this software without specific prior written permission.
+*
+* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS AND ANY
+* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+* DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
+* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+*
+*/
+using Axiom.Math;
+
+namespace OpenSim.Physics.Manager
+{
+ public delegate void PositionUpdate(PhysicsVector position);
+ public delegate void VelocityUpdate(PhysicsVector velocity);
+ public delegate void OrientationUpdate(Quaternion orientation);
+
+ public abstract class PhysicsActor
+ {
+ public event PositionUpdate OnPositionUpdate;
+ public event VelocityUpdate OnVelocityUpdate;
+ public event OrientationUpdate OnOrientationUpdate;
+
+ public static PhysicsActor Null
+ {
+ get
+ {
+ return new NullPhysicsActor();
+ }
+ }
+
+ public abstract PhysicsVector Position
+ {
+ get;
+ set;
+ }
+
+ public abstract PhysicsVector Velocity
+ {
+ get;
+ set;
+ }
+
+ public abstract PhysicsVector Acceleration
+ {
+ get;
+ }
+
+ public abstract Quaternion Orientation
+ {
+ get;
+ set;
+ }
+
+ public abstract bool Flying
+ {
+ get;
+ set;
+ }
+
+ public abstract bool Kinematic
+ {
+ get;
+ set;
+ }
+
+ public abstract void AddForce(PhysicsVector force);
+
+ public abstract void SetMomentum(PhysicsVector momentum);
+ }
+
+ public class NullPhysicsActor : PhysicsActor
+ {
+ public override PhysicsVector Position
+ {
+ get
+ {
+ return PhysicsVector.Zero;
+ }
+ set
+ {
+ return;
+ }
+ }
+
+ public override PhysicsVector Velocity
+ {
+ get
+ {
+ return PhysicsVector.Zero;
+ }
+ set
+ {
+ return;
+ }
+ }
+
+ public override Quaternion Orientation
+ {
+ get
+ {
+ return Quaternion.Identity;
+ }
+ set
+ {
+
+ }
+ }
+
+ public override PhysicsVector Acceleration
+ {
+ get { return PhysicsVector.Zero; }
+ }
+
+ public override bool Flying
+ {
+ get
+ {
+ return false;
+ }
+ set
+ {
+ return;
+ }
+ }
+
+ public override bool Kinematic
+ {
+ get
+ {
+ return true;
+ }
+ set
+ {
+ return;
+ }
+ }
+
+ public override void AddForce(PhysicsVector force)
+ {
+ return;
+ }
+
+ public override void SetMomentum(PhysicsVector momentum)
+ {
+ return;
+ }
+ }
+}
diff --git a/OpenSim/Region/Physics/Manager/PhysicsManager.cs b/OpenSim/Region/Physics/Manager/PhysicsManager.cs
index 265bce6..7c475e7 100644
--- a/OpenSim/Region/Physics/Manager/PhysicsManager.cs
+++ b/OpenSim/Region/Physics/Manager/PhysicsManager.cs
@@ -1,115 +1,115 @@
-/*
-* Copyright (c) Contributors, http://www.openmetaverse.org/
-* See CONTRIBUTORS.TXT for a full list of copyright holders.
-*
-* Redistribution and use in source and binary forms, with or without
-* modification, are permitted provided that the following conditions are met:
-* * Redistributions of source code must retain the above copyright
-* notice, this list of conditions and the following disclaimer.
-* * Redistributions in binary form must reproduce the above copyright
-* notice, this list of conditions and the following disclaimer in the
-* documentation and/or other materials provided with the distribution.
-* * Neither the name of the OpenSim Project nor the
-* names of its contributors may be used to endorse or promote products
-* derived from this software without specific prior written permission.
-*
-* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS AND ANY
-* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
-* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
-* DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
-* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
-* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
-* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
-* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
-* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-*
-*/
-using System;
-using System.Collections.Generic;
-using System.IO;
-using System.Reflection;
-using OpenSim.Framework.Console;
-
-namespace OpenSim.Physics.Manager
-{
- ///
- /// Description of MyClass.
- ///
- public class PhysicsManager
- {
- private Dictionary _plugins=new Dictionary();
-
- public PhysicsManager()
- {
-
- }
-
- public PhysicsScene GetPhysicsScene(string engineName)
- {
- if (String.IsNullOrEmpty(engineName))
- {
- return PhysicsScene.Null;
- }
-
- if(_plugins.ContainsKey(engineName))
- {
- MainLog.Instance.WriteLine(LogPriority.LOW,"creating "+engineName);
- return _plugins[engineName].GetScene();
- }
- else
- {
- MainLog.Instance.WriteLine(LogPriority.MEDIUM,"couldn't find physicsEngine: {0}",engineName);
- throw new ArgumentException(String.Format("couldn't find physicsEngine: {0}",engineName));
- }
- }
-
- public void LoadPlugins()
- {
- string path = Path.Combine(AppDomain.CurrentDomain.BaseDirectory ,"Physics");
- string[] pluginFiles = Directory.GetFiles(path, "*.dll");
-
-
- for(int i= 0; i
+ /// Description of MyClass.
+ ///
+ public class PhysicsManager
+ {
+ private Dictionary _plugins=new Dictionary();
+
+ public PhysicsManager()
+ {
+
+ }
+
+ public PhysicsScene GetPhysicsScene(string engineName)
+ {
+ if (String.IsNullOrEmpty(engineName))
+ {
+ return PhysicsScene.Null;
+ }
+
+ if(_plugins.ContainsKey(engineName))
+ {
+ MainLog.Instance.WriteLine(LogPriority.LOW,"creating "+engineName);
+ return _plugins[engineName].GetScene();
+ }
+ else
+ {
+ MainLog.Instance.WriteLine(LogPriority.MEDIUM,"couldn't find physicsEngine: {0}",engineName);
+ throw new ArgumentException(String.Format("couldn't find physicsEngine: {0}",engineName));
+ }
+ }
+
+ public void LoadPlugins()
+ {
+ string path = Path.Combine(AppDomain.CurrentDomain.BaseDirectory ,"Physics");
+ string[] pluginFiles = Directory.GetFiles(path, "*.dll");
+
+
+ for(int i= 0; i";
- }
- }
-}
+/*
+* Copyright (c) Contributors, http://www.openmetaverse.org/
+* See CONTRIBUTORS.TXT for a full list of copyright holders.
+*
+* Redistribution and use in source and binary forms, with or without
+* modification, are permitted provided that the following conditions are met:
+* * Redistributions of source code must retain the above copyright
+* notice, this list of conditions and the following disclaimer.
+* * Redistributions in binary form must reproduce the above copyright
+* notice, this list of conditions and the following disclaimer in the
+* documentation and/or other materials provided with the distribution.
+* * Neither the name of the OpenSim Project nor the
+* names of its contributors may be used to endorse or promote products
+* derived from this software without specific prior written permission.
+*
+* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS AND ANY
+* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+* DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
+* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+*
+*/
+namespace OpenSim.Physics.Manager
+{
+ public class PhysicsVector
+ {
+ public float X;
+ public float Y;
+ public float Z;
+
+ public PhysicsVector()
+ {
+
+ }
+
+ public PhysicsVector(float x, float y, float z)
+ {
+ X = x;
+ Y = y;
+ Z = z;
+ }
+
+ public static readonly PhysicsVector Zero = new PhysicsVector(0f, 0f, 0f);
+
+ public override string ToString()
+ {
+ return "<" + this.X + "," + this.Y + "," + this.Z + ">";
+ }
+ }
+}
diff --git a/OpenSim/Region/Physics/OdePlugin/AssemblyInfo.cs b/OpenSim/Region/Physics/OdePlugin/AssemblyInfo.cs
index ee10430..662b75a 100644
--- a/OpenSim/Region/Physics/OdePlugin/AssemblyInfo.cs
+++ b/OpenSim/Region/Physics/OdePlugin/AssemblyInfo.cs
@@ -1,56 +1,56 @@
-/*
-* Copyright (c) Contributors, http://www.openmetaverse.org/
-* See CONTRIBUTORS.TXT for a full list of copyright holders.
-*
-* Redistribution and use in source and binary forms, with or without
-* modification, are permitted provided that the following conditions are met:
-* * Redistributions of source code must retain the above copyright
-* notice, this list of conditions and the following disclaimer.
-* * Redistributions in binary form must reproduce the above copyright
-* notice, this list of conditions and the following disclaimer in the
-* documentation and/or other materials provided with the distribution.
-* * Neither the name of the OpenSim Project nor the
-* names of its contributors may be used to endorse or promote products
-* derived from this software without specific prior written permission.
-*
-* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS AND ANY
-* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
-* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
-* DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
-* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
-* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
-* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
-* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
-* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-*
-*/
-using System.Reflection;
-using System.Runtime.InteropServices;
-// Information about this assembly is defined by the following
-// attributes.
-//
-// change them to the information which is associated with the assembly
-// you compile.
-
-[assembly: AssemblyTitle("RealPhysXplugin")]
-[assembly: AssemblyDescription("")]
-[assembly: AssemblyConfiguration("")]
-[assembly: AssemblyCompany("")]
-[assembly: AssemblyProduct("RealPhysXplugin")]
-[assembly: AssemblyCopyright("")]
-[assembly: AssemblyTrademark("")]
-[assembly: AssemblyCulture("")]
-
-// This sets the default COM visibility of types in the assembly to invisible.
-// If you need to expose a type to COM, use [ComVisible(true)] on that type.
-[assembly: ComVisible(false)]
-
-// The assembly version has following format :
-//
-// Major.Minor.Build.Revision
-//
-// You can specify all values by your own or you can build default build and revision
-// numbers with the '*' character (the default):
-
-[assembly: AssemblyVersion("1.0.*")]
+/*
+* Copyright (c) Contributors, http://www.openmetaverse.org/
+* See CONTRIBUTORS.TXT for a full list of copyright holders.
+*
+* Redistribution and use in source and binary forms, with or without
+* modification, are permitted provided that the following conditions are met:
+* * Redistributions of source code must retain the above copyright
+* notice, this list of conditions and the following disclaimer.
+* * Redistributions in binary form must reproduce the above copyright
+* notice, this list of conditions and the following disclaimer in the
+* documentation and/or other materials provided with the distribution.
+* * Neither the name of the OpenSim Project nor the
+* names of its contributors may be used to endorse or promote products
+* derived from this software without specific prior written permission.
+*
+* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS AND ANY
+* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+* DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
+* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+*
+*/
+using System.Reflection;
+using System.Runtime.InteropServices;
+// Information about this assembly is defined by the following
+// attributes.
+//
+// change them to the information which is associated with the assembly
+// you compile.
+
+[assembly: AssemblyTitle("RealPhysXplugin")]
+[assembly: AssemblyDescription("")]
+[assembly: AssemblyConfiguration("")]
+[assembly: AssemblyCompany("")]
+[assembly: AssemblyProduct("RealPhysXplugin")]
+[assembly: AssemblyCopyright("")]
+[assembly: AssemblyTrademark("")]
+[assembly: AssemblyCulture("")]
+
+// This sets the default COM visibility of types in the assembly to invisible.
+// If you need to expose a type to COM, use [ComVisible(true)] on that type.
+[assembly: ComVisible(false)]
+
+// The assembly version has following format :
+//
+// Major.Minor.Build.Revision
+//
+// You can specify all values by your own or you can build default build and revision
+// numbers with the '*' character (the default):
+
+[assembly: AssemblyVersion("1.0.*")]
diff --git a/OpenSim/Region/Physics/OdePlugin/OdePlugin.cs b/OpenSim/Region/Physics/OdePlugin/OdePlugin.cs
index 2780188..486fa9e 100644
--- a/OpenSim/Region/Physics/OdePlugin/OdePlugin.cs
+++ b/OpenSim/Region/Physics/OdePlugin/OdePlugin.cs
@@ -1,457 +1,457 @@
-/*
-* Copyright (c) Contributors, http://www.openmetaverse.org/
-* See CONTRIBUTORS.TXT for a full list of copyright holders.
-*
-* Redistribution and use in source and binary forms, with or without
-* modification, are permitted provided that the following conditions are met:
-* * Redistributions of source code must retain the above copyright
-* notice, this list of conditions and the following disclaimer.
-* * Redistributions in binary form must reproduce the above copyright
-* notice, this list of conditions and the following disclaimer in the
-* documentation and/or other materials provided with the distribution.
-* * Neither the name of the OpenSim Project nor the
-* names of its contributors may be used to endorse or promote products
-* derived from this software without specific prior written permission.
-*
-* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS AND ANY
-* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
-* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
-* DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
-* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
-* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
-* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
-* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
-* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-*
-*/
-using System;
-using System.Collections.Generic;
-using Axiom.Math;
-using Ode.NET;
-using OpenSim.Physics.Manager;
-
-namespace OpenSim.Region.Physics.OdePlugin
-{
- ///
- /// ODE plugin
- ///
- public class OdePlugin : IPhysicsPlugin
- {
- private OdeScene _mScene;
-
- public OdePlugin()
- {
-
- }
-
- public bool Init()
- {
- return true;
- }
-
- public PhysicsScene GetScene()
- {
- if (_mScene == null)
- {
- _mScene = new OdeScene();
- }
- return (_mScene);
- }
-
- public string GetName()
- {
- return ("OpenDynamicsEngine");
- }
-
- public void Dispose()
- {
-
- }
- }
-
- public class OdeScene : PhysicsScene
- {
- static public IntPtr world;
- static public IntPtr space;
- static private IntPtr contactgroup;
- static private IntPtr LandGeom;
- //static private IntPtr Land;
- private double[] _heightmap;
- static private d.NearCallback nearCallback = near;
- private List _characters = new List();
- private static d.ContactGeom[] contacts = new d.ContactGeom[30];
- private static d.Contact contact;
-
- public OdeScene()
- {
- contact.surface.mode = d.ContactFlags.Bounce | d.ContactFlags.SoftCFM;
- contact.surface.mu = d.Infinity;
- contact.surface.mu2 = 0.0f;
- contact.surface.bounce = 0.1f;
- contact.surface.bounce_vel = 0.1f;
- contact.surface.soft_cfm = 0.01f;
-
- world = d.WorldCreate();
- space = d.HashSpaceCreate(IntPtr.Zero);
- contactgroup = d.JointGroupCreate(0);
- d.WorldSetGravity(world, 0.0f, 0.0f, -0.5f);
- //d.WorldSetCFM(world, 1e-5f);
- d.WorldSetAutoDisableFlag(world, false);
- d.WorldSetContactSurfaceLayer(world, 0.001f);
- // d.CreatePlane(space, 0, 0, 1, 0);
- this._heightmap = new double[65536];
- }
-
- // This function blatantly ripped off from BoxStack.cs
- static private void near(IntPtr space, IntPtr g1, IntPtr g2)
- {
- IntPtr b1 = d.GeomGetBody(g1);
- IntPtr b2 = d.GeomGetBody(g2);
- if (b1 != IntPtr.Zero && b2 != IntPtr.Zero && d.AreConnectedExcluding(b1, b2, d.JointType.Contact))
- return;
-
- int count = d.Collide(g1, g2, 500, contacts, d.ContactGeom.SizeOf);
- for (int i = 0; i < count; ++i)
- {
- contact.geom = contacts[i];
- IntPtr joint = d.JointCreateContact(world, contactgroup, ref contact);
- d.JointAttach(joint, b1, b2);
- }
-
- }
-
- public override PhysicsActor AddAvatar(PhysicsVector position)
- {
- PhysicsVector pos = new PhysicsVector();
- pos.X = position.X;
- pos.Y = position.Y;
- pos.Z = position.Z + 20;
- OdeCharacter newAv = new OdeCharacter(this, pos);
- this._characters.Add(newAv);
- return newAv;
- }
-
- public override void RemoveAvatar(PhysicsActor actor)
- {
-
- }
-
- public override PhysicsActor AddPrim(PhysicsVector position, PhysicsVector size)
- {
- PhysicsVector pos = new PhysicsVector();
- pos.X = position.X;
- pos.Y = position.Y;
- pos.Z = position.Z;
- PhysicsVector siz = new PhysicsVector();
- siz.X = size.X;
- siz.Y = size.Y;
- siz.Z = size.Z;
- return new OdePrim();
- }
-
- public override void Simulate(float timeStep)
- {
- foreach (OdeCharacter actor in _characters)
- {
- actor.Move(timeStep * 5f);
- }
- d.SpaceCollide(space, IntPtr.Zero, nearCallback);
- d.WorldQuickStep(world, timeStep * 5f);
- d.JointGroupEmpty(contactgroup);
- foreach (OdeCharacter actor in _characters)
- {
- actor.UpdatePosition();
- }
-
- }
-
- public override void GetResults()
- {
-
- }
-
- public override bool IsThreaded
- {
- get
- {
- return (false); // for now we won't be multithreaded
- }
- }
-
- public override void SetTerrain(float[] heightMap)
- {
- for (int i = 0; i < 65536; i++)
- {
- // this._heightmap[i] = (double)heightMap[i];
- // dbm (danx0r) -- heightmap x,y must be swapped for Ode (should fix ODE, but for now...)
- int x = i & 0xff;
- int y = i >> 8;
- this._heightmap[i] = (double)heightMap[x * 256 + y];
- }
- IntPtr HeightmapData = d.GeomHeightfieldDataCreate();
- d.GeomHeightfieldDataBuildDouble(HeightmapData, _heightmap, 0, 256, 256, 256, 256, 1.0f, 0.0f, 2.0f, 0);
- d.GeomHeightfieldDataSetBounds(HeightmapData, 256, 256);
- LandGeom = d.CreateHeightfield(space, HeightmapData, 1);
- d.Matrix3 R = new d.Matrix3();
-
- Quaternion q1 =Quaternion.FromAngleAxis(1.5707f, new Vector3(1,0,0));
- Quaternion q2 =Quaternion.FromAngleAxis(1.5707f, new Vector3(0,1,0));
- //Axiom.Math.Quaternion q3 = Axiom.Math.Quaternion.FromAngleAxis(3.14f, new Axiom.Math.Vector3(0, 0, 1));
-
- q1 = q1 * q2;
- //q1 = q1 * q3;
- Vector3 v3 = new Vector3();
- float angle = 0;
- q1.ToAngleAxis(ref angle, ref v3);
-
- d.RFromAxisAndAngle(out R, v3.x, v3.y, v3.z, angle);
- d.GeomSetRotation(LandGeom, ref R);
- d.GeomSetPosition(LandGeom, 128, 128, 0);
- }
-
- public override void DeleteTerrain()
- {
-
- }
- }
-
- public class OdeCharacter : PhysicsActor
- {
- private PhysicsVector _position;
- private PhysicsVector _velocity;
- private PhysicsVector _acceleration;
- private bool flying;
- //private float gravityAccel;
- private IntPtr BoundingCapsule;
- IntPtr capsule_geom;
- d.Mass capsule_mass;
-
- public OdeCharacter(OdeScene parent_scene, PhysicsVector pos)
- {
- _velocity = new PhysicsVector();
- _position = pos;
- _acceleration = new PhysicsVector();
- d.MassSetCapsule(out capsule_mass, 5.0f, 3, 0.5f, 2f);
- capsule_geom = d.CreateCapsule(OdeScene.space, 0.5f, 2f);
- this.BoundingCapsule = d.BodyCreate(OdeScene.world);
- d.BodySetMass(BoundingCapsule, ref capsule_mass);
- d.BodySetPosition(BoundingCapsule, pos.X, pos.Y, pos.Z);
- d.GeomSetBody(capsule_geom, BoundingCapsule);
- }
-
- public override bool Flying
- {
- get
- {
- return flying;
- }
- set
- {
- flying = value;
- }
- }
-
- public override PhysicsVector Position
- {
- get
- {
- return _position;
- }
- set
- {
- _position = value;
- }
- }
-
- public override PhysicsVector Velocity
- {
- get
- {
- return _velocity;
- }
- set
- {
- _velocity = value;
- }
- }
-
- public override bool Kinematic
- {
- get
- {
- return false;
- }
- set
- {
-
- }
- }
-
- public override Quaternion Orientation
- {
- get
- {
- return Quaternion.Identity;
- }
- set
- {
-
- }
- }
-
- public override PhysicsVector Acceleration
- {
- get
- {
- return _acceleration;
- }
-
- }
- public void SetAcceleration(PhysicsVector accel)
- {
- this._acceleration = accel;
- }
-
- public override void AddForce(PhysicsVector force)
- {
-
- }
-
- public override void SetMomentum(PhysicsVector momentum)
- {
-
- }
-
- public void Move(float timeStep)
- {
- PhysicsVector vec = new PhysicsVector();
- vec.X = this._velocity.X * timeStep;
- vec.Y = this._velocity.Y * timeStep;
- if (flying)
- {
- vec.Z = (this._velocity.Z + 0.5f) * timeStep;
- }
- d.BodySetLinearVel(this.BoundingCapsule, vec.X, vec.Y, vec.Z);
- }
-
- public void UpdatePosition()
- {
- d.Vector3 vec = d.BodyGetPosition(BoundingCapsule);
- this._position.X = vec.X;
- this._position.Y = vec.Y;
- this._position.Z = vec.Z+1.0f;
- }
- }
-
- public class OdePrim : PhysicsActor
- {
- private PhysicsVector _position;
- private PhysicsVector _velocity;
- private PhysicsVector _acceleration;
-
- public OdePrim()
- {
- _velocity = new PhysicsVector();
- _position = new PhysicsVector();
- _acceleration = new PhysicsVector();
- }
- public override bool Flying
- {
- get
- {
- return false; //no flying prims for you
- }
- set
- {
-
- }
- }
- public override PhysicsVector Position
- {
- get
- {
- PhysicsVector pos = new PhysicsVector();
- // PhysicsVector vec = this._prim.Position;
- //pos.X = vec.X;
- //pos.Y = vec.Y;
- //pos.Z = vec.Z;
- return pos;
-
- }
- set
- {
- /*PhysicsVector vec = value;
- PhysicsVector pos = new PhysicsVector();
- pos.X = vec.X;
- pos.Y = vec.Y;
- pos.Z = vec.Z;
- this._prim.Position = pos;*/
- }
- }
-
- public override PhysicsVector Velocity
- {
- get
- {
- return _velocity;
- }
- set
- {
- _velocity = value;
- }
- }
-
- public override bool Kinematic
- {
- get
- {
- return false;
- //return this._prim.Kinematic;
- }
- set
- {
- //this._prim.Kinematic = value;
- }
- }
-
- public override Quaternion Orientation
- {
- get
- {
- Quaternion res = new Quaternion();
- return res;
- }
- set
- {
-
- }
- }
-
- public override PhysicsVector Acceleration
- {
- get
- {
- return _acceleration;
- }
-
- }
- public void SetAcceleration(PhysicsVector accel)
- {
- this._acceleration = accel;
- }
-
- public override void AddForce(PhysicsVector force)
- {
-
- }
-
- public override void SetMomentum(PhysicsVector momentum)
- {
-
- }
-
-
- }
-
-}
+/*
+* Copyright (c) Contributors, http://www.openmetaverse.org/
+* See CONTRIBUTORS.TXT for a full list of copyright holders.
+*
+* Redistribution and use in source and binary forms, with or without
+* modification, are permitted provided that the following conditions are met:
+* * Redistributions of source code must retain the above copyright
+* notice, this list of conditions and the following disclaimer.
+* * Redistributions in binary form must reproduce the above copyright
+* notice, this list of conditions and the following disclaimer in the
+* documentation and/or other materials provided with the distribution.
+* * Neither the name of the OpenSim Project nor the
+* names of its contributors may be used to endorse or promote products
+* derived from this software without specific prior written permission.
+*
+* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS AND ANY
+* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+* DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
+* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+*
+*/
+using System;
+using System.Collections.Generic;
+using Axiom.Math;
+using Ode.NET;
+using OpenSim.Physics.Manager;
+
+namespace OpenSim.Region.Physics.OdePlugin
+{
+ ///
+ /// ODE plugin
+ ///
+ public class OdePlugin : IPhysicsPlugin
+ {
+ private OdeScene _mScene;
+
+ public OdePlugin()
+ {
+
+ }
+
+ public bool Init()
+ {
+ return true;
+ }
+
+ public PhysicsScene GetScene()
+ {
+ if (_mScene == null)
+ {
+ _mScene = new OdeScene();
+ }
+ return (_mScene);
+ }
+
+ public string GetName()
+ {
+ return ("OpenDynamicsEngine");
+ }
+
+ public void Dispose()
+ {
+
+ }
+ }
+
+ public class OdeScene : PhysicsScene
+ {
+ static public IntPtr world;
+ static public IntPtr space;
+ static private IntPtr contactgroup;
+ static private IntPtr LandGeom;
+ //static private IntPtr Land;
+ private double[] _heightmap;
+ static private d.NearCallback nearCallback = near;
+ private List _characters = new List();
+ private static d.ContactGeom[] contacts = new d.ContactGeom[30];
+ private static d.Contact contact;
+
+ public OdeScene()
+ {
+ contact.surface.mode = d.ContactFlags.Bounce | d.ContactFlags.SoftCFM;
+ contact.surface.mu = d.Infinity;
+ contact.surface.mu2 = 0.0f;
+ contact.surface.bounce = 0.1f;
+ contact.surface.bounce_vel = 0.1f;
+ contact.surface.soft_cfm = 0.01f;
+
+ world = d.WorldCreate();
+ space = d.HashSpaceCreate(IntPtr.Zero);
+ contactgroup = d.JointGroupCreate(0);
+ d.WorldSetGravity(world, 0.0f, 0.0f, -0.5f);
+ //d.WorldSetCFM(world, 1e-5f);
+ d.WorldSetAutoDisableFlag(world, false);
+ d.WorldSetContactSurfaceLayer(world, 0.001f);
+ // d.CreatePlane(space, 0, 0, 1, 0);
+ this._heightmap = new double[65536];
+ }
+
+ // This function blatantly ripped off from BoxStack.cs
+ static private void near(IntPtr space, IntPtr g1, IntPtr g2)
+ {
+ IntPtr b1 = d.GeomGetBody(g1);
+ IntPtr b2 = d.GeomGetBody(g2);
+ if (b1 != IntPtr.Zero && b2 != IntPtr.Zero && d.AreConnectedExcluding(b1, b2, d.JointType.Contact))
+ return;
+
+ int count = d.Collide(g1, g2, 500, contacts, d.ContactGeom.SizeOf);
+ for (int i = 0; i < count; ++i)
+ {
+ contact.geom = contacts[i];
+ IntPtr joint = d.JointCreateContact(world, contactgroup, ref contact);
+ d.JointAttach(joint, b1, b2);
+ }
+
+ }
+
+ public override PhysicsActor AddAvatar(PhysicsVector position)
+ {
+ PhysicsVector pos = new PhysicsVector();
+ pos.X = position.X;
+ pos.Y = position.Y;
+ pos.Z = position.Z + 20;
+ OdeCharacter newAv = new OdeCharacter(this, pos);
+ this._characters.Add(newAv);
+ return newAv;
+ }
+
+ public override void RemoveAvatar(PhysicsActor actor)
+ {
+
+ }
+
+ public override PhysicsActor AddPrim(PhysicsVector position, PhysicsVector size)
+ {
+ PhysicsVector pos = new PhysicsVector();
+ pos.X = position.X;
+ pos.Y = position.Y;
+ pos.Z = position.Z;
+ PhysicsVector siz = new PhysicsVector();
+ siz.X = size.X;
+ siz.Y = size.Y;
+ siz.Z = size.Z;
+ return new OdePrim();
+ }
+
+ public override void Simulate(float timeStep)
+ {
+ foreach (OdeCharacter actor in _characters)
+ {
+ actor.Move(timeStep * 5f);
+ }
+ d.SpaceCollide(space, IntPtr.Zero, nearCallback);
+ d.WorldQuickStep(world, timeStep * 5f);
+ d.JointGroupEmpty(contactgroup);
+ foreach (OdeCharacter actor in _characters)
+ {
+ actor.UpdatePosition();
+ }
+
+ }
+
+ public override void GetResults()
+ {
+
+ }
+
+ public override bool IsThreaded
+ {
+ get
+ {
+ return (false); // for now we won't be multithreaded
+ }
+ }
+
+ public override void SetTerrain(float[] heightMap)
+ {
+ for (int i = 0; i < 65536; i++)
+ {
+ // this._heightmap[i] = (double)heightMap[i];
+ // dbm (danx0r) -- heightmap x,y must be swapped for Ode (should fix ODE, but for now...)
+ int x = i & 0xff;
+ int y = i >> 8;
+ this._heightmap[i] = (double)heightMap[x * 256 + y];
+ }
+ IntPtr HeightmapData = d.GeomHeightfieldDataCreate();
+ d.GeomHeightfieldDataBuildDouble(HeightmapData, _heightmap, 0, 256, 256, 256, 256, 1.0f, 0.0f, 2.0f, 0);
+ d.GeomHeightfieldDataSetBounds(HeightmapData, 256, 256);
+ LandGeom = d.CreateHeightfield(space, HeightmapData, 1);
+ d.Matrix3 R = new d.Matrix3();
+
+ Quaternion q1 =Quaternion.FromAngleAxis(1.5707f, new Vector3(1,0,0));
+ Quaternion q2 =Quaternion.FromAngleAxis(1.5707f, new Vector3(0,1,0));
+ //Axiom.Math.Quaternion q3 = Axiom.Math.Quaternion.FromAngleAxis(3.14f, new Axiom.Math.Vector3(0, 0, 1));
+
+ q1 = q1 * q2;
+ //q1 = q1 * q3;
+ Vector3 v3 = new Vector3();
+ float angle = 0;
+ q1.ToAngleAxis(ref angle, ref v3);
+
+ d.RFromAxisAndAngle(out R, v3.x, v3.y, v3.z, angle);
+ d.GeomSetRotation(LandGeom, ref R);
+ d.GeomSetPosition(LandGeom, 128, 128, 0);
+ }
+
+ public override void DeleteTerrain()
+ {
+
+ }
+ }
+
+ public class OdeCharacter : PhysicsActor
+ {
+ private PhysicsVector _position;
+ private PhysicsVector _velocity;
+ private PhysicsVector _acceleration;
+ private bool flying;
+ //private float gravityAccel;
+ private IntPtr BoundingCapsule;
+ IntPtr capsule_geom;
+ d.Mass capsule_mass;
+
+ public OdeCharacter(OdeScene parent_scene, PhysicsVector pos)
+ {
+ _velocity = new PhysicsVector();
+ _position = pos;
+ _acceleration = new PhysicsVector();
+ d.MassSetCapsule(out capsule_mass, 5.0f, 3, 0.5f, 2f);
+ capsule_geom = d.CreateCapsule(OdeScene.space, 0.5f, 2f);
+ this.BoundingCapsule = d.BodyCreate(OdeScene.world);
+ d.BodySetMass(BoundingCapsule, ref capsule_mass);
+ d.BodySetPosition(BoundingCapsule, pos.X, pos.Y, pos.Z);
+ d.GeomSetBody(capsule_geom, BoundingCapsule);
+ }
+
+ public override bool Flying
+ {
+ get
+ {
+ return flying;
+ }
+ set
+ {
+ flying = value;
+ }
+ }
+
+ public override PhysicsVector Position
+ {
+ get
+ {
+ return _position;
+ }
+ set
+ {
+ _position = value;
+ }
+ }
+
+ public override PhysicsVector Velocity
+ {
+ get
+ {
+ return _velocity;
+ }
+ set
+ {
+ _velocity = value;
+ }
+ }
+
+ public override bool Kinematic
+ {
+ get
+ {
+ return false;
+ }
+ set
+ {
+
+ }
+ }
+
+ public override Quaternion Orientation
+ {
+ get
+ {
+ return Quaternion.Identity;
+ }
+ set
+ {
+
+ }
+ }
+
+ public override PhysicsVector Acceleration
+ {
+ get
+ {
+ return _acceleration;
+ }
+
+ }
+ public void SetAcceleration(PhysicsVector accel)
+ {
+ this._acceleration = accel;
+ }
+
+ public override void AddForce(PhysicsVector force)
+ {
+
+ }
+
+ public override void SetMomentum(PhysicsVector momentum)
+ {
+
+ }
+
+ public void Move(float timeStep)
+ {
+ PhysicsVector vec = new PhysicsVector();
+ vec.X = this._velocity.X * timeStep;
+ vec.Y = this._velocity.Y * timeStep;
+ if (flying)
+ {
+ vec.Z = (this._velocity.Z + 0.5f) * timeStep;
+ }
+ d.BodySetLinearVel(this.BoundingCapsule, vec.X, vec.Y, vec.Z);
+ }
+
+ public void UpdatePosition()
+ {
+ d.Vector3 vec = d.BodyGetPosition(BoundingCapsule);
+ this._position.X = vec.X;
+ this._position.Y = vec.Y;
+ this._position.Z = vec.Z+1.0f;
+ }
+ }
+
+ public class OdePrim : PhysicsActor
+ {
+ private PhysicsVector _position;
+ private PhysicsVector _velocity;
+ private PhysicsVector _acceleration;
+
+ public OdePrim()
+ {
+ _velocity = new PhysicsVector();
+ _position = new PhysicsVector();
+ _acceleration = new PhysicsVector();
+ }
+ public override bool Flying
+ {
+ get
+ {
+ return false; //no flying prims for you
+ }
+ set
+ {
+
+ }
+ }
+ public override PhysicsVector Position
+ {
+ get
+ {
+ PhysicsVector pos = new PhysicsVector();
+ // PhysicsVector vec = this._prim.Position;
+ //pos.X = vec.X;
+ //pos.Y = vec.Y;
+ //pos.Z = vec.Z;
+ return pos;
+
+ }
+ set
+ {
+ /*PhysicsVector vec = value;
+ PhysicsVector pos = new PhysicsVector();
+ pos.X = vec.X;
+ pos.Y = vec.Y;
+ pos.Z = vec.Z;
+ this._prim.Position = pos;*/
+ }
+ }
+
+ public override PhysicsVector Velocity
+ {
+ get
+ {
+ return _velocity;
+ }
+ set
+ {
+ _velocity = value;
+ }
+ }
+
+ public override bool Kinematic
+ {
+ get
+ {
+ return false;
+ //return this._prim.Kinematic;
+ }
+ set
+ {
+ //this._prim.Kinematic = value;
+ }
+ }
+
+ public override Quaternion Orientation
+ {
+ get
+ {
+ Quaternion res = new Quaternion();
+ return res;
+ }
+ set
+ {
+
+ }
+ }
+
+ public override PhysicsVector Acceleration
+ {
+ get
+ {
+ return _acceleration;
+ }
+
+ }
+ public void SetAcceleration(PhysicsVector accel)
+ {
+ this._acceleration = accel;
+ }
+
+ public override void AddForce(PhysicsVector force)
+ {
+
+ }
+
+ public override void SetMomentum(PhysicsVector momentum)
+ {
+
+ }
+
+
+ }
+
+}
diff --git a/OpenSim/Region/Physics/PhysXPlugin/AssemblyInfo.cs b/OpenSim/Region/Physics/PhysXPlugin/AssemblyInfo.cs
index ee10430..662b75a 100644
--- a/OpenSim/Region/Physics/PhysXPlugin/AssemblyInfo.cs
+++ b/OpenSim/Region/Physics/PhysXPlugin/AssemblyInfo.cs
@@ -1,56 +1,56 @@
-/*
-* Copyright (c) Contributors, http://www.openmetaverse.org/
-* See CONTRIBUTORS.TXT for a full list of copyright holders.
-*
-* Redistribution and use in source and binary forms, with or without
-* modification, are permitted provided that the following conditions are met:
-* * Redistributions of source code must retain the above copyright
-* notice, this list of conditions and the following disclaimer.
-* * Redistributions in binary form must reproduce the above copyright
-* notice, this list of conditions and the following disclaimer in the
-* documentation and/or other materials provided with the distribution.
-* * Neither the name of the OpenSim Project nor the
-* names of its contributors may be used to endorse or promote products
-* derived from this software without specific prior written permission.
-*
-* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS AND ANY
-* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
-* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
-* DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
-* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
-* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
-* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
-* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
-* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-*
-*/
-using System.Reflection;
-using System.Runtime.InteropServices;
-// Information about this assembly is defined by the following
-// attributes.
-//
-// change them to the information which is associated with the assembly
-// you compile.
-
-[assembly: AssemblyTitle("RealPhysXplugin")]
-[assembly: AssemblyDescription("")]
-[assembly: AssemblyConfiguration("")]
-[assembly: AssemblyCompany("")]
-[assembly: AssemblyProduct("RealPhysXplugin")]
-[assembly: AssemblyCopyright("")]
-[assembly: AssemblyTrademark("")]
-[assembly: AssemblyCulture("")]
-
-// This sets the default COM visibility of types in the assembly to invisible.
-// If you need to expose a type to COM, use [ComVisible(true)] on that type.
-[assembly: ComVisible(false)]
-
-// The assembly version has following format :
-//
-// Major.Minor.Build.Revision
-//
-// You can specify all values by your own or you can build default build and revision
-// numbers with the '*' character (the default):
-
-[assembly: AssemblyVersion("1.0.*")]
+/*
+* Copyright (c) Contributors, http://www.openmetaverse.org/
+* See CONTRIBUTORS.TXT for a full list of copyright holders.
+*
+* Redistribution and use in source and binary forms, with or without
+* modification, are permitted provided that the following conditions are met:
+* * Redistributions of source code must retain the above copyright
+* notice, this list of conditions and the following disclaimer.
+* * Redistributions in binary form must reproduce the above copyright
+* notice, this list of conditions and the following disclaimer in the
+* documentation and/or other materials provided with the distribution.
+* * Neither the name of the OpenSim Project nor the
+* names of its contributors may be used to endorse or promote products
+* derived from this software without specific prior written permission.
+*
+* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS AND ANY
+* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+* DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
+* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+*
+*/
+using System.Reflection;
+using System.Runtime.InteropServices;
+// Information about this assembly is defined by the following
+// attributes.
+//
+// change them to the information which is associated with the assembly
+// you compile.
+
+[assembly: AssemblyTitle("RealPhysXplugin")]
+[assembly: AssemblyDescription("")]
+[assembly: AssemblyConfiguration("")]
+[assembly: AssemblyCompany("")]
+[assembly: AssemblyProduct("RealPhysXplugin")]
+[assembly: AssemblyCopyright("")]
+[assembly: AssemblyTrademark("")]
+[assembly: AssemblyCulture("")]
+
+// This sets the default COM visibility of types in the assembly to invisible.
+// If you need to expose a type to COM, use [ComVisible(true)] on that type.
+[assembly: ComVisible(false)]
+
+// The assembly version has following format :
+//
+// Major.Minor.Build.Revision
+//
+// You can specify all values by your own or you can build default build and revision
+// numbers with the '*' character (the default):
+
+[assembly: AssemblyVersion("1.0.*")]
diff --git a/OpenSim/Region/Physics/PhysXPlugin/PhysXPlugin.cs b/OpenSim/Region/Physics/PhysXPlugin/PhysXPlugin.cs
index 4c82549..111d436 100644
--- a/OpenSim/Region/Physics/PhysXPlugin/PhysXPlugin.cs
+++ b/OpenSim/Region/Physics/PhysXPlugin/PhysXPlugin.cs
@@ -1,425 +1,425 @@
-/*/*
-* Copyright (c) Contributors, http://www.openmetaverse.org/
-* See CONTRIBUTORS.TXT for a full list of copyright holders.
-*
-* Redistribution and use in source and binary forms, with or without
-* modification, are permitted provided that the following conditions are met:
-* * Redistributions of source code must retain the above copyright
-* notice, this list of conditions and the following disclaimer.
-* * Redistributions in binary form must reproduce the above copyright
-* notice, this list of conditions and the following disclaimer in the
-* documentation and/or other materials provided with the distribution.
-* * Neither the name of the OpenSim Project nor the
-* names of its contributors may be used to endorse or promote products
-* derived from this software without specific prior written permission.
-*
-* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS AND ANY
-* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
-* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
-* DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
-* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
-* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
-* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
-* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
-* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-*
-*/
-using System;
-using System.Collections.Generic;
-using OpenSim.Physics.Manager;
-using PhysXWrapper;
-using Quaternion=Axiom.Math.Quaternion;
-
-namespace OpenSim.Region.Physics.PhysXPlugin
-{
- ///
- /// Will be the PhysX plugin but for now will be a very basic physics engine
- ///
- public class PhysXPlugin : IPhysicsPlugin
- {
- private PhysXScene _mScene;
-
- public PhysXPlugin()
- {
-
- }
-
- public bool Init()
- {
- return true;
- }
-
- public PhysicsScene GetScene()
- {
- if(_mScene == null)
- {
- _mScene = new PhysXScene();
- }
- return(_mScene);
- }
-
- public string GetName()
- {
- return("RealPhysX");
- }
-
- public void Dispose()
- {
-
- }
- }
-
- public class PhysXScene :PhysicsScene
- {
- private List _characters = new List();
- private List _prims = new List();
- private float[] _heightMap = null;
- private NxPhysicsSDK mySdk;
- private NxScene scene;
-
- public PhysXScene()
- {
- mySdk = NxPhysicsSDK.CreateSDK();
- Console.WriteLine("Sdk created - now creating scene");
- scene = mySdk.CreateScene();
-
- }
-
- public override PhysicsActor AddAvatar(PhysicsVector position)
- {
- Vec3 pos = new Vec3();
- pos.X = position.X;
- pos.Y = position.Y;
- pos.Z = position.Z;
- PhysXCharacter act = new PhysXCharacter( scene.AddCharacter(pos));
- act.Position = position;
- _characters.Add(act);
- return act;
- }
-
- public override void RemoveAvatar(PhysicsActor actor)
- {
-
- }
-
- public override PhysicsActor AddPrim(PhysicsVector position, PhysicsVector size)
- {
- Vec3 pos = new Vec3();
- pos.X = position.X;
- pos.Y = position.Y;
- pos.Z = position.Z;
- Vec3 siz = new Vec3();
- siz.X = size.X;
- siz.Y = size.Y;
- siz.Z = size.Z;
- PhysXPrim act = new PhysXPrim( scene.AddNewBox(pos, siz));
- _prims.Add(act);
- return act;
- }
- public override void Simulate(float timeStep)
- {
- try
- {
- foreach (PhysXCharacter actor in _characters)
- {
- actor.Move(timeStep);
- }
- scene.Simulate(timeStep);
- scene.FetchResults();
- scene.UpdateControllers();
-
- foreach (PhysXCharacter actor in _characters)
- {
- actor.UpdatePosition();
- }
- }
- catch (Exception e)
- {
- Console.WriteLine(e.Message);
- }
-
- }
-
- public override void GetResults()
- {
-
- }
-
- public override bool IsThreaded
- {
- get
- {
- return(false); // for now we won't be multithreaded
- }
- }
-
- public override void SetTerrain(float[] heightMap)
- {
- if (this._heightMap != null)
- {
- Console.WriteLine("PhysX - deleting old terrain");
- this.scene.DeleteTerrain();
- }
- this._heightMap = heightMap;
- this.scene.AddTerrain(heightMap);
- }
-
- public override void DeleteTerrain()
- {
- this.scene.DeleteTerrain();
- }
- }
-
- public class PhysXCharacter : PhysicsActor
- {
- private PhysicsVector _position;
- private PhysicsVector _velocity;
- private PhysicsVector _acceleration;
- private NxCharacter _character;
- private bool flying;
- private float gravityAccel;
-
- public PhysXCharacter(NxCharacter character)
- {
- _velocity = new PhysicsVector();
- _position = new PhysicsVector();
- _acceleration = new PhysicsVector();
- _character = character;
- }
-
- public override bool Flying
- {
- get
- {
- return flying;
- }
- set
- {
- flying = value;
- }
- }
-
- public override PhysicsVector Position
- {
- get
- {
- return _position;
- }
- set
- {
- _position = value;
- Vec3 ps = new Vec3();
- ps.X = value.X;
- ps.Y = value.Y;
- ps.Z = value.Z;
- this._character.Position = ps;
- }
- }
-
- public override PhysicsVector Velocity
- {
- get
- {
- return _velocity;
- }
- set
- {
- _velocity = value;
- }
- }
-
- public override bool Kinematic
- {
- get
- {
- return false;
- }
- set
- {
-
- }
- }
-
- public override Quaternion Orientation
- {
- get
- {
- return Quaternion.Identity;
- }
- set
- {
-
- }
- }
-
- public override PhysicsVector Acceleration
- {
- get
- {
- return _acceleration;
- }
-
- }
- public void SetAcceleration (PhysicsVector accel)
- {
- this._acceleration = accel;
- }
-
- public override void AddForce(PhysicsVector force)
- {
-
- }
-
- public override void SetMomentum(PhysicsVector momentum)
- {
-
- }
-
- public void Move(float timeStep)
- {
- Vec3 vec = new Vec3();
- vec.X = this._velocity.X * timeStep;
- vec.Y = this._velocity.Y * timeStep;
- if(flying)
- {
- vec.Z = ( this._velocity.Z) * timeStep;
- }
- else
- {
- gravityAccel+= -9.8f;
- vec.Z = (gravityAccel + this._velocity.Z) * timeStep;
- }
- int res = this._character.Move(vec);
- if(res == 1)
- {
- gravityAccel = 0;
- }
- }
-
- public void UpdatePosition()
- {
- Vec3 vec = this._character.Position;
- this._position.X = vec.X;
- this._position.Y = vec.Y;
- this._position.Z = vec.Z;
- }
- }
-
- public class PhysXPrim : PhysicsActor
- {
- private PhysicsVector _position;
- private PhysicsVector _velocity;
- private PhysicsVector _acceleration;
- private NxActor _prim;
-
- public PhysXPrim(NxActor prim)
- {
- _velocity = new PhysicsVector();
- _position = new PhysicsVector();
- _acceleration = new PhysicsVector();
- _prim = prim;
- }
- public override bool Flying
- {
- get
- {
- return false; //no flying prims for you
- }
- set
- {
-
- }
- }
- public override PhysicsVector Position
- {
- get
- {
- PhysicsVector pos = new PhysicsVector();
- Vec3 vec = this._prim.Position;
- pos.X = vec.X;
- pos.Y = vec.Y;
- pos.Z = vec.Z;
- return pos;
-
- }
- set
- {
- PhysicsVector vec = value;
- Vec3 pos = new Vec3();
- pos.X = vec.X;
- pos.Y = vec.Y;
- pos.Z = vec.Z;
- this._prim.Position = pos;
- }
- }
-
- public override PhysicsVector Velocity
- {
- get
- {
- return _velocity;
- }
- set
- {
- _velocity = value;
- }
- }
-
- public override bool Kinematic
- {
- get
- {
- return this._prim.Kinematic;
- }
- set
- {
- this._prim.Kinematic = value;
- }
- }
-
- public override Quaternion Orientation
- {
- get
- {
- Quaternion res = new Quaternion();
- PhysXWrapper.Quaternion quat = this._prim.GetOrientation();
- res.w = quat.W;
- res.x = quat.X;
- res.y = quat.Y;
- res.z = quat.Z;
- return res;
- }
- set
- {
-
- }
- }
-
- public override PhysicsVector Acceleration
- {
- get
- {
- return _acceleration;
- }
-
- }
- public void SetAcceleration (PhysicsVector accel)
- {
- this._acceleration = accel;
- }
-
- public override void AddForce(PhysicsVector force)
- {
-
- }
-
- public override void SetMomentum(PhysicsVector momentum)
- {
-
- }
-
-
- }
-
-}
+/*/*
+* Copyright (c) Contributors, http://www.openmetaverse.org/
+* See CONTRIBUTORS.TXT for a full list of copyright holders.
+*
+* Redistribution and use in source and binary forms, with or without
+* modification, are permitted provided that the following conditions are met:
+* * Redistributions of source code must retain the above copyright
+* notice, this list of conditions and the following disclaimer.
+* * Redistributions in binary form must reproduce the above copyright
+* notice, this list of conditions and the following disclaimer in the
+* documentation and/or other materials provided with the distribution.
+* * Neither the name of the OpenSim Project nor the
+* names of its contributors may be used to endorse or promote products
+* derived from this software without specific prior written permission.
+*
+* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS AND ANY
+* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+* DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
+* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+*
+*/
+using System;
+using System.Collections.Generic;
+using OpenSim.Physics.Manager;
+using PhysXWrapper;
+using Quaternion=Axiom.Math.Quaternion;
+
+namespace OpenSim.Region.Physics.PhysXPlugin
+{
+ ///
+ /// Will be the PhysX plugin but for now will be a very basic physics engine
+ ///
+ public class PhysXPlugin : IPhysicsPlugin
+ {
+ private PhysXScene _mScene;
+
+ public PhysXPlugin()
+ {
+
+ }
+
+ public bool Init()
+ {
+ return true;
+ }
+
+ public PhysicsScene GetScene()
+ {
+ if(_mScene == null)
+ {
+ _mScene = new PhysXScene();
+ }
+ return(_mScene);
+ }
+
+ public string GetName()
+ {
+ return("RealPhysX");
+ }
+
+ public void Dispose()
+ {
+
+ }
+ }
+
+ public class PhysXScene :PhysicsScene
+ {
+ private List _characters = new List();
+ private List _prims = new List();
+ private float[] _heightMap = null;
+ private NxPhysicsSDK mySdk;
+ private NxScene scene;
+
+ public PhysXScene()
+ {
+ mySdk = NxPhysicsSDK.CreateSDK();
+ Console.WriteLine("Sdk created - now creating scene");
+ scene = mySdk.CreateScene();
+
+ }
+
+ public override PhysicsActor AddAvatar(PhysicsVector position)
+ {
+ Vec3 pos = new Vec3();
+ pos.X = position.X;
+ pos.Y = position.Y;
+ pos.Z = position.Z;
+ PhysXCharacter act = new PhysXCharacter( scene.AddCharacter(pos));
+ act.Position = position;
+ _characters.Add(act);
+ return act;
+ }
+
+ public override void RemoveAvatar(PhysicsActor actor)
+ {
+
+ }
+
+ public override PhysicsActor AddPrim(PhysicsVector position, PhysicsVector size)
+ {
+ Vec3 pos = new Vec3();
+ pos.X = position.X;
+ pos.Y = position.Y;
+ pos.Z = position.Z;
+ Vec3 siz = new Vec3();
+ siz.X = size.X;
+ siz.Y = size.Y;
+ siz.Z = size.Z;
+ PhysXPrim act = new PhysXPrim( scene.AddNewBox(pos, siz));
+ _prims.Add(act);
+ return act;
+ }
+ public override void Simulate(float timeStep)
+ {
+ try
+ {
+ foreach (PhysXCharacter actor in _characters)
+ {
+ actor.Move(timeStep);
+ }
+ scene.Simulate(timeStep);
+ scene.FetchResults();
+ scene.UpdateControllers();
+
+ foreach (PhysXCharacter actor in _characters)
+ {
+ actor.UpdatePosition();
+ }
+ }
+ catch (Exception e)
+ {
+ Console.WriteLine(e.Message);
+ }
+
+ }
+
+ public override void GetResults()
+ {
+
+ }
+
+ public override bool IsThreaded
+ {
+ get
+ {
+ return(false); // for now we won't be multithreaded
+ }
+ }
+
+ public override void SetTerrain(float[] heightMap)
+ {
+ if (this._heightMap != null)
+ {
+ Console.WriteLine("PhysX - deleting old terrain");
+ this.scene.DeleteTerrain();
+ }
+ this._heightMap = heightMap;
+ this.scene.AddTerrain(heightMap);
+ }
+
+ public override void DeleteTerrain()
+ {
+ this.scene.DeleteTerrain();
+ }
+ }
+
+ public class PhysXCharacter : PhysicsActor
+ {
+ private PhysicsVector _position;
+ private PhysicsVector _velocity;
+ private PhysicsVector _acceleration;
+ private NxCharacter _character;
+ private bool flying;
+ private float gravityAccel;
+
+ public PhysXCharacter(NxCharacter character)
+ {
+ _velocity = new PhysicsVector();
+ _position = new PhysicsVector();
+ _acceleration = new PhysicsVector();
+ _character = character;
+ }
+
+ public override bool Flying
+ {
+ get
+ {
+ return flying;
+ }
+ set
+ {
+ flying = value;
+ }
+ }
+
+ public override PhysicsVector Position
+ {
+ get
+ {
+ return _position;
+ }
+ set
+ {
+ _position = value;
+ Vec3 ps = new Vec3();
+ ps.X = value.X;
+ ps.Y = value.Y;
+ ps.Z = value.Z;
+ this._character.Position = ps;
+ }
+ }
+
+ public override PhysicsVector Velocity
+ {
+ get
+ {
+ return _velocity;
+ }
+ set
+ {
+ _velocity = value;
+ }
+ }
+
+ public override bool Kinematic
+ {
+ get
+ {
+ return false;
+ }
+ set
+ {
+
+ }
+ }
+
+ public override Quaternion Orientation
+ {
+ get
+ {
+ return Quaternion.Identity;
+ }
+ set
+ {
+
+ }
+ }
+
+ public override PhysicsVector Acceleration
+ {
+ get
+ {
+ return _acceleration;
+ }
+
+ }
+ public void SetAcceleration (PhysicsVector accel)
+ {
+ this._acceleration = accel;
+ }
+
+ public override void AddForce(PhysicsVector force)
+ {
+
+ }
+
+ public override void SetMomentum(PhysicsVector momentum)
+ {
+
+ }
+
+ public void Move(float timeStep)
+ {
+ Vec3 vec = new Vec3();
+ vec.X = this._velocity.X * timeStep;
+ vec.Y = this._velocity.Y * timeStep;
+ if(flying)
+ {
+ vec.Z = ( this._velocity.Z) * timeStep;
+ }
+ else
+ {
+ gravityAccel+= -9.8f;
+ vec.Z = (gravityAccel + this._velocity.Z) * timeStep;
+ }
+ int res = this._character.Move(vec);
+ if(res == 1)
+ {
+ gravityAccel = 0;
+ }
+ }
+
+ public void UpdatePosition()
+ {
+ Vec3 vec = this._character.Position;
+ this._position.X = vec.X;
+ this._position.Y = vec.Y;
+ this._position.Z = vec.Z;
+ }
+ }
+
+ public class PhysXPrim : PhysicsActor
+ {
+ private PhysicsVector _position;
+ private PhysicsVector _velocity;
+ private PhysicsVector _acceleration;
+ private NxActor _prim;
+
+ public PhysXPrim(NxActor prim)
+ {
+ _velocity = new PhysicsVector();
+ _position = new PhysicsVector();
+ _acceleration = new PhysicsVector();
+ _prim = prim;
+ }
+ public override bool Flying
+ {
+ get
+ {
+ return false; //no flying prims for you
+ }
+ set
+ {
+
+ }
+ }
+ public override PhysicsVector Position
+ {
+ get
+ {
+ PhysicsVector pos = new PhysicsVector();
+ Vec3 vec = this._prim.Position;
+ pos.X = vec.X;
+ pos.Y = vec.Y;
+ pos.Z = vec.Z;
+ return pos;
+
+ }
+ set
+ {
+ PhysicsVector vec = value;
+ Vec3 pos = new Vec3();
+ pos.X = vec.X;
+ pos.Y = vec.Y;
+ pos.Z = vec.Z;
+ this._prim.Position = pos;
+ }
+ }
+
+ public override PhysicsVector Velocity
+ {
+ get
+ {
+ return _velocity;
+ }
+ set
+ {
+ _velocity = value;
+ }
+ }
+
+ public override bool Kinematic
+ {
+ get
+ {
+ return this._prim.Kinematic;
+ }
+ set
+ {
+ this._prim.Kinematic = value;
+ }
+ }
+
+ public override Quaternion Orientation
+ {
+ get
+ {
+ Quaternion res = new Quaternion();
+ PhysXWrapper.Quaternion quat = this._prim.GetOrientation();
+ res.w = quat.W;
+ res.x = quat.X;
+ res.y = quat.Y;
+ res.z = quat.Z;
+ return res;
+ }
+ set
+ {
+
+ }
+ }
+
+ public override PhysicsVector Acceleration
+ {
+ get
+ {
+ return _acceleration;
+ }
+
+ }
+ public void SetAcceleration (PhysicsVector accel)
+ {
+ this._acceleration = accel;
+ }
+
+ public override void AddForce(PhysicsVector force)
+ {
+
+ }
+
+ public override void SetMomentum(PhysicsVector momentum)
+ {
+
+ }
+
+
+ }
+
+}
--
cgit v1.1