Search in sources :

Example 1 with PointCloudData

use of gaiasky.data.util.PointCloudData in project gaiasky by langurmonkey.

the class KeyframesPathObject method refreshSingleVector.

public void refreshSingleVector(VertsObject vo, Vector3d pos, Vector3d vec) {
    PointCloudData p = vo.pointCloudData;
    p.x.set(0, pos.x);
    p.y.set(0, pos.y);
    p.z.set(0, pos.z);
    p.x.set(1, pos.x + vec.x);
    p.y.set(1, pos.y + vec.y);
    p.z.set(1, pos.z + vec.z);
    vo.markForUpdate();
}
Also used : PointCloudData(gaiasky.data.util.PointCloudData)

Example 2 with PointCloudData

use of gaiasky.data.util.PointCloudData in project gaiasky by langurmonkey.

the class NotificationsInterface method notify.

@Override
public void notify(final Event event, Object source, final Object... data) {
    synchronized (lock) {
        switch(event) {
            case POST_NOTIFICATION:
                LoggerLevel level = (LoggerLevel) data[0];
                Object[] dat = (Object[]) data[1];
                String message = "";
                boolean perm = false;
                for (int i = 0; i < dat.length; i++) {
                    if (i == dat.length - 1 && dat[i] instanceof Boolean) {
                        perm = (Boolean) dat[i];
                    } else {
                        message += dat[i].toString();
                        if (i < dat.length - 1 && !(i == dat.length - 2 && dat[dat.length - 1] instanceof Boolean)) {
                            message += TAG_SEPARATOR;
                        }
                    }
                }
                addMessage(message, perm, level);
                break;
            case FOCUS_CHANGED:
                if (data[0] != null) {
                    IFocus sgn = null;
                    if (data[0] instanceof String) {
                        sgn = GaiaSky.instance.sceneGraph.findFocus((String) data[0]);
                    } else {
                        sgn = (IFocus) data[0];
                    }
                    addMessage(I18n.txt("notif.camerafocus", sgn.getName()));
                }
                break;
            case TIME_STATE_CMD:
                Boolean bool = (Boolean) data[0];
                if (bool == null) {
                    addMessage(I18n.txt("notif.toggle", I18n.txt("gui.time")));
                } else {
                    addMessage(I18n.txt("notif.simulation." + (bool ? "resume" : "pause")));
                }
                break;
            case TOGGLE_VISIBILITY_CMD:
                if (data.length == 2)
                    addMessage(I18n.txt("notif.visibility." + (((Boolean) data[1]) ? "on" : "off"), I18n.txt((String) data[0])));
                else
                    addMessage(I18n.txt("notif.visibility.toggle", I18n.txt((String) data[0])));
                break;
            case FOCUS_LOCK_CMD:
            case ORIENTATION_LOCK_CMD:
            case TOGGLE_AMBIENT_LIGHT:
            case OCTREE_PARTICLE_FADE_CMD:
                addMessage(data[0] + (((Boolean) data[1]) ? " on" : " off"));
                break;
            case CAMERA_MODE_CMD:
                CameraMode cm = (CameraMode) data[0];
                if (cm != CameraMode.FOCUS_MODE)
                    addMessage(I18n.txt("notif.cameramode.change", data[0]));
                break;
            case TIME_WARP_CHANGED_INFO:
                addMessage(I18n.txt("notif.timepace.change", data[0]));
                break;
            case FOV_CHANGE_NOTIFICATION:
                // addMessage("Field of view changed to " + (float) data[0]);
                break;
            case JAVA_EXCEPTION:
                Throwable t = (Throwable) data[0];
                StringWriter sw = new StringWriter();
                PrintWriter pw = new PrintWriter(sw);
                t.printStackTrace(pw);
                String stackTrace = sw.toString();
                if (data.length == 1) {
                    if (I18n.bundle != null)
                        addMessage(I18n.txt("notif.error", stackTrace));
                    else
                        addMessage("Error: " + stackTrace);
                } else {
                    if (I18n.bundle != null)
                        addMessage(I18n.txt("notif.error", data[1] + TAG_SEPARATOR + stackTrace));
                    else
                        addMessage("Error: " + data[1] + TAG_SEPARATOR + stackTrace);
                }
                break;
            case ORBIT_DATA_LOADED:
                addMessage(I18n.txt("notif.orbitdata.loaded", data[1], ((PointCloudData) data[0]).getNumPoints()), false, LoggerLevel.DEBUG);
                break;
            case SCREENSHOT_INFO:
                addMessage(I18n.txt("notif.screenshot", data[0]));
                break;
            case STEREOSCOPIC_CMD:
                addMessage(I18n.txt("notif.toggle", I18n.txt("notif.stereoscopic")));
                break;
            case DISPLAY_GUI_CMD:
                boolean displayGui = (Boolean) data[0];
                addMessage(I18n.txt("notif." + (!displayGui ? "activated" : "deactivated"), data[1]));
                break;
            case STEREO_PROFILE_CMD:
                addMessage(I18n.txt("notif.stereoscopic.profile", StereoProfile.values()[(Integer) data[0]].toString()));
                break;
            case FRAME_OUTPUT_CMD:
                boolean activated = (Boolean) data[0];
                if (activated) {
                    addMessage(I18n.txt("notif.activated", I18n.txt("element.frameoutput")));
                } else {
                    addMessage(I18n.txt("notif.deactivated", I18n.txt("element.frameoutput")));
                }
                break;
            case SCREEN_NOTIFICATION_CMD:
                String title = (String) data[0];
                String[] msgs = (String[]) data[1];
                float time = (Float) data[2];
                // Log to output
                addMessage(title);
                for (String msg : msgs) addMessage(msg);
                break;
            case MODE_POPUP_CMD:
                ModePopupInfo mpi = (ModePopupInfo) data[0];
                if (mpi != null) {
                    addMessage(mpi.title);
                    addMessage(mpi.header);
                    for (Pair<String[], String> p : mpi.mappings) {
                        String[] keys = p.getFirst();
                        String action = p.getSecond();
                        StringBuilder msg = new StringBuilder();
                        msg.append("<");
                        for (int i = 0; i < keys.length; i++) {
                            msg.append(keys[i].toUpperCase());
                            if (i < keys.length - 1) {
                                msg.append("+");
                            }
                        }
                        msg.append("> " + action);
                        addMessage(msg.toString());
                    }
                }
                break;
            default:
                break;
        }
    }
}
Also used : PointCloudData(gaiasky.data.util.PointCloudData) StringBuilder(com.badlogic.gdx.utils.StringBuilder) CameraMode(gaiasky.scenegraph.camera.CameraManager.CameraMode) LoggerLevel(gaiasky.util.Logger.LoggerLevel) IFocus(gaiasky.scenegraph.IFocus) StringWriter(java.io.StringWriter) PrintWriter(java.io.PrintWriter)

