From 318376707de4f5406958239eac069f24ef8ef62a Mon Sep 17 00:00:00 2001 From: Brian McBee Date: Sat, 18 Aug 2007 23:05:02 +0000 Subject: starting to add bits and pieces to physics prims that we will eventually need for collisions. not hooked in yet. --- .../BasicPhysicsPlugin/BasicPhysicsPlugin.cs | 2 +- OpenSim/Region/Physics/Manager/PhysicsScene.cs | 5 ++-- OpenSim/Region/Physics/OdePlugin/OdePlugin.cs | 35 +++++++++++++++++----- OpenSim/Region/Physics/PhysXPlugin/PhysXPlugin.cs | 2 +- 4 files changed, 33 insertions(+), 11 deletions(-) (limited to 'OpenSim/Region') diff --git a/OpenSim/Region/Physics/BasicPhysicsPlugin/BasicPhysicsPlugin.cs b/OpenSim/Region/Physics/BasicPhysicsPlugin/BasicPhysicsPlugin.cs index 6732d98..a990318 100644 --- a/OpenSim/Region/Physics/BasicPhysicsPlugin/BasicPhysicsPlugin.cs +++ b/OpenSim/Region/Physics/BasicPhysicsPlugin/BasicPhysicsPlugin.cs @@ -90,7 +90,7 @@ namespace OpenSim.Region.Physics.BasicPhysicsPlugin } - public override PhysicsActor AddPrim(PhysicsVector position, PhysicsVector size) + public override PhysicsActor AddPrim(PhysicsVector position, PhysicsVector size, Quaternion rotation) { return null; } diff --git a/OpenSim/Region/Physics/Manager/PhysicsScene.cs b/OpenSim/Region/Physics/Manager/PhysicsScene.cs index fb6358a..0e75b04 100644 --- a/OpenSim/Region/Physics/Manager/PhysicsScene.cs +++ b/OpenSim/Region/Physics/Manager/PhysicsScene.cs @@ -26,6 +26,7 @@ * */ using OpenSim.Framework.Console; +using Axiom.Math; namespace OpenSim.Physics.Manager { @@ -43,7 +44,7 @@ namespace OpenSim.Physics.Manager public abstract void RemoveAvatar(PhysicsActor actor); - public abstract PhysicsActor AddPrim(PhysicsVector position, PhysicsVector size); + public abstract PhysicsActor AddPrim(PhysicsVector position, PhysicsVector size, Quaternion rotation); public abstract void Simulate(float timeStep); @@ -73,7 +74,7 @@ namespace OpenSim.Physics.Manager } - public override PhysicsActor AddPrim(PhysicsVector position, PhysicsVector size) + public override PhysicsActor AddPrim(PhysicsVector position, PhysicsVector size, Quaternion rotation) { MainLog.Instance.Verbose("NullPhysicsScene : AddPrim({0},{1})", position, size); return PhysicsActor.Null; diff --git a/OpenSim/Region/Physics/OdePlugin/OdePlugin.cs b/OpenSim/Region/Physics/OdePlugin/OdePlugin.cs index 4b1d3f0..af79e63 100644 --- a/OpenSim/Region/Physics/OdePlugin/OdePlugin.cs +++ b/OpenSim/Region/Physics/OdePlugin/OdePlugin.cs @@ -80,6 +80,7 @@ namespace OpenSim.Region.Physics.OdePlugin private double[] _heightmap; static private d.NearCallback nearCallback = near; private List _characters = new List(); + private List _prims = new List(); private static d.ContactGeom[] contacts = new d.ContactGeom[30]; private static d.Contact contact; @@ -134,7 +135,7 @@ namespace OpenSim.Region.Physics.OdePlugin } - public override PhysicsActor AddPrim(PhysicsVector position, PhysicsVector size) + public override PhysicsActor AddPrim(PhysicsVector position, PhysicsVector size, Quaternion rotation) { PhysicsVector pos = new PhysicsVector(); pos.X = position.X; @@ -144,7 +145,14 @@ namespace OpenSim.Region.Physics.OdePlugin siz.X = size.X; siz.Y = size.Y; siz.Z = size.Z; - return new OdePrim(); + Quaternion rot = new Quaternion(); + rot.w = rotation.w; + rot.x = rotation.x; + rot.y = rotation.y; + rot.z = rotation.z; + OdePrim newPrim = new OdePrim(this, pos, siz, rot); + this._prims.Add(newPrim); + return newPrim; } public override void Simulate(float timeStep) @@ -347,15 +355,29 @@ 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; - public OdePrim() + public OdePrim(OdeScene parent_scene, PhysicsVector pos, PhysicsVector size, Quaternion rotation) { _velocity = new PhysicsVector(); - _position = new PhysicsVector(); + _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; } public override bool Flying { @@ -420,12 +442,11 @@ namespace OpenSim.Region.Physics.OdePlugin { get { - Quaternion res = new Quaternion(); - return res; + return _orientation; } set { - + _orientation = value; } } diff --git a/OpenSim/Region/Physics/PhysXPlugin/PhysXPlugin.cs b/OpenSim/Region/Physics/PhysXPlugin/PhysXPlugin.cs index 111d436..679d233 100644 --- a/OpenSim/Region/Physics/PhysXPlugin/PhysXPlugin.cs +++ b/OpenSim/Region/Physics/PhysXPlugin/PhysXPlugin.cs @@ -103,7 +103,7 @@ namespace OpenSim.Region.Physics.PhysXPlugin } - public override PhysicsActor AddPrim(PhysicsVector position, PhysicsVector size) + public override PhysicsActor AddPrim(PhysicsVector position, PhysicsVector size, Quaternion rotation) { Vec3 pos = new Vec3(); pos.X = position.X; -- cgit v1.1