Skip to content

Commit

Permalink
Gesture support(#7) and Leap Motion interaction(selection) with the g…
Browse files Browse the repository at this point in the history
…eometry(#3)

+Added keytap gesture support to select nodes on the geometry
    ->hover the tip of the right index finger over the geometry and do a keytap motion with the right middle finger to select the node 
    ->the index finger is the "pointing device" and the keytap of the middle finger will simulate a mouse click on that position

+Added circle gesture to make the geometry rotate by 360° in the direction the finger(right index finger) was rotated
    ->only detects circle gestures of the right index finger
    ->while the animation is playing, the user can stop the animation by doing another circle gesture

+Reduced the width of the hand cylinders
  • Loading branch information
esontak committed May 17, 2015
1 parent 3f1c681 commit f617858
Show file tree
Hide file tree
Showing 7 changed files with 159 additions and 67 deletions.
Binary file modified .gradle/2.0/taskArtifacts/cache.properties.lock
Binary file not shown.
Binary file modified .gradle/2.0/taskArtifacts/fileHashes.bin
Binary file not shown.
Binary file modified .gradle/2.0/taskArtifacts/fileSnapshots.bin
Binary file not shown.
Binary file modified .gradle/2.0/taskArtifacts/taskArtifacts.bin
Binary file not shown.
73 changes: 55 additions & 18 deletions src/main/java/edu/gcsc/jfx3d/LeapMotionListener.java
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,9 @@ class LeapMotionListener extends Listener {
private final BooleanProperty handVisible = new SimpleBooleanProperty(false);
private final Vector pos = new Vector(0, 0, 0);

private final BooleanProperty keyTapMiddleFinger = new SimpleBooleanProperty(false);
private final ObjectProperty<Point3D> circleGestureVector=new SimpleObjectProperty<>();

@Override
public void onInit(Controller controller) {
//System.out.println("Leap Motion Device initialized");
Expand All @@ -57,9 +60,17 @@ public void onInit(Controller controller) {
public void onConnect(Controller controller) {
System.out.println("Leap Motion Device connected");
// controller.enableGesture(Gesture.Type.TYPE_SWIPE);
// controller.enableGesture(Gesture.Type.TYPE_CIRCLE);
controller.enableGesture(Gesture.Type.TYPE_CIRCLE);
// controller.enableGesture(Gesture.Type.TYPE_SCREEN_TAP);
// controller.enableGesture(Gesture.Type.TYPE_KEY_TAP);
controller.enableGesture(Gesture.Type.TYPE_KEY_TAP);
circleGestureVector.set(Point3D.ZERO);
controller.config().setFloat("Gesture.Circle.MinRadius", 35.0f);
controller.config().setFloat("Gesture.Circle.MinArc", 4.0f);
controller.config().setFloat("Gesture.KeyTap.MinDownVelocity", 70.0f);
controller.config().setFloat("Gesture.KeyTap.HistorySeconds", .6f);
controller.config().setFloat("Gesture.KeyTap.MinDistance", 11.0f);
controller.config().save();

}

@Override
Expand All @@ -82,10 +93,11 @@ public void onFrame(Controller controller) {
handVisible.set(true);
Screen screen = controller.locatedScreens().get(0);
if (screen != null && screen.isValid()) {
keyTapMiddleFinger.set(false);

Hand hand = frame.hands().get(0);
if (hand.isValid()) {

//credits to José Pereda (http://jperedadnr.blogspot.de/)
pitchLeftAverage.add(new Double(hand.direction().pitch()));
rollLeftAverage.add(new Double(hand.palmNormal().roll()));
Expand All @@ -104,33 +116,50 @@ public void onFrame(Controller controller) {
hand.palmPosition().getZ()));
}

// for (Gesture g : frame.gestures()) {
// if (g.type() == Gesture.Type.TYPE_CIRCLE && g.state().equals(Gesture.State.STATE_START)) {
// System.out.println("CIRCLE START");
// }
// }

for (Gesture g : frame.gestures()) {
//detect keytap gesture with the right hand
if (g.type() == Gesture.Type.TYPE_KEY_TAP && hand.isRight()) {
KeyTapGesture keyTap = new KeyTapGesture(g);
Finger finger = new Finger(keyTap.pointable());
if (finger.type() == Finger.Type.TYPE_MIDDLE) {
keyTapMiddleFinger.set(true);
}
}

//detect circle gesture with the right hand
if (g.type() == Gesture.Type.TYPE_CIRCLE && hand.isRight()) {
CircleGesture circleG = new CircleGesture(g);
Finger finger = new Finger(circleG.pointable());
if (finger.type() == Finger.Type.TYPE_INDEX) {
Point3D p = new Point3D(circleG.normal().getX(),
circleG.normal().getY(),
-circleG.normal().getZ());
//negative z to transform it into the javafx coordinate system
circleGestureVector.set(p);
}
}
}

//get the bones of the fingers to show them in the javafx thread
fingerChanged.set(false);
bones.clear();
for (Finger finger : frame.fingers()) {
if (finger.isValid()) {
for (Bone.Type b : Bone.Type.values()) {
if ( !b.equals(Bone.Type.TYPE_METACARPAL)) { // only save the fingers
if (!b.equals(Bone.Type.TYPE_METACARPAL)) { // only save the fingers
bones.add(finger.bone(b));
}
}
}
}
fingerChanged.set(!bones.isEmpty());


Vector palmPosition = hand.palmPosition();
pos.setX(palmPosition.getX());
pos.setY(palmPosition.getY());
pos.setZ(palmPosition.getZ());

palmZcoordinates.set(pos.getZ());

Vector palmPosition = hand.palmPosition();
pos.setX(palmPosition.getX());
pos.setY(palmPosition.getY());
pos.setZ(palmPosition.getZ());

palmZcoordinates.set(pos.getZ());
}
}
} else {
Expand Down Expand Up @@ -217,4 +246,12 @@ public DoubleProperty palmZcoordinatePropery(){
return palmZcoordinates;
}

public BooleanProperty keyTapMiddleFingerProperty(){
return keyTapMiddleFinger;
}

public ObservableValue<Point3D> circleGestureVectorProperty(){
return circleGestureVector;
}

}
Loading

0 comments on commit f617858

Please sign in to comment.