Example 3 with PointCloudData

use of gaiasky.data.util.PointCloudData in project gaiasky by langurmonkey.

the class FileDataLoaderEclipticJulianTime method load.

/**
 * Loads the data in the input stream into an OrbitData object.
 *
 * @param data
 *            The input stream
 * @return The orbit data
 */
public PointCloudData load(InputStream data) throws Exception {
    PointCloudData orbitData = new PointCloudData();
    BufferedReader br = new BufferedReader(new InputStreamReader(data));
    String line;
    Timestamp last = new Timestamp(0);
    while ((line = br.readLine()) != null) {
        if (!line.isEmpty() && !line.startsWith("#")) {
            // Read line
            String[] tokens = line.split("\\s+");
            if (tokens.length >= 4) {
                // Valid data line
                Timestamp t = new Timestamp(getTime(tokens[0]));
                Matrix4d transform = new Matrix4d();
                transform.scl(Constants.KM_TO_U);
                if (!t.equals(last)) {
                    orbitData.time.add(t.toInstant());
                    Vector3d pos = new Vector3d(parsed(tokens[1]), parsed(tokens[2]), parsed(tokens[3]));
                    pos.mul(transform);
                    orbitData.x.add(pos.y);
                    orbitData.y.add(pos.z);
                    orbitData.z.add(pos.x);
                    last.setTime(t.getTime());
                }
            }
        }
    }
    br.close();
    return orbitData;
}
Also used : Matrix4d(gaiasky.util.math.Matrix4d) PointCloudData(gaiasky.data.util.PointCloudData) InputStreamReader(java.io.InputStreamReader) Vector3d(gaiasky.util.math.Vector3d) BufferedReader(java.io.BufferedReader) Timestamp(java.sql.Timestamp)

Example 4 with PointCloudData

use of gaiasky.data.util.PointCloudData in project gaiasky by langurmonkey.

the class HeliotropicOrbitDataLoader method main.

