/* ZColorMaterialApp.java */
package org.jfx.scene.paint.matbase1.test1;

import javafx.application.Application;
import javafx.org.scene.shape.ZNT_BoxCls;
import javafx.org.scene.shape.ZNT_CylinderCls;
import javafx.org.scene.shape.ZNT_Shape3DCls;
import javafx.scene.AmbientLight;
import javafx.scene.Group;
import javafx.scene.Node;
import javafx.scene.Parent;
import javafx.scene.PerspectiveCamera;
import javafx.scene.PointLight;
import javafx.scene.Scene;
import javafx.scene.paint.Color;
import javafx.scene.paint.PhongMaterial;
import javafx.scene.shape.CullFace;
import javafx.scene.shape.DrawMode;
import javafx.stage.Stage;
import org.jfx.scene.paint.matbase1.ZColorMaterialCls;

/**
 * This class is only used for test.
 *
 * @author ZZZ. No copyright(c). Public Domain.
 */
public class ZColorMaterialApp extends Application {

    protected Node[] buildShapeArray() {
        PhongMaterial material = new PhongMaterial();
        material.setDiffuseColor(Color.LIGHTGRAY);
        material.setSpecularColor(Color.rgb(30, 30, 30));
        //
        /*Shape3D[] meshView = new Shape3D[]{
            new Cylinder(100, 200),
            new Box(100, 100, 100),};*/
        ZNT_Shape3DCls[] meshView = new ZNT_Shape3DCls[]{
            new ZNT_CylinderCls(100, 200),
            new ZNT_BoxCls(100, 100, 100),};
        //
        for (int i = 0; i < meshView.length; ++i) {
            meshView[i].setMaterial(material);
            //
            meshView[i].setTranslateX((i + 1) * 220);
            meshView[i].setTranslateY(500);
            meshView[i].setTranslateZ(20);
            meshView[i].setDrawMode(DrawMode.FILL);
            meshView[i].setCullFace(CullFace.BACK);
        }
        //
        meshView[0].setMaterial(new ZColorMaterialCls(Color.GREEN));
        meshView[1].setMaterial(new ZColorMaterialCls(Color.BLUE));
        //
        return meshView;
    }

    protected Parent buildRoot() {
        Group root = new Group();
        //
        root.getChildren().addAll(buildShapeArray());
        //
        PointLight pointLight = new PointLight(Color.ANTIQUEWHITE);
        pointLight.setTranslateX(800);
        pointLight.setTranslateY(-100);
        pointLight.setTranslateZ(-1000);
        root.getChildren().add(pointLight);
        // We decide to add ambient...
        AmbientLight ambientLight = new AmbientLight(Color.WHITE);
        root.getChildren().add(ambientLight);
        //
        return root;
    }

    protected Scene buildScene() {
        Parent root = buildRoot();
        Scene scene = new Scene(root, 800, 800, true);
        //scene.setFill(Color.rgb(10, 10, 40));
        scene.setFill(Color.BLACK);
        scene.setCamera(new PerspectiveCamera(false));
        return scene;
    }

    @Override
    public void start(Stage stage) {
        stage.setScene(buildScene());
        stage.show();
    }

    public static void main(String[] args) {
        launch(args);
    }

}
