Update Sensor/SensorComponent documentation
This commit is contained in:
parent
704559e150
commit
54cb265be1
@ -13,8 +13,9 @@ namespace Passer {
|
|||||||
|
|
||||||
public virtual string name { get { return ""; } }
|
public virtual string name { get { return ""; } }
|
||||||
|
|
||||||
//public Transform sensorTransform;
|
/// <summary>
|
||||||
|
/// The sensor used for tracking
|
||||||
|
/// </summary>
|
||||||
public SensorComponent sensorComponent;
|
public SensorComponent sensorComponent;
|
||||||
|
|
||||||
public virtual void Start(Transform targetTransform) {
|
public virtual void Start(Transform targetTransform) {
|
||||||
@ -30,9 +31,6 @@ namespace Passer {
|
|||||||
if (sensorComponent == null)
|
if (sensorComponent == null)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
//if (sensorTransform == null)
|
|
||||||
// return;
|
|
||||||
|
|
||||||
if (!Application.isPlaying)
|
if (!Application.isPlaying)
|
||||||
sensorComponent.gameObject.SetActive(shown);
|
sensorComponent.gameObject.SetActive(shown);
|
||||||
|
|
||||||
|
@ -2,17 +2,43 @@
|
|||||||
|
|
||||||
namespace Passer.Tracking {
|
namespace Passer.Tracking {
|
||||||
|
|
||||||
public class SensorComponent : MonoBehaviour {
|
/// <summary>
|
||||||
|
/// A sensor component is used to add tracking to a transform
|
||||||
|
/// </summary>
|
||||||
|
/// Custom sensor implementation can be made by deriving from this class.
|
||||||
|
public abstract class SensorComponent : MonoBehaviour {
|
||||||
|
/// <summary>
|
||||||
|
/// The transform which is used as the root of the tracking space
|
||||||
|
/// </summary>
|
||||||
protected Transform trackerTransform;
|
protected Transform trackerTransform;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// The tracking status of the sensor
|
||||||
|
/// </summary>
|
||||||
public Tracker.Status status;
|
public Tracker.Status status;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// The confidence (0..1) of the tracked rotation
|
||||||
|
/// </summary>
|
||||||
public float rotationConfidence;
|
public float rotationConfidence;
|
||||||
|
/// <summary>
|
||||||
|
/// The confidence (0..1) of the tracked position
|
||||||
|
/// </summary>
|
||||||
public float positionConfidence;
|
public float positionConfidence;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Is used to set whether the sensor updates itself
|
||||||
|
/// </summary>
|
||||||
|
/// When enabled, the sensor will update itself.
|
||||||
|
/// When disabled, StartComponent and UpdateComponent need to be called to update the tracking status.
|
||||||
public bool autoUpdate = true;
|
public bool autoUpdate = true;
|
||||||
|
|
||||||
protected bool _show;
|
protected bool _show;
|
||||||
|
/// <summary>
|
||||||
|
/// The render status of the sensor
|
||||||
|
/// </summary>
|
||||||
|
/// When enabled, sensors with renderers attached will be rendered.
|
||||||
|
/// When disabled, sensors will not be rendered.
|
||||||
public virtual bool show {
|
public virtual bool show {
|
||||||
set {
|
set {
|
||||||
if (value == true && !_show) {
|
if (value == true && !_show) {
|
||||||
@ -31,6 +57,9 @@ namespace Passer.Tracking {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Enable or disable the renderers for this sensor.
|
||||||
|
/// </summary>
|
||||||
protected bool renderController {
|
protected bool renderController {
|
||||||
set {
|
set {
|
||||||
Renderer[] renderers = this.GetComponentsInChildren<Renderer>();
|
Renderer[] renderers = this.GetComponentsInChildren<Renderer>();
|
||||||
@ -39,33 +68,50 @@ namespace Passer.Tracking {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Initializes the sensor.
|
||||||
|
/// </summary>
|
||||||
|
/// When trackerTransform is null, it will be set automatically to the parent of this transform.
|
||||||
virtual protected void Awake() {
|
virtual protected void Awake() {
|
||||||
if (trackerTransform == null)
|
if (trackerTransform == null)
|
||||||
trackerTransform = transform.parent;
|
trackerTransform = transform.parent;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Starts the sensor
|
||||||
|
/// </summary>
|
||||||
|
/// Does nothing at this moment.
|
||||||
virtual protected void Start() {
|
virtual protected void Start() {
|
||||||
//if (autoUpdate)
|
|
||||||
// StartComponent(trackerTransform);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Start the manual updating of the sensor.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="trackerTransform"></param>
|
||||||
|
/// When this function has been called, autoUpdate will be disabled and the sensor will no longer update from Unity Updates.
|
||||||
|
/// Instead, UpdateComponent needs to be called to update the sensor data
|
||||||
public virtual void StartComponent(Transform trackerTransform) {
|
public virtual void StartComponent(Transform trackerTransform) {
|
||||||
// When this function has been called, the sensor will no longer update from Unity Updates.
|
|
||||||
// Instead, UpdateComponent needs to be called to update the sensor data
|
|
||||||
autoUpdate = false;
|
autoUpdate = false;
|
||||||
this.trackerTransform = trackerTransform;
|
this.trackerTransform = trackerTransform;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Updates the sensor
|
||||||
|
/// </summary>
|
||||||
|
/// When autoUpdate is enabled, this will call UpdateComponent.
|
||||||
private void Update() {
|
private void Update() {
|
||||||
if (autoUpdate)
|
if (autoUpdate)
|
||||||
UpdateComponent();
|
UpdateComponent();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Update the component manually
|
||||||
|
/// </summary>
|
||||||
|
/// This function is meant to be overridden
|
||||||
public virtual void UpdateComponent() {
|
public virtual void UpdateComponent() {
|
||||||
status = Tracker.Status.Unavailable;
|
status = Tracker.Status.Unavailable;
|
||||||
positionConfidence = 0;
|
positionConfidence = 0;
|
||||||
rotationConfidence = 0;
|
rotationConfidence = 0;
|
||||||
//gameObject.SetActive(showRealObjects);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user