Example usage for javafx.scene.shape MeshView setCullFace

List of usage examples for javafx.scene.shape MeshView setCullFace

Introduction

In this page you can find the example usage for javafx.scene.shape MeshView setCullFace.

Prototype

public final void setCullFace(CullFace value) 

Source Link

Usage

From source file:eu.mihosoft.vrl.fxscad.MainController.java

private void compile(String code) {

    csgObject = null;/*from   w w w.  j  av a  2  s .  c o  m*/

    clearLog();

    viewGroup.getChildren().clear();

    try {

        CompilerConfiguration cc = new CompilerConfiguration();

        cc.addCompilationCustomizers(
                new ImportCustomizer().addStarImports("eu.mihosoft.vrl.v3d", "eu.mihosoft.vrl.v3d.samples")
                        .addStaticStars("eu.mihosoft.vrl.v3d.Transform"));

        GroovyShell shell = new GroovyShell(getClass().getClassLoader(), new Binding(), cc);

        Script script = shell.parse(code);

        Object obj = script.run();

        if (obj instanceof CSG) {

            CSG csg = (CSG) obj;

            csgObject = csg;

            MeshContainer meshContainer = csg.toJavaFXMesh();

            final MeshView meshView = meshContainer.getAsMeshViews().get(0);

            setMeshScale(meshContainer, viewContainer.getBoundsInLocal(), meshView);

            PhongMaterial m = new PhongMaterial(Color.RED);

            meshView.setCullFace(CullFace.NONE);

            meshView.setMaterial(m);

            viewGroup.layoutXProperty().bind(viewContainer.widthProperty().divide(2));
            viewGroup.layoutYProperty().bind(viewContainer.heightProperty().divide(2));

            viewContainer.boundsInLocalProperty().addListener((ov, oldV, newV) -> {
                setMeshScale(meshContainer, newV, meshView);
            });

            VFX3DUtil.addMouseBehavior(meshView, viewContainer, MouseButton.PRIMARY);

            viewGroup.getChildren().add(meshView);

        } else {
            System.out.println(">> no CSG object returned :(");
        }

    } catch (Throwable ex) {
        ex.printStackTrace(System.err);
    }
}

From source file:be.makercafe.apps.makerbench.editors.JFXScadEditor.java

private void compile(String code) {

    csgObject = null;/*from www  .j ava2s  . co  m*/

    // clearLog();

    viewGroup.getChildren().clear();

    try {

        CompilerConfiguration cc = new CompilerConfiguration();

        cc.addCompilationCustomizers(
                new ImportCustomizer().addStarImports("eu.mihosoft.vrl.v3d", "eu.mihosoft.vrl.v3d.samples")
                        .addStaticStars("eu.mihosoft.vrl.v3d.Transform"));

        GroovyShell shell = new GroovyShell(getClass().getClassLoader(), new Binding(), cc);

        Script script = shell.parse(code);

        Object obj = script.run();

        if (obj instanceof CSG) {

            CSG csg = (CSG) obj;

            csgObject = csg;

            //Plane plane = new Plane();

            MeshContainer meshContainer = csg.toJavaFXMesh();

            final MeshView meshView = meshContainer.getAsMeshViews().get(0);

            setMeshScale(meshContainer, viewContainer.getBoundsInLocal(), meshView);

            PhongMaterial m = new PhongMaterial(Color.GREEN);

            meshView.setCullFace(CullFace.NONE);

            meshView.setMaterial(m);

            viewGroup.layoutXProperty().bind(viewContainer.widthProperty().divide(2));
            viewGroup.layoutYProperty().bind(viewContainer.heightProperty().divide(2));

            viewContainer.boundsInLocalProperty().addListener((ov, oldV, newV) -> {
                setMeshScale(meshContainer, newV, meshView);
            });

            VFX3DUtil.addMouseBehavior(meshView, viewContainer, MouseButton.PRIMARY);

            viewGroup.getChildren().add(meshView);

        } else {
            Logger.getLogger(this.getClass().getName()).log(Level.INFO, "No CSG object returned");
        }

    } catch (Throwable ex) {
        Logger.getLogger(this.getClass().getName()).log(Level.INFO, "Unsuspected xception", ex);
    }
}