aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim
diff options
context:
space:
mode:
Diffstat (limited to 'OpenSim')
-rw-r--r--OpenSim/Region/Physics/OdePlugin/OdePlugin.cs53
1 files changed, 49 insertions, 4 deletions
diff --git a/OpenSim/Region/Physics/OdePlugin/OdePlugin.cs b/OpenSim/Region/Physics/OdePlugin/OdePlugin.cs
index ac784cf..e9ac642 100644
--- a/OpenSim/Region/Physics/OdePlugin/OdePlugin.cs
+++ b/OpenSim/Region/Physics/OdePlugin/OdePlugin.cs
@@ -81,8 +81,9 @@ namespace OpenSim.Region.Physics.OdePlugin
81 public class OdeScene : PhysicsScene 81 public class OdeScene : PhysicsScene
82 { 82 {
83 private static float ODE_STEPSIZE = 0.004f; 83 private static float ODE_STEPSIZE = 0.004f;
84 private static bool RENDER_FLAG = false;
84 private IntPtr contactgroup; 85 private IntPtr contactgroup;
85 private IntPtr LandGeom; 86 private IntPtr LandGeom=(IntPtr)0;
86 private double[] _heightmap; 87 private double[] _heightmap;
87 private d.NearCallback nearCallback; 88 private d.NearCallback nearCallback;
88 public d.TriCallback triCallback; 89 public d.TriCallback triCallback;
@@ -316,8 +317,23 @@ namespace OpenSim.Region.Physics.OdePlugin
316 step_time += timeStep; 317 step_time += timeStep;
317 lock (OdeLock) 318 lock (OdeLock)
318 { 319 {
320 if (_characters.Count > 0 & RENDER_FLAG)
321 {
322 Console.WriteLine("RENDER: frame");
323 }
319 foreach (OdePrim p in _prims) 324 foreach (OdePrim p in _prims)
320 { 325 {
326 if (_characters.Count > 0 & RENDER_FLAG)
327 {
328 Vector3 rx, ry, rz;
329 p.Orientation.ToAxes(out rx, out ry, out rz);
330 Console.WriteLine("RENDER: block; " + p.Size.X + ", " + p.Size.Y + ", " + p.Size.Z + "; " +
331 " 0, 0, 1; " + //shape, size, color
332 (p.Position.X - 128.0f) + ", " + (p.Position.Y - 128.0f) + ", " + (p.Position.Z - 33.0f) + "; " + // position
333 rx.x + "," + ry.x + "," + rz.x + ", " + // rotation
334 rx.y + "," + ry.y + "," + rz.y + ", " +
335 rx.z + "," + ry.z + "," + rz.z);
336 }
321 } 337 }
322 int i = 0; 338 int i = 0;
323 while (step_time > 0.0f) 339 while (step_time > 0.0f)
@@ -336,6 +352,29 @@ namespace OpenSim.Region.Physics.OdePlugin
336 foreach (OdeCharacter actor in _characters) 352 foreach (OdeCharacter actor in _characters)
337 { 353 {
338 actor.UpdatePositionAndVelocity(); 354 actor.UpdatePositionAndVelocity();
355 if (RENDER_FLAG)
356 {
357 /// debugging code
358 float Zoff = -33.0f;
359 d.Matrix3 temp = d.BodyGetRotation(actor.Body);
360 Console.WriteLine("RENDER: cylinder; " + // shape
361 OdeCharacter.CAPSULE_RADIUS + ", " + OdeCharacter.CAPSULE_LENGTH + //size
362 "; 0, 1, 0; " + // color
363 (actor.Position.X - 128.0f) + ", " + (actor.Position.Y - 128.0f) + ", " + (actor.Position.Z + Zoff) + "; " + // position
364 temp.M00 + "," + temp.M10 + "," + temp.M20 + ", " + // rotation
365 temp.M01 + "," + temp.M11 + "," + temp.M21 + ", " +
366 temp.M02 + "," + temp.M12 + "," + temp.M22);
367 d.Vector3 caphead; d.BodyGetRelPointPos(actor.Body, 0, 0, OdeCharacter.CAPSULE_LENGTH * .5f, out caphead);
368 d.Vector3 capfoot; d.BodyGetRelPointPos(actor.Body, 0, 0, -OdeCharacter.CAPSULE_LENGTH * .5f, out capfoot);
369 Console.WriteLine("RENDER: sphere; " + OdeCharacter.CAPSULE_RADIUS + // shape, size
370 "; 1, 0, 1; " + //color
371 (caphead.X - 128.0f) + ", " + (caphead.Y - 128.0f) + ", " + (caphead.Z + Zoff) + "; " + // position
372 "1,0,0, 0,1,0, 0,0,1"); // rotation
373 Console.WriteLine("RENDER: sphere; " + OdeCharacter.CAPSULE_RADIUS + // shape, size
374 "; 1, 0, 0; " + //color
375 (capfoot.X - 128.0f) + ", " + (capfoot.Y - 128.0f) + ", " + (capfoot.Z + Zoff) + "; " + // position
376 "1,0,0, 0,1,0, 0,0,1"); // rotation
377 }
339 } 378 }
340 } 379 }
341 } 380 }
@@ -366,6 +405,10 @@ namespace OpenSim.Region.Physics.OdePlugin
366 405
367 lock (OdeLock) 406 lock (OdeLock)
368 { 407 {
408 if (!(LandGeom == (IntPtr)0))
409 {
410 d.SpaceRemove(space, LandGeom);
411 }
369 IntPtr HeightmapData = d.GeomHeightfieldDataCreate(); 412 IntPtr HeightmapData = d.GeomHeightfieldDataCreate();
370 d.GeomHeightfieldDataBuildDouble(HeightmapData, _heightmap, 0, 256, 256, 256, 256, 1.0f, 0.0f, 2.0f, 0); 413 d.GeomHeightfieldDataBuildDouble(HeightmapData, _heightmap, 0, 256, 256, 256, 256, 1.0f, 0.0f, 2.0f, 0);
371 d.GeomHeightfieldDataSetBounds(HeightmapData, 256, 256); 414 d.GeomHeightfieldDataSetBounds(HeightmapData, 256, 256);
@@ -407,6 +450,8 @@ namespace OpenSim.Region.Physics.OdePlugin
407 private static float PID_D=4000.0f; 450 private static float PID_D=4000.0f;
408 private static float PID_P=7000.0f; 451 private static float PID_P=7000.0f;
409 private static float POSTURE_SERVO = 10000.0f; 452 private static float POSTURE_SERVO = 10000.0f;
453 public static float CAPSULE_RADIUS = 0.5f;
454 public static float CAPSULE_LENGTH = 0.9f;
410 private bool flying = false; 455 private bool flying = false;
411 //private float gravityAccel; 456 //private float gravityAccel;
412 public IntPtr Body; 457 public IntPtr Body;
@@ -423,7 +468,7 @@ namespace OpenSim.Region.Physics.OdePlugin
423 _parent_scene = parent_scene; 468 _parent_scene = parent_scene;
424 lock (OdeScene.OdeLock) 469 lock (OdeScene.OdeLock)
425 { 470 {
426 Shell = d.CreateCapsule(parent_scene.space, 0.4f, 1.0f); 471 Shell = d.CreateCapsule(parent_scene.space, CAPSULE_RADIUS, CAPSULE_LENGTH);
427 d.MassSetCapsule(out ShellMass, 50.0f, 3, 0.4f, 1.0f); 472 d.MassSetCapsule(out ShellMass, 50.0f, 3, 0.4f, 1.0f);
428 Body = d.BodyCreate(parent_scene.world); 473 Body = d.BodyCreate(parent_scene.world);
429 d.BodySetMass(Body, ref ShellMass); 474 d.BodySetMass(Body, ref ShellMass);
@@ -628,11 +673,11 @@ namespace OpenSim.Region.Physics.OdePlugin
628 673
629 public class OdePrim : PhysicsActor 674 public class OdePrim : PhysicsActor
630 { 675 {
631 private PhysicsVector _position; 676 public PhysicsVector _position;
632 private PhysicsVector _velocity; 677 private PhysicsVector _velocity;
633 private PhysicsVector _size; 678 private PhysicsVector _size;
634 private PhysicsVector _acceleration; 679 private PhysicsVector _acceleration;
635 private Quaternion _orientation; 680 public Quaternion _orientation;
636 private Mesh _mesh; 681 private Mesh _mesh;
637 private PrimitiveBaseShape _pbs; 682 private PrimitiveBaseShape _pbs;
638 private OdeScene _parent_scene; 683 private OdeScene _parent_scene;