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);
}
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();
}
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);
}
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);
}
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);
}
Aggregations