Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/java/394.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
JavaFX 3D绕纬度旋转摄影机Y_Java_Javafx_3d - Fatal编程技术网

JavaFX 3D绕纬度旋转摄影机Y

JavaFX 3D绕纬度旋转摄影机Y,java,javafx,3d,Java,Javafx,3d,我已经定义了一个围绕场景原点旋转的摄影机,具有旋转X轴和旋转Y轴 我希望X轴定义Y轴相机的“高度”,使其围绕球体上的给定纬度旋转 我已将旋转定义为: _cameraTranslate = new Translate(0, 0, -10); _cameraRotateX = new MyRotate(0, 0, 0, 10, Rotate.X_AXIS); _cameraRotateY = new MyRotate(0, 0, 0, 10, Rotate.Y_AXIS);

我已经定义了一个围绕场景原点旋转的摄影机,具有旋转X轴和旋转Y轴

我希望X轴定义Y轴相机的“高度”,使其围绕球体上的给定纬度旋转

我已将旋转定义为:

    _cameraTranslate = new Translate(0, 0, -10);
    _cameraRotateX = new MyRotate(0, 0, 0, 10, Rotate.X_AXIS);
    _cameraRotateY = new MyRotate(0, 0, 0, 10, Rotate.Y_AXIS);
    _camera.getTransforms().addAll(_cameraTranslate, _cameraRotateX, _cameraRotateY);
并将其按如下方式旋转:

private void onMouseDragged(MouseEvent e) {
    _cameraRotateX.setAngle360(_cameraRotateX.getAngle() - (-e.getSceneY() + _mouseOldY));
    _cameraRotateY.setAngle360(_cameraRotateY.getAngle() - (e.getSceneX() - _mouseOldX));

    _mouseOldX = e.getSceneX();
    _mouseOldY = e.getSceneY();
}
这就是当我旋转时它所做的,移动世界,而不是保持X轴线平行于帧(如果有意义的话)


我意识到我必须修改X相机的轴(上下移动的轴)。当相机绕Y轴旋转时,X轴和Z轴移动,因此需要相应地调整旋转

相反,我添加了一个Point3D,每次移动Y摄影机时都会对其进行修改:

_cameraRotateXAxis = new Point3D(1, 0, 0);
_cameraRotateX = new MyRotate(0, 0, 0, 10, _cameraRotateXAxis);
在鼠标标记方法中:

private void onMouseDragged(MouseEvent e) {
    _cameraRotateX.setAngle360(_cameraRotateX.getAngle() - (-e.getSceneY() + _mouseOldY));
    _cameraRotateY.setAngle360(_cameraRotateY.getAngle() - (e.getSceneX() - _mouseOldX));

    _cameraRotateXAxis = _cameraRotateXAxis.add(-_cameraRotateXAxis.getX(), -_cameraRotateXAxis.getY(), -_cameraRotateXAxis.getZ());

    double angle = _cameraRotateY.getAngle();
    double newDelta = _cameraRotateY.getAngle()%90 / 90d;
    if (angle >= 0 && angle < 90) {
        _cameraRotateXAxis = _cameraRotateXAxis.add(-(1 - newDelta), 0, newDelta);
    }
    else if (angle >= 90 && angle < 180) {
        _cameraRotateXAxis = _cameraRotateXAxis.add(newDelta, 0, 1 -newDelta);
    }
    else if (angle >= 180 && angle < 270) {
        _cameraRotateXAxis = _cameraRotateXAxis.add(1 - newDelta, 0, -newDelta);
    }
    else {
        _cameraRotateXAxis = _cameraRotateXAxis.add(-newDelta, 0, -(1 - newDelta));
    }

    _mouseOldX = e.getSceneX();
    _mouseOldY = e.getSceneY();
}
MouseEvent(MouseEvent e)上的私有void{
_cameraRotateX.setAngle360(_cameraRotateX.getAngle()-(-e.getSceneY()+_mouseOldY));
_cameraRotateY.setAngle360(_cameraRotateY.getAngle()-(e.getSceneX()-_mouseOldX));
_cameraRotateXAxis=\u cameraRotateXAxis.add(-\u cameraRotateXAxis.getX(),-\u cameraRotateXAxis.getY(),-\u cameraRotateXAxis.getZ());
双角度=_cameraRotateY.getAngle();
double newDelta=_cameraRotateY.getAngle()%90/90d;
如果(角度>=0和角度<90){
_cameraRotateXAxis=_cameraRotateXAxis.add(-(1-newDelta),0,newDelta);
}
否则,如果(角度>=90和角度<180){
_cameraRotateXAxis=\u cameraRotateXAxis.add(newDelta,0,1-newDelta);
}
否则,如果(角度>=180和角度<270){
_cameraRotateXAxis=\u cameraRotateXAxis.add(1-newDelta,0-newDelta);
}
否则{
_cameraRotateXAxis=_cameraRotateXAxis.add(-newDelta,0,-(1-newDelta));
}
_mouseOldX=e.getSceneX();
_mouseOldY=e.getSceneY();
}