Search in sources :

Example 21 with Matrix4f

use of org.lwjgl.util.vector.Matrix4f in project j6dof-flight-sim by chris-ali.

the class ParticleRenderer method updateModelViewMatrix.

private void updateModelViewMatrix(Vector3f position, float rotation, float scale, Matrix4f viewMatrix, float[] vboData) {
    Matrix4f modelMatrix = new Matrix4f();
    Matrix4f.translate(position, modelMatrix, modelMatrix);
    // Calculate transpose of upper left 3x3 matrix
    modelMatrix.m00 = viewMatrix.m00;
    modelMatrix.m01 = viewMatrix.m10;
    modelMatrix.m02 = viewMatrix.m20;
    modelMatrix.m10 = viewMatrix.m01;
    modelMatrix.m11 = viewMatrix.m11;
    modelMatrix.m12 = viewMatrix.m21;
    modelMatrix.m20 = viewMatrix.m02;
    modelMatrix.m21 = viewMatrix.m12;
    modelMatrix.m22 = viewMatrix.m22;
    Matrix4f.rotate((float) Math.toRadians(rotation), new Vector3f(0, 0, 1), modelMatrix, modelMatrix);
    Matrix4f.scale(new Vector3f(scale, scale, scale), modelMatrix, modelMatrix);
    Matrix4f modelViewMatrix = Matrix4f.mul(viewMatrix, modelMatrix, null);
    storeMatrixData(modelViewMatrix, vboData);
}
Also used : Matrix4f(org.lwjgl.util.vector.Matrix4f) Vector3f(org.lwjgl.util.vector.Vector3f)

Example 22 with Matrix4f

use of org.lwjgl.util.vector.Matrix4f in project j6dof-flight-sim by chris-ali.

the class ParticleRenderer method render.

public void render(Map<ParticleTexture, List<Particle>> particles, Camera camera) {
    Matrix4f viewMatrix = RenderingUtilities.createViewMatrix(camera);
    prepare();
    shader.loadSkyColor(MasterRenderer.getSkyColor().x, MasterRenderer.getSkyColor().y, MasterRenderer.getSkyColor().z);
    shader.loadFog(MasterRenderer.getFogDensity(), MasterRenderer.getFogGradient());
    for (ParticleTexture texture : particles.keySet()) {
        bindTexture(texture);
        List<Particle> particleList = particles.get(texture);
        pointer = 0;
        float[] vboData = new float[particleList.size() * INSTANCE_DATA_LENGTH];
        for (Particle particle : particles.get(texture)) {
            // Subtracts out the camera roll to prevent clouds/particles rolling with the camera
            updateModelViewMatrix(particle.getPosition(), particle.getRotation() - camera.getRoll(), particle.getScale(), viewMatrix, vboData);
            updateTextureCoordinateInfo(particle, vboData);
        }
        loader.updateVBO(vbo, vboData, buffer);
        GL31.glDrawArraysInstanced(GL11.GL_TRIANGLE_STRIP, 0, quad.getVertexCount(), particleList.size());
    }
    finishRendering();
}
Also used : Particle(com.chrisali.javaflightsim.lwjgl.particles.Particle) Matrix4f(org.lwjgl.util.vector.Matrix4f) ParticleTexture(com.chrisali.javaflightsim.lwjgl.particles.ParticleTexture)

Example 23 with Matrix4f

use of org.lwjgl.util.vector.Matrix4f in project j6dof-flight-sim by chris-ali.

the class StaticShader method loadViewMatrix.

public void loadViewMatrix(Camera camera) {
    Matrix4f viewMatrix = RenderingUtilities.createViewMatrix(camera);
    super.loadMatrix(location_viewMatrix, viewMatrix);
}
Also used : Matrix4f(org.lwjgl.util.vector.Matrix4f)

Example 24 with Matrix4f

use of org.lwjgl.util.vector.Matrix4f in project j6dof-flight-sim by chris-ali.

the class TerrainShader method loadViewMatrix.

public void loadViewMatrix(Camera camera) {
    Matrix4f viewMatrix = RenderingUtilities.createViewMatrix(camera);
    super.loadMatrix(location_viewMatrix, viewMatrix);
}
Also used : Matrix4f(org.lwjgl.util.vector.Matrix4f)

Example 25 with Matrix4f

use of org.lwjgl.util.vector.Matrix4f in project j6dof-flight-sim by chris-ali.

the class WaterShader method loadViewMatrix.

public void loadViewMatrix(Camera camera) {
    Matrix4f viewMatrix = RenderingUtilities.createViewMatrix(camera);
    super.loadMatrix(location_viewMatrix, viewMatrix);
}
Also used : Matrix4f(org.lwjgl.util.vector.Matrix4f)

Aggregations

Matrix4f (org.lwjgl.util.vector.Matrix4f)29 Vector3f (org.lwjgl.util.vector.Vector3f)12 FloatBuffer (java.nio.FloatBuffer)4 Vector2f (org.lwjgl.util.vector.Vector2f)2 Vector4f (org.lwjgl.util.vector.Vector4f)2 GuiRectangle (betterquesting.api2.client.gui.misc.GuiRectangle)1 IGuiRect (betterquesting.api2.client.gui.misc.IGuiRect)1 InterfaceTexture (com.chrisali.javaflightsim.lwjgl.interfaces.ui.InterfaceTexture)1 Particle (com.chrisali.javaflightsim.lwjgl.particles.Particle)1 ParticleTexture (com.chrisali.javaflightsim.lwjgl.particles.ParticleTexture)1 WaterTile (com.chrisali.javaflightsim.lwjgl.water.WaterTile)1 ArabicShapingException (com.ibm.icu.text.ArabicShapingException)1 IOException (java.io.IOException)1 Random (java.util.Random)1 CelestialBodyRenderEvent (micdoodle8.mods.galacticraft.api.event.client.CelestialBodyRenderEvent)1 ScaledResolution (net.minecraft.client.gui.ScaledResolution)1