Search in sources :

Example 1 with CameraManager

use of gaiasky.scenegraph.camera.CameraManager in project gaiasky by langurmonkey.

the class SGRFov method render.

@Override
public void render(SceneGraphRenderer sgr, ICamera camera, double t, int rw, int rh, int tw, int th, FrameBuffer fb, PostProcessBean ppb) {
    boolean postProcess = postProcessCapture(ppb, fb, tw, th);
    // Viewport
    extendViewport.setCamera(camera.getCamera());
    extendViewport.setWorldSize(rw, rh);
    extendViewport.setScreenSize(rw * rw / tw, rh * rh / th);
    extendViewport.apply();
    /* FIELD OF VIEW CAMERA - we only render the star group process */
    FovCamera cam = ((CameraManager) camera).fovCamera;
    int fovMode = camera.getMode().getGaiaFovMode();
    if (fovMode == 1 || fovMode == 3) {
        cam.dirIndex = 0;
        sgr.renderScene(camera, t, rc);
    }
    if (fovMode == 2 || fovMode == 3) {
        cam.dirIndex = 1;
        sgr.renderScene(camera, t, rc);
    }
    // GLFW reports a window size of 0x0 with AMD Graphics on Windows when minimizing
    if (rw > 0 && rh > 0) {
        sendOrientationUpdate(camera.getCamera(), rw, rh);
        postProcessRender(ppb, fb, postProcess, camera, rw, rh);
    }
}
Also used : FovCamera(gaiasky.scenegraph.camera.FovCamera) CameraManager(gaiasky.scenegraph.camera.CameraManager)

Example 2 with CameraManager

use of gaiasky.scenegraph.camera.CameraManager in project gaiasky by langurmonkey.

the class ControllerGui method rebuildGui.

