Search in sources :

Example 1 with ItemZoom

use of io.xol.chunkstories.api.item.interfaces.ItemZoom in project chunkstories-core by Hugobros3.

the class EntityPlayer method setupCamera.

@Override
public void setupCamera(RenderingInterface rd) {
    synchronized (this) {
        lastCameraLocation = getLocation();
        rd.getCamera().setCameraPosition(new Vector3d(positionComponent.getLocation().add(0.0, eyePosition, 0.0)));
        // camera.pos = lastCameraLocation.clone().negate();
        // camera.pos.add(0d, -eyePosition, 0d);
        rd.getCamera().setRotationX(this.getEntityRotationComponent().getVerticalRotation());
        rd.getCamera().setRotationY(this.getEntityRotationComponent().getHorizontalRotation());
        float modifier = 1.0f;
        if (this.getSelectedItemComponent().getSelectedItem() != null && this.getSelectedItemComponent().getSelectedItem().getItem() instanceof ItemZoom) {
            ItemZoom item = (ItemZoom) this.getSelectedItemComponent().getSelectedItem().getItem();
            modifier = 1.0f / item.getZoomFactor();
        }
        rd.getCamera().setFOV(modifier * (float) (rd.getClient().getConfiguration().getDoubleOption("client.video.fov") + ((getVelocityComponent().getVelocity().x() * getVelocityComponent().getVelocity().x() + getVelocityComponent().getVelocity().z() * getVelocityComponent().getVelocity().z()) > 0.07 * 0.07 ? ((getVelocityComponent().getVelocity().x() * getVelocityComponent().getVelocity().x() + getVelocityComponent().getVelocity().z() * getVelocityComponent().getVelocity().z()) - 0.07 * 0.07) * 500 : 0)));
    }
}
Also used : Vector3d(org.joml.Vector3d) ItemZoom(io.xol.chunkstories.api.item.interfaces.ItemZoom)

Example 2 with ItemZoom

use of io.xol.chunkstories.api.item.interfaces.ItemZoom in project chunkstories-core by Hugobros3.

the class EntityPlayer method moveCamera.

protected void moveCamera(LocalPlayer controller) {
    if (isDead())
        return;
    double cPX = controller.getInputsManager().getMouse().getCursorX();
    double cPY = controller.getInputsManager().getMouse().getCursorY();
    double dx = 0, dy = 0;
    if (lastPX != -1f) {
        dx = cPX - controller.getWindow().getWidth() / 2.0;
        dy = cPY - controller.getWindow().getHeight() / 2.0;
    }
    lastPX = cPX;
    lastPY = cPY;
    double rotH = this.getEntityRotationComponent().getHorizontalRotation();
    double rotV = this.getEntityRotationComponent().getVerticalRotation();
    double modifier = 1.0f;
    if (this.getSelectedItemComponent().getSelectedItem() != null && this.getSelectedItemComponent().getSelectedItem().getItem() instanceof ItemZoom) {
        ItemZoom item = (ItemZoom) this.getSelectedItemComponent().getSelectedItem().getItem();
        modifier = 1.0 / item.getZoomFactor();
    }
    rotH += dx * modifier / 3f * controller.getClient().getConfiguration().getDoubleOption("client.input.mouseSensitivity");
    rotV -= dy * modifier / 3f * controller.getClient().getConfiguration().getDoubleOption("client.input.mouseSensitivity");
    this.getEntityRotationComponent().setRotation(rotH, rotV);
    controller.getInputsManager().getMouse().setMouseCursorLocation(controller.getWindow().getWidth() / 2.0, controller.getWindow().getHeight() / 2.0);
}
Also used : ItemZoom(io.xol.chunkstories.api.item.interfaces.ItemZoom)

Aggregations

ItemZoom (io.xol.chunkstories.api.item.interfaces.ItemZoom)2 Vector3d (org.joml.Vector3d)1