Projection.java

net.minecraft.client.renderer.Projection

信息

  • 全限定名:net.minecraft.client.renderer.Projection
  • 类型:public class
  • 包:net.minecraft.client.renderer
  • 源码路径:src/main/java/net/minecraft/client/renderer/Projection.java
  • 起始行号:L10
  • 职责:

    TODO

字段/常量

  • projectionType

    • 类型: ProjectionType
    • 修饰符: private
    • 源码定位: L11
    • 说明:

      TODO

  • zNear

    • 类型: float
    • 修饰符: private
    • 源码定位: L12
    • 说明:

      TODO

  • zFar

    • 类型: float
    • 修饰符: private
    • 源码定位: L13
    • 说明:

      TODO

  • perspectiveFov

    • 类型: float
    • 修饰符: private
    • 源码定位: L14
    • 说明:

      TODO

  • width

    • 类型: float
    • 修饰符: private
    • 源码定位: L15
    • 说明:

      TODO

  • height

    • 类型: float
    • 修饰符: private
    • 源码定位: L16
    • 说明:

      TODO

  • orthoInvertY

    • 类型: boolean
    • 修饰符: private
    • 源码定位: L17
    • 说明:

      TODO

  • isMatrixDirty

    • 类型: boolean
    • 修饰符: private
    • 源码定位: L18
    • 说明:

      TODO

  • matrix

    • 类型: Matrix4f
    • 修饰符: private final
    • 源码定位: L19
    • 说明:

      TODO

  • matrixVersion

    • 类型: long
    • 修饰符: private
    • 源码定位: L20
    • 说明:

      TODO

内部类/嵌套类型

构造器

方法

下面的方法块按源码顺序生成。

public void setupPerspective(float zNear, float zFar, float fov, float width, float height) @ L22

  • 方法名:setupPerspective
  • 源码定位:L22
  • 返回类型:void
  • 修饰符:public

参数:

  • zNear: float
  • zFar: float
  • fov: float
  • width: float
  • height: float

说明:

TODO

public void setupOrtho(float zNear, float zFar, float width, float height, boolean invertY) @ L39

  • 方法名:setupOrtho
  • 源码定位:L39
  • 返回类型:void
  • 修饰符:public

参数:

  • zNear: float
  • zFar: float
  • width: float
  • height: float
  • invertY: boolean

说明:

TODO

public void setSize(float width, float height) @ L57

  • 方法名:setSize
  • 源码定位:L57
  • 返回类型:void
  • 修饰符:public

参数:

  • width: float
  • height: float

说明:

TODO

public Matrix4f getMatrix(Matrix4f dest) @ L63

  • 方法名:getMatrix
  • 源码定位:L63
  • 返回类型:Matrix4f
  • 修饰符:public

参数:

  • dest: Matrix4f

说明:

TODO

public long getMatrixVersion() @ L95

  • 方法名:getMatrixVersion
  • 源码定位:L95
  • 返回类型:long
  • 修饰符:public

参数:

说明:

TODO

public float zNear() @ L99

  • 方法名:zNear
  • 源码定位:L99
  • 返回类型:float
  • 修饰符:public

参数:

说明:

TODO

public float zFar() @ L103

  • 方法名:zFar
  • 源码定位:L103
  • 返回类型:float
  • 修饰符:public

参数:

说明:

TODO

public float width() @ L107

  • 方法名:width
  • 源码定位:L107
  • 返回类型:float
  • 修饰符:public

参数:

说明:

TODO

public float height() @ L111

  • 方法名:height
  • 源码定位:L111
  • 返回类型:float
  • 修饰符:public

参数:

说明:

TODO

public float fov() @ L115

  • 方法名:fov
  • 源码定位:L115
  • 返回类型:float
  • 修饰符:public

参数:

说明:

TODO

public boolean invertY() @ L119

  • 方法名:invertY
  • 源码定位:L119
  • 返回类型:boolean
  • 修饰符:public

参数:

说明:

TODO

代码

@OnlyIn(Dist.CLIENT)
public class Projection {
    private ProjectionType projectionType = ProjectionType.PERSPECTIVE;
    private float zNear;
    private float zFar;
    private float perspectiveFov;
    private float width;
    private float height;
    private boolean orthoInvertY;
    private boolean isMatrixDirty;
    private final Matrix4f matrix = new Matrix4f();
    private long matrixVersion = -1L;
 
    public void setupPerspective(float zNear, float zFar, float fov, float width, float height) {
        if (this.projectionType != ProjectionType.PERSPECTIVE
            || this.zNear != zNear
            || this.zFar != zFar
            || this.perspectiveFov != fov
            || this.width != width
            || this.height != height) {
            this.isMatrixDirty = true;
            this.projectionType = ProjectionType.PERSPECTIVE;
            this.zNear = zNear;
            this.zFar = zFar;
            this.perspectiveFov = fov;
            this.width = width;
            this.height = height;
        }
    }
 
    public void setupOrtho(float zNear, float zFar, float width, float height, boolean invertY) {
        if (this.projectionType != ProjectionType.ORTHOGRAPHIC
            || this.zNear != zNear
            || this.zFar != zFar
            || this.width != width
            || this.height != height
            || this.orthoInvertY != invertY) {
            this.isMatrixDirty = true;
            this.projectionType = ProjectionType.ORTHOGRAPHIC;
            this.zNear = zNear;
            this.zFar = zFar;
            this.perspectiveFov = 0.0F;
            this.width = width;
            this.height = height;
            this.orthoInvertY = invertY;
        }
    }
 
    public void setSize(float width, float height) {
        this.isMatrixDirty = true;
        this.width = width;
        this.height = height;
    }
 
    public Matrix4f getMatrix(Matrix4f dest) {
        if (!this.isMatrixDirty) {
            return dest.set(this.matrix);
        } else {
            this.isMatrixDirty = false;
            this.matrixVersion++;
            return this.projectionType == ProjectionType.PERSPECTIVE
                ? dest.set(
                    this.matrix
                        .setPerspective(
                            this.perspectiveFov * (float) (Math.PI / 180.0),
                            this.width / this.height,
                            this.zNear,
                            this.zFar,
                            RenderSystem.getDevice().isZZeroToOne()
                        )
                )
                : dest.set(
                    this.matrix
                        .setOrtho(
                            0.0F,
                            this.width,
                            this.orthoInvertY ? this.height : 0.0F,
                            this.orthoInvertY ? 0.0F : this.height,
                            this.zNear,
                            this.zFar,
                            RenderSystem.getDevice().isZZeroToOne()
                        )
                );
        }
    }
 
    public long getMatrixVersion() {
        return this.isMatrixDirty ? this.matrixVersion + 1L : this.matrixVersion;
    }
 
    public float zNear() {
        return this.zNear;
    }
 
    public float zFar() {
        return this.zFar;
    }
 
    public float width() {
        return this.width;
    }
 
    public float height() {
        return this.height;
    }
 
    public float fov() {
        return this.perspectiveFov;
    }
 
    public boolean invertY() {
        return this.orthoInvertY;
    }
}

引用的其他类