Search in sources :

Example 6 with Keyframe

use of gaiasky.desktop.util.camera.Keyframe in project gaiasky by langurmonkey.

the class KeyframesPathObject method resamplePath.

public void resamplePath() {
    if (keyframes.size > 0) {
        Array<Array<Vector3d>> kfPositionsSep = new Array<>();
        double[] kfPositions = new double[keyframes.size * 3];
        Array<Vector3d> current = new Array<>();
        int i = 0;
        for (Keyframe kf : keyframes) {
            // Fill model table
            if (kf.seam) {
                if (i > 0 && i < keyframes.size - 1) {
                    current.add(kf.pos);
                    kfPositionsSep.add(current);
                    current = new Array<>();
                }
            }
            current.add(kf.pos);
            kfPositions[i * 3] = kf.pos.x;
            kfPositions[i * 3 + 1] = kf.pos.y;
            kfPositions[i * 3 + 2] = kf.pos.z;
            i++;
        }
        kfPositionsSep.add(current);
        double[] pathSamples = CameraKeyframeManager.instance.samplePaths(kfPositionsSep, kfPositions, 20, Settings.settings.camrecorder.keyframe.position);
        path.setPoints(pathSamples);
    }
}
Also used : Array(com.badlogic.gdx.utils.Array) Keyframe(gaiasky.desktop.util.camera.Keyframe) Vector3d(gaiasky.util.math.Vector3d)

Example 7 with Keyframe

use of gaiasky.desktop.util.camera.Keyframe in project gaiasky by langurmonkey.

the class KeyframesPathObject method refreshData.

/**
 * Refreshes the positions and orientations from the keyframes
 */
public void refreshData() {
    Array<Array<Vector3d>> kfPositionsSep = new Array<>();
    double[] kfPositions = new double[keyframes.size * 3];
    double[] kfDirections = new double[keyframes.size * 3];
    double[] kfUps = new double[keyframes.size * 3];
    boolean[] kfSeams = new boolean[keyframes.size];
    Array<Vector3d> current = new Array<>();
    int i = 0;
    for (Keyframe kf : keyframes) {
        // Fill positions
        if (kf.seam) {
            if (i > 0 && i < keyframes.size - 1) {
                current.add(kf.pos);
                kfPositionsSep.add(current);
                current = new Array<>();
            }
        }
        current.add(kf.pos);
        kfPositions[i * 3] = kf.pos.x;
        kfPositions[i * 3 + 1] = kf.pos.y;
        kfPositions[i * 3 + 2] = kf.pos.z;
        kfDirections[i * 3] = kf.dir.x;
        kfDirections[i * 3 + 1] = kf.dir.y;
        kfDirections[i * 3 + 2] = kf.dir.z;
        kfUps[i * 3] = kf.up.x;
        kfUps[i * 3 + 1] = kf.up.y;
        kfUps[i * 3 + 2] = kf.up.z;
        kfSeams[i] = kf.seam;
        i++;
    }
    kfPositionsSep.add(current);
    setPathKnots(kfPositions, kfDirections, kfUps, kfSeams);
    if (keyframes.size > 1) {
        segments.setPoints(kfPositions);
        double[] pathSamples = CameraKeyframeManager.instance.samplePaths(kfPositionsSep, kfPositions, 20, Settings.settings.camrecorder.keyframe.position);
        path.setPoints(pathSamples);
    } else {
        segments.clear();
        path.clear();
    }
}
Also used : Array(com.badlogic.gdx.utils.Array) Keyframe(gaiasky.desktop.util.camera.Keyframe) Vector3d(gaiasky.util.math.Vector3d)

Example 8 with Keyframe

use of gaiasky.desktop.util.camera.Keyframe in project gaiasky by langurmonkey.

the class KeyframesPathObject method select.

