Search in sources :

Example 31 with Vector4f

use of org.joml.Vector4f in project Terasology by MovingBlocks.

the class TessellatorHelper method addGUIQuadMesh.

public static void addGUIQuadMesh(Tessellator tessellator, Vector4f color, float sizeX, float sizeY) {
    tessellator.resetParams();
    tessellator.setColor(new Vector4f(color.x, color.y, color.z, color.w));
    tessellator.setUseLighting(false);
    tessellator.setUseNormals(false);
    tessellator.addPoly(new Vector3f[] { new Vector3f(0, 0, 0), new Vector3f(sizeX, 0, 0), new Vector3f(sizeX, sizeY, 0), new Vector3f(0, sizeY, 0) }, new Vector2f[] { new Vector2f(0, 0), new Vector2f(1, 0), new Vector2f(1, 1), new Vector2f(0, 1) });
    tessellator.setUseLighting(true);
    tessellator.setUseNormals(true);
}
Also used : Vector4f(org.joml.Vector4f) Vector2f(org.joml.Vector2f) Vector3f(org.joml.Vector3f)

Example 32 with Vector4f

use of org.joml.Vector4f in project Terasology by MovingBlocks.

the class OpenVRStereoCamera method updateMatrices.

@Override
public void updateMatrices(float fov) {
    prevViewProjectionMatrix.set(viewProjectionMatrix);
    org.joml.Matrix4f leftEyeProjection = vrProvider.getState().getEyeProjectionMatrix(0);
    org.joml.Matrix4f rightEyeProjection = vrProvider.getState().getEyeProjectionMatrix(1);
    org.joml.Matrix4f leftEyePose = vrProvider.getState().getEyePose(0);
    org.joml.Matrix4f rightEyePose = vrProvider.getState().getEyePose(1);
    float halfIPD = (float) Math.sqrt(Math.pow(leftEyePose.m30() - rightEyePose.m30(), 2) + Math.pow(leftEyePose.m31() - rightEyePose.m31(), 2) + Math.pow(leftEyePose.m32() - rightEyePose.m32(), 2)) / 2.0f;
    // set camera orientation
    Vector4f vecQuaternion = OpenVRUtil.convertToQuaternion(leftEyePose);
    Quaternionf quaternion = new Quaternionf(vecQuaternion.x, vecQuaternion.y, vecQuaternion.z, vecQuaternion.w);
    setOrientation(new Quat4f(quaternion.x, quaternion.y, quaternion.z, quaternion.w));
    // view matrix is inverse of pose matrix
    leftEyePose = leftEyePose.invert();
    rightEyePose = rightEyePose.invert();
    if (Math.sqrt(Math.pow(leftEyePose.m30(), 2) + Math.pow(leftEyePose.m31(), 2) + Math.pow(leftEyePose.m32(), 2)) < 0.25) {
        return;
    }
    jomlMatrix4f(leftEyeProjection, projectionMatrixLeftEye);
    jomlMatrix4f(rightEyeProjection, projectionMatrixRightEye);
    projectionMatrix = projectionMatrixLeftEye;
    jomlMatrix4f(leftEyePose, viewMatrixLeftEye);
    jomlMatrix4f(rightEyePose, viewMatrixRightEye);
    viewMatrix = viewMatrixLeftEye;
    normViewMatrix = viewMatrixLeftEye;
    reflectionMatrix.setRow(0, 1.0f, 0.0f, 0.0f, 0.0f);
    reflectionMatrix.setRow(1, 0.0f, -1.0f, 0.0f, 2f * (-position.y + 32f));
    reflectionMatrix.setRow(2, 0.0f, 0.0f, 1.0f, 0.0f);
    reflectionMatrix.setRow(3, 0.0f, 0.0f, 0.0f, 1.0f);
    viewMatrixReflected.mul(viewMatrix, reflectionMatrix);
    reflectionMatrix.setRow(1, 0.0f, -1.0f, 0.0f, 0.0f);
    normViewMatrixReflected.mul(normViewMatrix, reflectionMatrix);
    viewTranslationLeftEye.setIdentity();
    viewTranslationLeftEye.setTranslation(new Vector3f(halfIPD, 0.0f, 0.0f));
    viewTranslationRightEye.setIdentity();
    viewTranslationRightEye.setTranslation(new Vector3f(-halfIPD, 0.0f, 0.0f));
    viewMatrixReflectedLeftEye.mul(viewMatrixReflected, viewTranslationLeftEye);
    viewMatrixReflectedRightEye.mul(viewMatrixReflected, viewTranslationRightEye);
    viewProjectionMatrixLeftEye = MatrixUtils.calcViewProjectionMatrix(viewMatrixLeftEye, projectionMatrixLeftEye);
    viewProjectionMatrixRightEye = MatrixUtils.calcViewProjectionMatrix(viewMatrixRightEye, projectionMatrixRightEye);
    inverseViewProjectionMatrixLeftEye = new Matrix4f(viewProjectionMatrixLeftEye);
    inverseViewProjectionMatrixRightEye = new Matrix4f(viewProjectionMatrixRightEye);
    inverseViewProjectionMatrixLeftEye.invert(viewProjectionMatrixLeftEye);
    inverseViewProjectionMatrixRightEye.invert(viewProjectionMatrixRightEye);
    inverseProjectionMatrixLeftEye = new Matrix4f(projectionMatrixLeftEye);
    inverseProjectionMatrixRightEye = new Matrix4f(projectionMatrixRightEye);
    inverseProjectionMatrixLeftEye.invert(projectionMatrixLeftEye);
    inverseProjectionMatrixRightEye.invert(projectionMatrixRightEye);
    updateFrustum();
}
Also used : Matrix4f(org.terasology.math.geom.Matrix4f) Vector4f(org.joml.Vector4f) Vector3f(org.terasology.math.geom.Vector3f) Quaternionf(org.joml.Quaternionf) Quat4f(org.terasology.math.geom.Quat4f)

