Java Code Examples for org.joml.Matrix4f#m30()

The following examples show how to use org.joml.Matrix4f#m30() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: Renderer.java    From lwjglbook with Apache License 2.0 6 votes vote down vote up
private void renderSkyBox(Window window, Camera camera, Scene scene) {
    SkyBox skyBox = scene.getSkyBox();
    if (skyBox != null) {
        skyBoxShaderProgram.bind();

        skyBoxShaderProgram.setUniform("texture_sampler", 0);

        Matrix4f projectionMatrix = transformation.getProjectionMatrix();
        skyBoxShaderProgram.setUniform("projectionMatrix", projectionMatrix);
        Matrix4f viewMatrix = transformation.getViewMatrix();
        viewMatrix.m30(0);
        viewMatrix.m31(0);
        viewMatrix.m32(0);
        Matrix4f modelViewMatrix = transformation.buildModelViewMatrix(skyBox, viewMatrix);
        skyBoxShaderProgram.setUniform("modelViewMatrix", modelViewMatrix);
        skyBoxShaderProgram.setUniform("ambientLight", scene.getSceneLight().getSkyBoxLight());

        scene.getSkyBox().getMesh().render();

        skyBoxShaderProgram.unbind();
    }
}
 
Example 2
Source File: Renderer.java    From lwjglbook with Apache License 2.0 6 votes vote down vote up
private void renderSkyBox(Window window, Camera camera, Scene scene) {
    SkyBox skyBox = scene.getSkyBox();
    if (skyBox != null) {
        skyBoxShaderProgram.bind();

        skyBoxShaderProgram.setUniform("texture_sampler", 0);

        Matrix4f projectionMatrix = transformation.getProjectionMatrix();
        skyBoxShaderProgram.setUniform("projectionMatrix", projectionMatrix);
        Matrix4f viewMatrix = transformation.getViewMatrix();
        viewMatrix.m30(0);
        viewMatrix.m31(0);
        viewMatrix.m32(0);
        Matrix4f modelViewMatrix = transformation.buildModelViewMatrix(skyBox, viewMatrix);
        skyBoxShaderProgram.setUniform("modelViewMatrix", modelViewMatrix);
        skyBoxShaderProgram.setUniform("ambientLight", scene.getSceneLight().getSkyBoxLight());

        scene.getSkyBox().getMesh().render();

        skyBoxShaderProgram.unbind();
    }
}
 
Example 3
Source File: Renderer.java    From lwjglbook with Apache License 2.0 6 votes vote down vote up
private void renderSkyBox(Window window, Camera camera, Scene scene) {
    skyBoxShaderProgram.bind();

    skyBoxShaderProgram.setUniform("texture_sampler", 0);

    Matrix4f projectionMatrix = transformation.getProjectionMatrix();
    skyBoxShaderProgram.setUniform("projectionMatrix", projectionMatrix);
    SkyBox skyBox = scene.getSkyBox();
    Matrix4f viewMatrix = transformation.getViewMatrix();
    viewMatrix.m30(0);
    viewMatrix.m31(0);
    viewMatrix.m32(0);
    Matrix4f modelViewMatrix = transformation.buildModelViewMatrix(skyBox, viewMatrix);
    skyBoxShaderProgram.setUniform("modelViewMatrix", modelViewMatrix);
    skyBoxShaderProgram.setUniform("ambientLight", scene.getSceneLight().getSkyBoxLight());

    scene.getSkyBox().getMesh().render();

    skyBoxShaderProgram.unbind();
}
 