public IFocus select(int screenX, int screenY, int minPixDist, NaturalCamera camera) {
    Vector3 pos = F31.get();
    Vector3d aux = D31.get();
    for (Keyframe kf : keyframes) {
        Vector3d posd = aux.set(kf.pos).add(camera.getInversePos());
        pos.set(posd.valuesf());
        if (camera.direction.dot(posd) > 0) {
            // The object is in front of us
            double angle = 0.0001;
            PerspectiveCamera perspectiveCamera;
            if (Settings.settings.program.modeStereo.active) {
                if (screenX < Gdx.graphics.getWidth() / 2f) {
                    perspectiveCamera = camera.getCameraStereoLeft();
                } else {
                    perspectiveCamera = camera.getCameraStereoRight();
                }
                perspectiveCamera.update();
            } else {
                perspectiveCamera = camera.camera;
            }
            angle = (float) Math.toDegrees(angle * camera.getFovFactor()) * (40f / perspectiveCamera.fieldOfView);
            double pixelSize = Math.max(minPixDist, ((angle * perspectiveCamera.viewportHeight) / perspectiveCamera.fieldOfView) / 2);
            perspectiveCamera.project(pos);
            pos.y = perspectiveCamera.viewportHeight - pos.y;
            if (Settings.settings.program.modeStereo.active) {
                pos.x /= 2;
            }
            // Check click distance
            if (checkClickDistance(screenX, screenY, pos, camera, perspectiveCamera, pixelSize)) {
                // Hit
                select(kf);
                initFocus();
                focus.pos.set(selected.pos);
                focus.setName(selected.name);
                return focus;
            }
        }
    }
    return null;
}
Also used : Keyframe(gaiasky.desktop.util.camera.Keyframe) Vector3d(gaiasky.util.math.Vector3d) Vector3(com.badlogic.gdx.math.Vector3) PerspectiveCamera(com.badlogic.gdx.graphics.PerspectiveCamera)

Example 9 with Keyframe

use of gaiasky.desktop.util.camera.Keyframe in project gaiasky by langurmonkey.

the class KeyframesWindow method notify.

@Override
public void notify(final Event event, Object source, final Object... data) {
    switch(event) {
        case KEYFRAME_ADD:
            addKeyframe(-1);
            break;
        case UPDATE_CAM_RECORDER:
            synchronized (lock) {
                t = (ITimeFrameProvider) data[0];
                pos = (Vector3b) data[1];
                dir = (Vector3d) data[2];
                up = (Vector3d) data[3];
            }
            break;
        case KEYFRAMES_REFRESH:
            reinitialiseKeyframes(keyframes, null);
            break;
        case KEYFRAME_SELECT:
            Keyframe kf = (Keyframe) data[0];
            OwnLabel nl = keyframeNames.get(kf);
            if (nl != null) {
                colorBak = nl.getColor().cpy();
                nl.setColor(skin.getColor("theme"));
                scrollToKeyframe(kf);
            }
            break;
        case KEYFRAME_UNSELECT:
            kf = (Keyframe) data[0];
            nl = keyframeNames.get(kf);
            if (nl != null && colorBak != null) {
                nl.setColor(colorBak);
            }
            break;
        default:
            break;
    }
}
Also used : Keyframe(gaiasky.desktop.util.camera.Keyframe)

Example 10 with Keyframe

use of gaiasky.desktop.util.camera.Keyframe in project gaiasky by langurmonkey.

the class KeyframesWindow method addKeyframesToTable.

private void addKeyframesToTable(Array<Keyframe> keyframes, Table table) {
    int i = 0;
    double prevT = 0;
    for (Keyframe kf : keyframes) {
        // Add to UI table
        addKeyframeToTable(kf, prevT, i, table);
        prevT += kf.seconds;
        i++;
    }
    if (keyframesPathObject != null) {
        GaiaSky.postRunnable(() -> {
            keyframesPathObject.setKeyframes(keyframes);
            keyframesPathObject.refreshData();
        });
    }
}
Also used : Keyframe(gaiasky.desktop.util.camera.Keyframe)

Aggregations

Keyframe (gaiasky.desktop.util.camera.Keyframe)10 Vector3d (gaiasky.util.math.Vector3d)5 Array (com.badlogic.gdx.utils.Array)3 ChangeEvent (com.badlogic.gdx.scenes.scene2d.utils.ChangeListener.ChangeEvent)2 PerspectiveCamera (com.badlogic.gdx.graphics.PerspectiveCamera)1 Vector3 (com.badlogic.gdx.math.Vector3)1 FloatValidator (gaiasky.util.validator.FloatValidator)1 LengthValidator (gaiasky.util.validator.LengthValidator)1 RegexpValidator (gaiasky.util.validator.RegexpValidator)1 Date (java.util.Date)1