@Override
protected void rebuildGui() {
    // Clean up
    content.clear();
    menu.clear();
    tabButtons.clear();
    tabContents.clear();
    model.clear();
    float w = 1440f;
    float h = 640f;
    // Widget width
    float ww = 400f;
    float wh = 64f;
    float sw = ww;
    float sh = 96f;
    float tfw = 240f;
    // Tab width
    float tw = 224f;
    // Create contents
    // SEARCH
    Actor[][] searchModel = new Actor[11][5];
    model.add(searchModel);
    searchT = new Table(skin);
    searchT.setSize(w, h);
    searchField = new OwnTextField("", skin, "big");
    searchField.setProgrammaticChangeEvents(true);
    searchField.setSize(ww, wh);
    searchField.setMessageText("Search...");
    searchField.addListener((event) -> {
        if (event instanceof ChangeEvent) {
            ChangeEvent ie = (ChangeEvent) event;
            if (!searchField.getText().equals(currentInputText) && !searchField.getText().isBlank()) {
                // Process only if text changed
                currentInputText = searchField.getText();
                String name = currentInputText.toLowerCase().trim();
                if (!checkString(name, sg)) {
                    if (name.matches("[0-9]+")) {
                        // Check with 'HIP '
                        checkString("hip " + name, sg);
                    } else if (name.matches("hip [0-9]+") || name.matches("HIP [0-9]+")) {
                        // Check without 'HIP '
                        checkString(name.substring(4), sg);
                    }
                }
            }
        }
        return false;
    });
    searchT.add(searchField).colspan(11).padBottom(pad5).row();
    infoMessage = new OwnLabel("", skin, "default-blue");
    infoCell = searchT.add();
    infoCell.colspan(10).padBottom(pad20).row();
    // First row
    addTextKey("Q", searchModel, 0, 0, false);
    addTextKey("W", searchModel, 1, 0, false);
    addTextKey("E", searchModel, 2, 0, false);
    addTextKey("R", searchModel, 3, 0, false);
    addTextKey("T", searchModel, 4, 0, false);
    addTextKey("Y", searchModel, 5, 0, false);
    addTextKey("U", searchModel, 6, 0, false);
    addTextKey("I", searchModel, 7, 0, false);
    addTextKey("O", searchModel, 8, 0, false);
    addTextKey("P", searchModel, 9, 0, false);
    addTextKey("<--", (event) -> {
        if (event instanceof ChangeEvent) {
            if (!searchField.getText().isBlank()) {
                searchField.setText(searchField.getText().substring(0, searchField.getText().length() - 1));
            }
        }
        return false;
    }, searchModel, 10, 0, true, tfw / 1.5f, pad10, 0);
    // Second row
    searchT.add().padRight(pad5).padBottom(pad10);
    addTextKey("A", searchModel, 1, 1, false);
    addTextKey("S", searchModel, 2, 1, false);
    addTextKey("D", searchModel, 3, 1, false);
    addTextKey("F", searchModel, 4, 1, false);
    addTextKey("G", searchModel, 5, 1, false);
    addTextKey("H", searchModel, 6, 1, false);
    addTextKey("J", searchModel, 7, 1, false);
    addTextKey("K", searchModel, 8, 1, false);
    addTextKey("L", searchModel, 9, 1, false);
    addTextKey("Clear", (event) -> {
        if (event instanceof ChangeEvent) {
            if (!searchField.getText().isBlank()) {
                searchField.setText("");
            }
        }
        return false;
    }, searchModel, 10, 1, true, tfw / 1.5f, pad10, 0);
    // Third row
    searchT.add().padRight(pad5).padBottom(pad10);
    searchT.add().padRight(pad5).padBottom(pad10);
    addTextKey("Z", searchModel, 2, 2, false);
    addTextKey("X", searchModel, 3, 2, false);
    addTextKey("C", searchModel, 4, 2, false);
    addTextKey("V", searchModel, 5, 2, false);
    addTextKey("B", searchModel, 6, 2, false);
    addTextKey("N", searchModel, 7, 2, false);
    addTextKey("M", searchModel, 8, 2, false);
    addTextKey("-", searchModel, 9, 2, true);
    // Fourth row
    searchT.add().padRight(pad5).padBottom(pad10);
    searchT.add().padRight(pad5).padBottom(pad10);
    searchT.add().padRight(pad5).padBottom(pad10);
    addTextKey("SPACE", (event) -> {
        if (event instanceof ChangeEvent) {
            searchField.setText(searchField.getText() + " ");
        }
        return false;
    }, searchModel, 5, 3, false, tfw * 2f, pad5, 6);
    tabContents.add(container(searchT, w, h));
    updatePads(searchT);
    // CAMERA
    Actor[][] cameraModel = new Actor[2][4];
    model.add(cameraModel);
    camT = new Table(skin);
    camT.setSize(w, h);
    CameraManager cm = GaiaSky.instance.getCameraManager();
    // Focus
    cameraFocus = new OwnTextButton(CameraMode.FOCUS_MODE.toStringI18n(), skin, "toggle-big");
    cameraModel[0][0] = cameraFocus;
    cameraFocus.setWidth(ww);
    cameraFocus.setChecked(cm.getMode().isFocus());
    cameraFocus.addListener(event -> {
        if (event instanceof ChangeEvent) {
            if (cameraFocus.isChecked()) {
                em.post(Event.CAMERA_MODE_CMD, cameraFocus, CameraMode.FOCUS_MODE);
                cameraFree.setProgrammaticChangeEvents(false);
                cameraFree.setChecked(false);
                cameraFree.setProgrammaticChangeEvents(true);
            }
            return true;
        }
        return false;
    });
    // Free
    cameraFree = new OwnTextButton(CameraMode.FREE_MODE.toStringI18n(), skin, "toggle-big");
    cameraModel[0][1] = cameraFree;
    cameraFree.setWidth(ww);
    cameraFree.setChecked(cm.getMode().isFree());
    cameraFree.addListener(event -> {
        if (event instanceof ChangeEvent) {
            if (cameraFree.isChecked()) {
                em.post(Event.CAMERA_MODE_CMD, cameraFree, CameraMode.FREE_MODE);
                cameraFocus.setProgrammaticChangeEvents(false);
                cameraFocus.setChecked(false);
                cameraFocus.setProgrammaticChangeEvents(true);
            }
            return true;
        }
        return false;
    });
    // Cinematic
    cameraCinematic = new OwnTextButton(I18n.txt("gui.camera.cinematic"), skin, "toggle-big");
    cameraModel[0][2] = cameraCinematic;
    cameraCinematic.setWidth(ww);
    cameraCinematic.setChecked(Settings.settings.scene.camera.cinematic);
    cameraCinematic.addListener(event -> {
        if (event instanceof ChangeEvent) {
            em.post(Event.CAMERA_CINEMATIC_CMD, cameraCinematic, cameraCinematic.isChecked());
            return true;
        }
        return false;
    });
    // FOV
    fovSlider = new OwnSliderPlus(I18n.txt("gui.camera.fov"), Constants.MIN_FOV, Constants.MAX_FOV, Constants.SLIDER_STEP_SMALL, false, skin);
    cameraModel[1][0] = fovSlider;
    fovSlider.setValueSuffix("°");
    fovSlider.setName("field of view");
    fovSlider.setWidth(sw);
    fovSlider.setHeight(sh);
    fovSlider.setValue(Settings.settings.scene.camera.fov);
    fovSlider.setDisabled(Settings.settings.program.modeCubemap.isFixedFov());
    fovSlider.addListener(event -> {
        if (event instanceof ChangeEvent && !SlaveManager.projectionActive() && !Settings.settings.program.modeCubemap.isFixedFov()) {
            float value = fovSlider.getMappedValue();
            EventManager.publish(Event.FOV_CHANGED_CMD, fovSlider, value);
            return true;
        }
        return false;
    });
    // Speed
    camSpeedSlider = new OwnSliderPlus(I18n.txt("gui.camera.speed"), Constants.MIN_SLIDER, Constants.MAX_SLIDER, Constants.SLIDER_STEP, Constants.MIN_CAM_SPEED, Constants.MAX_CAM_SPEED, skin);
    cameraModel[1][1] = camSpeedSlider;
    camSpeedSlider.setName("camera speed");
    camSpeedSlider.setWidth(sw);
    camSpeedSlider.setHeight(sh);
    camSpeedSlider.setMappedValue(Settings.settings.scene.camera.speed);
    camSpeedSlider.addListener(event -> {
        if (event instanceof ChangeEvent) {
            EventManager.publish(Event.CAMERA_SPEED_CMD, camSpeedSlider, camSpeedSlider.getMappedValue(), false);
            return true;
        }
        return false;
    });
    // Rot
    camRotSlider = new OwnSliderPlus(I18n.txt("gui.rotation.speed"), Constants.MIN_SLIDER, Constants.MAX_SLIDER, Constants.SLIDER_STEP, Constants.MIN_ROT_SPEED, Constants.MAX_ROT_SPEED, skin);
    cameraModel[1][2] = camRotSlider;
    camRotSlider.setName("rotate speed");
    camRotSlider.setWidth(sw);
    camRotSlider.setHeight(sh);
    camRotSlider.setMappedValue(Settings.settings.scene.camera.rotate);
    camRotSlider.addListener(event -> {
        if (event instanceof ChangeEvent) {
            EventManager.publish(Event.ROTATION_SPEED_CMD, camRotSlider, camRotSlider.getMappedValue());
            return true;
        }
        return false;
    });
    // Turn
    camTurnSlider = new OwnSliderPlus(I18n.txt("gui.turn.speed"), Constants.MIN_SLIDER, Constants.MAX_SLIDER, Constants.SLIDER_STEP, Constants.MIN_TURN_SPEED, Constants.MAX_TURN_SPEED, skin);
    cameraModel[1][3] = camTurnSlider;
    camTurnSlider.setName("turn speed");
    camTurnSlider.setWidth(sw);
    camTurnSlider.setHeight(sh);
    camTurnSlider.setMappedValue(Settings.settings.scene.camera.turn);
    camTurnSlider.addListener(event -> {
        if (event instanceof ChangeEvent) {
            EventManager.publish(Event.TURNING_SPEED_CMD, camTurnSlider, camTurnSlider.getMappedValue(), false);
            return true;
        }
        return false;
    });
    camT.add(cameraFocus).padBottom(pad10).padRight(pad30);
    camT.add(fovSlider).padBottom(pad10).row();
    camT.add(cameraFree).padBottom(pad10).padRight(pad30);
    camT.add(camSpeedSlider).padBottom(pad10).row();
    camT.add(cameraCinematic).padBottom(pad10).padRight(pad30);
    camT.add(camRotSlider).padBottom(pad10).row();
    camT.add().padBottom(pad10).padRight(pad30);
    camT.add(camTurnSlider).padBottom(pad10).row();
    tabContents.add(container(camT, w, h));
    updatePads(camT);
    // TIME
    Actor[][] timeModel = new Actor[3][2];
    model.add(timeModel);
    timeT = new Table(skin);
    boolean timeOn = Settings.settings.runtime.timeOn;
    timeStartStop = new OwnTextButton(I18n.txt(timeOn ? "gui.time.pause" : "gui.time.start"), skin, "toggle-big");
    timeModel[1][0] = timeStartStop;
    timeStartStop.setWidth(ww);
    timeStartStop.setChecked(timeOn);
    timeStartStop.addListener(event -> {
        if (event instanceof ChangeEvent) {
            em.post(Event.TIME_STATE_CMD, timeStartStop, timeStartStop.isChecked());
            timeStartStop.setText(I18n.txt(timeStartStop.isChecked() ? "gui.time.pause" : "gui.time.start"));
            return true;
        }
        return false;
    });
    timeUp = new OwnTextIconButton(I18n.txt("gui.time.speedup"), Align.right, skin, "fwd");
    timeModel[2][0] = timeUp;
    timeUp.setWidth(ww);
    timeUp.addListener(event -> {
        if (event instanceof ChangeEvent) {
            em.post(Event.TIME_WARP_INCREASE_CMD, timeUp);
            return true;
        }
        return false;
    });
    timeDown = new OwnTextIconButton(I18n.txt("gui.time.slowdown"), skin, "bwd");
    timeModel[0][0] = timeDown;
    timeDown.setWidth(ww);
    timeDown.addListener(event -> {
        if (event instanceof ChangeEvent) {
            em.post(Event.TIME_WARP_DECREASE_CMD, timeDown);
            return true;
        }
        return false;
    });
    timeReset = new OwnTextIconButton(I18n.txt("action.resettime"), Align.center, skin, "reload");
    timeModel[1][1] = timeReset;
    timeReset.setWidth(ww);
    timeReset.addListener(event -> {
        if (event instanceof ChangeEvent) {
            em.post(Event.TIME_CHANGE_CMD, timeReset, Instant.now());
            return true;
        }
        return false;
    });
    timeT.add(timeDown).padBottom(pad30).padRight(pad10);
    timeT.add(timeStartStop).padBottom(pad30).padRight(pad10);
    timeT.add(timeUp).padBottom(pad30).row();
    timeT.add(timeReset).padRight(pad10).padLeft(pad10).colspan(3).padBottom(pad10).row();
    tabContents.add(container(timeT, w, h));
    updatePads(timeT);
    // TYPES
    int visTableCols = 6;
    Actor[][] typesModel = new Actor[visTableCols][7];
    model.add(typesModel);
    typesT = new Table(skin);
    float buttonPadHor = 9.6f;
    float buttonPadVert = 4f;
    Set<Button> buttons = new HashSet<>();
    ComponentType[] visibilityEntities = ComponentType.values();
    boolean[] visible = new boolean[visibilityEntities.length];
    for (int i = 0; i < visibilityEntities.length; i++) visible[i] = GaiaSky.instance.sgr.visible.get(visibilityEntities[i].ordinal());
    if (visibilityEntities != null) {
        int di = 0, dj = 0;
        for (int i = 0; i < visibilityEntities.length; i++) {
            final ComponentType ct = visibilityEntities[i];
            final String name = ct.getName();
            if (name != null) {
                Button button;
                if (ct.style != null) {
                    Image icon = new Image(skin.getDrawable(ct.style));
                    button = new OwnTextIconButton("", icon, skin, "toggle");
                } else {
                    button = new OwnTextButton(name, skin, "toggle");
                }
                // Name is the key
                button.setName(ct.key);
                typesModel[di][dj] = button;
                button.setChecked(visible[i]);
                button.addListener(event -> {
                    if (event instanceof ChangeEvent) {
                        EventManager.publish(Event.TOGGLE_VISIBILITY_CMD, button, ct.key, button.isChecked());
                        return true;
                    }
                    return false;
                });
                Cell c = typesT.add(button).padBottom(buttonPadVert).left();
                if ((i + 1) % visTableCols == 0) {
                    typesT.row();
                    di = 0;
                    dj++;
                } else {
                    c.padRight(buttonPadHor);
                    di++;
                }
                buttons.add(button);
            }
        }
    }
    typesT.setSize(w, h);
    tabContents.add(container(typesT, w, h));
    updatePads(typesT);
    // OPTIONS
    Actor[][] optionsModel = new Actor[1][4];
    model.add(optionsModel);
    optT = new Table(skin);
    // Slider
    bloomSlider = new OwnSliderPlus(I18n.txt("gui.bloom"), Constants.MIN_SLIDER, Constants.MAX_SLIDER * 0.2f, 1f, false, skin, "ui-19");
    bloomSlider.setWidth(sw);
    bloomSlider.setHeight(sh);
    bloomSlider.setValue(Settings.settings.postprocess.bloom.intensity * 10f);
    bloomSlider.addListener(event -> {
        if (event instanceof ChangeEvent) {
            EventManager.publish(Event.BLOOM_CMD, bloomSlider, bloomSlider.getValue() / 10f);
            return true;
        }
        return false;
    });
    optionsModel[0][0] = bloomSlider;
    optT.add(bloomSlider).padBottom(pad10).row();
    // Lens flare
    flareButton = new OwnTextButton(I18n.txt("gui.lensflare"), skin, "toggle-big");
    optionsModel[0][1] = flareButton;
    flareButton.setWidth(ww);
    flareButton.setChecked(Settings.settings.postprocess.lensFlare);
    flareButton.addListener(event -> {
        if (event instanceof ChangeEvent) {
            EventManager.publish(Event.LENS_FLARE_CMD, flareButton, flareButton.isChecked());
            return true;
        }
        return false;
    });
    optT.add(flareButton).padBottom(pad10).row();
    // Star glow
    starGlowButton = new OwnTextButton(I18n.txt("gui.lightscattering"), skin, "toggle-big");
    optionsModel[0][2] = starGlowButton;
    starGlowButton.setWidth(ww);
    starGlowButton.setChecked(Settings.settings.postprocess.lightGlow);
    starGlowButton.addListener(event -> {
        if (event instanceof ChangeEvent) {
            EventManager.publish(Event.LIGHT_SCATTERING_CMD, starGlowButton, starGlowButton.isChecked());
            return true;
        }
        return false;
    });
    optT.add(starGlowButton).padBottom(pad10).row();
    // Motion blur
    motionBlurButton = new OwnTextButton(I18n.txt("gui.motionblur"), skin, "toggle-big");
    optionsModel[0][3] = motionBlurButton;
    motionBlurButton.setWidth(ww);
    motionBlurButton.setChecked(Settings.settings.postprocess.motionBlur);
    motionBlurButton.addListener(event -> {
        if (event instanceof ChangeEvent) {
            EventManager.publish(Event.MOTION_BLUR_CMD, motionBlurButton, motionBlurButton.isChecked());
            return true;
        }
        return false;
    });
    optT.add(motionBlurButton);
    tabContents.add(container(optT, w, h));
    updatePads(optT);
    // SYSTEM
    Actor[][] systemModel = new Actor[1][1];
    model.add(systemModel);
    sysT = new Table(skin);
    quit = new OwnTextIconButton(I18n.txt("gui.quit.title"), Align.center, skin, "quit");
    systemModel[0][0] = quit;
    quit.setWidth(ww);
    quit.addListener(event -> {
        if (event instanceof ChangeEvent) {
            GaiaSky.postRunnable(() -> Gdx.app.exit());
            return true;
        }
        return false;
    });
    sysT.add(quit);
    tabContents.add(container(sysT, w, h));
    updatePads(sysT);
    // Create tab buttons
    searchButton = new OwnTextButton(I18n.txt("gui.search"), skin, "toggle-big");
    tabButtons.add(searchButton);
    searchButton.addListener((event) -> {
        if (event instanceof ChangeEvent) {
            selectedTab = tabButtons.indexOf(searchButton);
            updateTabs();
        }
        return false;
    });
    cameraButton = new OwnTextButton(I18n.txt("gui.camera"), skin, "toggle-big");
    tabButtons.add(cameraButton);
    cameraButton.addListener((event) -> {
        if (event instanceof ChangeEvent) {
            selectedTab = tabButtons.indexOf(cameraButton);
            updateTabs();
        }
        return false;
    });
    timeButton = new OwnTextButton(I18n.txt("gui.time"), skin, "toggle-big");
    tabButtons.add(timeButton);
    timeButton.addListener((event) -> {
        if (event instanceof ChangeEvent) {
            selectedTab = tabButtons.indexOf(timeButton);
            updateTabs();
        }
        return false;
    });
    typesButton = new OwnTextButton(I18n.txt("gui.types"), skin, "toggle-big");
    tabButtons.add(typesButton);
    typesButton.addListener((event) -> {
        if (event instanceof ChangeEvent) {
            selectedTab = tabButtons.indexOf(typesButton);
            updateTabs();
        }
        return false;
    });
    optionsButton = new OwnTextButton(I18n.txt("gui.options"), skin, "toggle-big");
    tabButtons.add(optionsButton);
    optionsButton.addListener((event) -> {
        if (event instanceof ChangeEvent) {
            selectedTab = tabButtons.indexOf(optionsButton);
            updateTabs();
        }
        return false;
    });
    systemButton = new OwnTextButton(I18n.txt("gui.system"), skin, "toggle-big");
    tabButtons.add(systemButton);
    systemButton.addListener((event) -> {
        if (event instanceof ChangeEvent) {
            selectedTab = tabButtons.indexOf(systemButton);
            updateTabs();
        }
        return false;
    });
    for (OwnTextButton b : tabButtons) {
        b.pad(pad10);
        b.setMinWidth(tw);
    }
    // Left and Right indicators
    OwnTextButton lb, rb;
    rb = new OwnTextIconButton("RB", Align.right, skin, "caret-right");
    rb.addListener((event) -> {
        if (event instanceof ChangeEvent) {
            tabRight();
        }
        return false;
    });
    rb.pad(pad10);
    lb = new OwnTextIconButton("LB", Align.left, skin, "caret-left");
    lb.addListener((event) -> {
        if (event instanceof ChangeEvent) {
            tabLeft();
        }
        return false;
    });
    lb.pad(pad10);
    menu.add(lb).center().padBottom(pad10).padRight(pad30);
    menu.add(searchButton).center().padBottom(pad10);
    menu.add(cameraButton).center().padBottom(pad10);
    menu.add(timeButton).center().padBottom(pad10);
    menu.add(typesButton).center().padBottom(pad10);
    menu.add(optionsButton).center().padBottom(pad10);
    menu.add(systemButton).center().padBottom(pad10);
    menu.add(rb).center().padBottom(pad10).padLeft(pad30).row();
    contentCell = menu.add().colspan(7);
    Table padTable = new Table(skin);
    padTable.pad(pad30);
    padTable.setBackground("table-border");
    menu.pack();
    padTable.add(menu).center();
    content.add(padTable);
    content.setFillParent(true);
    content.center();
    content.pack();
    updateTabs();
    updateFocused(true);
    if (sg == null)
        sg = GaiaSky.instance.sceneGraph;
}
Also used : ComponentType(gaiasky.render.ComponentTypes.ComponentType) CameraManager(gaiasky.scenegraph.camera.CameraManager) ChangeEvent(com.badlogic.gdx.scenes.scene2d.utils.ChangeListener.ChangeEvent) Actor(com.badlogic.gdx.scenes.scene2d.Actor) HashSet(java.util.HashSet)

