use of hellfirepvp.astralsorcery.client.util.draw.RenderInfo in project AstralSorcery by HellFirePvP.
the class RenderingDrawUtils method renderFacingQuadVB.
public static void renderFacingQuadVB(IVertexBuilder vb, MatrixStack renderStack, double px, double py, double pz, float scale, float angle, float u, float v, float uLength, float vLength, int r, int g, int b, int alpha) {
Vector3 pos = new Vector3(px, py, pz);
RenderInfo ri = RenderInfo.getInstance();
ActiveRenderInfo ari = ri.getARI();
float arX = ri.getRotationX();
float arZ = ri.getRotationZ();
float arYZ = ri.getRotationYZ();
float arXY = ri.getRotationXY();
float arXZ = ri.getRotationXZ();
Vector3d view = ari.getProjectedView();
Vector3f look = ari.getViewVector();
Vector3 iPos = new Vector3(view);
Vector3 v1 = new Vector3(-arX * scale - arYZ * scale, -arXZ * scale, -arZ * scale - arXY * scale);
Vector3 v2 = new Vector3(-arX * scale + arYZ * scale, arXZ * scale, -arZ * scale + arXY * scale);
Vector3 v3 = new Vector3(arX * scale + arYZ * scale, arXZ * scale, arZ * scale + arXY * scale);
Vector3 v4 = new Vector3(arX * scale - arYZ * scale, -arXZ * scale, arZ * scale - arXY * scale);
if (angle != 0.0F) {
float cAngle = MathHelper.cos(angle * 0.5F);
float cAngleSq = cAngle * cAngle;
Vector3 vAngle = new Vector3(MathHelper.sin(angle * 0.5F) * look.getX(), MathHelper.sin(angle * 0.5F) * look.getY(), MathHelper.sin(angle * 0.5F) * look.getZ());
v1 = vAngle.clone().multiply(2 * v1.dot(vAngle)).add(v1.clone().multiply(cAngleSq - vAngle.dot(vAngle))).add(vAngle.clone().crossProduct(v1.clone().multiply(2 * cAngle)));
v2 = vAngle.clone().multiply(2 * v2.dot(vAngle)).add(v2.clone().multiply(cAngleSq - vAngle.dot(vAngle))).add(vAngle.clone().crossProduct(v2.clone().multiply(2 * cAngle)));
v3 = vAngle.clone().multiply(2 * v3.dot(vAngle)).add(v3.clone().multiply(cAngleSq - vAngle.dot(vAngle))).add(vAngle.clone().crossProduct(v3.clone().multiply(2 * cAngle)));
v4 = vAngle.clone().multiply(2 * v4.dot(vAngle)).add(v4.clone().multiply(cAngleSq - vAngle.dot(vAngle))).add(vAngle.clone().crossProduct(v4.clone().multiply(2 * cAngle)));
}
Matrix4f matr = renderStack.getLast().getMatrix();
pos.clone().add(v1).subtract(iPos).drawPos(matr, vb).color(r, g, b, alpha).tex(u + uLength, v + vLength).endVertex();
pos.clone().add(v2).subtract(iPos).drawPos(matr, vb).color(r, g, b, alpha).tex(u + uLength, v).endVertex();
pos.clone().add(v3).subtract(iPos).drawPos(matr, vb).color(r, g, b, alpha).tex(u, v).endVertex();
pos.clone().add(v4).subtract(iPos).drawPos(matr, vb).color(r, g, b, alpha).tex(u, v + vLength).endVertex();
}
Aggregations