use of hellfirepvp.astralsorcery.common.constellation.star.StarLocation in project AstralSorcery by HellFirePvP.
the class RenderingConstellationUtils method renderConstellationIntoWorldFlat.
public static void renderConstellationIntoWorldFlat(Color color, IConstellation c, MatrixStack renderStack, IRenderTypeBuffer buffer, Vector3 offset, double scale, double line, float brightness) {
Matrix4f matr = renderStack.getLast().getMatrix();
Vector3 thisOffset = offset.clone();
double starSize = 1D / ((double) IConstellation.STAR_GRID_WIDTH_HEIGHT) * scale;
int r = color.getRed();
int g = color.getGreen();
int b = color.getBlue();
int connAlpha = (int) ((brightness * 0.8F) * 255F);
int starAlpha = (int) (brightness * 255F);
int outlineAlpha = (int) ((brightness * 0.5F) * 255F);
Vector3 drawOffset = new Vector3(-15.5D * starSize, 0, -15.5D * starSize);
Vector3 dirU = new Vector3(scale, 0, 0);
Vector3 dirV = new Vector3(0, 0, scale);
IVertexBuilder buf;
ConstellationBackgroundInfo backgroundInfo = ConstellationRenderInfos.getBackgroundRenderInfo(c);
if (backgroundInfo != null) {
buf = buffer.getBuffer(backgroundInfo.getRenderType());
Vector3 offsetRender = thisOffset.clone().add(0, 0.005, 0);
offsetRender = offsetRender.add(drawOffset);
Vector3 pos2 = offsetRender.clone().add(dirU.clone().multiply(0)).add(dirV.clone().multiply(1));
pos2.drawPos(matr, buf).color(r, g, b, outlineAlpha).tex(0, 1).endVertex();
pos2 = offsetRender.clone().add(dirU.clone().multiply(1)).add(dirV.clone().multiply(1));
pos2.drawPos(matr, buf).color(r, g, b, outlineAlpha).tex(1, 1).endVertex();
pos2 = offsetRender.clone().add(dirU.clone().multiply(1)).add(dirV.clone().multiply(0));
pos2.drawPos(matr, buf).color(r, g, b, outlineAlpha).tex(1, 0).endVertex();
pos2 = offsetRender.clone().add(dirU.clone().multiply(0)).add(dirV.clone().multiply(0));
pos2.drawPos(matr, buf).color(r, g, b, outlineAlpha).tex(0, 0).endVertex();
}
buf = buffer.getBuffer(RenderTypesAS.CONSTELLATION_WORLD_CONNECTION);
for (StarConnection sc : c.getStarConnections()) {
thisOffset.addY(0.001);
dirU = new Vector3(sc.to.x, 0, sc.to.y).subtract(sc.from.x, 0, sc.from.y).multiply(starSize);
dirV = dirU.clone().crossProduct(new Vector3(0, 1, 0)).setY(0).normalize().multiply(line * starSize);
Vector3 starOffset = thisOffset.clone().addX(sc.from.x * starSize).addZ(sc.from.y * starSize);
Vector3 offsetRender = starOffset.subtract(dirV.clone().divide(2));
offsetRender.add(drawOffset);
Vector3 pos = offsetRender.clone().add(dirU.clone().multiply(0)).add(dirV.clone().multiply(1));
pos.drawPos(matr, buf).color(r, g, b, connAlpha).tex(1, 0).endVertex();
pos = offsetRender.clone().add(dirU.clone().multiply(1)).add(dirV.clone().multiply(1));
pos.drawPos(matr, buf).color(r, g, b, connAlpha).tex(0, 0).endVertex();
pos = offsetRender.clone().add(dirU.clone().multiply(1)).add(dirV.clone().multiply(0));
pos.drawPos(matr, buf).color(r, g, b, connAlpha).tex(0, 1).endVertex();
pos = offsetRender.clone().add(dirU.clone().multiply(0)).add(dirV.clone().multiply(0));
pos.drawPos(matr, buf).color(r, g, b, connAlpha).tex(1, 1).endVertex();
}
dirU = new Vector3(starSize * 2, 0, 0);
dirV = new Vector3(0, 0, starSize * 2);
buf = buffer.getBuffer(RenderTypesAS.CONSTELLATION_WORLD_STAR);
for (StarLocation sl : c.getStars()) {
Vector3 offsetRender = thisOffset.clone().add(sl.x * starSize - starSize, 0.005, sl.y * starSize - starSize);
offsetRender.add(drawOffset);
Vector3 pos = offsetRender.clone().add(dirU.clone().multiply(0)).add(dirV.clone().multiply(1));
pos.drawPos(matr, buf).color(r, g, b, starAlpha).tex(1, 0).endVertex();
pos = offsetRender.clone().add(dirU.clone().multiply(1)).add(dirV.clone().multiply(1));
pos.drawPos(matr, buf).color(r, g, b, starAlpha).tex(0, 0).endVertex();
pos = offsetRender.clone().add(dirU.clone().multiply(1)).add(dirV.clone().multiply(0));
pos.drawPos(matr, buf).color(r, g, b, starAlpha).tex(0, 1).endVertex();
pos = offsetRender.clone().add(dirU.clone().multiply(0)).add(dirV.clone().multiply(0));
pos.drawPos(matr, buf).color(r, g, b, starAlpha).tex(1, 1).endVertex();
}
}
use of hellfirepvp.astralsorcery.common.constellation.star.StarLocation in project AstralSorcery by HellFirePvP.
the class ScreenHandTelescope method drawTelescopeCell.
private void drawTelescopeCell(MatrixStack renderStack, float pTicks) {
boolean canSeeSky = this.canObserverSeeSky(Minecraft.getInstance().player.getPosition(), 1);
float pitch = Minecraft.getInstance().player.getPitch(pTicks);
float angleOpacity = 0F;
if (pitch < -60F) {
angleOpacity = 1F;
} else if (pitch < -10F) {
angleOpacity = (Math.abs(pitch) - 10F) / 50F;
if (DayTimeHelper.isNight(Minecraft.getInstance().world)) {
angleOpacity *= angleOpacity;
}
}
float brMultiplier = angleOpacity;
RenderSystem.enableBlend();
Blending.DEFAULT.apply();
RenderSystem.disableAlphaTest();
this.setBlitOffset(-10);
this.drawSkyBackground(renderStack, pTicks, canSeeSky, angleOpacity);
if (!this.isInitialized()) {
this.setBlitOffset(0);
RenderSystem.enableAlphaTest();
Blending.DEFAULT.apply();
RenderSystem.disableBlend();
return;
}
WorldContext ctx = SkyHandler.getContext(Minecraft.getInstance().world, LogicalSide.CLIENT);
if (ctx != null && canSeeSky) {
Random gen = ctx.getDayRandom();
double guiFactor = Minecraft.getInstance().getMainWindow().getGuiScaleFactor();
float playerYaw = Minecraft.getInstance().player.rotationYaw % 360F;
if (playerYaw < 0) {
playerYaw += 360F;
}
if (playerYaw >= 180F) {
playerYaw -= 360F;
}
float playerPitch = Minecraft.getInstance().player.rotationPitch;
this.setBlitOffset(-9);
float starSize = 5F;
TexturesAS.TEX_STAR_1.bindTexture();
RenderingUtils.draw(GL11.GL_QUADS, DefaultVertexFormats.POSITION_COLOR_TEX, buf -> {
for (Point.Float pos : this.usedStars) {
float brightness = 0.4F + (RenderingConstellationUtils.stdFlicker(ClientScheduler.getClientTick(), pTicks, 10 + gen.nextInt(20))) * 0.5F;
brightness = this.multiplyStarBrightness(pTicks, brightness);
brightness *= brMultiplier;
RenderingGuiUtils.rect(buf, renderStack, pos.x + this.getGuiLeft(), pos.y + this.getGuiTop(), getGuiZLevel(), starSize, starSize).color(brightness, brightness, brightness, brightness).draw();
}
});
this.setBlitOffset(-7);
for (DrawArea areas : this.getVisibleDrawAreas()) {
for (IConstellation cst : areas.getDisplayMap().keySet()) {
ConstellationDisplayInformation info = areas.getDisplayMap().get(cst);
info.getFrameDrawInformation().clear();
if (!(info instanceof PlayerAngledConstellationInformation)) {
continue;
}
PlayerAngledConstellationInformation cstInfo = (PlayerAngledConstellationInformation) info;
float diffYaw = playerYaw - cstInfo.getYaw();
float diffPitch = playerPitch - cstInfo.getPitch();
float maxDistance = 35F;
if ((Math.abs(diffYaw) <= maxDistance || Math.abs(playerYaw + 360F) <= maxDistance) && Math.abs(diffPitch) <= maxDistance) {
float rainBr = 1F - Minecraft.getInstance().world.getRainStrength(pTicks);
int wPart = MathHelper.floor(this.getGuiWidth() * 0.1F);
int hPart = MathHelper.floor(this.getGuiHeight() * 0.1F);
float xFactor = diffYaw / 8F;
float yFactor = diffPitch / 8F;
GL11.glEnable(GL11.GL_SCISSOR_TEST);
GL11.glScissor(MathHelper.floor((this.getGuiLeft() + 5) * guiFactor), MathHelper.floor((this.getGuiTop() + 5) * guiFactor), MathHelper.floor((this.getGuiWidth() - 10) * guiFactor), MathHelper.floor((this.getGuiHeight() - 10) * guiFactor));
Map<StarLocation, Rectangle.Float> cstRenderInfo = RenderingConstellationUtils.renderConstellationIntoGUI(cst.getTierRenderColor(), cst, renderStack, this.getGuiLeft() + wPart + MathHelper.floor((xFactor / guiFactor) * this.getGuiWidth()), this.getGuiTop() + hPart + MathHelper.floor((yFactor / guiFactor) * this.getGuiHeight()), this.getGuiZLevel(), this.getGuiWidth() - MathHelper.floor(wPart * 1.5F), this.getGuiHeight() - MathHelper.floor(hPart * 1.5F), 2F, () -> (0.3F + 0.7F * RenderingConstellationUtils.conCFlicker(ClientScheduler.getClientTick(), pTicks, 5 + gen.nextInt(15))) * rainBr * brMultiplier, ResearchHelper.getClientProgress().hasConstellationDiscovered(cst), true);
GL11.glDisable(GL11.GL_SCISSOR_TEST);
info.getFrameDrawInformation().putAll(cstRenderInfo);
}
}
}
this.setBlitOffset(-5);
this.renderDrawnLines(renderStack, gen, pTicks);
}
this.setBlitOffset(0);
RenderSystem.enableAlphaTest();
Blending.DEFAULT.apply();
RenderSystem.disableBlend();
}
use of hellfirepvp.astralsorcery.common.constellation.star.StarLocation in project AstralSorcery by HellFirePvP.
the class EngravedStarMap method createConstellationOffsets.
private static List<Rectangle.Double> createConstellationOffsets(DrawnConstellation cst) {
float width = DrawnConstellation.CONSTELLATION_STAR_SIZE;
List<Rectangle.Double> positions = new ArrayList<>();
for (StarLocation star : cst.getConstellation().getStars()) {
// Rescale from 32 to 20 width, move to drawn offset coordinates
double starX = star.x * DrawnConstellation.CONSTELLATION_SIZE_PART + cst.getPoint().getX() - DrawnConstellation.CONSTELLATION_DRAW_SIZE / 2F - (width / 2F);
double starY = star.y * DrawnConstellation.CONSTELLATION_SIZE_PART + cst.getPoint().getY() - DrawnConstellation.CONSTELLATION_DRAW_SIZE / 2F - (width / 2F);
positions.add(new Rectangle.Double(starX, starY, width, width));
}
return positions;
}
use of hellfirepvp.astralsorcery.common.constellation.star.StarLocation in project AstralSorcery by HellFirePvP.
the class ConstellationGenerator method findConnection.
private static StarLocation findConnection(Random rand, StarLocation sl, List<StarLocation> stars, List<StarConnection> existingConnections) {
List<StarLocation> others = Lists.newArrayList(stars);
others.remove(sl);
if (others.isEmpty())
return null;
Collections.shuffle(others, rand);
lblStars: for (StarLocation other : others) {
StarConnection conn = new StarConnection(sl, other);
for (StarConnection otherConnection : existingConnections) {
if (intersect(conn, otherConnection)) {
continue lblStars;
}
}
return other;
}
return null;
}
use of hellfirepvp.astralsorcery.common.constellation.star.StarLocation in project AstralSorcery by HellFirePvP.
the class ConstellationGenerator method isIntersecting.
private static boolean isIntersecting(StarConnection part, Point p) {
StarConnection originPart = new StarConnection(new StarLocation(0, 0), new StarLocation(part.to.x - part.from.x, part.to.y - part.from.y));
Point originOffset = new Point(p.x - part.from.x, p.y - part.from.y);
return cross(originPart.to.asPoint(), originOffset) < 0;
}
Aggregations