Example 4
Source File: AnimMeshesLoader.java    From lwjglbook with Apache License 2.0 6 votes vote down vote up
private static Matrix4f toMatrix(AIMatrix4x4 aiMatrix4x4) {
    Matrix4f result = new Matrix4f();
    result.m00(aiMatrix4x4.a1());
    result.m10(aiMatrix4x4.a2());
    result.m20(aiMatrix4x4.a3());
    result.m30(aiMatrix4x4.a4());
    result.m01(aiMatrix4x4.b1());
    result.m11(aiMatrix4x4.b2());
    result.m21(aiMatrix4x4.b3());
    result.m31(aiMatrix4x4.b4());
    result.m02(aiMatrix4x4.c1());
    result.m12(aiMatrix4x4.c2());
    result.m22(aiMatrix4x4.c3());
    result.m32(aiMatrix4x4.c4());
    result.m03(aiMatrix4x4.d1());
    result.m13(aiMatrix4x4.d2());
    result.m23(aiMatrix4x4.d3());
    result.m33(aiMatrix4x4.d4());

    return result;
}
 
Example 5
Source File: Renderer.java    From lwjglbook with Apache License 2.0 6 votes vote down vote up
private void renderSkyBox(Window window, Camera camera, Scene scene) {
    skyBoxShaderProgram.bind();

    skyBoxShaderProgram.setUniform("texture_sampler", 0);

    Matrix4f projectionMatrix = transformation.getProjectionMatrix();
    skyBoxShaderProgram.setUniform("projectionMatrix", projectionMatrix);
    SkyBox skyBox = scene.getSkyBox();
    Matrix4f viewMatrix = transformation.getViewMatrix();
    viewMatrix.m30(0);
    viewMatrix.m31(0);
    viewMatrix.m32(0);
    Matrix4f modelViewMatrix = transformation.buildModelViewMatrix(skyBox, viewMatrix);
    skyBoxShaderProgram.setUniform("modelViewMatrix", modelViewMatrix);
    skyBoxShaderProgram.setUniform("ambientLight", scene.getSceneLight().getAmbientLight());

    scene.getSkyBox().getMesh().render();

    skyBoxShaderProgram.unbind();
}
 
Example 6
Source File: Renderer.java    From lwjglbook with Apache License 2.0 6 votes vote down vote up
private void renderSkyBox(Window window, Camera camera, Scene scene) {
    skyBoxShaderProgram.bind();

    skyBoxShaderProgram.setUniform("texture_sampler", 0);

    // Update projection Matrix
    Matrix4f projectionMatrix = transformation.getProjectionMatrix(FOV, window.getWidth(), window.getHeight(), Z_NEAR, Z_FAR);
    skyBoxShaderProgram.setUniform("projectionMatrix", projectionMatrix);
    SkyBox skyBox = scene.getSkyBox();
    Matrix4f viewMatrix = transformation.getViewMatrix(camera);
    viewMatrix.m30(0);
    viewMatrix.m31(0);
    viewMatrix.m32(0);
    Matrix4f modelViewMatrix = transformation.getModelViewMatrix(skyBox, viewMatrix);
    skyBoxShaderProgram.setUniform("modelViewMatrix", modelViewMatrix);
    skyBoxShaderProgram.setUniform("ambientLight", scene.getSceneLight().getAmbientLight());
            
    scene.getSkyBox().getMesh().render();

    skyBoxShaderProgram.unbind();
}
 
Example 7
Source File: Renderer.java    From lwjglbook with Apache License 2.0 6 votes vote down vote up
private void renderSkyBox(Window window, Camera camera, Scene scene) {
    skyBoxShaderProgram.bind();

    skyBoxShaderProgram.setUniform("texture_sampler", 0);

    Matrix4f projectionMatrix = transformation.getProjectionMatrix();
    skyBoxShaderProgram.setUniform("projectionMatrix", projectionMatrix);
    SkyBox skyBox = scene.getSkyBox();
    Matrix4f viewMatrix = transformation.getViewMatrix();
    viewMatrix.m30(0);
    viewMatrix.m31(0);
    viewMatrix.m32(0);
    Matrix4f modelViewMatrix = transformation.buildModelViewMatrix(skyBox, viewMatrix);
    skyBoxShaderProgram.setUniform("modelViewMatrix", modelViewMatrix);
    skyBoxShaderProgram.setUniform("ambientLight", scene.getSceneLight().getSkyBoxLight());

    scene.getSkyBox().getMesh().render();

    skyBoxShaderProgram.unbind();
}
 
