public
Created

Dummy 1.0

  • Download Gist
static_dummy.java
Java
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76
import com.netopyr.javafx.ik.Bone;
import com.netopyr.javafx.ik.Skeleton;
import javafx.application.Application;
import javafx.scene.Scene;
import javafx.scene.shape.Circle;
import javafx.scene.shape.Ellipse;
import javafx.stage.Stage;
 
public class Dummy extends Application {
 
private static final int WIDTH = 800;
private static final int HEIGHT = 600;
 
@Override
public void start(Stage stage) throws Exception {
// Definition of head
final Bone head = new Bone(30, 90);
head.getContent().add(new Ellipse(20, 15));
 
// Definition of torso
final Bone torso = new Bone(80, 0);
torso.getContent().add(new Ellipse(40, 0, 50, 20));
head.getChildren().add(torso);
 
final Bone[] upperArm = new Bone[2];
final Bone[] upperLeg = new Bone[2];
 
for (int i=0; i<2; i++) {
 
// Definition upper arms
upperArm[i] = new Bone(60, 60 - 90 * i);
upperArm[i].getContent().add(new Ellipse(22.5, 0, 30, 12.5));
 
// Definition of lower arms
final Bone lowerArm = new Bone(60, -90);
lowerArm.getContent().addAll(
new Circle(12.5),
new Ellipse(30, 0, 20, 12.5),
new Circle(60, 0, 12.5)
);
upperArm[i].getChildren().add(lowerArm);
 
// Definition of upper legs
upperLeg[i] = new Bone(60, 30 - 90*i);
upperLeg[i].getContent().add(new Ellipse(20, 0, 30, 15));
 
// Definition of lower legs
final Bone lowerLeg = new Bone(75, 90);
lowerLeg.getContent().addAll(
new Circle(15),
new Ellipse(40, 0, 30, 15),
new Ellipse(75, -10, 10, 22.5)
);
upperLeg[i].getChildren().add(lowerLeg);
}
 
// Connect arms and legs to head and torso
head.getChildren().addAll(upperArm);
torso.getChildren().addAll(upperLeg);
 
// Creating the skeleton
final Skeleton skeleton = new Skeleton();
skeleton.setTranslateX(WIDTH / 2);
skeleton.setTranslateY(HEIGHT / 4);
head.setSkeleton(skeleton);
 
// Setting the stage
stage.setScene(new Scene(skeleton, WIDTH, HEIGHT));
stage.setTitle("Dummy");
stage.show();
}
 
public static void main(String... args) {
launch(args);
}
}

Please sign in to comment on this gist.

Something went wrong with that request. Please try again.