Search in sources :

Example 6 with IParticleRecord

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;
}
Also used : IParticleRecord(gaiasky.scenegraph.particle.IParticleRecord)

Example 7 with IParticleRecord

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()));
                    }
                }
            }
        }
    }
}
Also used : IPosition(gaiasky.util.tree.IPosition) IParticleRecord(gaiasky.scenegraph.particle.IParticleRecord) AbstractOctreeWrapper(gaiasky.scenegraph.octreewrapper.AbstractOctreeWrapper)

Example 8 with IParticleRecord

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();
}
Also used : IParticleRecord(gaiasky.scenegraph.particle.IParticleRecord) IStarGroupDataProvider(gaiasky.data.group.IStarGroupDataProvider)

Example 9 with IParticleRecord

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;
}
Also used : IParticleRecord(gaiasky.scenegraph.particle.IParticleRecord) VariableRecord(gaiasky.scenegraph.particle.VariableRecord)

Example 10 with IParticleRecord

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);
            }
        }
    }
}
Also used : IParticleRecord(gaiasky.scenegraph.particle.IParticleRecord)

Aggregations

IParticleRecord (gaiasky.scenegraph.particle.IParticleRecord)48 Vector3d (gaiasky.util.math.Vector3d)10 StarGroup (gaiasky.scenegraph.StarGroup)8 ArrayList (java.util.ArrayList)6 Array (com.badlogic.gdx.utils.Array)5 Vector3 (com.badlogic.gdx.math.Vector3)4 ParticleGroup (gaiasky.scenegraph.ParticleGroup)4 OctreeNode (gaiasky.util.tree.OctreeNode)4 FileHandle (com.badlogic.gdx.files.FileHandle)3 ParticleRecord (gaiasky.scenegraph.particle.ParticleRecord)3 Coordinates (gaiasky.util.coord.Coordinates)3 Matrix4 (com.badlogic.gdx.math.Matrix4)2 LongMap (com.badlogic.gdx.utils.LongMap)2 Method (com.badlogic.gdx.utils.reflect.Method)2 ReflectionException (com.badlogic.gdx.utils.reflect.ReflectionException)2 IStarGroupDataProvider (gaiasky.data.group.IStarGroupDataProvider)2 SceneGraphNode (gaiasky.scenegraph.SceneGraphNode)2 ICamera (gaiasky.scenegraph.camera.ICamera)2 AbstractOctreeWrapper (gaiasky.scenegraph.octreewrapper.AbstractOctreeWrapper)2 BillboardDataset (gaiasky.scenegraph.particle.BillboardDataset)2