Search in sources :

Example 1 with Vector2d

use of logisticspipes.utils.math.Vector2d 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;
        }
    }
}
Also used : Vector2d(logisticspipes.utils.math.Vector2d) Vector3d(logisticspipes.utils.math.Vector3d)

Aggregations

Vector2d (logisticspipes.utils.math.Vector2d)1 Vector3d (logisticspipes.utils.math.Vector3d)1