Skip to content

Commit

Permalink
Added "undo" to the voice interaction
Browse files Browse the repository at this point in the history
  • Loading branch information
Stefan Medack committed Jul 2, 2012
1 parent 81b7f7e commit d4cca4d
Show file tree
Hide file tree
Showing 5 changed files with 83 additions and 60 deletions.
27 changes: 16 additions & 11 deletions .classpath
Original file line number Diff line number Diff line change
@@ -1,11 +1,16 @@
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
<classpathentry kind="src" path="src"/>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.6"/>
<classpathentry kind="lib" path="lib/peasycam.jar"/>
<classpathentry kind="lib" path="lib/SimpleOpenNI.jar"/>
<classpathentry kind="lib" path="lib/core.jar"/>
<classpathentry kind="lib" path="lib/sphinx4.jar"/>
<classpathentry kind="lib" path="lib/WSJ_8gau_13dCep_16k_40mel_130Hz_6800Hz.jar"/>
<classpathentry kind="output" path="bin"/>
</classpath>
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
<classpathentry kind="src" path="src">
<attributes>
<attribute name="org.eclipse.jdt.launching.CLASSPATH_ATTR_LIBRARY_PATH_ENTRY" value="mubix/bin"/>
</attributes>
</classpathentry>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.6"/>
<classpathentry kind="lib" path="lib/peasycam.jar"/>
<classpathentry kind="lib" path="lib/sphinx4.jar"/>
<classpathentry kind="lib" path="lib/core.jar"/>
<classpathentry kind="lib" path="lib/log4j-1.2.16.jar"/>
<classpathentry kind="lib" path="lib/SimpleOpenNI.jar"/>
<classpathentry kind="lib" path="lib/WSJ_8gau_13dCep_16k_40mel_130Hz_6800Hz.jar"/>
<classpathentry kind="output" path="bin"/>
</classpath>
24 changes: 24 additions & 0 deletions src/de/tub/mubix/main/Cube.java
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package de.tub.mubix.main;

import java.util.ArrayList;
import java.util.LinkedList;

