From 75f6c3d36455fa542e67c16a96c1fda61e9956d5 Mon Sep 17 00:00:00 2001 From: Brian McBee Date: Sun, 19 Aug 2007 06:14:36 +0000 Subject: More prep work for adding prims to ODE physics --- .../BasicPhysicsPlugin/BasicPhysicsPlugin.cs | 11 ++++ OpenSim/Region/Physics/Manager/PhysicsActor.cs | 18 ++++++ OpenSim/Region/Physics/OdePlugin/OdePlugin.cs | 75 +++++++++++++--------- OpenSim/Region/Physics/PhysXPlugin/PhysXPlugin.cs | 25 +++++++- 4 files changed, 96 insertions(+), 33 deletions(-) (limited to 'OpenSim/Region/Physics') diff --git a/OpenSim/Region/Physics/BasicPhysicsPlugin/BasicPhysicsPlugin.cs b/OpenSim/Region/Physics/BasicPhysicsPlugin/BasicPhysicsPlugin.cs index a990318..92b6929 100644 --- a/OpenSim/Region/Physics/BasicPhysicsPlugin/BasicPhysicsPlugin.cs +++ b/OpenSim/Region/Physics/BasicPhysicsPlugin/BasicPhysicsPlugin.cs @@ -203,6 +203,17 @@ namespace OpenSim.Region.Physics.BasicPhysicsPlugin } } + public override PhysicsVector Size + { + get + { + return new PhysicsVector(0, 0, 0); + } + set + { + } + } + public override PhysicsVector Velocity { get diff --git a/OpenSim/Region/Physics/Manager/PhysicsActor.cs b/OpenSim/Region/Physics/Manager/PhysicsActor.cs index d0faf02..ed987b0 100644 --- a/OpenSim/Region/Physics/Manager/PhysicsActor.cs +++ b/OpenSim/Region/Physics/Manager/PhysicsActor.cs @@ -49,6 +49,12 @@ namespace OpenSim.Physics.Manager } } + public abstract PhysicsVector Size + { + get; + set; + } + public abstract PhysicsVector Position { get; @@ -103,6 +109,18 @@ namespace OpenSim.Physics.Manager } } + public override PhysicsVector Size + { + get + { + return PhysicsVector.Zero; + } + set + { + return; + } + } + public override PhysicsVector Velocity { get diff --git a/OpenSim/Region/Physics/OdePlugin/OdePlugin.cs b/OpenSim/Region/Physics/OdePlugin/OdePlugin.cs index af79e63..397ba6d 100644 --- a/OpenSim/Region/Physics/OdePlugin/OdePlugin.cs +++ b/OpenSim/Region/Physics/OdePlugin/OdePlugin.cs @@ -272,6 +272,18 @@ namespace OpenSim.Region.Physics.OdePlugin } } + public override PhysicsVector Size + { + get + { + return new PhysicsVector(0,0,0); + } + set + { + } + } + + public override PhysicsVector Velocity { get @@ -355,15 +367,12 @@ namespace OpenSim.Region.Physics.OdePlugin public class OdePrim : PhysicsActor { - private PhysicsVector _position; private PhysicsVector _velocity; private PhysicsVector _size; private PhysicsVector _acceleration; private Quaternion _orientation; - private IntPtr BoundingCapsule; - IntPtr capsule_geom; - d.Mass capsule_mass; + IntPtr prim_geom; public OdePrim(OdeScene parent_scene, PhysicsVector pos, PhysicsVector size, Quaternion rotation) { @@ -371,14 +380,17 @@ namespace OpenSim.Region.Physics.OdePlugin _position = pos; _size = size; _acceleration = new PhysicsVector(); - d.MassSetCapsule(out capsule_mass, 50.0f, 3, 0.5f, 2f); - capsule_geom = d.CreateBox(OdeScene.space, _size.X, _size.Y, _size.Z); - 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); _orientation = rotation; + prim_geom = d.CreateBox(OdeScene.space, _size.X, _size.Y, _size.Z); + d.GeomSetPosition(prim_geom, _position.X, _position.Y, _position.Z); + d.Quaternion myrot = new d.Quaternion(); + myrot.W = rotation.w; + myrot.X = rotation.x; + myrot.Y = rotation.y; + myrot.Z = rotation.z; + d.GeomSetQuaternion(prim_geom, ref myrot); } + public override bool Flying { get @@ -387,29 +399,31 @@ namespace OpenSim.Region.Physics.OdePlugin } 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; + return _position; + } + set + { + _position = value; + d.GeomSetPosition(prim_geom, _position.X, _position.Y, _position.Z); + } + } + public override PhysicsVector Size + { + get + { + return _size; } set { - /*PhysicsVector vec = value; - PhysicsVector pos = new PhysicsVector(); - pos.X = vec.X; - pos.Y = vec.Y; - pos.Z = vec.Z; - this._prim.Position = pos;*/ + _size = value; } } @@ -430,11 +444,9 @@ namespace OpenSim.Region.Physics.OdePlugin get { return false; - //return this._prim.Kinematic; } set { - //this._prim.Kinematic = value; } } @@ -447,6 +459,12 @@ namespace OpenSim.Region.Physics.OdePlugin set { _orientation = value; + d.Quaternion myrot = new d.Quaternion(); + myrot.W = _orientation.w; + myrot.X = _orientation.x; + myrot.Y = _orientation.y; + myrot.Z = _orientation.z; + d.GeomSetQuaternion(prim_geom, ref myrot); } } @@ -456,8 +474,8 @@ namespace OpenSim.Region.Physics.OdePlugin { return _acceleration; } - } + public void SetAcceleration(PhysicsVector accel) { this._acceleration = accel; @@ -465,15 +483,10 @@ namespace OpenSim.Region.Physics.OdePlugin public override void AddForce(PhysicsVector force) { - } public override void SetMomentum(PhysicsVector momentum) { - } - - } - } diff --git a/OpenSim/Region/Physics/PhysXPlugin/PhysXPlugin.cs b/OpenSim/Region/Physics/PhysXPlugin/PhysXPlugin.cs index 679d233..f86eedf 100644 --- a/OpenSim/Region/Physics/PhysXPlugin/PhysXPlugin.cs +++ b/OpenSim/Region/Physics/PhysXPlugin/PhysXPlugin.cs @@ -216,7 +216,17 @@ namespace OpenSim.Region.Physics.PhysXPlugin this._character.Position = ps; } } - + + public override PhysicsVector Size + { + get + { + return new PhysicsVector(0,0,0); + } + set + { + } + } public override PhysicsVector Velocity { get @@ -353,7 +363,18 @@ namespace OpenSim.Region.Physics.PhysXPlugin this._prim.Position = pos; } } - + + public override PhysicsVector Size + { + get + { + return new PhysicsVector(0, 0, 0); + } + set + { + } + } + public override PhysicsVector Velocity { get -- cgit v1.1