use of org.lwjgl.util.vector.Matrix4f in project lwjgl by LWJGL.
the class GLMatrix method glRotatef.
public static void glRotatef(final float angle, final float x, final float y, final float z) {
final Matrix4f m = getCurrentMatrix();
v3f.set(x, y, z);
m.rotate((float) toRadians(angle), v3f);
}
use of org.lwjgl.util.vector.Matrix4f in project lwjgl by LWJGL.
the class GLMatrix method glPushMatrix.
public static void glPushMatrix() {
final Stack<Matrix4f> stack = getCurrentStack();
stack.push(new Matrix4f(stack.peek()));
}
use of org.lwjgl.util.vector.Matrix4f in project Galacticraft by micdoodle8.
the class GuiCelestialSelection method drawScreen.
@Override
public void drawScreen(int mousePosX, int mousePosY, float partialTicks) {
if (Mouse.hasWheel()) {
float wheel = Mouse.getDWheel() / (this.selectedBody == null ? 500.0F : 250.0F);
if (wheel != 0) {
if (this.selectedBody == null || (this.viewState == EnumView.PREVIEW && !this.isZoomed())) {
// Minimum zoom increased from 0.55F to 1F to allow zoom out to see other solar systems
this.zoom = Math.min(Math.max(this.zoom + wheel * ((this.zoom + 2.0F)) / 10.0F, -1.0F), 3);
} else {
this.planetZoom = Math.min(Math.max(this.planetZoom + wheel, -4.9F), 5);
}
}
}
GL11.glPushMatrix();
GL11.glEnable(GL11.GL_BLEND);
Matrix4f camMatrix = new Matrix4f();
// See EntityRenderer.java:setupOverlayRendering
Matrix4f.translate(new Vector3f(0.0F, 0.0F, -9000.0F), camMatrix, camMatrix);
Matrix4f viewMatrix = new Matrix4f();
viewMatrix.m00 = 2.0F / width;
viewMatrix.m11 = 2.0F / -height;
viewMatrix.m22 = -2.0F / 9000.0F;
viewMatrix.m30 = -1.0F;
viewMatrix.m31 = 1.0F;
viewMatrix.m32 = -2.0F;
GL11.glMatrixMode(GL11.GL_PROJECTION);
GL11.glLoadIdentity();
FloatBuffer fb = BufferUtils.createFloatBuffer(16 * Float.SIZE);
fb.rewind();
viewMatrix.store(fb);
fb.flip();
GL11.glMultMatrix(fb);
fb.clear();
GL11.glMatrixMode(GL11.GL_MODELVIEW);
GL11.glLoadIdentity();
fb.rewind();
camMatrix.store(fb);
fb.flip();
fb.clear();
GL11.glMultMatrix(fb);
this.setBlackBackground();
GL11.glPushMatrix();
Matrix4f worldMatrix = this.setIsometric(partialTicks);
mainWorldMatrix = worldMatrix;
// 194.4F;
float gridSize = 7000F;
// TODO: Add dynamic map sizing, to allow the map to be small by default and expand when more distant solar systems are added.
this.drawGrid(gridSize, height / 3 / 3.5F);
this.drawCircles();
GL11.glPopMatrix();
HashMap<CelestialBody, Matrix4f> matrixMap = this.drawCelestialBodies(worldMatrix);
this.planetPosMap.clear();
for (Map.Entry<CelestialBody, Matrix4f> e : matrixMap.entrySet()) {
Matrix4f planetMatrix = e.getValue();
Matrix4f matrix0 = Matrix4f.mul(viewMatrix, planetMatrix, planetMatrix);
int x = (int) Math.floor((matrix0.m30 * 0.5 + 0.5) * Minecraft.getMinecraft().displayWidth);
int y = (int) Math.floor(Minecraft.getMinecraft().displayHeight - (matrix0.m31 * 0.5 + 0.5) * Minecraft.getMinecraft().displayHeight);
Vector2f vec = new Vector2f(x, y);
Matrix4f scaleVec = new Matrix4f();
scaleVec.m00 = matrix0.m00;
scaleVec.m11 = matrix0.m11;
scaleVec.m22 = matrix0.m22;
Vector4f newVec = Matrix4f.transform(scaleVec, new Vector4f(2, -2, 0, 0), null);
float iconSize = (newVec.y * (Minecraft.getMinecraft().displayHeight / 2.0F)) * (e.getKey() instanceof Star ? 2 : 1) * (e.getKey() == this.selectedBody ? 1.5F : 1.0F);
// Store size on-screen in Z-value for ease
this.planetPosMap.put(e.getKey(), new Vector3f(vec.x, vec.y, iconSize));
}
this.drawSelectionCursor(fb, worldMatrix);
try {
this.drawButtons(mousePosX, mousePosY);
} catch (Exception e) {
if (!this.errorLogged) {
this.errorLogged = true;
GCLog.severe("Problem identifying planet or dimension in an add on for Galacticraft!");
GCLog.severe("(The problem is likely caused by a dimension ID conflict. Check configs for dimension clashes. You can also try disabling Mars space station in configs.)");
e.printStackTrace();
}
}
this.drawBorder();
GL11.glPopMatrix();
GL11.glMatrixMode(GL11.GL_PROJECTION);
GL11.glLoadIdentity();
GL11.glMatrixMode(GL11.GL_MODELVIEW);
GL11.glLoadIdentity();
}
use of org.lwjgl.util.vector.Matrix4f in project Galacticraft by micdoodle8.
the class GuiCelestialSelection method setIsometric.
public Matrix4f setIsometric(float partialTicks) {
Matrix4f mat0 = new Matrix4f();
Matrix4f.translate(new Vector3f(width / 2.0F, height / 2, 0), mat0, mat0);
Matrix4f.rotate((float) Math.toRadians(55), new Vector3f(1, 0, 0), mat0, mat0);
Matrix4f.rotate((float) Math.toRadians(-45), new Vector3f(0, 0, 1), mat0, mat0);
float zoomLocal = this.getZoomAdvanced();
this.zoom = zoomLocal;
Matrix4f.scale(new Vector3f(1.1f + zoomLocal, 1.1F + zoomLocal, 1.1F + zoomLocal), mat0, mat0);
Vector2f cBodyPos = this.getTranslationAdvanced(partialTicks);
this.position = this.getTranslationAdvanced(partialTicks);
Matrix4f.translate(new Vector3f(-cBodyPos.x, -cBodyPos.y, 0), mat0, mat0);
FloatBuffer fb = BufferUtils.createFloatBuffer(16);
fb.rewind();
mat0.store(fb);
fb.flip();
GL11.glMultMatrix(fb);
return mat0;
}
use of org.lwjgl.util.vector.Matrix4f in project Galacticraft by micdoodle8.
the class GuiCelestialSelection method drawSelectionCursor.
protected void drawSelectionCursor(FloatBuffer fb, Matrix4f worldMatrix) {
GL11.glPushMatrix();
switch(this.selectionState) {
case SELECTED:
if (this.selectedBody != null) {
Matrix4f worldMatrix0 = new Matrix4f(worldMatrix);
Matrix4f.translate(this.getCelestialBodyPosition(this.selectedBody), worldMatrix0, worldMatrix0);
Matrix4f worldMatrix1 = new Matrix4f();
Matrix4f.rotate((float) Math.toRadians(45), new Vector3f(0, 0, 1), worldMatrix1, worldMatrix1);
Matrix4f.rotate((float) Math.toRadians(-55), new Vector3f(1, 0, 0), worldMatrix1, worldMatrix1);
worldMatrix1 = Matrix4f.mul(worldMatrix0, worldMatrix1, worldMatrix1);
fb.rewind();
worldMatrix1.store(fb);
fb.flip();
GL11.glMultMatrix(fb);
fb.clear();
GL11.glScalef(1 / 15.0F, 1 / 15.0F, 1);
this.mc.renderEngine.bindTexture(GuiCelestialSelection.guiMain0);
float colMod = this.getZoomAdvanced() < 4.9F ? (float) (Math.sin(this.ticksSinceSelection / 2.0F) * 0.5F + 0.5F) : 1.0F;
GL11.glColor4f(1.0F, 1.0F, 0.0F, 1 * colMod);
int width = (int) Math.floor((getWidthForCelestialBodyStatic(this.selectedBody) / 2.0) * (this.selectedBody instanceof Moon ? 9.0 : 30.0));
this.drawTexturedModalRect(-width, -width, width * 2, width * 2, 266, 29, 100, 100, false, false);
}
break;
case ZOOMED:
if (this.selectedBody != null) {
Matrix4f worldMatrix0 = new Matrix4f(worldMatrix);
Matrix4f.translate(this.getCelestialBodyPosition(this.selectedBody), worldMatrix0, worldMatrix0);
Matrix4f worldMatrix1 = new Matrix4f();
Matrix4f.rotate((float) Math.toRadians(45), new Vector3f(0, 0, 1), worldMatrix1, worldMatrix1);
Matrix4f.rotate((float) Math.toRadians(-55), new Vector3f(1, 0, 0), worldMatrix1, worldMatrix1);
worldMatrix1 = Matrix4f.mul(worldMatrix0, worldMatrix1, worldMatrix1);
fb.rewind();
worldMatrix1.store(fb);
fb.flip();
GL11.glMultMatrix(fb);
fb.clear();
float div = (this.zoom + 1.0F - this.planetZoom);
float scale = Math.max(0.3F, 1.5F / (this.ticksSinceSelection / 5.0F)) * 2.0F / div;
GL11.glScalef(scale, scale, 1);
this.mc.renderEngine.bindTexture(GuiCelestialSelection.guiMain0);
float colMod = this.getZoomAdvanced() < 4.9F ? (float) (Math.sin(this.ticksSinceSelection / 1.0F) * 0.5F + 0.5F) : 1.0F;
GL11.glColor4f(0.4F, 0.8F, 1.0F, 1 * colMod);
int width = getWidthForCelestialBodyStatic(this.selectedBody) * 13;
this.drawTexturedModalRect(-width, -width, width * 2, width * 2, 266, 29, 100, 100, false, false);
}
break;
default:
break;
}
GL11.glPopMatrix();
}
Aggregations