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;
}
}引用的其他类
-
- 引用位置:
字段
- 引用位置:
-
- 引用位置:
方法调用 - 关联成员:
RenderSystem.getDevice()
- 引用位置: