/// <summary>
/// This method returns a vector (displacement) obtained by user input,
/// either from clicking or typing. The input works by asking for a
/// basepoint and then for a second point, which can be typed with absolute
/// or relative coordinates. The difference between the 2 points is returned.
/// </summary>
/// <param name="v">The vector (diplacement) to be returned or Vector3.Empty if
/// no vector could be obtained.</param>
/// <returns>True if a valid vector (displacement) could be obtained, false otherwise.</returns>
public bool GetVector(out Microsoft.DirectX.Vector3 v)
{
Snap.Magnet m1, m2;
// Ask for 1st point
if ((m1 = GetPoint(Culture.Get("getVector1"))) == null)
{
v = Microsoft.DirectX.Vector3.Empty;
return false;
}
// Activate vector Tracking
Tracking.TrackingService ts = TrackingService;
TrackingService = Tracking.VectorTrackingService.Instance;
Microsoft.DirectX.Vector3 origin = m1.SnapPositionInt;
TrackingService.SetPoint(origin);
SnapPrimaryPoint = new Canguro.Controller.Snap.PointMagnet(origin, Canguro.Controller.Snap.PointMagnetType.SimplePoint);
// Ask for 2nd point
if ((m2 = GetPoint(Culture.Get("getVector2"))) == null)
{
v = Microsoft.DirectX.Vector3.Empty;
TrackingService = ts;
return false;
}
SnapPrimaryPoint = new Canguro.Controller.Snap.PointMagnet(m2.SnapPositionInt, Canguro.Controller.Snap.PointMagnetType.SimplePoint);
// Calculate and return difference
v = m2.SnapPositionInt - origin;
Model.UnitSystem.UnitSystem us = Canguro.Model.UnitSystem.UnitSystemsManager.Instance.CurrentSystem;
v.X = us.FromInternational(v.X, Canguro.Model.UnitSystem.Units.Distance);
v.Y = us.FromInternational(v.Y, Canguro.Model.UnitSystem.Units.Distance);
v.Z = us.FromInternational(v.Z, Canguro.Model.UnitSystem.Units.Distance);
TrackingService = ts;
return true;
}