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