Example 8
Source File: AnimMeshesLoader.java    From lwjglbook with Apache License 2.0 6 votes vote down vote up
private static Matrix4f toMatrix(AIMatrix4x4 aiMatrix4x4) {
    Matrix4f result = new Matrix4f();
    result.m00(aiMatrix4x4.a1());
    result.m10(aiMatrix4x4.a2());
    result.m20(aiMatrix4x4.a3());
    result.m30(aiMatrix4x4.a4());
    result.m01(aiMatrix4x4.b1());
    result.m11(aiMatrix4x4.b2());
    result.m21(aiMatrix4x4.b3());
    result.m31(aiMatrix4x4.b4());
    result.m02(aiMatrix4x4.c1());
    result.m12(aiMatrix4x4.c2());
    result.m22(aiMatrix4x4.c3());
    result.m32(aiMatrix4x4.c4());
    result.m03(aiMatrix4x4.d1());
    result.m13(aiMatrix4x4.d2());
    result.m23(aiMatrix4x4.d3());
    result.m33(aiMatrix4x4.d4());

    return result;
}
 
Example 9
Source File: Renderer.java    From lwjglbook with Apache License 2.0 6 votes vote down vote up
private void renderSkyBox(Window window, Camera camera, Scene scene) {
    skyBoxShaderProgram.bind();

    skyBoxShaderProgram.setUniform("texture_sampler", 0);

    Matrix4f projectionMatrix = transformation.getProjectionMatrix();
    skyBoxShaderProgram.setUniform("projectionMatrix", projectionMatrix);
    SkyBox skyBox = scene.getSkyBox();
    Matrix4f viewMatrix = transformation.getViewMatrix();
    viewMatrix.m30(0);
    viewMatrix.m31(0);
    viewMatrix.m32(0);
    Matrix4f modelViewMatrix = transformation.buildModelViewMatrix(skyBox, viewMatrix);
    skyBoxShaderProgram.setUniform("modelViewMatrix", modelViewMatrix);
    skyBoxShaderProgram.setUniform("ambientLight", scene.getSceneLight().getSkyBoxLight());

    scene.getSkyBox().getMesh().render();

    skyBoxShaderProgram.unbind();
}
 
Example 10
Source File: Renderer.java    From lwjglbook with Apache License 2.0 6 votes vote down vote up
private void renderSkyBox(Window window, Camera camera, Scene scene) {
    SkyBox skyBox = scene.getSkyBox();
    if (skyBox != null) {
        skyBoxShaderProgram.bind();

        skyBoxShaderProgram.setUniform("texture_sampler", 0);

        Matrix4f projectionMatrix = transformation.getProjectionMatrix();
        skyBoxShaderProgram.setUniform("projectionMatrix", projectionMatrix);
        Matrix4f viewMatrix = transformation.getViewMatrix();
        viewMatrix.m30(0);
        viewMatrix.m31(0);
        viewMatrix.m32(0);
        Matrix4f modelViewMatrix = transformation.buildModelViewMatrix(skyBox, viewMatrix);
        skyBoxShaderProgram.setUniform("modelViewMatrix", modelViewMatrix);
        skyBoxShaderProgram.setUniform("ambientLight", scene.getSceneLight().getSkyBoxLight());

        scene.getSkyBox().getMesh().render();

        skyBoxShaderProgram.unbind();
    }
}
 
