use of com.neuronrobotics.sdk.common.DMDevice in project BowlerStudio by CommonWealthRobotics.
the class BowlerStudioController method addObject.
public static void addObject(Object o, File source) {
if (List.class.isInstance(o)) {
List<Object> c = (List<Object>) o;
for (int i = 0; i < c.size(); i++) {
// Log.warning("Loading array Lists with removals " + c.get(i));
addObject(c.get(i), source);
}
return;
}
if (CSG.class.isInstance(o)) {
CSG csg = (CSG) o;
Platform.runLater(() -> {
// new RuntimeException().printStackTrace();
CreatureLab3dController.getEngine().addObject(csg, source);
});
return;
} else if (Tab.class.isInstance(o)) {
getBowlerStudio().addTab((Tab) o, true);
return;
} else if (Node.class.isInstance(o)) {
getBowlerStudio().addNode((Node) o);
return;
} else if (Polygon.class.isInstance(o)) {
Polygon p = (Polygon) o;
List<Vertex> vertices = p.vertices;
javafx.scene.paint.Color color = new javafx.scene.paint.Color(Math.random() * 0.5 + 0.5, Math.random() * 0.5 + 0.5, Math.random() * 0.5 + 0.5, 1);
// double stroke = 0.5;
// for (int i = 1; i < vertices.size(); i++) {
// Line3D line = new Line3D(vertices.get(i - 1), vertices.get(i));
// line.setStrokeWidth(stroke);
// line.setStroke(color);
// getBowlerStudio().addNode(line);
// }
// // Connecting line
// Line3D line = new Line3D(vertices.get(0), vertices.get(vertices.size() - 1));
// line.setStrokeWidth(stroke);
// line.setStroke(color);
MeshContainer mesh = CSGtoJavafx.meshFromPolygon(p);
javafx.scene.shape.MeshView current = mesh.getAsMeshViews().get(0);
current.setMaterial(new PhongMaterial(color));
current.setCullFace(CullFace.NONE);
getBowlerStudio().addNode(current);
return;
} else if (BowlerAbstractDevice.class.isInstance(o)) {
BowlerAbstractDevice bad = (BowlerAbstractDevice) o;
ConnectionManager.addConnection((BowlerAbstractDevice) o, bad.getScriptingName());
return;
} else if (DMDevice.wrappable(o)) {
BowlerAbstractDevice bad;
try {
bad = new DMDevice(o);
ConnectionManager.addConnection(bad, bad.getScriptingName());
} catch (Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
}
Aggregations