public static void main(String[] args) {
    HeliotropicOrbitDataLoader l = new HeliotropicOrbitDataLoader();
    try {
        // Assets location
        String ASSETS_LOC = Settings.ASSETS_LOC;
        // Logger
        new ConsoleLogger();
        Gdx.files = new Lwjgl3Files();
        // Initialize number format
        NumberFormatFactory.initialize(new DesktopNumberFormatFactory());
        // Initialize date format
        DateFormatFactory.initialize(new DesktopDateFormatFactory());
        SettingsManager.initialize(new FileInputStream(ASSETS_LOC + "/conf/config.yaml"), new FileInputStream(ASSETS_LOC + "/dummyversion"));
        I18n.initialize(new FileHandle(ASSETS_LOC + "/i18n/gsbundle"));
        // Initialize math manager
        MathManager.initialize();
        String inputFile = System.getProperty("user.home") + "/Downloads/orbit.JWST.heliotropic.csv";
        String outputFile = System.getProperty("user.home") + "/Downloads/orbit.JWST.dat";
        PointCloudData od = l.load(new FileInputStream(inputFile));
        logger.info("Loaded and converted " + od.getNumPoints() + " orbit data points: " + inputFile);
        OrbitDataWriter.writeOrbitData(outputFile, od);
        logger.info("Results written successfully: " + outputFile);
    } catch (Exception e) {
        logger.error(e);
    }
}
Also used : Lwjgl3Files(com.badlogic.gdx.backends.lwjgl3.Lwjgl3Files) PointCloudData(gaiasky.data.util.PointCloudData) ConsoleLogger(gaiasky.interafce.ConsoleLogger) FileHandle(com.badlogic.gdx.files.FileHandle) DesktopNumberFormatFactory(gaiasky.desktop.format.DesktopNumberFormatFactory) DesktopDateFormatFactory(gaiasky.desktop.format.DesktopDateFormatFactory)

Example 5 with PointCloudData

use of gaiasky.data.util.PointCloudData in project gaiasky by langurmonkey.

the class OrbitalParametersProvider method load.

@Override
public void load(String file, OrbitDataLoaderParameter parameter, boolean newMethod) {
    if (newMethod) {
        OrbitComponent params = parameter.orbitalParamaters;
        Vector3d out = new Vector3d();
        try {
            // in days
            double period = params.period;
            // in days
            double epoch = params.epoch;
            data = new PointCloudData();
            data.period = period;
            // Step time in days, a full period over number of samples starting at epoch
            double t_step = period / (parameter.numSamples - 1.0);
            double t = 0.0;
            for (int n = 0; n < parameter.numSamples; n++) {
                params.loadDataPoint(out, t);
                if (n == parameter.numSamples - 1) {
                    // Close orbit
                    double sx = data.getX(0);
                    double sy = data.getY(0);
                    double sz = data.getZ(0);
                    data.x.add(sx);
                    data.y.add(sy);
                    data.z.add(sz);
                } else {
                    // Add point
                    data.x.add(out.x);
                    data.y.add(out.y);
                    data.z.add(out.z);
                }
                data.time.add(AstroUtils.julianDateToInstant(epoch + t));
                t += t_step;
            }
            EventManager.publish(Event.ORBIT_DATA_LOADED, this, data, parameter.name);
        } catch (Exception e) {
            Logger.getLogger(this.getClass()).error(e);
        }
    } else {
        loadOld(file, parameter);
    }
}
Also used : OrbitComponent(gaiasky.scenegraph.component.OrbitComponent) PointCloudData(gaiasky.data.util.PointCloudData) Vector3d(gaiasky.util.math.Vector3d)

Aggregations

PointCloudData (gaiasky.data.util.PointCloudData)13 Vector3d (gaiasky.util.math.Vector3d)7 Matrix4d (gaiasky.util.math.Matrix4d)3 IFocus (gaiasky.scenegraph.IFocus)2 CameraMode (gaiasky.scenegraph.camera.CameraManager.CameraMode)2 OrbitComponent (gaiasky.scenegraph.component.OrbitComponent)2 LoggerLevel (gaiasky.util.Logger.LoggerLevel)2 BufferedReader (java.io.BufferedReader)2 InputStreamReader (java.io.InputStreamReader)2 PrintWriter (java.io.PrintWriter)2 StringWriter (java.io.StringWriter)2 Timestamp (java.sql.Timestamp)2 Instant (java.time.Instant)2 Lwjgl3Files (com.badlogic.gdx.backends.lwjgl3.Lwjgl3Files)1 FileHandle (com.badlogic.gdx.files.FileHandle)1 StringBuilder (com.badlogic.gdx.utils.StringBuilder)1 DesktopDateFormatFactory (gaiasky.desktop.format.DesktopDateFormatFactory)1 DesktopNumberFormatFactory (gaiasky.desktop.format.DesktopNumberFormatFactory)1 ConsoleLogger (gaiasky.interafce.ConsoleLogger)1 Orbit (gaiasky.scenegraph.Orbit)1