Example 11
Source File: Renderer.java    From lwjglbook with Apache License 2.0 5 votes vote down vote up
private void renderSkyBox(Window window, Camera camera, Scene scene) {
    SkyBox skyBox = scene.getSkyBox();
    if (skyBox != null) {
        skyBoxShaderProgram.bind();

        skyBoxShaderProgram.setUniform("texture_sampler", 0);

        Matrix4f projectionMatrix = window.getProjectionMatrix();
        skyBoxShaderProgram.setUniform("projectionMatrix", projectionMatrix);
        Matrix4f viewMatrix = camera.getViewMatrix();
        float m30 = viewMatrix.m30();
        viewMatrix.m30(0);
        float m31 = viewMatrix.m31();
        viewMatrix.m31(0);
        float m32 = viewMatrix.m32();
        viewMatrix.m32(0);

        Mesh mesh = skyBox.getMesh();
        Matrix4f modelViewMatrix = transformation.buildModelViewMatrix(skyBox, viewMatrix);
        skyBoxShaderProgram.setUniform("modelViewMatrix", modelViewMatrix);
        skyBoxShaderProgram.setUniform("ambientLight", scene.getSceneLight().getSkyBoxLight());
        skyBoxShaderProgram.setUniform("colour", mesh.getMaterial().getAmbientColour());
        skyBoxShaderProgram.setUniform("hasTexture", mesh.getMaterial().isTextured() ? 1 : 0);

        mesh.render();

        viewMatrix.m30(m30);
        viewMatrix.m31(m31);
        viewMatrix.m32(m32);
        skyBoxShaderProgram.unbind();
    }
}
 
Example 12
Source File: Renderer.java    From lwjglbook with Apache License 2.0 5 votes vote down vote up
private void renderSkyBox(Window window, Camera camera, Scene scene) {
    SkyBox skyBox = scene.getSkyBox();
    if (skyBox != null) {
        skyBoxShaderProgram.bind();

        skyBoxShaderProgram.setUniform("texture_sampler", 0);

        Matrix4f projectionMatrix = window.getProjectionMatrix();
        skyBoxShaderProgram.setUniform("projectionMatrix", projectionMatrix);
        Matrix4f viewMatrix = camera.getViewMatrix();
        float m30 = viewMatrix.m30();
        viewMatrix.m30(0);
        float m31 = viewMatrix.m31();
        viewMatrix.m31(0);
        float m32 = viewMatrix.m32();
        viewMatrix.m32(0);

        Mesh mesh = skyBox.getMesh();
        Matrix4f modelViewMatrix = transformation.buildModelViewMatrix(skyBox, viewMatrix);
        skyBoxShaderProgram.setUniform("modelViewMatrix", modelViewMatrix);
        skyBoxShaderProgram.setUniform("ambientLight", scene.getSceneLight().getSkyBoxLight());
        skyBoxShaderProgram.setUniform("colour", mesh.getMaterial().getAmbientColour());
        skyBoxShaderProgram.setUniform("hasTexture", mesh.getMaterial().isTextured() ? 1 : 0);

        mesh.render();

        viewMatrix.m30(m30);
        viewMatrix.m31(m31);
        viewMatrix.m32(m32);
        skyBoxShaderProgram.unbind();
    }
}
 
Example 13
Source File: Renderer.java    From lwjglbook with Apache License 2.0 5 votes vote down vote up
private void renderSkyBox(Window window, Camera camera, Scene scene) {
    SkyBox skyBox = scene.getSkyBox();
    if (skyBox != null) {
        skyBoxShaderProgram.bind();

        skyBoxShaderProgram.setUniform("texture_sampler", 0);

        Matrix4f projectionMatrix = window.getProjectionMatrix();
        skyBoxShaderProgram.setUniform("projectionMatrix", projectionMatrix);
        Matrix4f viewMatrix = camera.getViewMatrix();
        float m30 = viewMatrix.m30();
        viewMatrix.m30(0);
        float m31 = viewMatrix.m31();
        viewMatrix.m31(0);
        float m32 = viewMatrix.m32();
        viewMatrix.m32(0);

        Mesh mesh = skyBox.getMesh();
        Matrix4f modelViewMatrix = transformation.buildModelViewMatrix(skyBox, viewMatrix);
        skyBoxShaderProgram.setUniform("modelViewMatrix", modelViewMatrix);
        skyBoxShaderProgram.setUniform("ambientLight", scene.getSceneLight().getSkyBoxLight());
        skyBoxShaderProgram.setUniform("colour", mesh.getMaterial().getAmbientColour());
        skyBoxShaderProgram.setUniform("hasTexture", mesh.getMaterial().isTextured() ? 1 : 0);

        mesh.render();

        viewMatrix.m30(m30);
        viewMatrix.m31(m31);
        viewMatrix.m32(m32);
        skyBoxShaderProgram.unbind();
    }
}
 
