Search in sources :

Example 36 with Vector4f

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

the class ChatManager method render.

public void render(RenderingInterface renderer) {
    while (chat.size() > chatHistorySize) chat.removeLast();
    if (// || !chatting)
    scroll < 0)
        scroll = 0;
    if (scroll > chatHistorySize)
        scroll = chatHistorySize;
    int scrollLinesSkip = scroll;
    int linesDrew = 0;
    int maxLines = 18;
    Iterator<ChatLine> i = chat.iterator();
    while (linesDrew < maxLines && i.hasNext()) {
        // if (a >= chatHistorySize - lines)
        ChatLine line = i.next();
        if (scrollLinesSkip > 0) {
            scrollLinesSkip--;
            continue;
        }
        Font font = renderer.getFontRenderer().getFont("LiberationSans-Regular", 12);
        float scale = 2f;
        font = renderer.getFontRenderer().getFont("LiberationSans-Regular__aa", 18);
        scale = 1.0f;
        int chatWidth = Math.max(750, Client.getInstance().getGameWindow().getWidth() / 4 * 3);
        String localizedLine = Client.getInstance().getContent().localization().localize(line.text);
        int actualLines = font.getLinesHeight(localizedLine, chatWidth / scale);
        linesDrew += actualLines;
        float alpha = (line.time + 10000L - System.currentTimeMillis()) / 1000f;
        if (alpha < 0)
            alpha = 0;
        if (alpha > 1 || ingame.getGameWindow().getLayer() instanceof ChatPanelOverlay)
            alpha = 1;
        renderer.getFontRenderer().drawStringWithShadow(font, 9, (linesDrew - 1) * font.getLineHeight() * scale + 180 + (50), localizedLine, scale, scale, chatWidth, new Vector4f(1, 1, 1, alpha));
    }
}
Also used : Vector4f(org.joml.Vector4f) Font(io.xol.chunkstories.api.rendering.text.FontRenderer.Font)

Example 37 with Vector4f

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

the class PauseMenu method render.

@Override
public void render(RenderingInterface renderer) {
    parentLayer.render(renderer);
    Font font = renderer.getFontRenderer().getFont("LiberationSans-Regular", 11);
    String pauseText = renderer.getClient().getContent().localization().getLocalizedString("ingame.pause");
    renderer.getFontRenderer().drawStringWithShadow(font, renderer.getWindow().getWidth() / 2 - font.getWidth(pauseText) * 1.5f, renderer.getWindow().getHeight() / 2 + 48 * 3, pauseText, 3, 3, new Vector4f(1));
    resumeButton.setPosition(renderer.getWindow().getWidth() / 2 - resumeButton.getWidth() / 2, renderer.getWindow().getHeight() / 2 + 24 * 2 * getGuiScale());
    optionsButton.setPosition(resumeButton.getPositionX(), renderer.getWindow().getHeight() / 2 + 24 * getGuiScale());
    exitButton.setPosition(resumeButton.getPositionX(), renderer.getWindow().getHeight() / 2 - 24 * getGuiScale());
    resumeButton.render(renderer);
    optionsButton.render(renderer);
    exitButton.render(renderer);
}
Also used : Vector4f(org.joml.Vector4f) Font(io.xol.chunkstories.api.rendering.text.FontRenderer.Font)

Example 38 with Vector4f

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

the class MainMenu method render.

@Override
public void render(RenderingInterface renderingContext) {
    parentLayer.render(renderingContext);
    if (gameWindow.getLayer() == this && gameWindow.getClient().getConfiguration().getStringOption("client.game.log-policy").equals("undefined"))
        gameWindow.setLayer(new LogPolicyAsk(gameWindow, this));
    float spacing = 4;
    float buttonsAreaSize = largeSingleplayer.getWidth() * 2 + spacing * this.getGuiScale();
    float leftButtonX = this.getWidth() / 2 - buttonsAreaSize / 2 + 0.0f;
    float ySmall = (12) * this.getGuiScale();
    float yBig = ySmall + largeSingleplayer.getHeight() + (spacing) * this.getGuiScale();
    largeOnline.setPosition(leftButtonX, yBig);
    largeOnline.render(renderingContext);
    largeSingleplayer.setPosition(leftButtonX, ySmall);
    largeSingleplayer.render(renderingContext);
    float rightButtonX = leftButtonX + largeSingleplayer.getWidth() + (spacing) * this.getGuiScale();
    largeMods.setPosition(rightButtonX, yBig);
    largeMods.render(renderingContext);
    largeOptions.setPosition(rightButtonX, ySmall);
    largeOptions.render(renderingContext);
    // Notices
    Vector4f noticeColor = new Vector4f(0.5f);
    String version = "Chunk Stories Client " + VersionInfo.version;
    renderingContext.getFontRenderer().defaultFont().getWidth(version);
    renderingContext.getFontRenderer().drawString(renderingContext.getFontRenderer().defaultFont(), 4, 0, version, this.getGuiScale(), noticeColor);
    String copyrightNotice = "2015-2018 Hugo 'Gobrosse' Devillers";
    float noticeDekal = renderingContext.getFontRenderer().defaultFont().getWidth(copyrightNotice) * (this.getGuiScale());
    renderingContext.getFontRenderer().drawString(renderingContext.getFontRenderer().defaultFont(), renderingContext.getWindow().getWidth() - noticeDekal - 4, 0, copyrightNotice, this.getGuiScale(), noticeColor);
}
Also used : LogPolicyAsk(io.xol.chunkstories.gui.layer.config.LogPolicyAsk) Vector4f(org.joml.Vector4f)

