Search in sources :

Example 1 with Matrix4d

use of com.enderio.core.common.vecmath.Matrix4d in project EnderIO by SleepyTrousers.

the class BlockSceneRenderer method applyCamera.

private void applyCamera() {
    Rectangle vp = camera.getViewport();
    GL11.glViewport(vp.x, vp.y, vp.width, vp.height);
    GL11.glClear(GL11.GL_DEPTH_BUFFER_BIT);
    GL11.glMatrixMode(GL11.GL_PROJECTION);
    final Matrix4d camaraViewMatrix = camera.getTransposeProjectionMatrix();
    if (camaraViewMatrix != null) {
        RenderUtil.loadMatrix(camaraViewMatrix);
    }
    GL11.glMatrixMode(GL11.GL_MODELVIEW);
    final Matrix4d cameraViewMatrix = camera.getTransposeViewMatrix();
    if (cameraViewMatrix != null) {
        RenderUtil.loadMatrix(cameraViewMatrix);
    }
    GL11.glTranslatef(-(float) eye.x, -(float) eye.y, -(float) eye.z);
}
Also used : Matrix4d(com.enderio.core.common.vecmath.Matrix4d) Rectangle(java.awt.Rectangle)

Example 2 with Matrix4d

use of com.enderio.core.common.vecmath.Matrix4d in project EnderIO by SleepyTrousers.

the class TravelController method onRender.

@SubscribeEvent
public void onRender(@Nonnull RenderWorldLastEvent event) {
    Minecraft mc = Minecraft.getMinecraft();
    Vector3d eye = Util.getEyePositionEio(mc.player);
    Vector3d lookAt = Util.getLookVecEio(mc.player);
    lookAt.add(eye);
    Matrix4d mv = VecmathUtil.createMatrixAsLookAt(eye, lookAt, new Vector3d(0, 1, 0));
    float fov = Minecraft.getMinecraft().gameSettings.fovSetting;
    Matrix4d pr = VecmathUtil.createProjectionMatrixAsPerspective(fov, 0.05f, mc.gameSettings.renderDistanceChunks * 16, mc.displayWidth, mc.displayHeight);
    currentView.setProjectionMatrix(pr);
    currentView.setViewMatrix(mv);
    currentView.setViewport(0, 0, mc.displayWidth, mc.displayHeight);
    fovRad = Math.toRadians(fov);
    tanFovRad = Math.tanh(fovRad);
}
Also used : Matrix4d(com.enderio.core.common.vecmath.Matrix4d) Vector3d(com.enderio.core.common.vecmath.Vector3d) Minecraft(net.minecraft.client.Minecraft) SubscribeEvent(net.minecraftforge.fml.common.eventhandler.SubscribeEvent)

Example 3 with Matrix4d

use of com.enderio.core.common.vecmath.Matrix4d in project EnderIO by SleepyTrousers.

the class IoConfigRenderer method applyCamera.

private void applyCamera(float partialTick) {
    Rectangle vp = camera.getViewport();
    GL11.glViewport(vp.x, vp.y, vp.width, vp.height);
    GL11.glClear(GL11.GL_DEPTH_BUFFER_BIT);
    GL11.glMatrixMode(GL11.GL_PROJECTION);
    final Matrix4d camaraViewMatrix = camera.getTransposeProjectionMatrix();
    if (camaraViewMatrix != null) {
        RenderUtil.loadMatrix(camaraViewMatrix);
    }
    GL11.glMatrixMode(GL11.GL_MODELVIEW);
    final Matrix4d cameraViewMatrix = camera.getTransposeViewMatrix();
    if (cameraViewMatrix != null) {
        RenderUtil.loadMatrix(cameraViewMatrix);
    }
    GL11.glTranslatef(-(float) eye.x, -(float) eye.y, -(float) eye.z);
}
Also used : Matrix4d(com.enderio.core.common.vecmath.Matrix4d) Rectangle(java.awt.Rectangle)

Aggregations

Matrix4d (com.enderio.core.common.vecmath.Matrix4d)3 Rectangle (java.awt.Rectangle)2 Vector3d (com.enderio.core.common.vecmath.Vector3d)1 Minecraft (net.minecraft.client.Minecraft)1 SubscribeEvent (net.minecraftforge.fml.common.eventhandler.SubscribeEvent)1