use of gaiasky.util.math.Vector3d in project gaiasky by langurmonkey.
the class RecursiveGrid method update.
@Override
public void update(ITimeFrameProvider time, final Vector3b parentTransform, ICamera camera, float opacity) {
this.distToCamera = getDistanceToOrigin(camera);
this.currentDistance = this.distToCamera;
this.regime = this.distToCamera * Constants.DISTANCE_SCALE_FACTOR > 5e7 * Constants.PC_TO_U ? (byte) 2 : (byte) 1;
this.opacity = opacity * this.getVisibilityOpacityFactor();
super.updateOpacity();
if (Settings.settings.program.recursiveGrid.origin.isFocus() && camera.getFocus() != null) {
// Baked fade-in as we get close to focus
IFocus focus = camera.getFocus();
this.opacity *= MathUtilsd.lint(this.distToCamera, focus.getRadius() * 4d, focus.getRadius() * 10d, 0d, 1d);
}
this.fovFactor = camera.getFovFactor() * .75e-3f;
updateLocalTransform(camera);
// Distance in u_tessQuality
getGridScaling(distToCamera, scalingFading);
// Compute projection lines to refsys
if (Settings.settings.program.recursiveGrid.origin.isRefSys() && Settings.settings.program.recursiveGrid.projectionLines && camera.getFocus() != null) {
IFocus focus = camera.getFocus();
Vector3d cpos = D33.get();
Vector3d fpos = D34.get();
getCFPos(cpos, fpos, camera, focus);
// Line in XZ
getZXLine(a, b, cpos, fpos);
d01 = p01.set(b).sub(a).len();
p01.setLength(d01 / 2d).add(a);
// Line in Y
getYLine(c, d, cpos, fpos);
d02 = p02.set(c).sub(d).len();
p02.setLength(d02 / 2d).add(d);
} else {
d01 = -1;
d02 = -1;
}
if (!this.copy && this.opacity > 0) {
addToRenderLists(camera);
}
}
use of gaiasky.util.math.Vector3d in project gaiasky by langurmonkey.
the class Satellite method forceUpdatePosition.
/**
* Default implementation, only sets the result of the coordinates call to
* pos
*
* @param time Time to get the coordinates
* @param force Whether to force the update
*/
protected void forceUpdatePosition(ITimeFrameProvider time, boolean force) {
if (time.getHdiff() != 0 || force) {
coordinatesTimeOverflow = coordinates.getEquatorialCartesianCoordinates(time.getTime(), pos) == null;
// Convert to cartesian coordinates and put them in aux3 vector
Vector3d aux3 = D31.get();
Coordinates.cartesianToSpherical(pos, aux3);
posSph.set((float) (Nature.TO_DEG * aux3.x), (float) (Nature.TO_DEG * aux3.y));
if (rc != null)
rc.update(time);
}
}
use of gaiasky.util.math.Vector3d in project gaiasky by langurmonkey.
the class ShapeObject method textPosition.
@Override
public void textPosition(ICamera cam, Vector3d out) {
out.set(translation);
double len = out.len();
out.clamp(0, len - getRadius()).scl(0.9f);
out.x += getRadius() * 0.5;
Vector3d aux = D32.get();
aux.set(cam.getUp());
aux.crs(out).nor();
float dist = -0.015f * (float) out.len();
aux.add(cam.getUp()).nor().scl(dist);
out.add(aux);
GlobalResources.applyRelativisticAberration(out, cam);
RelativisticEffectsManager.getInstance().gravitationalWavePos(out);
}
use of gaiasky.util.math.Vector3d in project gaiasky by langurmonkey.
the class ShapeObject method updateLocal.
/**
* Updates the local transform matrix.
*
* @param time The time frame provider.
* @param camera The camera.
*/
@Override
public void updateLocal(ITimeFrameProvider time, ICamera camera) {
if (track != null) {
track.getAbsolutePosition(trackName.toLowerCase(Locale.ROOT), pos);
}
// Update pos, local transform
this.translation.add(pos);
this.localTransform.idt().translate(this.translation.put(F31.get())).scl(this.size);
Vector3d aux = D31.get();
this.distToCamera = (float) aux.set(translation).len();
this.viewAngle = (float) FastMath.atan(size / distToCamera);
this.viewAngleApparent = this.viewAngle / camera.getFovFactor();
if (!copy) {
addToRenderLists(camera);
}
this.opacity *= 0.5f * this.getVisibilityOpacityFactor();
}
use of gaiasky.util.math.Vector3d in project gaiasky by langurmonkey.
the class ShapeObject method render.
/**
* Label rendering
*/
@Override
public void render(ExtSpriteBatch batch, ExtShaderProgram shader, FontRenderSystem sys, RenderingContext rc, ICamera camera) {
Vector3d pos = D31.get();
textPosition(camera, pos);
shader.setUniformf("u_viewAngle", (float) this.viewAngle * 500f);
shader.setUniformf("u_viewAnglePow", 1f);
shader.setUniformf("u_thOverFactor", 1f);
shader.setUniformf("u_thOverFactorScl", 1f);
render3DLabel(batch, shader, sys.fontDistanceField, camera, rc, text(), pos, distToCamera, textScale() * camera.getFovFactor(), textSize() * camera.getFovFactor(), this.forceLabel);
}
Aggregations