Example 3 with CameraManager

use of gaiasky.scenegraph.camera.CameraManager in project gaiasky by langurmonkey.

the class GaiaSky method create.

@Override
public void create() {
    startTime = TimeUtils.millis();
    // Log level
    Gdx.app.setLogLevel(debugMode ? Application.LOG_DEBUG : Application.LOG_INFO);
    Logger.level = debugMode ? Logger.LoggerLevel.DEBUG : Logger.LoggerLevel.INFO;
    consoleLogger = new ConsoleLogger();
    if (debugMode)
        logger.debug("Logging level set to DEBUG");
    // Init graphics and window
    graphics = Gdx.graphics;
    window = headless ? null : ((Lwjgl3Graphics) graphics).getWindow();
    // Basic info
    logger.info(settings.version.version, I18n.txt("gui.build", settings.version.build));
    logger.info("Display mode", graphics.getWidth() + "x" + graphics.getHeight(), "Fullscreen: " + Gdx.graphics.isFullscreen());
    logger.info("Device", GL30.glGetString(GL30.GL_RENDERER));
    logger.info(I18n.txt("notif.glversion", GL30.glGetString(GL30.GL_VERSION)));
    logger.info(I18n.txt("notif.glslversion", GL30.glGetString(GL30.GL_SHADING_LANGUAGE_VERSION)));
    logger.info(I18n.txt("notif.javaversion", System.getProperty("java.version"), System.getProperty("java.vendor")));
    // Frame buffer map
    frameBufferMap = new HashMap<>();
    // Disable all kinds of input
    EventManager.publish(Event.INPUT_ENABLED_CMD, this, false);
    if (!settings.initialized) {
        logger.error(new RuntimeException(I18n.txt("notif.error", "global configuration not initialized")));
        return;
    }
    // Initialise times
    final ITimeFrameProvider clock = new GlobalClock(1, Instant.now());
    final ITimeFrameProvider real = new RealTimeClock();
    time = settings.runtime.realTime ? real : clock;
    t = 0;
    // Initialise i18n
    I18n.initialize();
    // Tooltips
    TooltipManager.getInstance().initialTime = 1f;
    TooltipManager.getInstance().hideAll();
    // Initialise asset manager
    final FileHandleResolver internalResolver = new InternalFileHandleResolver();
    final FileHandleResolver dataResolver = fileName -> settings.data.dataFileHandle(fileName);
    assetManager = new AssetManager(internalResolver);
    assetManager.setLoader(com.badlogic.gdx.graphics.Texture.class, ".pfm", new PFMTextureLoader(dataResolver));
    assetManager.setLoader(PFMData.class, new PFMDataLoader(dataResolver));
    assetManager.setLoader(ISceneGraph.class, new SGLoader(dataResolver));
    assetManager.setLoader(PointCloudData.class, new OrbitDataLoader(dataResolver));
    assetManager.setLoader(GaiaAttitudeServer.class, new GaiaAttitudeLoader(dataResolver));
    assetManager.setLoader(ExtShaderProgram.class, new ShaderProgramProvider(internalResolver, ".vertex.glsl", ".fragment.glsl"));
    assetManager.setLoader(BitmapFont.class, new BitmapFontLoader(internalResolver));
    assetManager.setLoader(AtmosphereShaderProvider.class, new AtmosphereShaderProviderLoader<>(internalResolver));
    assetManager.setLoader(GroundShaderProvider.class, new GroundShaderProviderLoader<>(internalResolver));
    assetManager.setLoader(TessellationShaderProvider.class, new TessellationShaderProviderLoader<>(internalResolver));
    assetManager.setLoader(RelativisticShaderProvider.class, new RelativisticShaderProviderLoader<>(internalResolver));
    assetManager.setLoader(IntModel.class, ".obj", new OwnObjLoader(new RegularInputStreamProvider(), internalResolver));
    assetManager.setLoader(IntModel.class, ".obj.gz", new OwnObjLoader(new GzipInputStreamProvider(), internalResolver));
    assetManager.setLoader(IntModel.class, ".g3dj", new G3dModelLoader(new JsonReader(), internalResolver));
    assetManager.setLoader(IntModel.class, ".g3db", new G3dModelLoader(new UBJsonReader(), internalResolver));
    // Remove Model loaders
    // Init global resources
    this.globalResources = new GlobalResources(assetManager);
    // Initialize screenshots manager
    new ScreenshotsManager(globalResources);
    // Catalog manager
    this.catalogManager = new CatalogManager();
    this.scripting = new EventScriptingInterface(this.assetManager, this.catalogManager);
    // Initialise master manager
    MasterManager.initialize();
    // Load slave assets
    SlaveManager.load(assetManager);
    // Initialise dataset updater
    this.executorService = new GaiaSkyExecutorService();
    // Bookmarks
    this.bookmarksManager = new BookmarksManager();
    // Location log
    LocationLogManager.initialize();
    // Init timer thread
    Timer.instance();
    // Initialise Cameras
    cameraManager = new CameraManager(assetManager, CameraMode.FOCUS_MODE, vr, globalResources);
    // Set asset manager to asset bean
    AssetBean.setAssetManager(assetManager);
    // Create vr context if possible
    final VRStatus vrStatus = createVR();
    cameraManager.updateFrustumPlanes();
    // Tooltip to 1s
    TooltipManager.getInstance().initialTime = 1f;
    // Initialise Gaia attitudes
    assetManager.load(Constants.ATTITUDE_FOLDER, GaiaAttitudeServer.class, new GaiaAttitudeLoaderParameter());
    // Initialise hidden helper user
    HiddenHelperUser.initialize();
    // Initialise gravitational waves helper
    RelativisticEffectsManager.initialize(time);
    // GUI
    guis = new ArrayList<>(3);
    // Post-processor
    postProcessor = PostProcessorFactory.instance.getPostProcessor();
    // Scene graph renderer
    sgr = new SceneGraphRenderer(vrContext, globalResources);
    sgr.initialize(assetManager);
    // Initialise scripting gateway server
    if (!noScripting)
        ScriptingServer.initialize();
    // Tell the asset manager to load all the assets
    final Set<AssetBean> assets = AssetBean.getAssets();
    for (AssetBean ab : assets) {
        ab.load(assetManager);
    }
    renderBatch = globalResources.getSpriteBatch();
    EventManager.instance.subscribe(this, Event.LOAD_DATA_CMD);
    welcomeGui = new WelcomeGui(globalResources.getSkin(), graphics, 1f / settings.program.ui.scale, skipWelcome, vrStatus);
    welcomeGui.initialize(assetManager, globalResources.getSpriteBatch());
    Gdx.input.setInputProcessor(welcomeGui.getGuiStage());
    if (settings.runtime.openVr) {
        welcomeGuiVR = new VRGui<>(WelcomeGuiVR.class, (int) (settings.graphics.backBufferResolution[0] / 2f), globalResources.getSkin(), graphics, 1f / settings.program.ui.scale);
        welcomeGuiVR.initialize(assetManager, globalResources.getSpriteBatch());
    }
    // GL clear state
    Gdx.gl.glClearColor(0, 0, 0, 0);
    Gdx.gl.glClearDepthf(1f);
}
Also used : ICamera(gaiasky.scenegraph.camera.ICamera) RegularInputStreamProvider(gaiasky.util.gdx.loader.is.RegularInputStreamProvider) SysUtils(gaiasky.desktop.util.SysUtils) Task(com.badlogic.gdx.utils.Timer.Task) TooltipManager(com.badlogic.gdx.scenes.scene2d.ui.TooltipManager) Logger(gaiasky.util.Logger) GL20(com.badlogic.gdx.graphics.GL20) PingPongBuffer(gaiasky.util.gdx.contrib.postprocess.utils.PingPongBuffer) IObserver(gaiasky.event.IObserver) RenderType(gaiasky.render.IPostProcessor.RenderType) VRCompositor(org.lwjgl.openvr.VRCompositor) gaiasky.util.gdx.loader(gaiasky.util.gdx.loader) RelativisticEffectsManager(gaiasky.util.gravwaves.RelativisticEffectsManager) gaiasky.interafce(gaiasky.interafce) GaiaSkyExecutorService(gaiasky.util.ds.GaiaSkyExecutorService) Path(java.nio.file.Path) EventScriptingInterface(gaiasky.script.EventScriptingInterface) InternalFileHandleResolver(com.badlogic.gdx.assets.loaders.resolvers.InternalFileHandleResolver) GzipInputStreamProvider(gaiasky.util.gdx.loader.is.GzipInputStreamProvider) PointCloudData(gaiasky.data.util.PointCloudData) AssetManager(com.badlogic.gdx.assets.AssetManager) SAMPClient(gaiasky.util.samp.SAMPClient) Event(gaiasky.event.Event) VRContext(gaiasky.vr.openvr.VRContext) com.badlogic.gdx(com.badlogic.gdx) Lwjgl3WindowConfiguration(com.badlogic.gdx.backends.lwjgl3.Lwjgl3WindowConfiguration) HiddenHelperUser(gaiasky.script.HiddenHelperUser) Instant(java.time.Instant) AssetBean(gaiasky.data.AssetBean) IScriptingInterface(gaiasky.script.IScriptingInterface) Texture(org.lwjgl.openvr.Texture) StreamingOctreeLoader(gaiasky.data.StreamingOctreeLoader) CameraManager(gaiasky.scenegraph.camera.CameraManager) gaiasky.assets(gaiasky.assets) OctreeNode(gaiasky.util.tree.OctreeNode) EventManager(gaiasky.event.EventManager) CrashReporter(gaiasky.desktop.util.CrashReporter) CameraMode(gaiasky.scenegraph.camera.CameraManager.CameraMode) java.util(java.util) Attribute(gaiasky.util.gdx.shader.attribute.Attribute) GaiaAttitudeServer(gaiasky.util.gaia.GaiaAttitudeServer) GL30(org.lwjgl.opengl.GL30) PostProcessBean(gaiasky.render.IPostProcessor.PostProcessBean) ScreenshotsManager(gaiasky.screenshot.ScreenshotsManager) AtomicBoolean(java.util.concurrent.atomic.AtomicBoolean) FileHandleResolver(com.badlogic.gdx.assets.loaders.FileHandleResolver) Lwjgl3Window(com.badlogic.gdx.backends.lwjgl3.Lwjgl3Window) RealTimeClock(gaiasky.util.time.RealTimeClock) gaiasky.scenegraph(gaiasky.scenegraph) ScriptingServer(gaiasky.script.ScriptingServer) com.badlogic.gdx.utils(com.badlogic.gdx.utils) VRDevice(gaiasky.vr.openvr.VRContext.VRDevice) Format(com.badlogic.gdx.graphics.Pixmap.Format) ModelComponent(gaiasky.scenegraph.component.ModelComponent) GlobalClock(gaiasky.util.time.GlobalClock) FrameBuffer(com.badlogic.gdx.graphics.glutils.FrameBuffer) gaiasky.render(gaiasky.render) Lwjgl3Application(com.badlogic.gdx.backends.lwjgl3.Lwjgl3Application) SpriteBatch(com.badlogic.gdx.graphics.g2d.SpriteBatch) VRDeviceType(gaiasky.vr.openvr.VRContext.VRDeviceType) Timer(com.badlogic.gdx.utils.Timer) ComponentType(gaiasky.render.ComponentTypes.ComponentType) BitmapFont(gaiasky.util.gdx.g2d.BitmapFont) GaiaAttitudeLoaderParameter(gaiasky.assets.GaiaAttitudeLoader.GaiaAttitudeLoaderParameter) Lwjgl3Graphics(com.badlogic.gdx.backends.lwjgl3.Lwjgl3Graphics) gaiasky.util(gaiasky.util) IntModel(gaiasky.util.gdx.model.IntModel) SGLoaderParameter(gaiasky.assets.SGLoader.SGLoaderParameter) ITimeFrameProvider(gaiasky.util.time.ITimeFrameProvider) File(java.io.File) VR(org.lwjgl.openvr.VR) VRStatus(gaiasky.vr.openvr.VRStatus) Log(gaiasky.util.Logger.Log) gaiasky.util.gdx.shader(gaiasky.util.gdx.shader) GaiaSkyExecutorService(gaiasky.util.ds.GaiaSkyExecutorService) GaiaAttitudeLoaderParameter(gaiasky.assets.GaiaAttitudeLoader.GaiaAttitudeLoaderParameter) ScreenshotsManager(gaiasky.screenshot.ScreenshotsManager) Lwjgl3Graphics(com.badlogic.gdx.backends.lwjgl3.Lwjgl3Graphics) InternalFileHandleResolver(com.badlogic.gdx.assets.loaders.resolvers.InternalFileHandleResolver) FileHandleResolver(com.badlogic.gdx.assets.loaders.FileHandleResolver) VRStatus(gaiasky.vr.openvr.VRStatus) ITimeFrameProvider(gaiasky.util.time.ITimeFrameProvider) EventScriptingInterface(gaiasky.script.EventScriptingInterface) AssetManager(com.badlogic.gdx.assets.AssetManager) RealTimeClock(gaiasky.util.time.RealTimeClock) GzipInputStreamProvider(gaiasky.util.gdx.loader.is.GzipInputStreamProvider) CameraManager(gaiasky.scenegraph.camera.CameraManager) AssetBean(gaiasky.data.AssetBean) InternalFileHandleResolver(com.badlogic.gdx.assets.loaders.resolvers.InternalFileHandleResolver) GlobalClock(gaiasky.util.time.GlobalClock) RegularInputStreamProvider(gaiasky.util.gdx.loader.is.RegularInputStreamProvider)

