use of org.joml.Vector3f in project chunkstories-core by Hugobros3.
the class EntityPlayer method drawEntityOverlay.
@Override
public void drawEntityOverlay(RenderingInterface renderer) {
// super.drawEntityOverlay(renderer);
if (this.equals(((WorldClient) getWorld()).getClient().getPlayer().getControlledEntity())) {
float scale = 2.0f;
renderer.textures().getTexture("./textures/gui/hud/hud_survival.png").setLinearFiltering(false);
renderer.getGuiRenderer().drawBoxWindowsSpaceWithSize(renderer.getWindow().getWidth() / 2 - 256 * 0.5f * scale, 64 + 64 + 16 - 32 * 0.5f * scale, 256 * scale, 32 * scale, 0, 32f / 256f, 1, 0, renderer.textures().getTexture("./textures/gui/hud/hud_survival.png"), false, true, null);
// Health bar
int horizontalBitsToDraw = (int) (8 + 118 * Math2.clamp(getHealth() / getMaxHealth(), 0.0, 1.0));
renderer.getGuiRenderer().drawBoxWindowsSpaceWithSize(renderer.getWindow().getWidth() / 2 - 128 * scale, 64 + 64 + 16 - 32 * 0.5f * scale, horizontalBitsToDraw * scale, 32 * scale, 0, 64f / 256f, horizontalBitsToDraw / 256f, 32f / 256f, renderer.textures().getTexture("./textures/gui/hud/hud_survival.png"), false, true, new Vector4f(1.0f, 1.0f, 1.0f, 0.75f));
// Food bar
horizontalBitsToDraw = (int) (0 + 126 * Math2.clamp(getFoodLevel() / 100f, 0.0, 1.0));
renderer.getGuiRenderer().drawBoxWindowsSpaceWithSize(renderer.getWindow().getWidth() / 2 + 0 * 128 * scale + 0, 64 + 64 + 16 - 32 * 0.5f * scale, horizontalBitsToDraw * scale, 32 * scale, 0.5f, 64f / 256f, 0.5f + horizontalBitsToDraw / 256f, 32f / 256f, renderer.textures().getTexture("./textures/gui/hud/hud_survival.png"), false, true, new Vector4f(1.0f, 1.0f, 1.0f, 0.75f));
// If we're using an item that can render an overlay
if (this.getSelectedItemComponent().getSelectedItem() != null) {
ItemPile pile = this.getSelectedItemComponent().getSelectedItem();
if (pile.getItem() instanceof ItemOverlay)
((ItemOverlay) pile.getItem()).drawItemOverlay(renderer, pile);
}
// We don't want to render our own tag do we ?
return;
}
// Renders the nametag above the player heads
Vector3d pos = getLocation();
// don't render tags too far out
if (pos.distance(renderer.getCamera().getCameraPosition()) > 32f)
return;
// Don't render a dead player tag
if (this.getHealth() <= 0)
return;
Vector3fc posOnScreen = renderer.getCamera().transform3DCoordinate(new Vector3f((float) (double) pos.x(), (float) (double) pos.y() + 2.0f, (float) (double) pos.z()));
float scale = posOnScreen.z();
// + rotH;
String txt = name.getName();
float dekal = renderer.getFontRenderer().defaultFont().getWidth(txt) * 16 * scale;
// System.out.println("dekal"+dekal);
if (scale > 0)
renderer.getFontRenderer().drawStringWithShadow(renderer.getFontRenderer().defaultFont(), posOnScreen.x() - dekal / 2, posOnScreen.y(), txt, 16 * scale, 16 * scale, new Vector4f(1, 1, 1, 1));
}
use of org.joml.Vector3f in project chunkstories-core by Hugobros3.
the class DefaultItemRenderer method renderItemInWorld.
@Override
public void renderItemInWorld(RenderingInterface renderingInterface, ItemPile pile, World world, Location location, Matrix4f handTransformation) {
Matrix4f handTransformation2 = new Matrix4f(handTransformation);
handTransformation2.rotate((float) (Math.PI / 2f), new Vector3f(0.0f, 0.0f, 1.0f));
handTransformation2.rotate((float) (Math.PI / 2f), new Vector3f(0.0f, 1.0f, 0.0f));
handTransformation2.translate(new Vector3f(-0.0f, 0.0f, 0.2f));
// handTransformation2.translate(new Vector3f(-0.00f, -0.15f, 0.0f));
handTransformation2.scale(new Vector3f(1.0f, 0.20f * pile.getItem().getDefinition().getSlotsWidth(), 0.20f * pile.getItem().getDefinition().getSlotsHeight()));
renderingInterface.setObjectMatrix(handTransformation2);
textures.getTexture(pile.getTextureName()).setLinearFiltering(false);
Texture2D texture = textures.getTexture(pile.getTextureName());
if (texture == null)
texture = textures.getTexture("items/icons/notex.png");
texture.setLinearFiltering(false);
renderingInterface.bindAlbedoTexture(texture);
draw3DPlane(renderingInterface);
}
use of org.joml.Vector3f in project chunkstories-core by Hugobros3.
the class ParticleFireLight method getRenderer.
@Override
public ParticleTypeRenderer getRenderer(ParticlesRenderer particlesRenderer) {
return new ParticleTypeRenderer(particlesRenderer) {
@Override
public void beginRenderingForType(RenderingInterface renderingContext) {
super.beginRenderingForType(renderingContext);
renderingContext.setBlendMode(BlendMode.PREMULT_ALPHA);
renderingContext.getRenderTargetManager().setDepthMask(false);
// renderingContext.setDepthTestMode(DepthTestMode.DISABLED);
// System.out.println("k");
String temp_scale = "./textures/particles/fire_temp_scale_expl.png";
renderingContext.bindTexture2D("colorTempSampler", particlesRenderer.getContent().textures().getTexture(temp_scale));
particlesRenderer.getContent().textures().getTexture(temp_scale).setLinearFiltering(true);
particlesRenderer.getContent().textures().getTexture(temp_scale).setTextureWrapping(false);
getAlbedoTexture().setMipMapping(true);
getAlbedoTexture().setLinearFiltering(true);
getAlbedoTexture().setTextureWrapping(false);
}
@Override
public void forEach_Rendering(RenderingInterface renderingContext, ParticleData data) {
ParticleFireData b = (ParticleFireData) data;
renderingContext.getLightsRenderer().queueLight(new Light(new Vector3f(1.0f, 252f / 255f, 1 / 255f), new Vector3f((float) data.x(), (float) data.y(), (float) data.z()), 25f * Math2.clamp((float) (double) b.vel.x() * 5000, 0.0, 1.0)));
// System.out.println("k");
/*data.setY((float) (data.y() + (Math.random() - 0.1) * 0.0015));
data.setX((float) (data.x() + (Math.random() - 0.5) * 0.0015));
data.setZ((float) (data.z() + (Math.random() - 0.5) * 0.0015));
*/
((ParticleFireData) data).timer--;
if (((ParticleFireData) data).timer < 0)
data.destroy();
}
@Override
public void destroy() {
}
};
}
use of org.joml.Vector3f in project chunkstories-core by Hugobros3.
the class ParticleLightningStrike method getRenderer.
@Override
public ParticleTypeRenderer getRenderer(ParticlesRenderer particlesRenderer) {
return new ParticleTypeRenderer(particlesRenderer) {
@Override
public void forEach_Rendering(RenderingInterface renderingContext, ParticleData data) {
Content content = ParticleLightningStrike.this.getType().store().parent();
if (content instanceof ClientContent) {
ClientContent clientContent = (ClientContent) content;
LocalPlayer player = clientContent.getContext().getPlayer();
Entity entity = player.getControlledEntity();
if (entity != null) {
Location loc = entity.getLocation();
data.set((float) (double) data.x(), (float) (double) loc.y() + 1024, (float) (double) data.z());
}
}
renderingContext.getLightsRenderer().queueLight(new Light(new Vector3f(226 / 255f, 255 / 255f, 226 / 255f).mul((float) (1f + Math.random())), new Vector3f((float) data.x(), (float) data.y(), (float) data.z()), 102004f + (float) Math.random() * 5f));
}
@Override
public void destroy() {
}
};
}
use of org.joml.Vector3f in project chunkstories-core by Hugobros3.
the class DefaultSkyRenderer method render.
public void render(RenderingInterface renderingContext) {
try {
long worldTime = renderingContext.getWorldRenderer().getWorld().getTime();
this.dayTime = (worldTime % 10000) / 10000f;
} catch (NullPointerException e) {
}
renderingContext.setDepthTestMode(DepthTestMode.DISABLED);
renderingContext.setBlendMode(BlendMode.DISABLED);
renderingContext.setCullingMode(CullingMode.DISABLED);
renderingContext.getRenderTargetManager().setDepthMask(false);
Vector3f sunPosVector = getSunPosition();
Shader skyShader = renderingContext.useShader("sky");
skyShader.setUniform1f("overcastFactor", world.getWeather());
skyShader.setUniform3f("sunPos", sunPosVector.x(), sunPosVector.y(), sunPosVector.z());
skyShader.setUniform1f("time", dayTime);
renderingContext.getCamera().setupShader(skyShader);
renderingContext.drawFSQuad();
renderingContext.setBlendMode(BlendMode.MIX);
Shader starsShader = renderingContext.useShader("stars");
starsShader.setUniform3f("sunPos", sunPosVector.x(), sunPosVector.y(), sunPosVector.z());
starsShader.setUniform3f("color", 1f, 1f, 1f);
renderingContext.getCamera().setupShader(starsShader);
int NB_STARS = 500;
// starsVertexBuffer = null;
if (starsVertexBuffer == null) {
starsVertexBuffer = renderingContext.newVertexBuffer();
ByteBuffer bb = ByteBuffer.allocateDirect(4 * 3 * NB_STARS);
bb.order(ByteOrder.LITTLE_ENDIAN);
// System.out.println(stars.order());
for (int i = 0; i < NB_STARS; i++) {
Vector3f star = new Vector3f((float) Math.random() * 2f - 1f, (float) Math.random(), (float) Math.random() * 2f - 1f);
star.normalize();
star.mul(100f);
bb.putFloat(star.x());
bb.putFloat(star.y());
bb.putFloat(star.z());
// stars.put(new float[] { star.x(), star.y(), star.z() });
}
bb.flip();
starsVertexBuffer.uploadData(bb);
}
renderingContext.bindAttribute("vertexIn", starsVertexBuffer.asAttributeSource(VertexFormat.FLOAT, 3));
renderingContext.draw(Primitive.POINT, 0, NB_STARS);
renderingContext.getRenderTargetManager().setDepthMask(true);
renderingContext.setBlendMode(BlendMode.DISABLED);
renderingContext.setDepthTestMode(DepthTestMode.LESS_OR_EQUAL);
cloudsRenderer.renderClouds(renderingContext);
}
Aggregations