OrthoViewHandler.java 文件源码

java
阅读 20 收藏 0 点赞 0 评论 0

项目:mineshot 作者:
@SubscribeEvent
public void onFogDensity(EntityViewRenderEvent.FogDensity evt) {
    if (!enabled) {
        return;
    }

    // update zoom and rotation
    if (!modifierKeyPressed()) {
        int ticksElapsed = tick - tickPrevious;
        double partial = evt.getRenderPartialTicks();
        double elapsed = ticksElapsed + (partial - partialPrevious);
        elapsed *= SECONDS_PER_TICK * ROTATE_SPEED;
        updateZoomAndRotation(elapsed);

        tickPrevious = tick;
        partialPrevious = partial;
    }

    float width = zoom * (MC.displayWidth / (float) MC.displayHeight);
    float height = zoom;

    // override projection matrix
    GlStateManager.matrixMode(GL_PROJECTION);
    GlStateManager.loadIdentity();

    Projection.ortho(-width, width, -height, height, clip ? 0 : -9999, 9999);

    // rotate the orthographic camera with the player view
    if (freeCam) {
        xRot = MC.player.rotationPitch;
        yRot = MC.player.rotationYaw - 180;
    }

    // override camera view matrix
    GlStateManager.matrixMode(GL_MODELVIEW);
    GlStateManager.loadIdentity();
    GlStateManager.rotate(xRot, 1, 0, 0);
    GlStateManager.rotate(yRot, 0, 1, 0);

    // fix particle rotation if the camera isn't following the player view
    if (!freeCam) {
        float pitch = xRot;
        float yaw = yRot + 180;
        setRotationX(MathHelper.cos(yaw * (float) Math.PI / 180f));
        setRotationZ(MathHelper.sin(yaw * (float) Math.PI / 180f));
        setRotationYZ(-ActiveRenderInfo.getRotationZ() * MathHelper.sin(pitch * (float) Math.PI / 180f));
        setRotationXY(ActiveRenderInfo.getRotationX() * MathHelper.sin(pitch * (float) Math.PI / 180f));
        setRotationXZ(MathHelper.cos(pitch * (float) Math.PI / 180f));
    }
}
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号