Example 33 with Vector4f

use of org.joml.Vector4f in project chunkstories by Hugobros3.

the class LanguageSelectionScreen method render.

@Override
public void render(RenderingInterface renderingContext) {
    float scale = this.getGuiScale();
    if (scroll < 0)
        scroll = 0;
    this.parentLayer.getRootLayer().render(renderingContext);
    int posY = (int) (renderingContext.getWindow().getHeight() - scale * (64 + 32));
    renderingContext.getFontRenderer().drawStringWithShadow(renderingContext.getFontRenderer().getFont("LiberationSans-Regular", 11 * scale), 8 * scale, renderingContext.getWindow().getHeight() - 32 * scale, "Welcome - Bienvenue - Wilkomen - Etc", 2, 2, new Vector4f(1));
    int remainingSpace = (int) Math.floor(renderingContext.getWindow().getHeight() / 96 - 2);
    while (scroll + remainingSpace > languages.size()) scroll--;
    int skip = scroll;
    for (LanguageButton langButton : languages) {
        if (skip-- > 0)
            continue;
        if (remainingSpace-- <= 0)
            break;
        int maxWidth = renderingContext.getWindow().getWidth() - 64 * 2;
        // maxWidth / scale);
        langButton.setWidth(256);
        langButton.setPosition(renderingContext.getWindow().getWidth() / 2 - langButton.getWidth() / 2, posY);
        langButton.render(renderingContext);
        posY -= langButton.getHeight() + (4) * scale;
    }
    if (allowBackButton) {
        backOption.setPosition(8, 8);
        backOption.render(renderingContext);
    }
}
Also used : Vector4f(org.joml.Vector4f)

Example 34 with Vector4f

use of org.joml.Vector4f in project chunkstories by Hugobros3.

the class LogPolicyAsk method render.

@Override
public void render(RenderingInterface renderer) {
    parentLayer.render(renderer);
    float scale = gameWindow.getGuiScale();
    renderer.getGuiRenderer().drawBoxWindowsSpace(0, 0, renderer.getWindow().getWidth(), renderer.getWindow().getHeight(), 0, 0, 0, 0, null, false, true, new Vector4f(0.0f, 0.0f, 0.0f, 0.5f));
    renderer.getFontRenderer().drawStringWithShadow(renderer.getFontRenderer().getFont("LiberationSans-Regular__aa", 16 * scale), 30, renderer.getWindow().getHeight() - 64, Client.getInstance().getContent().localization().getLocalizedString("logpolicy.title"), 1, 1, new Vector4f(1));
    Font logPolicyTextFont = renderer.getFontRenderer().getFont("LiberationSans-Regular__aa", 12 * scale);
    renderer.getFontRenderer().drawString(logPolicyTextFont, 30, renderer.getWindow().getHeight() - 128, message, 1, width - 60);
    float seperation = 4 * scale;
    float groupSize = acceptButton.getWidth() + refuseButton.getWidth() + seperation;
    acceptButton.setPosition(renderer.getWindow().getWidth() / 2 - groupSize / 2, renderer.getWindow().getHeight() / 4 - 32);
    acceptButton.render(renderer);
    refuseButton.setPosition(renderer.getWindow().getWidth() / 2 - groupSize / 2 + seperation + acceptButton.getWidth(), renderer.getWindow().getHeight() / 4 - 32);
    refuseButton.render(renderer);
}
Also used : Vector4f(org.joml.Vector4f) Font(io.xol.chunkstories.api.rendering.text.FontRenderer.Font)