import processing.core.PApplet;
import processing.core.PVector;
Expand All @@ -17,8 +18,18 @@ public class Cube {
public int clock = 0;
public int faceTurn = 0;

public int getFaceTurn() {
return faceTurn;
}

public void setFaceTurn(int faceTurn) {
this.faceTurn = faceTurn;
this.pushMove(faceTurn);
}

public boolean mixCube = false;
public boolean reverseRotation = false;
private LinkedList<Integer> moveList = null;

ArrayList<Integer> listNumOfSiteRotation;
int numOfSiteRotation = 0;
Expand All @@ -41,6 +52,7 @@ public class Cube {
public Cube(PApplet parent) {// The points for each square on the face
this.parent = parent;

moveList = new LinkedList<Integer>();
squareMatrix = new PVector[6][9][4];
for (int i = 0; i < 3; i++)
for (int j = 0; j < 3; j++) {
Expand Down Expand Up @@ -626,4 +638,16 @@ public void singleTwist() {
faceTurn = 0;
}
}

public void undoLastMove() {
if (!moveList.isEmpty()) {
reverseRotation = true;
faceTurn = moveList.getLast();
moveList.removeLast();
}
}

public void pushMove(int faceTurn) {
moveList.add(faceTurn);
}
}
14 changes: 2 additions & 12 deletions src/de/tub/mubix/main/Mubix.java
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
package de.tub.mubix.main;

import java.util.LinkedList;

import peasy.PeasyCam;
import processing.core.PApplet;
import processing.core.PVector;
Expand All @@ -26,8 +24,6 @@ public class Mubix extends PApplet {
final boolean enableMultimodal = true;
boolean showDepth = false;

private LinkedList<Integer> moveList = null;

// int clock = 0;
// int ith = 0;
// int faceTurn = 0;
Expand Down Expand Up @@ -66,8 +62,6 @@ public void setup() {
cam.setActive(false); // deactivate mouse rotation
theCube = new Cube(this);

moveList = new LinkedList<Integer>();

// bkg_img = loadImage("cube_black_1024_640.jpg");
// bkg_img.filter(OPAQUE);

Expand Down Expand Up @@ -393,11 +387,7 @@ public void keyPressed() {
theCube.mixCube = false;
}
if ((key == 'ö') || (key == 'Ö') || (key == ',')) {
if (!moveList.isEmpty()) {
theCube.reverseRotation = true;
theCube.faceTurn = moveList.getLast();
moveList.removeLast();
}
theCube.undoLastMove();
}
if ((key == 'd') || (key == 'D')) {
this.showDepth = !this.showDepth;
Expand All @@ -421,7 +411,7 @@ public void keyPressed() {
}

public void setMoveReminder(int faceTurn) {
moveList.add(faceTurn);
theCube.pushMove(faceTurn);
}

// mm mehtods
Expand Down
76 changes: 40 additions & 36 deletions src/de/tub/mubix/speechControl/SpeechControl.java
Original file line number Diff line number Diff line change
Expand Up @@ -49,111 +49,115 @@ private void extractCommand(Result result) {
}

if (s != "" && this.cube.clock == 0) {
if(s.contains("undo")){
this.cube.undoLastMove();
}

if (trackpad.getFocusX() == 0 && trackpad.getFocusY() == 0) {
if (s.contains("up")) {
this.cube.faceTurn = 11;
this.cube.setFaceTurn(11);
} else if (s.contains("down")) {
this.cube.faceTurn = 12;
this.cube.setFaceTurn(12);
} else if (s.contains("right")) {
this.cube.faceTurn = 41;
this.cube.setFaceTurn(41);
} else if (s.contains("left")) {
this.cube.faceTurn = 42;
this.cube.setFaceTurn(42);
}
}

if (trackpad.getFocusX() == 0 && trackpad.getFocusY() == 1) {
if (s.contains("up")) {
this.cube.faceTurn = 11;
this.cube.setFaceTurn(11);
} else if (s.contains("down")) {
this.cube.faceTurn = 12;
this.cube.setFaceTurn(12);
} else if (s.contains("right")) {
this.cube.faceTurn = 51;
this.cube.setFaceTurn(51);
} else if (s.contains("left")) {
this.cube.faceTurn = 52;
this.cube.setFaceTurn(52);
}
}

if (trackpad.getFocusX() == 0 && trackpad.getFocusY() == 2) {
if (s.contains("up")) {
this.cube.faceTurn = 11;
this.cube.setFaceTurn(11);
} else if (s.contains("down")) {
this.cube.faceTurn = 12;
this.cube.setFaceTurn(12);
} else if (s.contains("right")) {
this.cube.faceTurn = 61;
this.cube.setFaceTurn(61);
} else if (s.contains("left")) {
this.cube.faceTurn = 62;
this.cube.setFaceTurn(62);
}
}

if (trackpad.getFocusX() == 1 && trackpad.getFocusY() == 0) {
if (s.contains("up")) {
this.cube.faceTurn = 21;
this.cube.setFaceTurn(21);
} else if (s.contains("down")) {
this.cube.faceTurn = 22;
this.cube.setFaceTurn(22);
} else if (s.contains("right")) {
this.cube.faceTurn = 41;
this.cube.setFaceTurn(41);
} else if (s.contains("left")) {
this.cube.faceTurn = 42;
this.cube.setFaceTurn(42);
}
}

if (trackpad.getFocusX() == 1 && trackpad.getFocusY() == 1) {
if (s.contains("up")) {
this.cube.faceTurn = 101;
this.cube.setFaceTurn(101);
} else if (s.contains("down")) {
this.cube.faceTurn = 102;
this.cube.setFaceTurn(102);
} else if (s.contains("right")) {
this.cube.faceTurn = 104;
this.cube.setFaceTurn(104);
} else if (s.contains("left")) {
this.cube.faceTurn = 103;
this.cube.setFaceTurn(103);
}
}

if (trackpad.getFocusX() == 1 && trackpad.getFocusY() == 2) {
if (s.contains("up")) {
this.cube.faceTurn = 21;
this.cube.setFaceTurn(21);
} else if (s.contains("down")) {
this.cube.faceTurn = 22;
this.cube.setFaceTurn(22);
} else if (s.contains("right")) {
this.cube.faceTurn = 61;
this.cube.setFaceTurn(61);
} else if (s.contains("left")) {
this.cube.faceTurn = 62;
this.cube.setFaceTurn(62);
}
}

if (trackpad.getFocusX() == 2 && trackpad.getFocusY() == 0) {
if (s.contains("up")) {
this.cube.faceTurn = 31;
this.cube.setFaceTurn(31);
} else if (s.contains("down")) {
this.cube.faceTurn = 32;
this.cube.setFaceTurn(32);
} else if (s.contains("right")) {
this.cube.faceTurn = 41;
this.cube.setFaceTurn(41);
} else if (s.contains("left")) {
this.cube.faceTurn = 42;
this.cube.setFaceTurn(42);
}
}

if (trackpad.getFocusX() == 2 && trackpad.getFocusY() == 1) {
if (s.contains("up")) {
this.cube.faceTurn = 31;
this.cube.setFaceTurn(31);
} else if (s.contains("down")) {
this.cube.faceTurn = 32;
this.cube.setFaceTurn(32);
} else if (s.contains("right")) {
this.cube.faceTurn = 51;
this.cube.setFaceTurn(51);
} else if (s.contains("left")) {
this.cube.faceTurn = 52;
this.cube.setFaceTurn(52);
}
}

if (trackpad.getFocusX() == 2 && trackpad.getFocusY() == 2) {
if (s.contains("up")) {
this.cube.faceTurn = 31;
this.cube.setFaceTurn(31);
} else if (s.contains("down")) {
this.cube.faceTurn = 32;
this.cube.setFaceTurn(32);
} else if (s.contains("right")) {
this.cube.faceTurn = 61;
this.cube.setFaceTurn(61);
} else if (s.contains("left")) {
this.cube.faceTurn = 62;
this.cube.setFaceTurn(62);
}
}

Expand Down
2 changes: 1 addition & 1 deletion src/de/tub/mubix/speechControl/speech.gram
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,4 @@

grammar hello;

public <greet> = ( up | down | left | right );
public <greet> = ( up | down | left | right | undo);

0 comments on commit d4cca4d

Please sign in to comment.