Skip to content

Commit

Permalink
Merge pull request #29 from ButterscotchVanilla/main
Browse files Browse the repository at this point in the history
Add AutoBone, a skeleton auto-configuration algorithm
  • Loading branch information
Eirenliel committed Aug 20, 2021
2 parents 5f6a6ba + 337912f commit e3b977c
Show file tree
Hide file tree
Showing 9 changed files with 1,617 additions and 27 deletions.
6 changes: 1 addition & 5 deletions .github/workflows/gradle.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,7 @@

name: SlimeVR Server

on:
push:
branches: [ main ]
pull_request:
branches: [ main ]
on: [push, pull_request]

jobs:
test:
Expand Down
22 changes: 20 additions & 2 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,24 @@ plugins {
id 'java-library'
}

sourceCompatibility = 1.8
targetCompatibility = 1.8

// Set compiler to use UTF-8
compileJava.options.encoding = 'UTF-8'
compileTestJava.options.encoding = 'UTF-8'
javadoc.options.encoding = 'UTF-8'

tasks.withType(JavaCompile) {
options.encoding = 'UTF-8'
}
tasks.withType(Test) {
systemProperty('file.encoding', 'UTF-8')
}
tasks.withType(Javadoc){
options.encoding = 'UTF-8'
}

repositories {
// Use jcenter for resolving dependencies.
// You can declare any Maven/Ivy/file repository here.
Expand All @@ -31,7 +49,7 @@ dependencies {

// This dependency is used internally, and not exposed to consumers on their own compile classpath.
implementation 'com.google.guava:guava:28.2-jre'


// Use JUnit test framework
testImplementation platform('org.junit:junit-bom:5.7.2')
Expand All @@ -48,7 +66,7 @@ task serverJar (type: Jar, dependsOn: subprojects.tasks['build']) {
manifest {
attributes 'Main-Class': 'io.eiren.vr.Main'
}

// Pack all dependencies within the JAR
from {
configurations.compile.collect { it.isDirectory() ? it : zipTree(it) }
Expand Down
52 changes: 32 additions & 20 deletions src/main/java/io/eiren/gui/SkeletonConfig.java
Original file line number Diff line number Diff line change
Expand Up @@ -11,33 +11,36 @@
import javax.swing.JLabel;
import javax.swing.event.MouseInputAdapter;

import io.eiren.gui.autobone.AutoBoneWindow;
import io.eiren.util.StringUtils;
import io.eiren.util.ann.ThreadSafe;
import io.eiren.vr.VRServer;
import io.eiren.vr.processor.HumanSkeletonWithLegs;
import io.eiren.vr.processor.HumanSkeleton;

public class SkeletonConfig extends EJBag {

private final VRServer server;
private final VRServerGUI gui;
private final AutoBoneWindow autoBone;
private Map<String, SkeletonLabel> labels = new HashMap<>();

public SkeletonConfig(VRServer server, VRServerGUI gui) {
super();
this.server = server;
this.gui = gui;
this.autoBone = new AutoBoneWindow(server, this);

setAlignmentY(TOP_ALIGNMENT);
server.humanPoseProcessor.addSkeletonUpdatedCallback(this::skeletonUpdated);
skeletonUpdated(null);
}

@ThreadSafe
public void skeletonUpdated(HumanSkeleton newSkeleton) {
java.awt.EventQueue.invokeLater(() -> {
removeAll();

int row = 0;

add(new JCheckBox("Extended pelvis model") {{
Expand All @@ -63,7 +66,7 @@ public void itemStateChanged(ItemEvent e) {
}
}}, s(c(0, row, 1), 3, 1));
row++;

/*
add(new JCheckBox("Extended knee model") {{
addItemListener(new ItemListener() {
Expand All @@ -89,17 +92,26 @@ public void itemStateChanged(ItemEvent e) {
}}, s(c(0, row, 1), 3, 1));
row++;
//*/

add(new TimedResetButton("Reset All", "All"), s(c(1, row, 1), 3, 1));
add(new JButton("Auto") {{
addMouseListener(new MouseInputAdapter() {
@Override
public void mouseClicked(MouseEvent e) {
autoBone.setVisible(true);
autoBone.toFront();
}
});
}}, s(c(4, row, 1), 3, 1));
row++;

add(new JLabel("Chest"), c(0, row, 1));
add(new AdjButton("+", "Chest", 0.01f), c(1, row, 1));
add(new SkeletonLabel("Chest"), c(2, row, 1));
add(new AdjButton("-", "Chest", -0.01f), c(3, row, 1));
add(new ResetButton("Reset", "Chest"), c(4, row, 1));
row++;

add(new JLabel("Waist"), c(0, row, 1));
add(new AdjButton("+", "Waist", 0.01f), c(1, row, 1));
add(new SkeletonLabel("Waist"), c(2, row, 1));
Expand Down Expand Up @@ -148,14 +160,14 @@ public void itemStateChanged(ItemEvent e) {
add(new AdjButton("-", "Neck", -0.01f), c(3, row, 1));
add(new ResetButton("Reset", "Neck"), c(4, row, 1));
row++;

add(new JLabel("Virtual waist"), c(0, row, 1));
add(new AdjButton("+", "Virtual waist", 0.01f), c(1, row, 1));
add(new SkeletonLabel("Virtual waist"), c(2, row, 1));
add(new AdjButton("-", "Virtual waist", -0.01f), c(3, row, 1));
add(new ResetButton("Reset", "Virtual waist"), c(4, row, 1));
row++;

gui.refresh();
});
}
Expand All @@ -168,14 +180,14 @@ public void refreshAll() {
});
});
}

private void change(String joint, float diff) {
float current = server.humanPoseProcessor.getSkeletonConfig(joint);
server.humanPoseProcessor.setSkeletonConfig(joint, current + diff);
server.saveConfig();
labels.get(joint).setText(StringUtils.prettyNumber((current + diff) * 100, 0));
}

private void reset(String joint) {
server.humanPoseProcessor.resetSkeletonConfig(joint);
server.saveConfig();
Expand All @@ -189,17 +201,17 @@ private void reset(String joint) {
});
}
}

private class SkeletonLabel extends JLabel {

public SkeletonLabel(String joint) {
super(StringUtils.prettyNumber(server.humanPoseProcessor.getSkeletonConfig(joint) * 100, 0));
labels.put(joint, this);
}
}

private class AdjButton extends JButton {

public AdjButton(String text, String joint, float diff) {
super(text);
addMouseListener(new MouseInputAdapter() {
Expand All @@ -210,9 +222,9 @@ public void mouseClicked(MouseEvent e) {
});
}
}

private class ResetButton extends JButton {

public ResetButton(String text, String joint) {
super(text);
addMouseListener(new MouseInputAdapter() {
Expand All @@ -223,9 +235,9 @@ public void mouseClicked(MouseEvent e) {
});
}
}

private class TimedResetButton extends JButton {

public TimedResetButton(String text, String joint) {
super(text);
addMouseListener(new MouseInputAdapter() {
Expand Down
Loading

0 comments on commit e3b977c

Please sign in to comment.