JavaFX 8 - How to set NearClip and FarClip on a Parallel Camera?

六月ゝ 毕业季﹏ 提交于 2021-02-10 22:51:50

问题


I am part of a team building an application that manipulates a visual model using JavaFX 8 3D. We use both a Perspective Camera and a Parallel Camera. The Perspective Camera is working as expected. It is currently working with isEyeAtCameraZero false. This was done for maximum compatibility with the Parallel Camera.

The Perspective Camera behaves correctly when camera.setNearClip() and camera.setFarClip() are called.

The Parallel Camera does not appear to respond to camera.setNearClip() and camera.setFarClip(). The Parallel Camera does perform near and far clipping, but I have been unable to change the Parallel Camera clipping range.

I am using an algorithm based on the pseudo code on the JavaFX 8 Camera javadocs page to calculate the values passed into camera.setNearClip() and camera.setFarClip(). This appears to work correctly with the Perspective Camera but not the Parallel Camera.

Can anyone offer advice on how to manage the clipping range of the Parallel Camera?


回答1:


The ParallelCamera seems to ignore the clipping distances when calculating the orthogonal projection. Instead the Scene/SubScene's width or height determines the far and near clipping planes according to the package private method:

void computeProjectionTransform(GeneralTransform3D proj) {
    final double viewWidth = getViewWidth();
    final double viewHeight = getViewHeight();
    final double halfDepth = (viewWidth > viewHeight) ? viewWidth / 2.0 : viewHeight / 2.0;

    proj.ortho(0.0, viewWidth, viewHeight, 0.0, -halfDepth, halfDepth);
}

This makes the ParallelCamera quite useless for 3D rendering in JavaFX.



来源:https://stackoverflow.com/questions/27812656/javafx-8-how-to-set-nearclip-and-farclip-on-a-parallel-camera

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!