Skip to content

Commit

Permalink
Edit mode refeito
Browse files Browse the repository at this point in the history
  • Loading branch information
EltonCN committed Aug 2, 2021
1 parent e6653e2 commit 3b4f4d2
Show file tree
Hide file tree
Showing 2 changed files with 101 additions and 28 deletions.
12 changes: 11 additions & 1 deletion Command.pde
Original file line number Diff line number Diff line change
Expand Up @@ -300,7 +300,7 @@ public class BodyInputManager extends InputManager
private boolean enableSlerp;
private ArrayList<RelativePoseID> relativePoseID;

private static final float GESTURE_TIME = 5000.0;
private static final float GESTURE_TIME = 2500.0;

public BodyInputManager(MessageManager msgManager, float width, float height)
{
Expand Down Expand Up @@ -525,6 +525,16 @@ public class BodyInputManager extends InputManager

return result;
}

public float[] getKP(BodyInputID kp_id)
{
if(currentPose == null)
{
return null;
}

return currentPose.keypoints.get(kp_id.name());
}
}

/**
Expand Down
117 changes: 90 additions & 27 deletions Rabisco.pde
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@ public class RabiscoMain
private String soundMode = "pottery";//"pottery","games", "embodie", "piano"

private boolean blackBackground = true;

private boolean drawMode = true;

public RabiscoMain(InputManager inputManager)
{
Expand All @@ -42,10 +44,55 @@ public class RabiscoMain
this.blackBackground = blackBackground;
}

private void configDraw()
public void configDraw()
{
println("draw mode");
drawMode = true;

oneIcon.hide();
twoIcon.hide();
threeIcon.hide();
okIcon.hide();
fistIcon.hide();

inputManager.clearCommands();

Method pointerMethod = null;

try
{
pointerMethod = cubo.getClass().getMethod("setPointer", PVector.class);
}
catch(Exception e)
{
println("ERRO");
}

PointerCommand pointerCommand = new PointerCommand(cubo, pointerMethod);

if (inputManager.haveInput(BodyInputID.WRIST_L))
{
inputManager.addCommand(BodyInputID.WRIST_L, pointerCommand);
}
else if (inputManager.haveInput(MouseInputID.POINTER))
{
inputManager.addCommand(MouseInputID.POINTER, pointerCommand);
}
}

public void configEdit()
{
println("edit mode");
drawMode = false;

oneIcon.show();
twoIcon.show();
threeIcon.show();
okIcon.show();
fistIcon.show();

inputManager.clearCommands();

Method lineMethod = null;
Method circleMethod = null;
Method squareMethod = null;
Expand All @@ -59,12 +106,10 @@ public class RabiscoMain
Method okLoadingMethod = null;
Method fistLoadingMethod = null;

Method editModeMethod = null;

Method drawModeMethod = null;
try
{
pointerMethod = cubo.getClass().getMethod("setPointer", PVector.class);

lineMethod = cubo.getClass().getMethod("lineStroke");
circleMethod = cubo.getClass().getMethod("circleStroke");
squareMethod = cubo.getClass().getMethod("squareStroke");
Expand All @@ -78,35 +123,27 @@ public class RabiscoMain
okLoadingMethod = okIcon.getClass().getMethod("setLoading", Float.TYPE);
fistLoadingMethod = fistIcon.getClass().getMethod("setLoading", Float.TYPE);

editModeMethod = this.getClass().getMethod("configEdit");
drawModeMethod = this.getClass().getMethod("configDraw");
}
catch(Exception e)
{
println("ERRO");
}

PointerCommand pointerCommand = new PointerCommand(cubo, pointerMethod);

TriggerCommand lineCommand = new TriggerCommand(cubo, lineMethod);
TriggerCommand circleCommand = new TriggerCommand(cubo, circleMethod);
TriggerCommand squareCommand = new TriggerCommand(cubo, squareMethod);
TriggerCommand rDownCommand = new TriggerCommand(cubo, rDownMethod);
TriggerCommand rLeftCommand = new TriggerCommand(cubo, rLeftMethod);

TriggerCommand drawModeCommand = new TriggerCommand(this, drawModeMethod);

AxisCommand oneLoading = new AxisCommand(oneIcon, oneLoadingMethod);
AxisCommand twoLoading = new AxisCommand(twoIcon, twoLoadingMethod);
AxisCommand threeLoading = new AxisCommand(threeIcon, threeLoadingMethod);
AxisCommand okLoading = new AxisCommand(okIcon, okLoadingMethod);
AxisCommand fistLoading = new AxisCommand(fistIcon, fistLoadingMethod);

if (inputManager.haveInput(BodyInputID.WRIST_L))
{
inputManager.addCommand(BodyInputID.WRIST_L, pointerCommand);
}
else if (inputManager.haveInput(MouseInputID.POINTER))
{
inputManager.addCommand(MouseInputID.POINTER, pointerCommand);
}

if(inputManager.haveInput(GestureInputID.FIVE))
{
Expand All @@ -122,22 +159,21 @@ public class RabiscoMain
inputManager.addCommand(GestureInputID.THREE_LOADING, threeLoading);
inputManager.addCommand(GestureInputID.OK_LOADING, okLoading);
inputManager.addCommand(GestureInputID.FIST_LOADING, fistLoading);

inputManager.addCommand(GestureInputID.ONE, drawModeCommand);
inputManager.addCommand(GestureInputID.TWO, drawModeCommand);
inputManager.addCommand(GestureInputID.THREE, drawModeCommand);
inputManager.addCommand(GestureInputID.OK, drawModeCommand);
inputManager.addCommand(GestureInputID.FIST, drawModeCommand);

}
else if (inputManager.haveInput(MouseInputID.RIGHT_BUTTON))
{
inputManager.addCommand(MouseInputID.RIGHT_BUTTON, rLeftCommand);

inputManager.addCommand(MouseInputID.RIGHT_BUTTON, drawModeCommand);
}

BodyInputManager bdInMan = (BodyInputManager) inputManager;
InputIdentifier inputID = bdInMan.createRelativeTrigger( BodyInputID.WRIST_L, BodyInputID.NOSE, 1, 1, true);
TriggerCommand editMode = new TriggerCommand(this, editModeMethod);
inputManager.addCommand(inputID, editMode);

}

public void configEdit()
{
println("teste");

}


Expand All @@ -152,8 +188,35 @@ public class RabiscoMain
background(255,255,255);
}

if(drawMode)
{
BodyInputManager bdInMan = (BodyInputManager) inputManager;

float[] nose, wl, wr;

nose = bdInMan.getKP(BodyInputID.NOSE);
wl = bdInMan.getKP(BodyInputID.WRIST_R);
wr = bdInMan.getKP(BodyInputID.WRIST_L);

if(wl != null && wr != null && nose != null)
{
if(wl[1] < nose[1] && wr[1] < nose[1])
{
configEdit();
}
}

}

cubo.run(g);

if(!drawMode)
{
colorMode(RGB, 255);
fill(125,125,125, 125);
rect(0,0, width, height);
}

oneIcon.run(g);
twoIcon.run(g);
threeIcon.run(g);
Expand Down

0 comments on commit 3b4f4d2

Please sign in to comment.