Example 35 with Vector4f

use of org.joml.Vector4f in project chunkstories by Hugobros3.

the class ModsSelection method render.

@Override
public void render(RenderingInterface renderer) {
    parentLayer.getRootLayer().render(renderer);
    int scale = Client.getInstance().getGameWindow().getGuiScale();
    String instructions = "Select the mods you want to use";
    Font font = renderer.getFontRenderer().getFont("LiberationSans-Regular", 16 * scale);
    renderer.getFontRenderer().drawStringWithShadow(font, 32, renderer.getWindow().getHeight() - 24 * scale, instructions, 1, 1, new Vector4f(1));
    backOption.setPosition(xPosition + 8, 8);
    backOption.render(renderer);
    // Display buttons
    float totalLengthOfButtons = 0;
    float spacing = 2 * scale;
    totalLengthOfButtons += applyMods.getWidth();
    totalLengthOfButtons += spacing;
    totalLengthOfButtons += locateExtMod.getWidth();
    totalLengthOfButtons += spacing;
    // totalLengthOfButtons += openModsFolder.getWidth();
    // totalLengthOfButtons += spacing;
    float buttonDisplayX = renderer.getWindow().getWidth() / 2 - totalLengthOfButtons / 2;
    float buttonDisplayY = 8;
    locateExtMod.setPosition(buttonDisplayX, buttonDisplayY);
    buttonDisplayX += locateExtMod.getWidth() + spacing;
    locateExtMod.render(renderer);
    openModsFolder.setPosition(buttonDisplayX, buttonDisplayY);
    buttonDisplayX += openModsFolder.getWidth() + spacing;
    openModsFolder.render(renderer);
    applyMods.setPosition(this.getWidth() - applyMods.getWidth() - 8, 8);
    buttonDisplayX += applyMods.getWidth() + spacing;
    applyMods.render(renderer);
    float offsetForButtons = applyMods.getPositionY() + applyMods.getHeight() + 8 * scale;
    float offsetForHeaderText = 32 * scale;
    modsContainer.setPosition((width - 480 * scale) / 2, offsetForButtons);
    modsContainer.setDimensions(480 * scale, height - (offsetForButtons + offsetForHeaderText));
    modsContainer.render(renderer);
}
Also used : Vector4f(org.joml.Vector4f) Font(io.xol.chunkstories.api.rendering.text.FontRenderer.Font)

Aggregations

Vector4f (org.joml.Vector4f)68 Vector3f (org.joml.Vector3f)13 Font (io.xol.chunkstories.api.rendering.text.FontRenderer.Font)12 Texture2D (io.xol.chunkstories.api.rendering.textures.Texture2D)6 Vector3d (org.joml.Vector3d)6 Shader (io.xol.chunkstories.api.rendering.shader.Shader)5 CellData (io.xol.chunkstories.api.world.cell.CellData)5 Vector2f (org.joml.Vector2f)5 Mouse (io.xol.chunkstories.api.input.Mouse)4 Texture2DGL (io.xol.chunkstories.renderer.opengl.texture.Texture2DGL)4 ByteBuffer (java.nio.ByteBuffer)4 Matrix4f (org.joml.Matrix4f)4 ItemPile (io.xol.chunkstories.api.item.inventory.ItemPile)3 STBEasyFont.stb_easy_font_print (org.lwjgl.stb.STBEasyFont.stb_easy_font_print)3 Location (io.xol.chunkstories.api.Location)2 Entity (io.xol.chunkstories.api.entity.Entity)2 EntityLiving (io.xol.chunkstories.api.entity.EntityLiving)2 GuiRenderer (io.xol.chunkstories.api.gui.GuiRenderer)2 CollisionBox (io.xol.chunkstories.api.physics.CollisionBox)2 Voxel (io.xol.chunkstories.api.voxel.Voxel)2