Example 4 with CameraManager

use of gaiasky.scenegraph.camera.CameraManager in project gaiasky by langurmonkey.

the class StarGroup method dispose.

@Override
public void dispose() {
    this.disposed = true;
    GaiaSky.instance.sceneGraph.remove(this, true);
    // Unsubscribe from all events
    EventManager.instance.removeAllSubscriptions(this);
    // Data to be gc'd
    this.pointData = null;
    // Remove focus if needed
    CameraManager cam = GaiaSky.instance.getCameraManager();
    if (cam != null && cam.getFocus() != null && cam.getFocus() == this) {
        this.setFocusIndex(-1);
        EventManager.publish(Event.CAMERA_MODE_CMD, this, CameraMode.FREE_MODE);
    }
}
Also used : CameraManager(gaiasky.scenegraph.camera.CameraManager)

Example 5 with CameraManager

use of gaiasky.scenegraph.camera.CameraManager in project gaiasky by langurmonkey.

the class ParticleGroup method dispose.

@Override
public void dispose() {
    this.disposed = true;
    GaiaSky.instance.sceneGraph.remove(this, true);
    // Unsubscribe from all events
    EventManager.instance.removeAllSubscriptions(this);
    // Data to be gc'd
    this.pointData = null;
    // Remove focus if needed
    CameraManager cam = GaiaSky.instance.getCameraManager();
    if (cam != null && cam.getFocus() != null && cam.getFocus() == this) {
        this.setFocusIndex(-1);
        EventManager.publish(Event.CAMERA_MODE_CMD, this, CameraMode.FREE_MODE);
    }
}
Also used : CameraManager(gaiasky.scenegraph.camera.CameraManager)

