Example usage for javafx.scene.paint PhongMaterial PhongMaterial

List of usage examples for javafx.scene.paint PhongMaterial PhongMaterial

Introduction

In this page you can find the example usage for javafx.scene.paint PhongMaterial PhongMaterial.

Prototype

public PhongMaterial(Color diffuseColor) 

Source Link

Document

Creates a new instance of PhongMaterial class using the specified color for its diffuseColor property.

Usage

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

private void compile(String code) {

    csgObject = null;/*from  w  w  w .ja va  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   w  ww .ja  va  2  s  .c om

    // 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);
    }
}