Search in sources :

Example 1 with Mat4

use of org.asassecreations.engine.math.vector.Mat4 in project Voxel_Game by ASasseCreations.

the class Minimap method render.

public static void render(final Light sun) {
    minimapCamera.position = new Vec3(GameCamera.position);
    minimapCamera.position.y = GameCamera.position.y + 20;
    minimapCamera.rotation.x = 90;
    minimapCamera.rotation.y = GameCamera.rotation.y;
    final float r = 32;
    final float l = -32;
    final float n = 1;
    final float f = 128;
    final float t = 32;
    final float b = -32;
    final Mat4 matrix = new Mat4();
    matrix.setIdentity();
    matrix.m00 = 2f / (r - l);
    matrix.m11 = 2f / (t - b);
    matrix.m22 = -2f / (f - n);
    matrix.m30 = -(r + l) / (r - l);
    matrix.m31 = -(t + b) / (t - b);
    matrix.m32 = -(f + n) / (f - n);
    framebuffer.bind();
    Renderer.clear();
    ChunkMinimapRenderer.begin(sun, matrix, minimapCamera);
    ChunkMinimapRenderer.render();
    ChunkMinimapRenderer.end();
    FrameBufferObject.unbind();
}
Also used : Mat4(org.asassecreations.engine.math.vector.Mat4) Vec3(org.asassecreations.engine.math.vector.Vec3)

Example 2 with Mat4

use of org.asassecreations.engine.math.vector.Mat4 in project Voxel_Game by ASasseCreations.

the class HandShader method loadViewMatrix.

public final void loadViewMatrix(final Mat4 m) {
    final Mat4 matrix = new Mat4(m);
    matrix.invert();
    loadMatrix(location_viewMatrix, matrix);
}
Also used : Mat4(org.asassecreations.engine.math.vector.Mat4)

Example 3 with Mat4

use of org.asassecreations.engine.math.vector.Mat4 in project Voxel_Game by ASasseCreations.

the class BlockRaycast method eyeSpace.

private static final Vec4 eyeSpace(final Vec4 clip, final float direction) {
    final Mat4 inverted = Mat4.invert(GameCamera.projection_primary, null);
    final Vec4 eyeCoords = Mat4.transform(inverted, clip, null);
    return new Vec4(eyeCoords.x, eyeCoords.y, direction, 0f);
}
Also used : Mat4(org.asassecreations.engine.math.vector.Mat4) Vec4(org.asassecreations.engine.math.vector.Vec4)

Example 4 with Mat4

use of org.asassecreations.engine.math.vector.Mat4 in project Voxel_Game by ASasseCreations.

the class SunRenderer method faceCamera.

private static final Mat4 faceCamera(final Vec3 position, final float scale, final Mat4 viewMatrix) {
    final Mat4 modelMatrix = new Mat4();
    Mat4.translate(position, modelMatrix, modelMatrix);
    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;
    Mat4.scale(new Vec3(scale, scale, scale), modelMatrix, modelMatrix);
    final Mat4 modelViewMatrix = Mat4.mul(viewMatrix, modelMatrix, null);
    return modelViewMatrix;
}
Also used : Mat4(org.asassecreations.engine.math.vector.Mat4) Vec3(org.asassecreations.engine.math.vector.Vec3)

Example 5 with Mat4

use of org.asassecreations.engine.math.vector.Mat4 in project Voxel_Game by ASasseCreations.

the class HandRenderer method render.

public static final void render(final Light sun) {
    final float time = Mathf.cos(Timings.globalTime_f);
    final float yBobbing = time / 12f;
    shader.start();
    shader.loadLight(sun);
    shader.loadViewMatrix(GameCamera.view);
    final Mat4 matrix = MatrixCreation.createTransformationMatrix(new Vec3(UserSettings.WALK_OFFSET_HORIZONTAL, UserSettings.WALK_OFFSET_VERTICLE + yBobbing, UserSettings.WALK_OFFSET_DEPTH), new Vec3(10f + time * 5f, -5f, 5f + time * 5f), new Vec3(0.3f, 0.3f, 0.3f));
    shader.loadTransformationMatrix(matrix);
    GL11.glDrawArrays(GL11.GL_TRIANGLES, 0, HandModel.MODEL.vertexCount);
    shader.stop();
}
Also used : Mat4(org.asassecreations.engine.math.vector.Mat4) Vec3(org.asassecreations.engine.math.vector.Vec3)

Aggregations

Mat4 (org.asassecreations.engine.math.vector.Mat4)6 Vec3 (org.asassecreations.engine.math.vector.Vec3)4 Vec4 (org.asassecreations.engine.math.vector.Vec4)2