Objective:

  • Detect hand gesture as rescaling gesture (need both hands)
  • The scale of selected object changes along with the distance between two palms

Implementation Steps

  1. Detect hand gesture as rescaling gesture (in our example, defined as palm-to-palm gesture, which can be customized and the only requirement is that palm position and direction should be able to capture).
  2. When two palms have a parallel forwards direction and opposite normal direction, and an object has been selected, the rescaling begins.
  3. The new scale is defined as: \(\text{new scale} = \text{original scale} * \text{current palm distance} / \text{reference palm distance}\),
    where \(\text{reference palm distance}\) is the distance between two palms when people naturally put two palms in front of the body, we set it to 33cm based on testing and measuring ourselves.
  4. Tricky bug: During the process of rescaling, the position and rotation of the selected object is somehow frozen, so when the rescaling ends, the object could potentially have collision with ground and be blown away. The collider component of the object shouldn't be disabled either, in order to prevent the object from falling through the ground. The solution is to mandatorily freeze the object at any updating frame before rescaling, and release all contraints after rescaling. In that way, the collision status of the object is updated every frame, preventing sudden collision and blown away.
  5. Since the scale of the object also affects the length, width, etc, the scale value will also be saved when the object is exported.

Demo video of gesture rescaling an object

This demo video shows:

  • The hand can create new object, select it for modification.
  • Two hands are used to rescale the selected object.
  • The minimum and maximum of the new scaling is limited due to limited detection of hand distance.
  • The object can be deleted.

Next Post Previous Post