Aggregations

CameraManager (gaiasky.scenegraph.camera.CameraManager)5 ComponentType (gaiasky.render.ComponentTypes.ComponentType)2 com.badlogic.gdx (com.badlogic.gdx)1 AssetManager (com.badlogic.gdx.assets.AssetManager)1 FileHandleResolver (com.badlogic.gdx.assets.loaders.FileHandleResolver)1 InternalFileHandleResolver (com.badlogic.gdx.assets.loaders.resolvers.InternalFileHandleResolver)1 Lwjgl3Application (com.badlogic.gdx.backends.lwjgl3.Lwjgl3Application)1 Lwjgl3Graphics (com.badlogic.gdx.backends.lwjgl3.Lwjgl3Graphics)1 Lwjgl3Window (com.badlogic.gdx.backends.lwjgl3.Lwjgl3Window)1 Lwjgl3WindowConfiguration (com.badlogic.gdx.backends.lwjgl3.Lwjgl3WindowConfiguration)1 GL20 (com.badlogic.gdx.graphics.GL20)1 Format (com.badlogic.gdx.graphics.Pixmap.Format)1 SpriteBatch (com.badlogic.gdx.graphics.g2d.SpriteBatch)1 FrameBuffer (com.badlogic.gdx.graphics.glutils.FrameBuffer)1 Actor (com.badlogic.gdx.scenes.scene2d.Actor)1 TooltipManager (com.badlogic.gdx.scenes.scene2d.ui.TooltipManager)1 ChangeEvent (com.badlogic.gdx.scenes.scene2d.utils.ChangeListener.ChangeEvent)1 com.badlogic.gdx.utils (com.badlogic.gdx.utils)1 Timer (com.badlogic.gdx.utils.Timer)1 Task (com.badlogic.gdx.utils.Timer.Task)1