I'm working on a 3D project in JavaFX 8. I have built a Car 3d Model with several TriangleMesh objects I'm also using several other JavaFX 'Shape 3D's to create the wheels and axles.
The problem is that the MeshViews elements seem transparent. I can see the other Shape3D objects thru it
2 Cylinders are visible even though the MeshView is in front of it
Here is an example of one of the TriangleMesh's I made
// ============================= ROOF ============================= //
TriangleMesh roofMesh = new TriangleMesh(VertexFormat.POINT_TEXCOORD);
roofMesh.getPoints().addAll(
/* X */ -roofWidth/2.f, /* Y */ roofHeight + wheelDiameter / 2 + wheelGap + doorHeight, /* Z */ - roofLength/2, //PT0
/* X */ roofWidth/2.f, /* Y */ roofHeight + wheelDiameter / 2 + wheelGap + doorHeight, /* Z */ - roofLength/2, //PT1
/* X */ -roofWidth/2.f, /* Y */ roofHeight + wheelDiameter / 2 + wheelGap + doorHeight, /* Z */ roofLength/2, //PT2
/* X */ roofWidth/2.f, /* Y */ roofHeight + wheelDiameter / 2 + wheelGap + doorHeight, /* Z */ roofLength/2 //PT3
);
roofMesh.getTexCoords().addAll(
0, 0, // t0
1, 0, // t1
0, 1, // t2
1, 1 // t3
);
roofMesh.getFaces().addAll(
1,1, 0,0,2,2,
3,3, 1,2 ,2,1
);
After Creating the mesh I'm creating a new MeshView object
meshViewMap.put("roof", new MeshView(roofMesh));
I have also applied a Material to the MeshViews:
private void setTexColor(Shape3D shape, Color c, String imagePath )
{
PhongMaterial pm = new PhongMaterial();
pm.setDiffuseColor(c);
pm.setSpecularColor(c);
shape.setMaterial(pm);
}
These are the Cylinder that you can see in the image:
//Create Axles
Cylinder frontCylinder = new Cylinder(0.5, bodyWidth);
Cylinder rearCylinder = new Cylinder(0.5, bodyWidth);
PhongMaterial cylinderMat = new PhongMaterial();
cylinderMat.setDiffuseColor(Color.BLACK);
cylinderMat.setSpecularColor(Color.BLACK);
frontCylinder.setMaterial(cylinderMat);
rearCylinder.setMaterial(cylinderMat);
frontCylinder.setRotate(90);
rearCylinder.setRotate(90);
frontCylinder.setTranslateZ( 0.7f * (bodyLength/2 + hoodLength/2));
rearCylinder.setTranslateZ( -0.4f * (bodyLength/2 + hoodLength/2));
frontCylinder.setTranslateY(wheelDiameter/2);
rearCylinder.setTranslateY(wheelDiameter/2);
this.getChildren().add(frontCylinder);
this.getChildren().add(rearCylinder);
I have tried to set the opacity to 1 even though it is the default value.
Java Version 8.0.121-b13