JavaFX 8 - 如何在并行相机上设置 NearClip 和 FarClip? [英] JavaFX 8 - How to set NearClip and FarClip on a Parallel Camera?

查看:40
本文介绍了JavaFX 8 - 如何在并行相机上设置 NearClip 和 FarClip?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我是构建应用程序的团队的一员,该应用程序使用 JavaFX 8 3D 操作可视化模型.我们同时使用透视相机和平行相机.透视相机按预期工作.它目前正在使用 isEyeAtCameraZero false.这样做是为了最大程度地兼容并行相机.

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.

camera.setNearClip()camera.setFarClip() 被调用时,透视相机的行为是正确的.

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

Parallel Camera 似乎没有响应 camera.setNearClip()camera.setFarClip().Parallel Camera 确实可以执行近距和远距剪裁,但我一直无法更改 Parallel Camera 剪裁范围.

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.

我正在使用基于 JavaFX 8 Camera javadocs 页面上的伪代码的算法来计算传递给 camera.setNearClip()camera 的值.setFarClip().这似乎适用于透视相机,但不适用于平行相机.

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?

推荐答案

ParallelCamera 在计算正交投影时似乎忽略了裁剪距离.相反,Scene/SubScene 的宽度或高度根据包私有方法确定远近裁剪平面:

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);
}

这使得 ParallelCamera 对于 JavaFX 中的 3D 渲染毫无用处.

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

这篇关于JavaFX 8 - 如何在并行相机上设置 NearClip 和 FarClip?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