下面列出了怎么用javafx.scene.DepthTest的API类实例代码及写法,或者点击链接到github查看源代码。
public KnotMesh(double majorRadius, double minorRadius, double wireRadius, double p, double q,
int rDivs, int tDivs, int lengthCrop, int wireCrop) {
setMajorRadius(majorRadius);
setMinorRadius(minorRadius);
setWireRadius(wireRadius);
setP(p);
setQ(q);
setLengthDivisions(rDivs);
setWireDivisions(tDivs);
setLengthCrop(lengthCrop);
setWireCrop(wireCrop);
updateMesh();
setCullFace(CullFace.BACK);
setDrawMode(DrawMode.FILL);
setDepthTest(DepthTest.ENABLE);
}
public IcosahedronMesh(int level, float diameter){
setLevel(level);
setDiameter(diameter);
updateMesh();
setCullFace(CullFace.BACK);
setDrawMode(DrawMode.FILL);
setDepthTest(DepthTest.ENABLE);
diameterProperty().addListener((obs,f0,f1)->{
if(mesh!=null && f0!=null && f1!=null && f0.floatValue()>0 && f1.floatValue()>0){
updateVertices(f1.floatValue()/f0.floatValue());
}
});
levelProperty().addListener((obs,i0,i1)->{
if(mesh!=null && i1!=null && i1.intValue()>=0){
updateMesh();
}
});
}
public CurvedSpringMesh(double majorRadius, double minorRadius, double wireRadius, double pitch, double length,
int rDivs, int tDivs, int lengthCrop, int wireCrop) {
setMajorRadius(majorRadius);
setMinorRadius(minorRadius);
setWireRadius(wireRadius);
setPitch(pitch);
setLength(length);
setLengthDivisions(rDivs);
setWireDivisions(tDivs);
setLengthCrop(lengthCrop);
setWireCrop(wireCrop);
updateMesh();
setCullFace(CullFace.BACK);
setDrawMode(DrawMode.FILL);
setDepthTest(DepthTest.ENABLE);
}
public SpringMesh(double meanRadius, double wireRadius, double pitch, double length,
int rDivs, int tDivs, int lengthCrop, int wireCrop) {
setMeanRadius(meanRadius);
setWireRadius(wireRadius);
setPitch(pitch);
setLength(length);
factor=length/pitch;
setLengthDivisions(rDivs);
setWireDivisions(tDivs);
setLengthCrop(lengthCrop);
setWireCrop(wireCrop);
updateMesh();
setCullFace(CullFace.BACK);
setDrawMode(DrawMode.FILL);
setDepthTest(DepthTest.ENABLE);
}
protected Sample3D(double width, double height) {
super(width, height);
Group group3d = new Group(create3dContent());
group3d.setDepthTest(DepthTest.ENABLE);
group3d.getTransforms().addAll(
new Translate(width / 2, height / 2),
new Rotate(180, Rotate.X_AXIS)
);
getChildren().add(group3d);
}
private static Group createViewer(final MediaPlayer player, final double scale, boolean blur) {
Group mediaGroup = new Group();
final MediaView mediaView = new MediaView(player);
if (blur) {
BoxBlur bb = new BoxBlur();
bb.setWidth(4);
bb.setHeight(4);
bb.setIterations(1);
mediaView.setEffect(bb);
}
double width = player.getMedia().getWidth();
double height = player.getMedia().getHeight();
mediaView.setFitWidth(width);
mediaView.setTranslateX(-width/2.0);
mediaView.setScaleX(-scale);
mediaView.setFitHeight(height);
mediaView.setTranslateY(-height/2.0);
mediaView.setScaleY(scale);
mediaView.setDepthTest(DepthTest.ENABLE);
mediaGroup.getChildren().add(mediaView);
return mediaGroup;
}
protected Sample3D(double width, double height) {
super(width, height);
Group group3d = new Group(create3dContent());
group3d.setDepthTest(DepthTest.ENABLE);
group3d.getTransforms().addAll(
new Translate(width / 2, height / 2),
new Rotate(180, Rotate.X_AXIS)
);
getChildren().add(group3d);
}
private static Group createViewer(final MediaPlayer player, final double scale, boolean blur) {
Group mediaGroup = new Group();
final MediaView mediaView = new MediaView(player);
if (blur) {
BoxBlur bb = new BoxBlur();
bb.setWidth(4);
bb.setHeight(4);
bb.setIterations(1);
mediaView.setEffect(bb);
}
double width = player.getMedia().getWidth();
double height = player.getMedia().getHeight();
mediaView.setFitWidth(width);
mediaView.setTranslateX(-width/2.0);
mediaView.setScaleX(-scale);
mediaView.setFitHeight(height);
mediaView.setTranslateY(-height/2.0);
mediaView.setScaleY(scale);
mediaView.setDepthTest(DepthTest.ENABLE);
mediaGroup.getChildren().add(mediaView);
return mediaGroup;
}
private void init(Stage primaryStage) {
Group root = new Group();
root.setDepthTest(DepthTest.ENABLE);
primaryStage.setResizable(false);
primaryStage.setScene(new Scene(root, 400, 150, true));
primaryStage.getScene().setCamera(new PerspectiveCamera());
root.getTransforms().addAll(
new Translate(400 / 2, 150 / 2),
new Rotate(180, Rotate.X_AXIS)
);
root.getChildren().add(create3dContent());
}
private void init(Stage primaryStage) {
Group root = new Group();
root.setDepthTest(DepthTest.ENABLE);
primaryStage.setResizable(false);
primaryStage.setScene(new Scene(root, 500, 500, true));
primaryStage.getScene().setCamera(new PerspectiveCamera());
root.getTransforms().addAll(
new Translate(500 / 2, 500 / 2),
new Rotate(180, Rotate.X_AXIS)
);
root.getChildren().add(create3dContent());
}
private void init(Stage primaryStage) {
Group root = new Group();
root.setDepthTest(DepthTest.ENABLE);
primaryStage.setResizable(false);
primaryStage.setScene(new Scene(root, 400, 500, true));
primaryStage.getScene().setCamera(new PerspectiveCamera());
root.getTransforms().addAll(
new Translate(400 / 2, 500 / 2 + 100),
new Rotate(180, Rotate.X_AXIS)
);
root.getChildren().add(create3dContent());
}
/** @param disabled Disable mouse interaction?
* @throws Exception on error
*/
public Viewer3d (final boolean disabled) throws Exception
{
axes = buildAxes();
view.getChildren().add(axes);
root = new Group(view);
root.setDepthTest(DepthTest.ENABLE);
scene = new SubScene(root, 1024, 768, true, SceneAntialiasing.BALANCED);
scene.setManaged(false);
scene.setFill(Color.GRAY);
scene.heightProperty().bind(heightProperty());
scene.widthProperty().bind(widthProperty());
buildCamera();
scene.setCamera(camera);
// Legend, placed on top of 3D scene
final HBox legend = new HBox(10, createAxisLabel("X Axis", Color.RED),
createAxisLabel("Y Axis", Color.GREEN),
createAxisLabel("Z Axis", Color.BLUE));
legend.setPadding(new Insets(10));
getChildren().setAll(scene, legend);
if (! disabled)
handleMouse(this);
}
public SegmentedTorusMesh(int rDivs, int tDivs, int crop, double radius, double tRadius) {
setRadiusDivisions(rDivs);
setTubeDivisions(tDivs);
setTorusCrop(crop);
setRadius(radius);
setTubeRadius(tRadius);
setDepthTest(DepthTest.ENABLE);
updateMesh();
}
public SegmentedTorus(int rDivs, int tDivs, int crop, double radius, double tRadius) {
this();
mesh.setRadiusDivisions(rDivs);
mesh.setTubeDivisions(tDivs);
mesh.setTorusCrop(crop);
mesh.setRadius(radius);
mesh.setTubeRadius(tRadius);
mesh.setDepthTest(DepthTest.ENABLE);
}
private void init() {
getChildren().add(histogramDataGroup);
if (selfLightEnabled) {
getChildren().add(selfLight);
}
setDepthTest(DepthTest.ENABLE);
}
private void init(){
getChildren().add(scatterDataGroup); //Holds ScatterPlot data
if(selfLightEnabled) {
getChildren().add(selfLight);
}
setDepthTest(DepthTest.ENABLE);
}
public CuboidMesh(double width, double height, double depth, int level, Point3D center){
setWidth(width);
setHeight(height);
setDepth(depth);
setLevel(level);
setCenter(center);
updateMesh();
setCullFace(CullFace.BACK);
setDrawMode(DrawMode.FILL);
setDepthTest(DepthTest.ENABLE);
}
public SurfacePlotMesh(Function<Point2D,Number> function, double rangeX, double rangeY, int divisionsX, int divisionsY, double functionScale) {
setFunction2D(function);
setRangeX(rangeX);
setRangeY(rangeY);
setDivisionsX(divisionsX);
setDivisionsY(divisionsY);
setFunctionScale(functionScale);
updateMesh();
setCullFace(CullFace.BACK);
setDrawMode(DrawMode.FILL);
setDepthTest(DepthTest.ENABLE);
}
public TriangulatedMesh(List<Point3D> points, List<List<Point3D>> pointsHole, int level, double height, double holeRadius, Bounds bounds) {
this.pointsExterior=points;
this.pointsHoles=pointsHole;
setLevel(level);
setHeight(height);
setHoleRadius(holeRadius);
setBounds(bounds);
updateMesh();
setCullFace(CullFace.BACK);
setDrawMode(DrawMode.FILL);
setDepthTest(DepthTest.ENABLE);
}
public PrismMesh(double radius, double height, int level, Point3D pIni, Point3D pEnd){
setAxisOrigin(pIni==null?new Point3D(0,(float)height/2f,0):pIni);
setAxisEnd(pEnd==null?new Point3D(0,-(float)height/2f,0):pEnd);
setRadius(radius);
setHeight(getAxisEnd().substract(getAxisOrigin()).magnitude());
setLevel(level);
updateMesh();
setCullFace(CullFace.BACK);
setDrawMode(DrawMode.FILL);
setDepthTest(DepthTest.ENABLE);
}
public SegmentedTorusMesh(int rDivs, int tDivs, int crop, double majorRadius, double minorRadius) {
setMajorRadiusDivisions(rDivs);
setMinorRadiusDivisions(tDivs);
setMajorRadiusCrop(crop);
setMajorRadius(majorRadius);
setMinorRadius(minorRadius);
updateMesh();
setCullFace(CullFace.BACK);
setDrawMode(DrawMode.FILL);
setDepthTest(DepthTest.ENABLE);
}
public CSGMesh(CSG primitive){
this.primitive=primitive;
updateMesh();
setCullFace(CullFace.BACK);
setDrawMode(DrawMode.FILL);
setDepthTest(DepthTest.ENABLE);
}
public BezierMesh(BezierHelper spline, double wireRadius,
int rDivs, int tDivs, int lengthCrop, int wireCrop) {
setSpline(spline);
setWireRadius(wireRadius);
setLengthDivisions(rDivs);
setWireDivisions(tDivs);
setLengthCrop(lengthCrop);
setWireCrop(wireCrop);
updateMesh();
setCullFace(CullFace.BACK);
setDrawMode(DrawMode.FILL);
setDepthTest(DepthTest.ENABLE);
}
public TorusMesh(int rDivs, int tDivs, double radius, double tRadius) {
setRadiusDivisions(rDivs);
setTubeDivisions(tDivs);
setRadius(radius);
setTubeRadius(tRadius);
setDepthTest(DepthTest.ENABLE);
updateMesh();
}
public SegmentedSphereMesh(int tDivs, int cropX, int cropY, double radius, Point3D center) {
setRadiusDivisions(tDivs);
setRadiusCropX(cropX);
setRadiusCropY(cropY);
setRadius(radius);
setzOffset(1);
setCenter(center);
updateMesh();
setCullFace(CullFace.BACK);
setDrawMode(DrawMode.FILL);
setDepthTest(DepthTest.ENABLE);
}
public FrustumMesh(double majorRadius, double minorRadius, double height, int level, Point3D pIni, Point3D pEnd){
setAxisOrigin(pIni==null?new Point3D(0,(float)height/2f,0):pIni);
setAxisEnd(pEnd==null?new Point3D(0,-(float)height/2f,0):pEnd);
setMajorRadius(majorRadius);
setMinorRadius(minorRadius);
setLevel(level);
updateMesh();
setCullFace(CullFace.BACK);
setDrawMode(DrawMode.FILL);
setDepthTest(DepthTest.ENABLE);
}
public TetrahedraMesh(double height, int level, Point3D center){
setHeight(height);
setLevel(level);
setCenter(center);
updateMesh();
setCullFace(CullFace.BACK);
setDrawMode(DrawMode.FILL);
setDepthTest(DepthTest.ENABLE);
}
public BillBoard() {
super();
Image image = new Image("http://overshoot.tv/sites/overshoot.tv/files/Oak_Tree_0.png");
setFitWidth(800);
setPreserveRatio(true);
setSmooth(true);
setImage(image);
setDepthTest(DepthTest.ENABLE);
}
private void init(){
buildAxes(axesSize, axesThickness);
buildPanels(axesSize);
buildGrids(axesSize, gridLineSpacing);
buildEventHandlers();
getChildren().add(scatterDataGroup); //Holds ScatterPlot data
if(selfLightEnabled) {
PointLight light = new PointLight(Color.WHITE);
getChildren().add(light);
}
setDepthTest(DepthTest.ENABLE);
}
public Fx3DRawDataFileDataset(RawDataFile dataFile, float[][] intensityValues, int rtResolution,
int mzResolution, double maxBinnedIntensity, String fileName, Color peakColor) {
super(dataFile, fileName, peakColor);
this.intensityValues = intensityValues;
this.rtResolution = rtResolution;
this.mzResolution = mzResolution;
this.maxBinnedIntensity = maxBinnedIntensity;
mesh = new TriangleMesh();
peakListIndices = new int[rtResolution][mzResolution];
float factorX = (float) SIZE / rtResolution;
float factorZ = (float) SIZE / mzResolution;
for (int i = 0; i < rtResolution; i++) {
for (int j = 0; j < mzResolution; j++) {
if (maxIntensityValue < intensityValues[i][j]) {
maxIntensityValue = intensityValues[i][j];
}
}
}
for (int x = 0; x < rtResolution; x++) {
for (int z = 0; z < mzResolution; z++) {
mesh.getPoints().addAll((float) x * factorX, -intensityValues[x][z] * AMPLIFI,
(float) z * factorZ);
if (intensityValues[x][z] > 0.022 * maxIntensityValue) {
peakListIndices[x][z] = 1;
}
}
}
int rtLength = rtResolution;
int mzLength = mzResolution;
float rtTotal = rtLength;
float mzTotal = mzLength;
for (float x = 0; x < rtLength - 1; x++) {
for (float y = 0; y < mzLength - 1; y++) {
float x0 = x / rtTotal;
float y0 = y / mzTotal;
float x1 = (x + 1) / rtTotal;
float y1 = (y + 1) / mzTotal;
mesh.getTexCoords().addAll( //
x0, y0, // 0, top-left
x0, y1, // 1, bottom-left
x1, y0, // 2, top-right
x1, y1 // 3, bottom-right
);
}
}
// faces
for (int x = 0; x < rtLength - 1; x++) {
for (int z = 0; z < mzLength - 1; z++) {
int tl = x * mzLength + z; // top-left
int bl = x * mzLength + z + 1; // bottom-left
int tr = (x + 1) * mzLength + z; // top-right
int br = (x + 1) * mzLength + z + 1; // bottom-right
int offset = (x * (mzLength - 1) + z) * 8 / 2; // div 2 because
// we have u AND
// v in the list
// working
mesh.getFaces().addAll(bl, offset + 1, tl, offset + 0, tr, offset + 2);
mesh.getFaces().addAll(tr, offset + 2, br, offset + 3, bl, offset + 1);
}
}
setNodeColor(peakColor);
meshView.setMesh(mesh);
meshView.setCullFace(CullFace.NONE);
meshView.setDrawMode(DrawMode.FILL);
meshView.setDepthTest(DepthTest.ENABLE);
logger.finest("Plot mesh is ready.");
}