use of gaiasky.scenegraph.particle.IParticleRecord in project gaiasky by langurmonkey.
the class EventScriptingInterface method getStarParameters.
@Override
public double[] getStarParameters(String id) {
SceneGraphNode sgn = getObject(id);
if (sgn instanceof StarGroup) {
// This star group contains the star
StarGroup sg = (StarGroup) sgn;
IParticleRecord sb = sg.getCandidateBean();
if (sb != null) {
double[] rgb = sb.rgb();
return new double[] { sb.ra(), sb.dec(), sb.parallax(), sb.mualpha(), sb.mudelta(), sb.radvel(), sb.appmag(), rgb[0], rgb[1], rgb[2] };
}
}
return null;
}
use of gaiasky.scenegraph.particle.IParticleRecord in project gaiasky by langurmonkey.
the class SceneGraph method addToHipMap.
private void addToHipMap(SceneGraphNode node) {
if (node instanceof AbstractOctreeWrapper) {
AbstractOctreeWrapper aow = (AbstractOctreeWrapper) node;
Set<SceneGraphNode> set = aow.parenthood.keySet();
for (SceneGraphNode ape : set) addToHipMap(ape);
} else {
synchronized (hipMap) {
if (node instanceof CelestialBody) {
CelestialBody s = (CelestialBody) node;
if (s instanceof Star && ((Star) s).hip > 0) {
if (hipMap.containsKey(((Star) s).hip)) {
logger.debug(I18n.txt("error.id.hip.duplicate", ((Star) s).hip));
} else {
hipMap.put(((Star) s).hip, s);
}
}
} else if (node instanceof StarGroup) {
List<IParticleRecord> stars = ((StarGroup) node).data();
for (IParticleRecord pb : stars) {
if (pb.hip() > 0) {
hipMap.put(pb.hip(), new Position(pb.x(), pb.y(), pb.z(), pb.pmx(), pb.pmy(), pb.pmz()));
}
}
}
}
}
}
use of gaiasky.scenegraph.particle.IParticleRecord in project gaiasky by langurmonkey.
the class StarGroup method initialize.
public void initialize() {
// Load data
try {
Class<?> clazz = Class.forName(provider);
IStarGroupDataProvider provider = (IStarGroupDataProvider) clazz.getConstructor().newInstance();
provider.setProviderParams(providerParams);
if (factor == null)
factor = 1d;
// Set data, generate index
List<IParticleRecord> l = provider.loadData(datafile, factor);
this.setData(l);
} catch (Exception e) {
Logger.getLogger(this.getClass()).error(e);
pointData = null;
}
computeMeanPosition();
setLabelPosition();
}
use of gaiasky.scenegraph.particle.IParticleRecord in project gaiasky by langurmonkey.
the class StarGroup method getVariableSizeScaling.
private double getVariableSizeScaling(final int idx) {
IParticleRecord ipr = pointData.get(idx);
if (ipr instanceof VariableRecord) {
VariableRecord vr = (VariableRecord) ipr;
double[] times = vr.variTimes;
float[] sizes = vr.variMags;
int n = vr.nVari;
// Days since epoch
double t = AstroUtils.getDaysSince(GaiaSky.instance.time.getTime(), this.getVariabilityepoch());
double t0 = times[0];
double t1 = times[n - 1];
double period = t1 - t0;
t = t % period;
for (int i = 0; i < n - 1; i++) {
double x0 = times[i] - t0;
double x1 = times[i + 1] - t0;
if (t >= x0 && t <= x1) {
return MathUtilsd.lint(t, x0, x1, sizes[i], sizes[i + 1]) / vr.size();
}
}
}
return 1;
}
use of gaiasky.scenegraph.particle.IParticleRecord in project gaiasky by langurmonkey.
the class ParticleGroup method render.
/**
* Label rendering
*/
@Override
public void render(ExtSpriteBatch batch, ExtShaderProgram shader, FontRenderSystem sys, RenderingContext rc, ICamera camera) {
// Dataset label
Vector3d pos = D31.get();
textPosition(camera, pos);
shader.setUniformf("u_viewAngle", 90f);
shader.setUniformf("u_viewAnglePow", 1f);
shader.setUniformf("u_thOverFactor", 1f);
shader.setUniformf("u_thOverFactorScl", 1f);
render3DLabel(batch, shader, sys.fontDistanceField, camera, rc, text(), pos, pos.len(), textScale() * 2f * camera.getFovFactor(), textSize() * camera.getFovFactor(), this.forceLabel);
// Particle labels
if (active != null) {
float thOverFactor = 1e-15f;
for (int i = 0; i < Math.min(50, pointData.size()); i++) {
IParticleRecord pb = pointData.get(active[i]);
if (pb.names() != null) {
Vector3d lpos = fetchPosition(pb, cPosD, D31.get(), 0);
float distToCamera = (float) lpos.len();
float viewAngle = 1e-4f / camera.getFovFactor();
textPosition(camera, lpos.put(D31.get()), distToCamera, 0);
shader.setUniformf("u_viewAngle", viewAngle);
shader.setUniformf("u_viewAnglePow", 1f);
shader.setUniformf("u_thOverFactor", thOverFactor);
shader.setUniformf("u_thOverFactorScl", camera.getFovFactor());
float textSize = (float) FastMath.tanh(viewAngle) * distToCamera * 1e5f;
float alpha = Math.min((float) FastMath.atan(textSize / distToCamera), 1.e-3f);
textSize = (float) FastMath.tan(alpha) * distToCamera * 0.5f;
render3DLabel(batch, shader, sys.fontDistanceField, camera, rc, pb.names()[0], lpos.put(D31.get()), distToCamera, textScale() * camera.getFovFactor(), textSize * camera.getFovFactor(), this.forceLabel);
}
}
}
}
Aggregations