use of logisticspipes.utils.math.Vector3d in project LogisticsPipes by RS485.
the class SideConfigDisplay method handleMouseInput.
public void handleMouseInput() {
if (Mouse.getEventButton() == 0) {
draggingRotate = Mouse.getEventButtonState();
}
if (Mouse.getEventButton() == 2) {
draggingMove = Mouse.getEventButtonState();
}
if (draggingRotate) {
double dx = (Mouse.getEventDX() / (double) mc.displayWidth);
double dy = (Mouse.getEventDY() / (double) mc.displayHeight);
if (Keyboard.isKeyDown(Keyboard.KEY_LCONTROL) || Keyboard.isKeyDown(Keyboard.KEY_LSHIFT)) {
distance -= dy * 15;
} else {
yaw -= 4 * dx * 180;
pitch += 2 * dy * 180;
pitch = (float) VecmathUtil.clamp(pitch, -80, 80);
}
}
if (draggingMove) {
double dx = Mouse.getEventDX();
double dy = -Mouse.getEventDY();
Vector3d orivec = camera.getWorldPoint(new Vector2d(0, 0));
Vector3d newvec = camera.getWorldPoint(new Vector2d(dx * distance, dy * distance)).negate();
origin.add(orivec).add(newvec);
}
distance -= Mouse.getEventDWheel() * 0.01;
distance = VecmathUtil.clamp(distance, 0.01, 200);
long elapsed = System.currentTimeMillis() - initTime;
int x = Mouse.getEventX();
int y = Mouse.getEventY();
Vector3d start = new Vector3d();
Vector3d end = new Vector3d();
if (camera.getRayForPixel(x, y, start, end)) {
end.multiply(distance * 2);
end.add(start);
updateSelection(start, end);
}
if (!Mouse.getEventButtonState() && camera.isValid() && elapsed > 500) {
boolean inNeigButBounds = false;
if (Mouse.getEventButton() == 1) {
if (selection != null) {
handleSelection(selection);
}
} else if (Mouse.getEventButton() == 0 && inNeigButBounds) {
renderNeighbours = !renderNeighbours;
}
}
}
use of logisticspipes.utils.math.Vector3d in project LogisticsPipes by RS485.
the class SideConfigDisplay method renderSelection.
private void renderSelection() {
if (selection == null) {
return;
}
BoundingBox bb = new BoundingBox(new DoubleCoordinates(selection.config));
TextureAtlasSprite icon = (TextureAtlasSprite) Textures.LOGISTICS_SIDE_SELECTION;
List<Vertex> corners = bb.getCornersWithUvForFace(selection.face, icon.getMinU(), icon.getMaxU(), icon.getMinV(), icon.getMaxV());
GlStateManager.disableDepth();
GlStateManager.disableLighting();
RenderUtil.bindBlockTexture();
BufferBuilder tes = Tessellator.getInstance().getBuffer();
GlStateManager.color(1, 1, 1);
Vector3d trans = new Vector3d((-origin.x) + eye.x, (-origin.y) + eye.y, (-origin.z) + eye.z);
tes.setTranslation(trans.x, trans.y, trans.z);
RenderUtil.addVerticesToTessellator(corners, DefaultVertexFormats.POSITION_TEX, true);
Tessellator.getInstance().draw();
tes.setTranslation(0, 0, 0);
}
use of logisticspipes.utils.math.Vector3d in project LogisticsPipes by RS485.
the class SideConfigDisplay method doTileEntityRenderPass.
private void doTileEntityRenderPass(List<DoubleCoordinates> blocks, int pass) {
for (DoubleCoordinates bc : blocks) {
TileEntity tile = world.getTileEntity(bc.getBlockPos());
if (tile != null) {
if (tile.shouldRenderInPass(pass)) {
Vector3d at = new Vector3d(eye.x, eye.y, eye.z);
at.x += bc.getXCoord() - origin.x;
at.y += bc.getYCoord() - origin.y;
at.z += bc.getZCoord() - origin.z;
if (tile.getClass() == TileEntityChest.class) {
TileEntityChest chest = (TileEntityChest) tile;
if (chest.adjacentChestXNeg != null) {
tile = chest.adjacentChestXNeg;
at.x--;
} else if (chest.adjacentChestZNeg != null) {
tile = chest.adjacentChestZNeg;
at.z--;
}
}
TileEntityRendererDispatcher.instance.render(tile, at.x, at.y, at.z, 0, -1, 0);
}
}
}
}
use of logisticspipes.utils.math.Vector3d in project LogisticsPipes by RS485.
the class LogisticsHUDRenderer method getCursor.
private int[] getCursor(IHeadUpDisplayRendererProvider renderer) {
Minecraft mc = FMLClientHandler.instance().getClient();
EntityPlayer player = mc.player;
Vector3d playerView = Vector3d.getFromAngles((270 - player.rotationYaw) / 360 * -2 * Math.PI, (player.rotationPitch) / 360 * -2 * Math.PI);
Vector3d playerPos = new Vector3d();
playerPos.x = player.posX;
playerPos.y = player.posY + player.getEyeHeight();
playerPos.z = player.posZ;
Vector3d panelPos = new Vector3d();
panelPos.x = renderer.getX() + 0.5;
panelPos.y = renderer.getY() + 0.5;
panelPos.z = renderer.getZ() + 0.5;
Vector3d panelView = new Vector3d();
panelView.x = playerPos.x - panelPos.x;
panelView.y = playerPos.y - panelPos.y;
panelView.z = playerPos.z - panelPos.z;
panelPos.add(panelView, 0.44D);
double d = panelPos.x * panelView.x + panelPos.y * panelView.y + panelPos.z * panelView.z;
double c = panelView.x * playerPos.x + panelView.y * playerPos.y + panelView.z * playerPos.z;
double b = panelView.x * playerView.x + panelView.y * playerView.y + panelView.z * playerView.z;
double a = (d - c) / b;
Vector3d viewPos = new Vector3d();
viewPos.x = playerPos.x + a * playerView.x - panelPos.x;
viewPos.y = playerPos.y + a * playerView.y - panelPos.y;
viewPos.z = playerPos.z + a * playerView.z - panelPos.z;
Vector3d panelScalVector1 = new Vector3d();
if (panelView.y == 0) {
panelScalVector1.x = 0;
panelScalVector1.y = 1;
panelScalVector1.z = 0;
} else {
panelScalVector1 = panelView.getOrtogonal(-panelView.x, null, -panelView.z).makeVectorLength(1.0D);
}
Vector3d panelScalVector2 = new Vector3d();
if (panelView.z == 0) {
panelScalVector2.x = 0;
panelScalVector2.y = 0;
panelScalVector2.z = 1;
} else {
panelScalVector2 = panelView.getOrtogonal(1.0D, 0.0D, null).makeVectorLength(1.0D);
}
if (panelScalVector1.y == 0) {
return new int[] {};
}
double cursorY = -viewPos.y / panelScalVector1.y;
Vector3d restViewPos = viewPos.clone();
restViewPos.x += cursorY * panelScalVector1.x;
restViewPos.y = 0;
restViewPos.z += cursorY * panelScalVector1.z;
double cursorX;
if (panelScalVector2.x == 0) {
cursorX = restViewPos.z / panelScalVector2.z;
} else {
cursorX = restViewPos.x / panelScalVector2.x;
}
cursorX *= 50 / 0.47D;
cursorY *= 50 / 0.47D;
if (panelView.z < 0) {
cursorX *= -1;
}
if (panelView.y < 0) {
cursorY *= -1;
}
return new int[] { (int) cursorX, (int) cursorY };
}
use of logisticspipes.utils.math.Vector3d in project LogisticsPipes by RS485.
the class SideConfigDisplay method renderScene.
private void renderScene(boolean tryNeighbours) {
if (tryNeighbours && !renderNeighbours)
return;
GL11.glEnable(GL11.GL_CULL_FACE);
GL11.glEnable(GL12.GL_RESCALE_NORMAL);
RenderHelper.disableStandardItemLighting();
mc.entityRenderer.disableLightmap(0);
RenderUtil.bindBlockTexture();
GL11.glDisable(GL11.GL_LIGHTING);
GL11.glEnable(GL11.GL_TEXTURE_2D);
GL11.glEnable(GL11.GL_ALPHA_TEST);
Vector3d trans = new Vector3d((-origin.x) + eye.x, (-origin.y) + eye.y, (-origin.z) + eye.z);
for (int pass = 0; pass < 1; pass++) {
if (!tryNeighbours) {
setGlStateForPass(pass, false);
doWorldRenderPass(trans, configurables, pass);
} else if (renderNeighbours) {
setGlStateForPass(pass, true);
doWorldRenderPass(trans, neighbours, pass);
}
}
RenderHelper.enableStandardItemLighting();
GL11.glEnable(GL11.GL_LIGHTING);
TileEntityRendererDispatcher.instance.field_147558_l = origin.x - eye.x;
TileEntityRendererDispatcher.instance.field_147560_j = origin.y - eye.y;
TileEntityRendererDispatcher.instance.field_147561_k = origin.z - eye.z;
TileEntityRendererDispatcher.staticPlayerX = origin.x - eye.x;
TileEntityRendererDispatcher.staticPlayerY = origin.y - eye.y;
TileEntityRendererDispatcher.staticPlayerZ = origin.z - eye.z;
for (int pass = 0; pass < 2; pass++) {
if (!tryNeighbours) {
setGlStateForPass(pass, false);
doTileEntityRenderPass(configurables, pass);
} else if (renderNeighbours) {
setGlStateForPass(pass, true);
doTileEntityRenderPass(neighbours, pass);
}
}
setGlStateForPass(0, false);
}
Aggregations