greenhouse
a creative coding toolkit for spatial interfaces

Hantenna Pointing Events

Special pointing events received from the Hantenna pipeline. For more information, check out the learning pages on handle user input and setting up your 3d sensor.

  • FistAppear ()
  • FistVanish ()
  • FistMove ()
  • FistMotion ()
  • FingerMove ()
  • Victory ()
  • RegisterFistPointer ()
  • RegisterVictoryDisplacement ()
  • RegisterFingerPointing ()
  • RegisterPointing ()
  • RegisterDisplacement ()
  • RegisterOneHandBlurt ()
  • RegisterTwoHandBlurt ()
  • IsStampedWith ()
  • IsLeftHandish ()
  • IsRightHandish ()
  • DoNotRegisterForDefaultEvents ()

Example

// The fist pointing, victory displacement and finger pointing events
// are automatically registered by default so FistAppear (), FistVanish(),
// FistMove (), FingerMove (), and Victory () functions can be overriden
// to receive those events.

#include "Greenhouse.h"

class CustomText  :  public Text
{ public:
  CustomText (const Str &s)  :  Text (s)  { }

  void Travail ()
    { if (! IsHeedless () && CurTime () > 5.0)
        { StopHeeding ();
          WARN ("Heeding exceeded 5 seconds, StopHeeding ()");
        }
    }

  void FistAppear (PointingEvent *e)
    { // get control of this object if there's no one already controlling it
      if (IsHeedless ())
        { ZeroTime ();
          Heed (e);
        }
    }

  void FistVanish (PointingEvent *e)
    { StopHeeding (); }

  void FistMove (PointingEvent *e)
    { // translate the text on fist move
      if (IsHeeding (e))
        { ZeroTime ();
          IncTranslation (6.0 * FistMotion (e, Loc ()));
        }
    }

  void FingerMove (PointingEvent *e)
    { // rotate the text in place on finger move
      IncRotation (UnWrangleRay (Feld () -> Up ()),
                   (e -> PhysOrigin () . x - e -> PrevOrigin () . x) / 250);
      IncRotation (UnWrangleRay (Feld () -> Over ()),
                  - (e -> PhysOrigin () . y - e -> PrevOrigin () . y) / 250);
    }

  void Victory (const Vect &displacement)
    { INFORM ("Current Victory displacement is " + ToStr (displacement)); }

  // Determine the stamp of the blurt event and also the left or right
  // handishness of the pose and set the string based on that.
  // void Blurt (BlurtEvent *e)
  //   { if (IsStampedWith (e, "llcoolj"))
  //       { if (IsLeftHandish (e))
  //           SetString ("previous");
  //         else if (IsRightHandish (e))
  //           SetString ("next");
  //         else
  //           SetString ("huh?");
  //       }
  //     else
  //       SetString ("whatever");
  //   }
};

void Setup ()
{ CustomText *ct = new CustomText ("Hello, Gestures!");
  ct -> SlapOnFeld ();
  ct -> RotationAnimateChase (0.75); //smooths out gesture movement
  ct -> TranslationAnimateChase (.25); //smooths out gesture movement

  // By default the following events are registered
  // RegisterFistPointer ();
  // RegisterVictoryDisplacement ();
  // RegisterFingerPointing ();

  // Call this function to register your own events rather than using and
  // receiving the default fist pointer, victory displacement and finger
  // pointing events.
  // DoNotRegisterForDefaultEvents ();

  // Registering events involves providing a unique "stamp" and either one or
  // two poses depending on the type of event.
  //
  // The following set of poses are recognized by the Hantenna pipeline:
  // NoPose
  // OpenPalmFingersTogetherPose: A flat palm with the thumb out.
  // OpenPalmFingersSpreadPose: Fingers spread with the thumb out.
  // OpenPalmFingersSpreadOrTogetherPose: Fingers together or spread with the thumb out.
  // LShapePose: The thumb out and first finger out in the shape of an "L".
  // NumberOnePose: The common North American hand shape for the number 1.
  // ClosedFistPose: Fingers and thumb tucked.
  // VictoryPose: Two fingers up and spread apart, and the thumb tucked.
  //
  // RegisterPointing ("fist", OpenPalmFingersSpreadPose, ClosedFistPose);
  // RegisterDisplacement ("victory", VictoryPose);
  // RegisterOneHandBlurt ("llcoolj", LShapePose);
  // RegisterTwoHandBlurt ("whatsup", LShapePose, LShapePose);
}