Example 14
Source File: Renderer.java    From lwjglbook with Apache License 2.0 5 votes vote down vote up
private void renderSkyBox(Window window, Camera camera, Scene scene) {
    SkyBox skyBox = scene.getSkyBox();
    if (skyBox != null) {
        skyBoxShaderProgram.bind();

        skyBoxShaderProgram.setUniform("texture_sampler", 0);

        Matrix4f projectionMatrix = transformation.getProjectionMatrix();
        skyBoxShaderProgram.setUniform("projectionMatrix", projectionMatrix);
        Matrix4f viewMatrix = transformation.getViewMatrix();
        float m30 = viewMatrix.m30();
        viewMatrix.m30(0);
        float m31 = viewMatrix.m31();
        viewMatrix.m31(0);
        float m32 = viewMatrix.m32();
        viewMatrix.m32(0);

        Mesh mesh = skyBox.getMesh();
        Matrix4f modelViewMatrix = transformation.buildModelViewMatrix(skyBox, viewMatrix);
        skyBoxShaderProgram.setUniform("modelViewMatrix", modelViewMatrix);
        skyBoxShaderProgram.setUniform("ambientLight", scene.getSceneLight().getSkyBoxLight());
        skyBoxShaderProgram.setUniform("colour", mesh.getMaterial().getAmbientColour());
        skyBoxShaderProgram.setUniform("hasTexture", mesh.getMaterial().isTextured() ? 1 : 0);

        mesh.render();

        viewMatrix.m30(m30);
        viewMatrix.m31(m31);
        viewMatrix.m32(m32);
        skyBoxShaderProgram.unbind();
    }
}
 
Example 15
Source File: Renderer.java    From lwjglbook with Apache License 2.0 5 votes vote down vote up
private void renderSkyBox(Window window, Camera camera, Scene scene) {
    SkyBox skyBox = scene.getSkyBox();
    if (skyBox != null) {
        skyBoxShaderProgram.bind();

        skyBoxShaderProgram.setUniform("texture_sampler", 0);

        Matrix4f projectionMatrix = transformation.getProjectionMatrix();
        skyBoxShaderProgram.setUniform("projectionMatrix", projectionMatrix);
        Matrix4f viewMatrix = transformation.getViewMatrix();
        float m30 = viewMatrix.m30();
        viewMatrix.m30(0);
        float m31 = viewMatrix.m31();
        viewMatrix.m31(0);
        float m32 = viewMatrix.m32();
        viewMatrix.m32(0);
        Matrix4f modelViewMatrix = transformation.buildModelViewMatrix(skyBox, viewMatrix);
        skyBoxShaderProgram.setUniform("modelViewMatrix", modelViewMatrix);
        skyBoxShaderProgram.setUniform("ambientLight", scene.getSceneLight().getSkyBoxLight());

        scene.getSkyBox().getMesh().render();

        viewMatrix.m30(m30);
        viewMatrix.m31(m31);
        viewMatrix.m32(m32);
        skyBoxShaderProgram.unbind();
    }
}
 