Example 39 with Vector4f

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

the class ServerSelection method render.

@Override
public void render(RenderingInterface renderer) {
    parentLayer.getRootLayer().render(renderer);
    float scale = this.getGuiScale();
    if (autologin && !ipForm.getText().equals(""))
        login();
    String instructions = "Select a server from the list or type in the address directly";
    Font font = renderer.getFontRenderer().getFont("LiberationSans-Regular", 11);
    renderer.getFontRenderer().drawStringWithShadow(font, 32, renderer.getWindow().getHeight() - 32 * 2, instructions, 3, 3, new Vector4f(1));
    // gui
    float txtbox = renderer.getWindow().getWidth() - connectButton.getWidth() - 48 - 8 * scale;
    ipForm.setPosition(25, renderer.getWindow().getHeight() - 100);
    ipForm.setWidth(txtbox / this.getGuiScale());
    ipForm.render(renderer);
    connectButton.setPosition(ipForm.getPositionX() + ipForm.getWidth() + 4 * scale, renderer.getWindow().getHeight() - 100);
    connectButton.render(renderer);
    backOption.setPosition(8, 8);
    backOption.render(renderer);
    updateServers();
    int s = Client.getInstance().getGameWindow().getGuiScale();
    float offsetForButtons = backOption.getPositionY() + backOption.getHeight() + 8 * scale;
    float offsetForHeaderText = 32 * scale + ipForm.getHeight();
    serverSelectionZone.setPosition((width - 480 * scale) / 2, offsetForButtons);
    serverSelectionZone.setDimensions(480 * scale, height - (offsetForButtons + offsetForHeaderText));
    serverSelectionZone.render(renderer);
}
Also used : Vector4f(org.joml.Vector4f) Font(io.xol.chunkstories.api.rendering.text.FontRenderer.Font)

Example 40 with Vector4f

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

the class VoxelItemRenderer method renderItemInWorld.

@Override
public void renderItemInWorld(RenderingInterface renderer, ItemPile pile, World world, Location location, Matrix4f handTransformation) {
    /*if (((ItemVoxel) pile.getItem()).getVoxel() instanceof VoxelCustomIcon) {
			fallbackRenderer.renderItemInWorld(renderer, pile, world, location, handTransformation);
			return;
		}*/
    Voxel voxel = ((ItemVoxel) pile.getItem()).getVoxel();
    if (voxel == null)
        return;
    CellData fakeCell = new DummyCell(0, 0, 0, voxel, 0, 0, 0) {

        CellData air = new DummyCell(0, 1, 0, voxel.store().air(), 0, 0, 0);

        @Override
        public int getBlocklight() {
            return voxel.getEmittedLightLevel(this);
        }

        @Override
        public CellData getNeightbor(int side) {
            return air;
        }

        @Override
        public int getMetaData() {
            return ((ItemVoxel) pile.getItem()).getVoxelMeta();
        }
    };
    float s = 0.45f;
    handTransformation.scale(new Vector3f(s, s, s));
    handTransformation.translate(new Vector3f(-0.25f, -0.5f, -0.5f));
    renderer.setObjectMatrix(handTransformation);
    // Add a light only on the opaque pass
    if (fakeCell.getBlocklight() > 0 && renderer.getCurrentPass().name.contains("gBuffers")) {
        Vector4f lightposition = new Vector4f(0.0f, 0.0f, 0.0f, 1.0f);
        handTransformation.transform(lightposition);
        Light heldBlockLight = new Light(new Vector3f(0.6f, 0.50f, 0.4f).mul(0.5f), new Vector3f(lightposition.x(), lightposition.y(), lightposition.z()), 15f);
        renderer.getLightsRenderer().queueLight(heldBlockLight);
        // If we hold a light source, prepare the shader accordingly
        renderer.currentShader().setUniform2f("worldLightIn", Math.max(world.peekSafely(location).getBlocklight(), fakeCell.getBlocklight()), world.peekSafely(location).getSunlight());
    }
    Texture2D texture = content.voxels().textures().getDiffuseAtlasTexture();
    texture.setLinearFiltering(false);
    renderer.bindAlbedoTexture(texture);
    Texture2D normalTexture = content.voxels().textures().getNormalAtlasTexture();
    normalTexture.setLinearFiltering(false);
    renderer.bindNormalTexture(normalTexture);
    Texture2D materialTexture = content.voxels().textures().getMaterialAtlasTexture();
    materialTexture.setLinearFiltering(false);
    renderer.bindMaterialTexture(materialTexture);
    renderFakeVoxel(renderer, fakeCell);
}
Also used : ItemVoxel(io.xol.chunkstories.api.item.ItemVoxel) Texture2D(io.xol.chunkstories.api.rendering.textures.Texture2D) Vector4f(org.joml.Vector4f) ItemVoxel(io.xol.chunkstories.api.item.ItemVoxel) Voxel(io.xol.chunkstories.api.voxel.Voxel) Light(io.xol.chunkstories.api.rendering.lightning.Light) Vector3f(org.joml.Vector3f) CellData(io.xol.chunkstories.api.world.cell.CellData) DummyCell(io.xol.chunkstories.api.world.cell.DummyCell)

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