Add llRotLookat pt1.

avinationmerge
KittoFlora 2009-10-26 00:10:23 +01:00
parent 91084653bd
commit 8428b25939
14 changed files with 296 additions and 31 deletions

View File

@ -1727,6 +1727,45 @@ namespace OpenSim.Region.Framework.Scenes
} }
} }
public void rotLookAt(Quaternion target, float strength, float damping)
{
SceneObjectPart rootpart = m_rootPart;
if (rootpart != null)
{
if (IsAttachment)
{
/*
ScenePresence avatar = m_scene.GetScenePresence(rootpart.AttachedAvatar);
if (avatar != null)
{
Rotate the Av?
} */
}
else
{
if (rootpart.PhysActor != null)
{
rootpart.PhysActor.APIDTarget = new Quaternion(target.X, target.Y, target.Z, target.W);
rootpart.PhysActor.APIDStrength = strength;
rootpart.PhysActor.APIDDamping = damping;
rootpart.PhysActor.APIDActive = true;
}
}
}
}
public void stopLookAt()
{
SceneObjectPart rootpart = m_rootPart;
if (rootpart != null)
{
if (rootpart.PhysActor != null)
{
rootpart.PhysActor.APIDActive = false;
}
}
}
/// <summary> /// <summary>
/// Uses a PID to attempt to clamp the object on the Z axis at the given height over tau seconds. /// Uses a PID to attempt to clamp the object on the Z axis at the given height over tau seconds.
/// </summary> /// </summary>

View File

@ -2188,6 +2188,11 @@ if (m_shape != null) {
ScheduleFullUpdate(); ScheduleFullUpdate();
} }
public void RotLookAt(Quaternion target, float strength, float damping)
{
m_parentGroup.rotLookAt(target, strength, damping);
}
/// <summary> /// <summary>
/// Schedules this prim for a full update /// Schedules this prim for a full update
/// </summary> /// </summary>
@ -2662,6 +2667,13 @@ if (m_shape != null) {
SetText(text); SetText(text);
} }
public void StopLookAt()
{
m_parentGroup.stopLookAt();
m_parentGroup.ScheduleGroupForTerseUpdate();
}
public void StopMoveToTarget() public void StopMoveToTarget()
{ {
m_parentGroup.stopMoveToTarget(); m_parentGroup.stopMoveToTarget();

View File

@ -307,6 +307,26 @@ namespace OpenSim.Region.Physics.BasicPhysicsPlugin
set { return; } set { return; }
} }
public override Quaternion APIDTarget
{
set { return; }
}
public override bool APIDActive
{
set { return; }
}
public override float APIDStrength
{
set { return; }
}
public override float APIDDamping
{
set { return; }
}
public override void SubscribeEvents(int ms) public override void SubscribeEvents(int ms)
{ {
} }

View File

@ -628,6 +628,12 @@ namespace OpenSim.Region.Physics.BulletDotNETPlugin
set { return; } set { return; }
} }
public override Quaternion APIDTarget { set { return; } }
public override bool APIDActive { set { return; } }
public override float APIDStrength { set { return; } }
public override float APIDDamping { set { return; } }
/// <summary> /// <summary>
/// Adds the force supplied to the Target Velocity /// Adds the force supplied to the Target Velocity
/// The PID controller takes this target velocity and tries to make it a reality /// The PID controller takes this target velocity and tries to make it a reality

View File