Example 16
Source File: Renderer.java    From lwjglbook with Apache License 2.0 5 votes vote down vote up
private void renderSkyBox(Window window, Camera camera, Scene scene) {
    SkyBox skyBox = scene.getSkyBox();
    if (skyBox != null) {
        skyBoxShaderProgram.bind();

        skyBoxShaderProgram.setUniform("texture_sampler", 0);

        Matrix4f projectionMatrix = transformation.getProjectionMatrix();
        skyBoxShaderProgram.setUniform("projectionMatrix", projectionMatrix);
        Matrix4f viewMatrix = transformation.getViewMatrix();
        float m30 = viewMatrix.m30();
        viewMatrix.m30(0);
        float m31 = viewMatrix.m31();
        viewMatrix.m31(0);
        float m32 = viewMatrix.m32();
        viewMatrix.m32(0);

        Mesh mesh = skyBox.getMesh();
        Matrix4f modelViewMatrix = transformation.buildModelViewMatrix(skyBox, viewMatrix);
        skyBoxShaderProgram.setUniform("modelViewMatrix", modelViewMatrix);
        skyBoxShaderProgram.setUniform("ambientLight", scene.getSceneLight().getSkyBoxLight());
        skyBoxShaderProgram.setUniform("colour", mesh.getMaterial().getAmbientColour());
        skyBoxShaderProgram.setUniform("hasTexture", mesh.getMaterial().isTextured() ? 1 : 0);

        mesh.render();

        viewMatrix.m30(m30);
        viewMatrix.m31(m31);
        viewMatrix.m32(m32);
        skyBoxShaderProgram.unbind();
    }
}
 
Example 17
Source File: Renderer.java    From lwjglbook with Apache License 2.0 5 votes vote down vote up
private void renderSkyBox(Window window, Camera camera, Scene scene) {
    SkyBox skyBox = scene.getSkyBox();
    if (skyBox != null) {
        skyBoxShaderProgram.bind();

        skyBoxShaderProgram.setUniform("texture_sampler", 0);

        Matrix4f projectionMatrix = transformation.getProjectionMatrix();
        skyBoxShaderProgram.setUniform("projectionMatrix", projectionMatrix);
        Matrix4f viewMatrix = transformation.getViewMatrix();
        float m30 = viewMatrix.m30();
        viewMatrix.m30(0);
        float m31 = viewMatrix.m31();
        viewMatrix.m31(0);
        float m32 = viewMatrix.m32();
        viewMatrix.m32(0);

        Mesh mesh = skyBox.getMesh();
        Matrix4f modelViewMatrix = transformation.buildModelViewMatrix(skyBox, viewMatrix);
        skyBoxShaderProgram.setUniform("modelViewMatrix", modelViewMatrix);
        skyBoxShaderProgram.setUniform("ambientLight", scene.getSceneLight().getSkyBoxLight());
        skyBoxShaderProgram.setUniform("colour", mesh.getMaterial().getAmbientColour());
        skyBoxShaderProgram.setUniform("hasTexture", mesh.getMaterial().isTextured() ? 1 : 0);

        mesh.render();

        viewMatrix.m30(m30);
        viewMatrix.m31(m31);
        viewMatrix.m32(m32);
        skyBoxShaderProgram.unbind();
    }
}
 
Example 18
Source File: Renderer.java    From lwjglbook with Apache License 2.0 5 votes vote down vote up
private void renderSkyBox(Window window, Camera camera, Scene scene) {
    SkyBox skyBox = scene.getSkyBox();
    if (skyBox != null) {
        skyBoxShaderProgram.bind();

        skyBoxShaderProgram.setUniform("texture_sampler", 0);

        Matrix4f projectionMatrix = window.getProjectionMatrix();
        skyBoxShaderProgram.setUniform("projectionMatrix", projectionMatrix);
        Matrix4f viewMatrix = camera.getViewMatrix();
        float m30 = viewMatrix.m30();
        viewMatrix.m30(0);
        float m31 = viewMatrix.m31();
        viewMatrix.m31(0);
        float m32 = viewMatrix.m32();
        viewMatrix.m32(0);

        Mesh mesh = skyBox.getMesh();
        Matrix4f modelViewMatrix = transformation.buildModelViewMatrix(skyBox, viewMatrix);
        skyBoxShaderProgram.setUniform("modelViewMatrix", modelViewMatrix);
        skyBoxShaderProgram.setUniform("ambientLight", scene.getSceneLight().getSkyBoxLight());
        skyBoxShaderProgram.setUniform("colour", mesh.getMaterial().getAmbientColour());
        skyBoxShaderProgram.setUniform("hasTexture", mesh.getMaterial().isTextured() ? 1 : 0);

        mesh.render();

        viewMatrix.m30(m30);
        viewMatrix.m31(m31);
        viewMatrix.m32(m32);
        skyBoxShaderProgram.unbind();
    }
}
 
