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);
}
}
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();
}
}
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;
}
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;
}
}
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();
});
}
}
Aggregations