use of hellfirepvp.astralsorcery.common.constellation.star.StarConnection 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.StarConnection 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.StarConnection 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;
}
use of hellfirepvp.astralsorcery.common.constellation.star.StarConnection in project AstralSorcery by HellFirePvP.
the class TileAttunementAltar method getConstellationConnectionPositions.
private Set<Tuple<BlockPos, BlockPos>> getConstellationConnectionPositions(IConstellation cst) {
Set<Tuple<BlockPos, BlockPos>> offsetPositions = new HashSet<>();
for (StarConnection conn : cst.getStarConnections()) {
StarLocation from = conn.getLeft();
StarLocation to = conn.getRight();
int fX = from.x / 2;
int fZ = from.y / 2;
int tX = to.x / 2;
int tZ = to.y / 2;
offsetPositions.add(new Tuple<>(new BlockPos(fX - 7, 0, fZ - 7).add(getPos()), new BlockPos(tX - 7, 0, tZ - 7).add(getPos())));
}
return offsetPositions;
}
use of hellfirepvp.astralsorcery.common.constellation.star.StarConnection in project AstralSorcery by HellFirePvP.
the class ConstellationGenerator method generateRandom.
public static GeneratedConstellation generateRandom(long seed, int stars) {
Random sRandom = new Random(seed);
String name = RandomWordGenerator.getGenerator().generateWord(seed, sRandom.nextFloat() > 0.6F ? 7 : 6);
GeneratedConstellation cst = new GeneratedConstellation(name);
List<StarLocation> tmpStars = Lists.newArrayList();
List<StarConnection> tmpConnections = Lists.newArrayList();
for (int i = 0; i < stars; i++) {
Point newPoint = pickStarPoint(sRandom, tmpStars, 6);
tmpStars.add(new StarLocation(newPoint.x, newPoint.y));
}
Iterator<StarLocation> it = tmpStars.iterator();
while (it.hasNext()) {
StarLocation sl = it.next();
StarLocation other = findConnection(sRandom, sl, tmpStars, tmpConnections);
if (other == null) {
it.remove();
continue;
}
tmpConnections.add(new StarConnection(sl, other));
}
tmpStars.forEach(s -> cst.addStar(s.x, s.y));
tmpConnections.forEach(c -> {
if (cst.getStars().contains(c.to) && cst.getStars().contains(c.from)) {
cst.addConnection(c.from, c.to);
}
});
return cst;
}
Aggregations