﻿using System.Collections;
using Augumenta;
using UnityEngine;

/**
 * FollowPoseHandler moves and rotates the game object so that it follows
 * the selected hand pose.
 */
public class FollowPoseHandler: PoseTransformer
{
	// object is always visible, even when there is no detection
	[Tooltip("Keep object visible/active even when there is no detections")]
	public bool alwaysVisible=true;

	public override void Start()
	{
		base.Start();
		gameObject.SetActive(alwaysVisible);
	}

	public override void OnPose(PoseEvent e, bool isNew, Vector3 p, Quaternion q)
	{
		// make object active unless finger
		gameObject.SetActive(true);
		TransformPose(gameObject, e, p, q);
	}
	public override void OnPoseLost(PoseEvent e)
	{
		// hide object only if 'alwaysVisible' is false
		gameObject.SetActive(alwaysVisible);
	}
}
