Search in sources :

Example 1 with DMDevice

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();
        }
    }
}
Also used : DMDevice(com.neuronrobotics.sdk.common.DMDevice) Color(java.awt.Color) IOException(java.io.IOException) BadLocationException(javax.swing.text.BadLocationException) MeshContainer(eu.mihosoft.vrl.v3d.MeshContainer) BowlerAbstractDevice(com.neuronrobotics.sdk.common.BowlerAbstractDevice) LocalFileScriptTab(com.neuronrobotics.bowlerstudio.tabs.LocalFileScriptTab) Tab(javafx.scene.control.Tab) CSG(eu.mihosoft.vrl.v3d.CSG) ArrayList(java.util.ArrayList) List(java.util.List) Polygon(eu.mihosoft.vrl.v3d.Polygon) PhongMaterial(javafx.scene.paint.PhongMaterial)

Aggregations

LocalFileScriptTab (com.neuronrobotics.bowlerstudio.tabs.LocalFileScriptTab)1 BowlerAbstractDevice (com.neuronrobotics.sdk.common.BowlerAbstractDevice)1 DMDevice (com.neuronrobotics.sdk.common.DMDevice)1 CSG (eu.mihosoft.vrl.v3d.CSG)1 MeshContainer (eu.mihosoft.vrl.v3d.MeshContainer)1 Polygon (eu.mihosoft.vrl.v3d.Polygon)1 Color (java.awt.Color)1 IOException (java.io.IOException)1 ArrayList (java.util.ArrayList)1 List (java.util.List)1 Tab (javafx.scene.control.Tab)1 PhongMaterial (javafx.scene.paint.PhongMaterial)1 BadLocationException (javax.swing.text.BadLocationException)1