Example 19
Source File: Renderer.java    From lwjglbook with Apache License 2.0 5 votes vote down vote up
private void renderSkyBox(Window window, Camera camera, Scene scene) {
    SkyBox skyBox = scene.getSkyBox();
    if (skyBox != null) {
        skyBoxShaderProgram.bind();

        skyBoxShaderProgram.setUniform("texture_sampler", 0);

        Matrix4f projectionMatrix = window.getProjectionMatrix();
        skyBoxShaderProgram.setUniform("projectionMatrix", projectionMatrix);
        Matrix4f viewMatrix = camera.getViewMatrix();
        float m30 = viewMatrix.m30();
        viewMatrix.m30(0);
        float m31 = viewMatrix.m31();
        viewMatrix.m31(0);
        float m32 = viewMatrix.m32();
        viewMatrix.m32(0);

        Mesh mesh = skyBox.getMesh();
        Matrix4f modelViewMatrix = transformation.buildModelViewMatrix(skyBox, viewMatrix);
        skyBoxShaderProgram.setUniform("modelViewMatrix", modelViewMatrix);
        skyBoxShaderProgram.setUniform("ambientLight", scene.getSceneLight().getSkyBoxLight());
        skyBoxShaderProgram.setUniform("colour", mesh.getMaterial().getAmbientColour());
        skyBoxShaderProgram.setUniform("hasTexture", mesh.getMaterial().isTextured() ? 1 : 0);

        mesh.render();

        viewMatrix.m30(m30);
        viewMatrix.m31(m31);
        viewMatrix.m32(m32);
        skyBoxShaderProgram.unbind();
    }
}
 
Example 20
Source File: Renderer.java    From lwjglbook with Apache License 2.0 5 votes vote down vote up
private void renderSkyBox(Window window, Camera camera, Scene scene) {
    SkyBox skyBox = scene.getSkyBox();
    if (skyBox != null) {
        skyBoxShaderProgram.bind();

        skyBoxShaderProgram.setUniform("texture_sampler", 0);

        Matrix4f projectionMatrix = window.getProjectionMatrix();
        skyBoxShaderProgram.setUniform("projectionMatrix", projectionMatrix);
        Matrix4f viewMatrix = camera.getViewMatrix();
        float m30 = viewMatrix.m30();
        viewMatrix.m30(0);
        float m31 = viewMatrix.m31();
        viewMatrix.m31(0);
        float m32 = viewMatrix.m32();
        viewMatrix.m32(0);

        Mesh mesh = skyBox.getMesh();
        Matrix4f modelViewMatrix = transformation.buildModelViewMatrix(skyBox, viewMatrix);
        skyBoxShaderProgram.setUniform("modelViewMatrix", modelViewMatrix);
        skyBoxShaderProgram.setUniform("ambientLight", scene.getSceneLight().getSkyBoxLight());
        skyBoxShaderProgram.setUniform("colour", mesh.getMaterial().getDiffuseColour());
        skyBoxShaderProgram.setUniform("hasTexture", mesh.getMaterial().isTextured() ? 1 : 0);

        glActiveTexture(GL_TEXTURE1);
        glBindTexture(GL_TEXTURE_2D, gBuffer.getDepthTexture());
        skyBoxShaderProgram.setUniform("screenSize", (float)window.getWidth(), (float)window.getHeight());
        skyBoxShaderProgram.setUniform("depthsText", 1);

        mesh.render();

        viewMatrix.m30(m30);
        viewMatrix.m31(m31);
        viewMatrix.m32(m32);
        skyBoxShaderProgram.unbind();
    }
}