Java Code Examples for javafx.scene.paint.PhongMaterial#setSpecularColor()
The following examples show how to use
javafx.scene.paint.PhongMaterial#setSpecularColor() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: ThreeDOM.java From scenic-view with GNU General Public License v3.0 | 6 votes |
private void buildAxes(Group world) { PhongMaterial redMaterial = new PhongMaterial(); redMaterial.setDiffuseColor(Color.DARKRED); redMaterial.setSpecularColor(Color.RED); PhongMaterial greenMaterial = new PhongMaterial(); greenMaterial.setDiffuseColor(Color.DARKGREEN); greenMaterial.setSpecularColor(Color.GREEN); PhongMaterial blueMaterial = new PhongMaterial(); blueMaterial.setDiffuseColor(Color.DARKBLUE); blueMaterial.setSpecularColor(Color.BLUE); Box xAxis = new Box(AXES_SIZE, 1, 1); xAxis.setMaterial(redMaterial); Box yAxis = new Box(1, AXES_SIZE, 1); yAxis.setMaterial(greenMaterial); Box zAxis = new Box(1, 1, AXES_SIZE); zAxis.setMaterial(blueMaterial); Group group = new Group(); group.getChildren().addAll(xAxis, yAxis, zAxis); group.setVisible(true); world.getChildren().addAll(group); group.visibleProperty().bind(checkBoxAxes.selectedProperty()); }
Example 2
Source File: Globe.java From mars-sim with GNU General Public License v3.0 | 6 votes |
private void buildSphereGroup() { final PhongMaterial material = new PhongMaterial(); material.setDiffuseColor(Color.WHITE);//TRANSPARENT);//BROWN); material.diffuseMapProperty().bind(Bindings.when(diffuseMap).then(dImage).otherwise((Image) null)); material.bumpMapProperty().bind(Bindings.when(bumpMap).then(nImage).otherwise((Image) null)); material.setSpecularColor(Color.LIGHTGRAY); //material.selfIlluminationMapProperty().bind(Bindings.when(selfIlluminationMap).then(siImage).otherwise((Image) null)); Xform marsXform = new Xform(); Sphere mars = new Sphere(300.0); mars.setMaterial(material); marsXform.getChildren().add(mars); sphereGroup.getChildren().add(marsXform); world.getChildren().addAll(sphereGroup);//, ambientXform); }
Example 3
Source File: Viewer3d.java From phoebus with Eclipse Public License 1.0 | 5 votes |
private Xform buildAxes() { Xform axes = new Xform(); final PhongMaterial red = new PhongMaterial(); red.setDiffuseColor(Color.RED); red.setSpecularColor(Color.DARKRED); final PhongMaterial green = new PhongMaterial(); green.setDiffuseColor(Color.GREEN); green.setSpecularColor(Color.DARKGREEN); final PhongMaterial blue = new PhongMaterial(); blue.setDiffuseColor(Color.BLUE); blue.setSpecularColor(Color.DARKBLUE); final Box xAxis = new Box(AXIS_LENGTH, 1, 1); final Box yAxis = new Box(1, AXIS_LENGTH, 1); final Box zAxis = new Box(1, 1, AXIS_LENGTH); xAxis.setTranslateX(AXIS_LENGTH/2 + 0.5); yAxis.setTranslateY(AXIS_LENGTH/2 + 0.5); zAxis.setTranslateZ(AXIS_LENGTH/2 + 0.5); xAxis.setMaterial(red); yAxis.setMaterial(green); zAxis.setMaterial(blue); axes.getChildren().addAll(xAxis, yAxis, zAxis); return axes; }
Example 4
Source File: ContentModel.java From gluon-samples with BSD 3-Clause "New" or "Revised" License | 5 votes |
private void buildAxes() { double length = 2d * dimModel; double width = dimModel / 100d; double radius = 2d * dimModel / 100d; final PhongMaterial redMaterial = new PhongMaterial(); redMaterial.setDiffuseColor(Color.DARKRED); redMaterial.setSpecularColor(Color.RED); final PhongMaterial greenMaterial = new PhongMaterial(); greenMaterial.setDiffuseColor(Color.DARKGREEN); greenMaterial.setSpecularColor(Color.GREEN); final PhongMaterial blueMaterial = new PhongMaterial(); blueMaterial.setDiffuseColor(Color.DARKBLUE); blueMaterial.setSpecularColor(Color.BLUE); Sphere xSphere = new Sphere(radius); Sphere ySphere = new Sphere(radius); Sphere zSphere = new Sphere(radius); xSphere.setMaterial(redMaterial); ySphere.setMaterial(greenMaterial); zSphere.setMaterial(blueMaterial); xSphere.setTranslateX(dimModel); ySphere.setTranslateY(dimModel); zSphere.setTranslateZ(dimModel); Box xAxis = new Box(length, width, width); Box yAxis = new Box(width, length, width); Box zAxis = new Box(width, width, length); xAxis.setMaterial(redMaterial); yAxis.setMaterial(greenMaterial); zAxis.setMaterial(blueMaterial); autoScalingGroup.getChildren().addAll(xAxis, yAxis, zAxis); autoScalingGroup.getChildren().addAll(xSphere, ySphere, zSphere); }
Example 5
Source File: Utils.java From gluon-samples with BSD 3-Clause "New" or "Revised" License | 5 votes |
public static PhongMaterial getMaterial(String face){ PhongMaterial arrowMat = new PhongMaterial(); arrowMat.setSpecularColor(Color.WHITESMOKE); Color color = Color.WHITE; switch(face){ case "F": case "Fi": color = Color.BLUE.brighter(); break; case "B": case "Bi": color = Color.BLUE.brighter(); break; case "R": case "Ri": color = Color.RED.brighter(); break; case "L": case "Li": color = Color.RED.brighter(); break; case "U": case "Ui": color = Color.FORESTGREEN.brighter(); break; case "D": case "Di": color = Color.FORESTGREEN.brighter(); break; case "Z": case "Zi": color = Color.BLUE.brighter(); break; case "X": case "Xi": color = Color.RED.brighter(); break; case "Y": case "Yi": color = Color.FORESTGREEN.brighter(); break; } arrowMat.setDiffuseColor(color); return arrowMat; }
Example 6
Source File: TriangleMeshHelper.java From FXyzLib with GNU General Public License v3.0 | 5 votes |
public Material getMaterialWithColor(Color color, String image){ PhongMaterial mat = new PhongMaterial(color); if(image!=null && !image.isEmpty()){ Image img = new Image(image); mat.setDiffuseMap(img); NormalMap normal = new NormalMap(img); // normal.setIntensity(10); // normal.setIntensityScale(2); mat.setBumpMap(normal); } mat.setSpecularPower(32); mat.setSpecularColor(Color.WHITE); return mat; }
Example 7
Source File: TriangleMeshHelper.java From FXyzLib with GNU General Public License v3.0 | 5 votes |
private void clearMaterialAndSetDiffMap(PhongMaterial mat, Image diff){ mat.setBumpMap(null); mat.setSpecularMap(null); mat.setSelfIlluminationMap(null); mat.setDiffuseColor(DEFAULT_DIFFUSE_COLOR); mat.setSpecularColor(DEFAULT_SPECULAR_COLOR); mat.setDiffuseMap(diff); }
Example 8
Source File: ContentModel.java From RubikFX with GNU General Public License v3.0 | 5 votes |
private void buildAxes() { double length = 2d*dimModel; double width = dimModel/100d; double radius = 2d*dimModel/100d; final PhongMaterial redMaterial = new PhongMaterial(); redMaterial.setDiffuseColor(Color.DARKRED); redMaterial.setSpecularColor(Color.RED); final PhongMaterial greenMaterial = new PhongMaterial(); greenMaterial.setDiffuseColor(Color.DARKGREEN); greenMaterial.setSpecularColor(Color.GREEN); final PhongMaterial blueMaterial = new PhongMaterial(); blueMaterial.setDiffuseColor(Color.DARKBLUE); blueMaterial.setSpecularColor(Color.BLUE); Sphere xSphere = new Sphere(radius); Sphere ySphere = new Sphere(radius); Sphere zSphere = new Sphere(radius); xSphere.setMaterial(redMaterial); ySphere.setMaterial(greenMaterial); zSphere.setMaterial(blueMaterial); xSphere.setTranslateX(dimModel); ySphere.setTranslateY(dimModel); zSphere.setTranslateZ(dimModel); Box xAxis = new Box(length, width, width); Box yAxis = new Box(width, length, width); Box zAxis = new Box(width, width, length); xAxis.setMaterial(redMaterial); yAxis.setMaterial(greenMaterial); zAxis.setMaterial(blueMaterial); autoScalingGroup.getChildren().addAll(xAxis, yAxis, zAxis); autoScalingGroup.getChildren().addAll(xSphere, ySphere, zSphere); }
Example 9
Source File: Utils.java From RubikFX with GNU General Public License v3.0 | 5 votes |
public static PhongMaterial getMaterial(String face){ PhongMaterial arrowMat = new PhongMaterial(); arrowMat.setSpecularColor(Color.WHITESMOKE); Color color=Color.WHITE; switch(face){ case "F": case "Fi": color=Color.BLUE.brighter(); break; case "B": case "Bi": color=Color.BLUE.brighter(); break; case "R": case "Ri": color=Color.RED.brighter(); break; case "L": case "Li": color=Color.RED.brighter(); break; case "U": case "Ui": color=Color.FORESTGREEN.brighter(); break; case "D": case "Di": color=Color.FORESTGREEN.brighter(); break; case "Z": case "Zi": color=Color.BLUE.brighter(); break; case "X": case "Xi": color=Color.RED.brighter(); break; case "Y": case "Yi": color=Color.FORESTGREEN.brighter(); break; } arrowMat.setDiffuseColor(color); return arrowMat; }
Example 10
Source File: Tile3D.java From scenic-view with GNU General Public License v3.0 | 4 votes |
public Tile3D(SVNode currentRoot2D, double factor2d3d, SVNode node2D, double depth, double thickness, ITile3DListener l, IThreeDOM i) { this.depth = depth; this.currentRoot2D = currentRoot2D; this.factor2d3d = factor2d3d; this.iTile3DListener = l; this.iThreeDOM = i; node2d = node2D; material = new PhongMaterial(); material.setDiffuseColor(Color.WHITE); material.setSpecularColor(Color.TRANSPARENT); Bounds bounds2D = localetoRoot(node2D); // Bounds bounds3D = new BoundingBox(bounds2D.getMinX() * factor2d3d, bounds2D.getMinY() * factor2d3d, bounds2D.getWidth() * factor2d3d, bounds2D.getHeight() * factor2d3d); super.setDepth(thickness); super.setWidth(bounds3D.getWidth()); super.setHeight(bounds3D.getHeight()); // Place object as 0,0 that is curently in the middle of 3D universe getTransforms().add(new Translate(bounds3D.getMinX() + bounds3D.getWidth() / 2, bounds3D.getMinY() + bounds3D.getHeight() / 2, 0)); setMaterial(material); snapshot(); super.setOnMouseMoved((MouseEvent me) -> { String mouseOverTileText = node2D.getImpl().getClass().getSimpleName(); iTile3DListener.onMouseMovedOnTile(mouseOverTileText); }); // super.setOnMouseClicked((MouseEvent event) -> { super.setOnMousePressed((MouseEvent event) -> { // Selection iTile3DListener.onMouseClickedOnTile(Tile3D.this); if(event.isSecondaryButtonDown()){ iTile3DListener.onMouseRightClickedOnTile(event); } }); }
Example 11
Source File: Meshes.java From paintera with GNU General Public License v2.0 | 4 votes |
public static PhongMaterial painteraPhongMaterial(final Color color) { final PhongMaterial material = new PhongMaterial(); material.setSpecularColor(color); material.setSpecularPower(50); return material; }
Example 12
Source File: Simple3DSphereApp.java From mars-sim with GNU General Public License v3.0 | 4 votes |
public Parent createContent() throws Exception { Image dImage = new Image(Simple3DSphereApp.class.getResource("/maps/earth-d.jpg").toExternalForm()); Image nImage = new Image(Simple3DSphereApp.class.getResource("/maps/earth-n.jpg").toExternalForm()); Image sImage = new Image(Simple3DSphereApp.class.getResource("/maps/earth-s.jpg").toExternalForm()); Image siImage = new Image(Simple3DSphereApp.class.getResource("/maps/earth-l.jpg").toExternalForm()); material = new PhongMaterial(); material.setDiffuseColor(Color.WHITE); material.diffuseMapProperty().bind( Bindings.when(diffuseMap).then(dImage).otherwise((Image) null)); material.setSpecularColor(Color.TRANSPARENT); material.specularMapProperty().bind( Bindings.when(specularMap).then(sImage).otherwise((Image) null)); material.bumpMapProperty().bind( Bindings.when(bumpMap).then(nImage).otherwise((Image) null)); material.selfIlluminationMapProperty().bind( Bindings.when(selfIlluminationMap).then(siImage).otherwise((Image) null)); earth = new Sphere(5); earth.setMaterial(material); earth.setRotationAxis(Rotate.Y_AXIS); // Create and position camera PerspectiveCamera camera = new PerspectiveCamera(true); camera.getTransforms().addAll( new Rotate(-20, Rotate.Y_AXIS), new Rotate(-20, Rotate.X_AXIS), new Translate(0, 0, -20)); sun = new PointLight(Color.rgb(255, 243, 234)); sun.translateXProperty().bind(sunDistance.multiply(-0.82)); sun.translateYProperty().bind(sunDistance.multiply(-0.41)); sun.translateZProperty().bind(sunDistance.multiply(-0.41)); sun.lightOnProperty().bind(sunLight); AmbientLight ambient = new AmbientLight(Color.rgb(1, 1, 1)); // Build the Scene Graph Group root = new Group(); root.getChildren().add(camera); root.getChildren().add(earth); root.getChildren().add(sun); root.getChildren().add(ambient); RotateTransition rt = new RotateTransition(Duration.seconds(24), earth); rt.setByAngle(360); rt.setInterpolator(Interpolator.LINEAR); rt.setCycleCount(Animation.INDEFINITE); rt.play(); // Use a SubScene SubScene subScene = new SubScene(root, 400, 300, true, SceneAntialiasing.BALANCED); subScene.setFill(Color.TRANSPARENT); subScene.setCamera(camera); return new Group(subScene); }
Example 13
Source File: SurfacePlot.java From FXyzLib with GNU General Public License v3.0 | 4 votes |
public void setHeightData(float[][] arrayY, int spacing, Color color, boolean ambient, boolean fill) { material = new PhongMaterial(); material.setSpecularColor(color); material.setDiffuseColor(color); mesh = new TriangleMesh(); // Fill Points for (int x = 0; x < arrayY.length; x++) { for (int z = 0; z < arrayY[0].length; z++) { mesh.getPoints().addAll(x * spacing, arrayY[x][z], z * spacing); } } //for now we'll just make an empty texCoordinate group mesh.getTexCoords().addAll(0, 0); int total = arrayY.length * arrayY.length; int nextRow = arrayY.length; //Add the faces "winding" the points generally counter clock wise for (int i = 0; i < total - nextRow -1; i++) { //Top upper left triangle mesh.getFaces().addAll(i,0,i+nextRow,0,i+1,0); //Top lower right triangle mesh.getFaces().addAll(i+nextRow,0,i+nextRow + 1,0,i+1,0); //Bottom } //Create a viewable MeshView to be added to the scene //To add a TriangleMesh to a 3D scene you need a MeshView container object meshView = new MeshView(mesh); //The MeshView allows you to control how the TriangleMesh is rendered if(fill) { meshView.setDrawMode(DrawMode.FILL); } else { meshView.setDrawMode(DrawMode.LINE); //show lines only by default } meshView.setCullFace(CullFace.BACK); //Removing culling to show back lines getChildren().add(meshView); meshView.setMaterial(material); if (ambient) { selfLight.getScope().add(meshView); if(!getChildren().contains(selfLight)) getChildren().add(selfLight); } else if(getChildren().contains(selfLight)) getChildren().remove(selfLight); setDepthTest(DepthTest.ENABLE); }
Example 14
Source File: PolyLine3D.java From FXyzLib with GNU General Public License v3.0 | 4 votes |
public PolyLine3D(List<Point3D> points, int width, Color color) { this.points = points; this.width = width; this.color = color; setDepthTest(DepthTest.ENABLE); mesh = new TriangleMesh(); //add each point. For each point add another point shifted on Z axis by width //This extra point allows us to build triangles later for(Point3D point: points) { mesh.getPoints().addAll(point.x,point.y,point.z); mesh.getPoints().addAll(point.x,point.y,point.z+width); } //add dummy Texture Coordinate mesh.getTexCoords().addAll(0,0); //Now generate trianglestrips for each line segment for(int i=2;i<points.size()*2;i+=2) { //add each segment //Vertices wound counter-clockwise which is the default front face of any Triange //These triangles live on the frontside of the line facing the camera mesh.getFaces().addAll(i,0,i-2,0,i+1,0); //add primary face mesh.getFaces().addAll(i+1,0,i-2,0,i-1,0); //add secondary Width face //Add the same faces but wind them clockwise so that the color looks correct when camera is rotated //These triangles live on the backside of the line facing away from initial the camera mesh.getFaces().addAll(i+1,0,i-2,0,i,0); //add primary face mesh.getFaces().addAll(i-1,0,i-2,0,i+1,0); //add secondary Width face } //Need to add the mesh to a MeshView before adding to our 3D scene meshView = new MeshView(mesh); meshView.setDrawMode(DrawMode.FILL); //Fill so that the line shows width material = new PhongMaterial(color); material.setDiffuseColor(color); material.setSpecularColor(color); meshView.setMaterial(material); //Make sure you Cull the Back so that no black shows through meshView.setCullFace(CullFace.BACK); //Add some ambient light so folks can see it AmbientLight light = new AmbientLight(Color.WHITE); light.getScope().add(meshView); getChildren().add(light); getChildren().add(meshView); }
Example 15
Source File: ScatterPlotMesh.java From FXyzLib with GNU General Public License v3.0 | 4 votes |
public void setXYZData(ArrayList<Double> xData, ArrayList<Double> yData, ArrayList<Double> zData) { xAxisData = xData; yAxisData = yData; zAxisData = zData; getChildren().clear(); //for now we will always default to x axis //later we could maybe dynamically determine the smallest axis and then //uses 0's for the other axes that are larger. ArrayList<Point3D> point3DList = new ArrayList<>(); for(int i=0;i<xAxisData.size();i++) { //some safety checks for array sizes double translateY = 0.0; double translateZ = 0.0; if(!yAxisData.isEmpty() && yAxisData.size() > i) translateY = yAxisData.get(i); if(!zAxisData.isEmpty() && zAxisData.size() > i) translateZ = zAxisData.get(i); setTranslateX(xAxisData.get(i)); //Convert to Floats and build list of adjusted points point3DList.add(new Point3D(new Float(xAxisData.get(i)), new Float(translateY), new Float(translateZ))); float width = 1; final TriangleMesh mesh = new TriangleMesh(); //add each point. For each point add another point shifted on Z axis by width //This extra point allows us to build triangles later for(Point3D point: point3DList) { //Rear points //top right rear point mesh.getPoints().addAll(point.x+width,point.y+width,point.z+width); //top left rear point mesh.getPoints().addAll(point.x-width,point.y+width,point.z+width); //bottom right rear point mesh.getPoints().addAll(point.x+width,point.y-width,point.z+width); //bottom left rear point mesh.getPoints().addAll(point.x-width,point.y-width,point.z+width); //Front points //top right front point mesh.getPoints().addAll(point.x+width,point.y+width,point.z-width); //top left front point mesh.getPoints().addAll(point.x-width,point.y+width,point.z-width); //bottom right front point mesh.getPoints().addAll(point.x+width,point.y-width,point.z-width); //bottom left front point mesh.getPoints().addAll(point.x-width,point.y-width,point.z-width); } //add dummy Texture Coordinate mesh.getTexCoords().addAll(0,0); //Now generate nodes for each point for(int p=8;p<point3DList.size()*7;p+=8) { //add each segment //Wind the next 8 vertices as a cube. The cube itself will represent the data //Vertices wound counter-clockwise which is the default front face of any Triangle //Rear triangle faces should be wound clockwise to face away from center mesh.getFaces().addAll(p,0,p+3,0,p+2,0); //TRR,BLR,BRR mesh.getFaces().addAll(p+3,0,p,0,p+1,0); //BLR,TRR,TLR //left side faces mesh.getFaces().addAll(p+1,0,p+5,0,p+3,0); //TLR,TLF,BLR mesh.getFaces().addAll(p+5,0,p+7,0,p+3,0); //TLF,BLR,BLF //front side faces mesh.getFaces().addAll(p+5,0,p+7,0,p+4,0); //TLF,BLF,TLR mesh.getFaces().addAll(p+4,0,p+7,0,p+6,0); //TRF,BLF,BRF //front side faces mesh.getFaces().addAll(p+4,0,p+6,0,p+2,0); //TRF,BRF,BRR mesh.getFaces().addAll(p+4,0,p+2,0,p,0); //TRF,BRR,TRR //Top faces mesh.getFaces().addAll(p,0,p+1,0,p+3,0); //TRR,TLR,TRF mesh.getFaces().addAll(p+1,0,p+5,0,p+3,0); //TLR,TLF,TRF //bottom faces mesh.getFaces().addAll(p+3,0,p+7,0,p+6,0); //BLR,BLF,BRF mesh.getFaces().addAll(p+3,0,p+6,0,p+2,0); //BLR,BRF,BRR } //Need to add the mesh to a MeshView before adding to our 3D scene MeshView meshView = new MeshView(mesh); meshView.setDrawMode(DrawMode.FILL); //Fill so that the line shows width Color hsb = Color.hsb((new Double(i) / 12) * 360, 1.0, 1.0, 0.5); PhongMaterial material = new PhongMaterial(hsb); material.setDiffuseColor(hsb); material.setSpecularColor(hsb); meshView.setMaterial(material); //Make sure you Cull the Back so that no black shows through meshView.setCullFace(CullFace.BACK); // //Add some ambient light so folks can see it // Group line = new Group(); // AmbientLight light = new AmbientLight(Color.WHITE); // light.getScope().add(meshView); // line.getChildren().add(light); // line.getChildren().add(meshView); getChildren().addAll(meshView); } }
Example 16
Source File: SphereSegment.java From FXyzLib with GNU General Public License v3.0 | 4 votes |
/** * @param radius radius of the sphere segment * @param color The sphere segment color. * @param phimin The starting azimutal angle [rad], 0-2*pi. * @param phimax The ending azimutal angle [rad], 0-2*pi, phimax > * phimin. * @param thetamin The starting polar angle [rad], -pi/2-pi/2. * @param thetamax The ending polar angle [rad], -pi/2-pi/2, thetamax > * thetamin. * @param granularity The number of segments of curves approximations, * granulariy > 2. * @param ambient Whether to have an ambient light or not * @param fill whether to show filled with the color param or as wire mesh */ public SphereSegment(double radius, Color color, double phimin, double phimax, double thetamin, double thetamax, int granularity, boolean ambient, boolean fill) { this.radius = radius; this.color = color; this.phimin = phimin; this.phimax = phimax; this.thetamin = thetamin; this.thetamax = thetamax; this.granularity = granularity; this.ambient = ambient; this.fill = fill; setDepthTest(DepthTest.ENABLE); mesh = new TriangleMesh(); // Fill Points double phi = phimin; double theta; PhongMaterial maxPhong = new PhongMaterial(); maxPhong.setSpecularColor(color); maxPhong.setDiffuseColor(color); for (int i = 0; i < granularity + 1; i++) { theta = thetamin; for (int j = 0; j < granularity + 1; j++) { Point3D p3D = new Point3D((float) (radius * Math.cos(theta) * Math.sin(phi)), (float) (radius * Math.cos(theta) * Math.cos(phi)), (float) (radius * Math.sin(theta))); mesh.getPoints().addAll(new Float(p3D.getX()), new Float(p3D.getY()), new Float(p3D.getZ())); theta += (thetamax - thetamin) / granularity; } phi += (phimax - phimin) / granularity; } //for now we'll just make an empty texCoordinate group mesh.getTexCoords().addAll(0, 0); //Add the faces "winding" the points generally counter clock wise for (int i = 0; i < granularity; i++) { int multiplier = (i * granularity) + i; //Up the Outside for (int j = multiplier; j < granularity + multiplier; j++) { mesh.getFaces().addAll(j, 0, j + 1, 0, j + granularity + 1, 0); //lower triangle mesh.getFaces().addAll(j + granularity + 1, 0, j + 1, 0, j + granularity + 2, 0); //upper triangle } //Down the Inside for (int j = granularity + multiplier; j > multiplier; j--) { mesh.getFaces().addAll(j, 0, j - 1, 0, j + granularity + 1, 0); //lower triangle mesh.getFaces().addAll(j - 1, 0, j + granularity, 0, j + granularity + 1, 0); //upper triangle } } //Create a viewable MeshView to be added to the scene //To add a TriangleMesh to a 3D scene you need a MeshView container object meshView = new MeshView(mesh); //The MeshView allows you to control how the TriangleMesh is rendered if (fill) { meshView.setDrawMode(DrawMode.FILL); } else { meshView.setDrawMode(DrawMode.LINE); //show lines only by default } meshView.setCullFace(CullFace.BACK); //Removing culling to show back lines getChildren().add(meshView); meshView.setMaterial(maxPhong); if (ambient) { AmbientLight light = new AmbientLight(Color.WHITE); light.getScope().add(meshView); getChildren().add(light); } }