@ -566,6 +566,11 @@ namespace OpenSim.Region.Physics.BulletDotNETPlugin
public override PIDHoverType PIDHoverType { set { m_PIDHoverType = value; } } public override PIDHoverType PIDHoverType { set { m_PIDHoverType = value; } }
public override float PIDHoverTau { set { m_PIDHoverTau = value; } } public override float PIDHoverTau { set { m_PIDHoverTau = value; } }
public override Quaternion APIDTarget { set { return; } }
public override bool APIDActive { set { return; } }
public override float APIDStrength { set { return; } }
public override float APIDDamping { set { return; } }
public override void AddForce(PhysicsVector force, bool pushforce) public override void AddForce(PhysicsVector force, bool pushforce)
{ {

View File

@ -1236,6 +1236,26 @@ namespace OpenSim.Region.Physics.BulletXPlugin
public override PIDHoverType PIDHoverType { set { return; } } public override PIDHoverType PIDHoverType { set { return; } }
public override float PIDHoverTau { set { return; } } public override float PIDHoverTau { set { return; } }
public override OpenMetaverse.Quaternion APIDTarget
{
set { return; }
}
public override bool APIDActive
{
set { return; }
}
public override float APIDStrength
{
set { return; }
}
public override float APIDDamping
{
set { return; }
}
public override void SubscribeEvents(int ms) public override void SubscribeEvents(int ms)
{ {

View File

@ -230,6 +230,11 @@ namespace OpenSim.Region.Physics.Manager
public abstract PIDHoverType PIDHoverType { set;} public abstract PIDHoverType PIDHoverType { set;}
public abstract float PIDHoverTau { set;} public abstract float PIDHoverTau { set;}
// For RotLookAt
public abstract Quaternion APIDTarget { set;}
public abstract bool APIDActive { set;}
public abstract float APIDStrength { set;}
public abstract float APIDDamping { set;}
public abstract void AddForce(PhysicsVector force, bool pushforce); public abstract void AddForce(PhysicsVector force, bool pushforce);
public abstract void AddAngularForce(PhysicsVector force, bool pushforce); public abstract void AddAngularForce(PhysicsVector force, bool pushforce);
@ -464,6 +469,12 @@ namespace OpenSim.Region.Physics.Manager
public override PIDHoverType PIDHoverType { set { return; } } public override PIDHoverType PIDHoverType { set { return; } }
public override float PIDHoverTau { set { return; } } public override float PIDHoverTau { set { return; } }
public override Quaternion APIDTarget { set { return; } }
public override bool APIDActive { set { return; } }
public override float APIDStrength { set { return; } }
public override float APIDDamping { set { return; } }
public override void SetMomentum(PhysicsVector momentum) public override void SetMomentum(PhysicsVector momentum)
{ {
} }

View File

@ -1206,6 +1206,28 @@ namespace OpenSim.Region.Physics.OdePlugin
public override PIDHoverType PIDHoverType { set { return; } } public override PIDHoverType PIDHoverType { set { return; } }
public override float PIDHoverTau { set { return; } } public override float PIDHoverTau { set { return; } }
public override Quaternion APIDTarget
{
set { return; }
}
public override bool APIDActive
{
set { return; }
}
public override float APIDStrength
{
set { return; }
}
public override float APIDDamping
{
set { return; }
}
public override void SubscribeEvents(int ms) public override void SubscribeEvents(int ms)
{ {
m_requestedUpdateFrequency = ms; m_requestedUpdateFrequency = ms;

View File

@ -119,7 +119,7 @@ namespace OpenSim.Region.Physics.OdePlugin
private float m_VhoverEfficiency = 0f; private float m_VhoverEfficiency = 0f;
private float m_VhoverTimescale = 0f; private float m_VhoverTimescale = 0f;
private float m_VhoverTargetHeight = -1.0f; // if <0 then no hover, else its the current target height private float m_VhoverTargetHeight = -1.0f; // if <0 then no hover, else its the current target height
private float m_VehicleBuoyancy = 0f; //KF: m_VehicleBuoyancy is set by VEHICLE_BUOYANCY for a vehicle. private float m_VehicleBuoyancy = 0f; // Set by VEHICLE_BUOYANCY, for a vehicle.
// Modifies gravity. Slider between -1 (double-gravity) and 1 (full anti-gravity) // Modifies gravity. Slider between -1 (double-gravity) and 1 (full anti-gravity)
// KF: So far I have found no good method to combine a script-requested .Z velocity and gravity. // KF: So far I have found no good method to combine a script-requested .Z velocity and gravity.
// Therefore only m_VehicleBuoyancy=1 (0g) will use the script-requested .Z velocity. // Therefore only m_VehicleBuoyancy=1 (0g) will use the script-requested .Z velocity.

View File

@ -1,15 +1,4 @@
/* /*
* Revised August 26 2009 by Kitto Flora. ODEDynamics.cs replaces
* ODEVehicleSettings.cs. It and ODEPrim.cs are re-organised:
* ODEPrim.cs contains methods dealing with Prim editing, Prim
* characteristics and Kinetic motion.
* ODEDynamics.cs contains methods dealing with Prim Physical motion
* (dynamics) and the associated settings. Old Linear and angular
* motors for dynamic motion have been replace with MoveLinear()
* and MoveAngular(); 'Physical' is used only to switch ODE dynamic
* simualtion on/off; VEHICAL_TYPE_NONE/VEHICAL_TYPE_<other> is to
* switch between 'VEHICLE' parameter use and general dynamics
* settings use.
* Copyright (c) Contributors, http://opensimulator.org/ * Copyright (c) Contributors, http://opensimulator.org/
* See CONTRIBUTORS.TXT for a full list of copyright holders. * See CONTRIBUTORS.TXT for a full list of copyright holders.
* *
@ -34,6 +23,18 @@
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT * 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 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
* Revised August 26 2009 by Kitto Flora. ODEDynamics.cs replaces
* ODEVehicleSettings.cs. It and ODEPrim.cs are re-organised:
* ODEPrim.cs contains methods dealing with Prim editing, Prim
* characteristics and Kinetic motion.
* ODEDynamics.cs contains methods dealing with Prim Physical motion
* (dynamics) and the associated settings. Old Linear and angular
* motors for dynamic motion have been replace with MoveLinear()
* and MoveAngular(); 'Physical' is used only to switch ODE dynamic
* simualtion on/off; VEHICAL_TYPE_NONE/VEHICAL_TYPE_<other> is to
* switch between 'VEHICLE' parameter use and general dynamics
* settings use.
*/ */
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
@ -83,6 +84,14 @@ namespace OpenSim.Region.Physics.OdePlugin
private float PID_G = 25f; private float PID_G = 25f;
private bool m_usePID = false; private bool m_usePID = false;
private Quaternion m_APIDTarget = new Quaternion();
private float m_APIDStrength = 0.5f;
private float m_APIDDamping = 0.5f;
private float APID_D = 35f;
private float APID_G = 25f;
private bool m_useAPID = false;
// KF: These next 7 params apply to llSetHoverHeight(float height, integer water, float tau), // KF: These next 7 params apply to llSetHoverHeight(float height, integer water, float tau),
// and are for non-VEHICLES only. // and are for non-VEHICLES only.
@ -93,7 +102,7 @@ namespace OpenSim.Region.Physics.OdePlugin
private float m_targetHoverHeight = 0f; private float m_targetHoverHeight = 0f;
private float m_groundHeight = 0f; private float m_groundHeight = 0f;
private float m_waterHeight = 0f; private float m_waterHeight = 0f;
private float m_buoyancy = 0f; //KF: m_buoyancy should be set by llSetBuoyancy() for non-vehicle. private float m_buoyancy = 0f; //Set by llSetBuoyancy(), for non-vehicles.
// private float m_tensor = 5f; // private float m_tensor = 5f;
private int body_autodisable_frames = 20; private int body_autodisable_frames = 20;
@ -1586,21 +1595,18 @@ Console.WriteLine(" JointCreateFixed");
//m_log.Info(m_collisionFlags.ToString()); //m_log.Info(m_collisionFlags.ToString());
//KF: m_buoyancy should be set by llSetBuoyancy() for non-vehicle. //KF: m_buoyancy is set by llSetBuoyancy() and is for non-vehicle.
// would come from SceneObjectPart.cs, public void SetBuoyancy(float fvalue) , PhysActor.Buoyancy = fvalue; ??
// m_buoyancy: (unlimited value) <0=Falls fast; 0=1g; 1=0g; >1 = floats up // m_buoyancy: (unlimited value) <0=Falls fast; 0=1g; 1=0g; >1 = floats up
// gravityz multiplier = 1 - m_buoyancy // NB Prims in ODE are no subject to global gravity
fz = _parent_scene.gravityz * (1.0f - m_buoyancy) * m_mass; fz = _parent_scene.gravityz * (1.0f - m_buoyancy) * m_mass; // force = acceleration * mass
if (m_usePID) if (m_usePID)
{ {
//Console.WriteLine("PID " + m_primName); //Console.WriteLine("PID " + m_primName);
// KF - this is for object move? eg. llSetPos() ? // KF - this is for object MoveToTarget.
//if (!d.BodyIsEnabled(Body)) //if (!d.BodyIsEnabled(Body))
//d.BodySetForce(Body, 0f, 0f, 0f); //d.BodySetForce(Body, 0f, 0f, 0f);
// If we're using the PID controller, then we have no gravity
//fz = (-1 * _parent_scene.gravityz) * m_mass; //KF: ?? Prims have no global gravity,so simply...
fz = 0f;
// no lock; for now it's only called from within Simulate() // no lock; for now it's only called from within Simulate()
@ -1744,7 +1750,36 @@ Console.WriteLine(" JointCreateFixed");
// We're flying and colliding with something // We're flying and colliding with something
fz = fz + ((_target_velocity.Z - vel.Z) * (PID_D) * m_mass); fz = fz + ((_target_velocity.Z - vel.Z) * (PID_D) * m_mass);
} }
} } // end m_useHoverPID && !m_usePID
if (m_useAPID)
{
// RotLookAt, apparently overrides all other rotation sources. Inputs:
// Quaternion m_APIDTarget
// float m_APIDStrength // perhaps ratio other forces to lookat force?
// float m_APIDDamping //'seconds to critically damps in'[sic]
// Factors:
// float APID_D
// float APID_G
// get present body rotation
d.Quaternion rot = d.BodyGetQuaternion(Body);
Quaternion rotq = new Quaternion(rot.X, rot.Y, rot.Z, rot.W);
Quaternion rot_diff = Quaternion.Inverse(rotq) * m_APIDTarget;
float diff_angle;
Vector3 diff_axis;
rot_diff.GetAxisAngle(out diff_axis, out diff_angle);
diff_axis.Normalize();
PhysicsVector rotforce = new PhysicsVector(diff_axis.X, diff_axis.Y, diff_axis.Z);
float RLAservo = timestep / m_APIDDamping;
rotforce = rotforce * RLAservo * m_mass;
d.BodyAddTorque(Body, rotforce.X, rotforce.Y, rotforce.Z);
// d.BodySetAngularVel (Body, m_lastAngularVelocity.X, m_lastAngularVelocity.Y, m_lastAngularVelocity.Z);
} // end m_useAPID
fx *= m_mass; fx *= m_mass;
fy *= m_mass; fy *= m_mass;
@ -2779,6 +2814,12 @@ Console.WriteLine(" JointCreateFixed");
public override bool PIDActive { set { m_usePID = value; } } public override bool PIDActive { set { m_usePID = value; } }
public override float PIDTau { set { m_PIDTau = value; } } public override float PIDTau { set { m_PIDTau = value; } }
// For RotLookAt
public override Quaternion APIDTarget { set { m_APIDTarget = value; } }
public override bool APIDActive { set { m_useAPID = value; } }
public override float APIDStrength { set { m_APIDStrength = value; } }
public override float APIDDamping { set { m_APIDDamping = value; } }
public override float PIDHoverHeight { set { m_PIDHoverHeight = value; ; } } public override float PIDHoverHeight { set { m_PIDHoverHeight = value; ; } }
public override bool PIDHoverActive { set { m_useHoverPID = value; } } public override bool PIDHoverActive { set { m_useHoverPID = value; } }
public override PIDHoverType PIDHoverType { set { m_PIDHoverType = value; } } public override PIDHoverType PIDHoverType { set { m_PIDHoverType = value; } }

View File

@ -308,6 +308,27 @@ namespace OpenSim.Region.Physics.POSPlugin
set { return; } set { return; }
} }
public override Quaternion APIDTarget
{
set { return; }
}
public override bool APIDActive
{
set { return; }
}
public override float APIDStrength
{
set { return; }
}
public override float APIDDamping
{
set { return; }
}
public override void SubscribeEvents(int ms) public override void SubscribeEvents(int ms)
{ {
} }

View File

@ -302,6 +302,26 @@ namespace OpenSim.Region.Physics.POSPlugin
{ {
set { return; } set { return; }
} }
public override Quaternion APIDTarget
{
set { return; }
}
public override bool APIDActive
{
set { return; }
}
public override float APIDStrength
{
set { return; }
}
public override float APIDDamping
{
set { return; }
}
public override void SubscribeEvents(int ms) public override void SubscribeEvents(int ms)
{ {

View File

@ -501,6 +501,28 @@ namespace OpenSim.Region.Physics.PhysXPlugin
public override PIDHoverType PIDHoverType { set { return; } } public override PIDHoverType PIDHoverType { set { return; } }
public override float PIDHoverTau { set { return; } } public override float PIDHoverTau { set { return; } }
public override Quaternion APIDTarget
{
set { return; }
}
public override bool APIDActive
{
set { return; }
}
public override float APIDStrength
{
set { return; }
}
public override float APIDDamping
{
set { return; }
}
public override void SubscribeEvents(int ms) public override void SubscribeEvents(int ms)
{ {
@ -783,6 +805,28 @@ namespace OpenSim.Region.Physics.PhysXPlugin
public override PIDHoverType PIDHoverType { set { return; } } public override PIDHoverType PIDHoverType { set { return; } }
public override float PIDHoverTau { set { return; } } public override float PIDHoverTau { set { return; } }
public override Quaternion APIDTarget
{
set { return; }
}
public override bool APIDActive
{
set { return; }
}
public override float APIDStrength
{
set { return; }
}
public override float APIDDamping
{
set { return; }
}
public override void SubscribeEvents(int ms) public override void SubscribeEvents(int ms)
{ {

View File

@ -2695,10 +2695,20 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
llSetRot(rot); llSetRot(rot);
} }
public void llRotLookAt(LSL_Rotation target, double strength, double damping)
{
m_host.AddScriptLPS(1);
// NotImplemented("llRotLookAt");
m_host.RotLookAt(Rot2Quaternion(target), (float)strength, (float)damping);
}
public void llStopLookAt() public void llStopLookAt()
{ {
m_host.AddScriptLPS(1); m_host.AddScriptLPS(1);
NotImplemented("llStopLookAt"); // NotImplemented("llStopLookAt");
m_host.StopLookAt();
} }
public void llSetTimerEvent(double sec) public void llSetTimerEvent(double sec)
@ -3042,12 +3052,6 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
m_host.AddScriptLPS(1); m_host.AddScriptLPS(1);
} }
public void llRotLookAt(LSL_Rotation target, double strength, double damping)
{
m_host.AddScriptLPS(1);
NotImplemented("llRotLookAt");
}
public LSL_Integer llStringLength(string str) public LSL_Integer llStringLength(string str)
{ {
m_host.AddScriptLPS(1); m_host.AddScriptLPS(1);