Search in sources :

Example 11 with PointCloudData

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

the class KeyframesPathObject method update.

public void update(ITimeFrameProvider time, final Vector3b parentTransform, ICamera camera, float opacity) {
    for (VertsObject vo : objects) vo.update(time, parentTransform, camera, opacity);
    // Update length of orientations
    for (VertsObject vo : orientations) {
        Vector3d p0 = D31.get();
        Vector3d p1 = D32.get();
        PointCloudData p = vo.pointCloudData;
        p0.set(p.x.get(0), p.y.get(0), p.z.get(0));
        p1.set(p.x.get(1), p.y.get(1), p.z.get(1));
        Vector3d c = D33.get().set(camera.getPos());
        double len = Math.max(1e-9, Math.atan(0.03) * c.dst(p0));
        Vector3d v = c.set(p1).sub(p0).nor().scl(len);
        p.x.set(1, p0.x + v.x);
        p.y.set(1, p0.y + v.y);
        p.z.set(1, p0.z + v.z);
        vo.markForUpdate();
    }
    this.addToRenderLists(camera);
}
Also used : PointCloudData(gaiasky.data.util.PointCloudData) Vector3d(gaiasky.util.math.Vector3d)

Example 12 with PointCloudData

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

the class KeyframesPathObject method setPathKnots.

public void setPathKnots(double[] kts, double[] dirs, double[] ups, boolean[] seams) {
    // Points - distribute seams and no seams
    int nSeams = 0, nNoSeams = 0;
    for (boolean seam : seams) {
        if (seam)
            nSeams++;
        else
            nNoSeams++;
    }
    double[] ktsS = new double[nSeams * 3];
    double[] ktsN = new double[nNoSeams * 3];
    int ktsi = 0, ktsni = 0;
    for (int i = 0; i < seams.length; i++) {
        if (seams[i]) {
            ktsS[ktsi] = kts[i * 3];
            ktsS[ktsi + 1] = kts[i * 3 + 1];
            ktsS[ktsi + 2] = kts[i * 3 + 2];
            ktsi += 3;
        } else {
            ktsN[ktsni] = kts[i * 3];
            ktsN[ktsni + 1] = kts[i * 3 + 1];
            ktsN[ktsni + 2] = kts[i * 3 + 2];
            ktsni += 3;
        }
    }
    knots.setPoints(ktsN);
    knotsSeam.setPoints(ktsS);
    int n = kts.length;
    if (orientations.size == (dirs.length + ups.length) / 3) {
        // We can just update what we have
        int j = 0;
        for (int i = 0; i < orientations.size; i++) {
            double[] targ = (i % 2 == 0) ? dirs : ups;
            VertsObject vo = orientations.get(i);
            PointCloudData p = vo.getPointCloud();
            p.x.set(0, kts[i / 2 * 3]);
            p.y.set(0, kts[i / 2 * 3 + 1]);
            p.z.set(0, kts[i / 2 * 3 + 2]);
            p.x.set(1, kts[i / 2 * 3] + targ[j]);
            p.y.set(1, kts[i / 2 * 3 + 1] + targ[j + 1]);
            p.z.set(1, kts[i / 2 * 3 + 2] + targ[j + 2]);
            if (i % 2 == 1)
                j += 3;
        }
    } else {
        // We start from scratch
        clearOrientations();
        for (int i = 0; i < n; i += 3) {
            addKnotOrientation(i / 3, kts[i], kts[i + 1], kts[i + 2], dirs[i], dirs[i + 1], dirs[i + 2], ups[i], ups[i + 1], ups[i + 2]);
        }
    }
}
Also used : PointCloudData(gaiasky.data.util.PointCloudData)

Example 13 with PointCloudData

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

the class ConsoleLogger method notify.

@Override
public void notify(final Event event, Object source, final Object... data) {
    switch(event) {
        case POST_NOTIFICATION:
            LoggerLevel level = (LoggerLevel) data[0];
            Object[] dat = (Object[]) data[1];
            StringBuilder message = new StringBuilder();
            for (int i = 0; i < dat.length; i++) {
                if (i != dat.length - 1 || !(dat[i] instanceof Boolean)) {
                    message.append(dat[i].toString());
                    if (i < dat.length - 1 && !(i == dat.length - 2 && dat[data.length - 1] instanceof Boolean)) {
                        message.append(TAG_SEPARATOR);
                    }
                }
            }
            addMessage(message.toString(), 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()), 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", Settings.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;
        default:
            break;
    }
}
Also used : PointCloudData(gaiasky.data.util.PointCloudData) CameraMode(gaiasky.scenegraph.camera.CameraManager.CameraMode) LoggerLevel(gaiasky.util.Logger.LoggerLevel) IFocus(gaiasky.scenegraph.IFocus) StringWriter(java.io.StringWriter) PrintWriter(java.io.PrintWriter)

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