fisheyelens.java

来自「Sunflow是一个照片级的渲染系统」· Java 代码 · 共 21 行

JAVA
21
字号
package org.sunflow.core.camera;

import org.sunflow.SunflowAPI;
import org.sunflow.core.CameraLens;
import org.sunflow.core.ParameterList;
import org.sunflow.core.Ray;

public class FisheyeLens implements CameraLens {
    public boolean update(ParameterList pl, SunflowAPI api) {
        return true;
    }

    public Ray getRay(float x, float y, int imageWidth, int imageHeight, double lensX, double lensY, double time) {
        float cx = 2.0f * x / imageWidth - 1.0f;
        float cy = 2.0f * y / imageHeight - 1.0f;
        float r2 = cx * cx + cy * cy;
        if (r2 > 1)
            return null; // outside the fisheye
        return new Ray(0, 0, 0, cx, cy, (float) -Math.sqrt(1 - r2));
    }
}

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?