use of gaiasky.util.math.Vector3b in project gaiasky by langurmonkey.
the class RecursiveGrid method initialize.
@Override
public void initialize() {
transformName = Settings.settings.scene.visibility.get(ComponentType.Galactic.toString()) ? "galacticToEquatorial" : (Settings.settings.scene.visibility.get(ComponentType.Ecliptic.toString()) ? "eclipticToEquatorial" : null);
coordinateSystem = new Matrix4();
coordinateSystemd = new Matrix4d();
mat4daux = new Matrix4d();
scalingFading = new Pair<>(0d, 0d);
updateCoordinateSystem();
nf = NumberFormatFactory.getFormatter("0.###E0");
cc = Settings.settings.scene.visibility.get(ComponentType.Galactic.toString()) ? ccGal : (Settings.settings.scene.visibility.get(ComponentType.Ecliptic.toString()) ? ccEcl : ccEq);
labelcolor = cc;
label = true;
labelPosition = new Vector3b();
localTransform = new Matrix4();
p01 = new Vector3d();
p02 = new Vector3d();
d01 = -1;
d02 = -1;
a = new Vector3d();
b = new Vector3d();
c = new Vector3d();
d = new Vector3d();
// Init billboard model
mc = new ModelComponent();
mc.setType("twofacedbillboard");
Map<String, Object> p = new HashMap<>();
p.put("diameter", 1d);
mc.setParams(p);
mc.forceInit = true;
mc.initialize(null);
mc.env.set(new ColorAttribute(ColorAttribute.AmbientLight, cc[0], cc[1], cc[2], cc[3]));
// Depth reads, no depth writes
mc.setDepthTest(GL20.GL_LEQUAL, false);
// Initialize annotations vectorR
initAnnotations();
}
use of gaiasky.util.math.Vector3b in project gaiasky by langurmonkey.
the class Spacecraft method updateLocalValues.
@Override
public void updateLocalValues(ITimeFrameProvider time, ICamera camera) {
if (yawv != 0 || pitchv != 0 || rollv != 0 || vel.len2() != 0 || render) {
// Poll keys
if (camera.getMode().isSpacecraft())
pollKeys(Gdx.graphics.getDeltaTime());
double dt = time.getDt();
// POSITION
pos = computePosition(dt, camera.getSecondClosestBody(), currentEnginePower, thrust, direction, force, accel, vel, pos);
if (leveling) {
// No velocity, we just stop Euler angle motions
if (yawv != 0) {
yawp = -Math.signum(yawv) * MathUtilsd.clamp(Math.abs(yawv), 0, 1);
}
if (pitchv != 0) {
pitchp = -Math.signum(pitchv) * MathUtilsd.clamp(Math.abs(pitchv), 0, 1);
}
if (rollv != 0) {
rollp = -Math.signum(rollv) * MathUtilsd.clamp(Math.abs(rollv), 0, 1);
}
if (Math.abs(yawv) < 1e-3 && Math.abs(pitchv) < 1e-3 && Math.abs(rollv) < 1e-3) {
setYawPower(0);
setPitchPower(0);
setRollPower(0);
yawv = 0;
pitchv = 0;
rollv = 0;
EventManager.publish(Event.SPACECRAFT_STABILISE_CMD, this, false);
}
}
double rollDiff = computeDirectionUp(dt, dirup);
double len = direction.len();
pitch = Math.asin(direction.y / len);
yaw = Math.atan2(direction.z, direction.x);
roll += rollDiff;
pitch = Math.toDegrees(pitch);
yaw = Math.toDegrees(yaw);
}
// Update float vectors
Vector3b camPos = B31.get().set(pos).add(camera.getInversePos());
camPos.put(posf);
direction.put(directionf);
up.put(upf);
}
use of gaiasky.util.math.Vector3b in project gaiasky by langurmonkey.
the class Star method addHit.
public void addHit(int screenX, int screenY, int w, int h, int minPixDist, NaturalCamera camera, Array<IFocus> hits) {
if (checkHitCondition()) {
Vector3 pos = F31.get();
Vector3b aux = B31.get();
Vector3b posD = getAbsolutePosition(aux).add(camera.getInversePos());
pos.set(posD.valuesf());
if (camera.direction.dot(posD) > 0) {
// The object is in front of us
double angle = computeViewAngle(camera.getFovFactor()) * Settings.settings.scene.star.brightness * 1e3f;
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
hits.add(this);
}
}
}
}
use of gaiasky.util.math.Vector3b in project gaiasky by langurmonkey.
the class LocationLogManager method addRecord.
/**
* Adds a new record with the given object, camera and time
*/
public void addRecord(final IFocus object, final ICamera camera, final ITimeFrameProvider time) {
if (object != null) {
final Instant entryTime = Instant.now();
final Instant simulationTime = time.getTime();
final String name = object.getClosestName();
// Check if the new record is already in the 10 most recent items
boolean found = false;
int stop = Math.max(0, locations.size() - 10);
for (int i = locations.size() - 1; i >= stop; i--) {
if (locations.get(i).name.equalsIgnoreCase(name)) {
found = true;
break;
}
}
if (!found) {
// Create record
final LocationRecord record = new LocationRecord();
record.name = name;
record.entryTime = entryTime;
record.simulationTime = simulationTime;
record.position = new Vector3b().set(camera.getPos());
record.direction = new Vector3d().set(camera.getDirection());
record.up = new Vector3d().set(camera.getUp());
if (locations.size() == MAX_SIZE) {
locations.pollFirst();
}
locations.add(record);
EventManager.publish(Event.NEW_LOCATION_RECORD, this, locations);
logger.debug(I18n.txt("gui.locationlog.newrecord", record.toStringFull()));
}
}
}
use of gaiasky.util.math.Vector3b in project gaiasky by langurmonkey.
the class AbstractVSOP87 method getEquatorialCartesianCoordinates.
@Override
public Vector3b getEquatorialCartesianCoordinates(Instant date, Vector3b out) {
Vector3b v = getEclipticSphericalCoordinates(date, out);
if (v == null)
return null;
Coordinates.sphericalToCartesian(out, out);
out.mul(Coordinates.eclToEq());
return out;
}
Aggregations