Search in sources :

Example 16 with SceneGraphNode

use of gaiasky.scenegraph.SceneGraphNode in project gaiasky by langurmonkey.

the class StarGroupBinaryIO method readParticles.

/**
 * Reads a single star group from the given input stream.
 *
 * @param in The input stream to read the star group from
 * @return A list with a single star group object
 */
public List<SceneGraphNode> readParticles(InputStream in) {
    List<IParticleRecord> data = provider.loadData(in, 1.0);
    StarGroup sg = new StarGroup();
    sg.setData(data);
    List<SceneGraphNode> l = new ArrayList<>(1);
    l.add(sg);
    return l;
}
Also used : StarGroup(gaiasky.scenegraph.StarGroup) SceneGraphNode(gaiasky.scenegraph.SceneGraphNode) IParticleRecord(gaiasky.scenegraph.particle.IParticleRecord) ArrayList(java.util.ArrayList)

Example 17 with SceneGraphNode

use of gaiasky.scenegraph.SceneGraphNode in project gaiasky by langurmonkey.

the class StarGroupSerializedIO method readParticles.

/**
 * Reads a single star group from the given input stream.
 *
 * @param in
 *            The input stream to read the star group from
 * @return A list with a single star group object
 */
public List<SceneGraphNode> readParticles(InputStream in) {
    List<IParticleRecord> data = provider.loadData(in, 1.0);
    StarGroup sg = new StarGroup();
    sg.setData(data);
    List<SceneGraphNode> l = new ArrayList<>(1);
    l.add(sg);
    return l;
}
Also used : StarGroup(gaiasky.scenegraph.StarGroup) SceneGraphNode(gaiasky.scenegraph.SceneGraphNode) IParticleRecord(gaiasky.scenegraph.particle.IParticleRecord) ArrayList(java.util.ArrayList)

Example 18 with SceneGraphNode

use of gaiasky.scenegraph.SceneGraphNode in project gaiasky by langurmonkey.

the class UpdaterTask method call.

@Override
public Void call() throws Exception {
    int size = nodes.size;
    for (int i = start; i < size; i += step) {
        SceneGraphNode node = nodes.get(i);
        float opacity = node instanceof Particle && node.octant != null ? node.octant.opacity : (node instanceof FadeNode ? 1f : node.opacity);
        node.update(time, node.parent.translation, camera, opacity);
    }
    return null;
}
Also used : Particle(gaiasky.scenegraph.Particle) SceneGraphNode(gaiasky.scenegraph.SceneGraphNode) FadeNode(gaiasky.scenegraph.FadeNode)

Example 19 with SceneGraphNode

use of gaiasky.scenegraph.SceneGraphNode in project gaiasky by langurmonkey.

the class BookmarksComponent method notify.

@Override
public void notify(final Event event, Object source, final Object... data) {
    switch(event) {
        case FOCUS_CHANGED:
            // Update focus selection in focus list
            SceneGraphNode sgn;
            if (data[0] instanceof String) {
                sgn = sg.getNode((String) data[0]);
            } else {
                sgn = (SceneGraphNode) data[0];
            }
            // Select only if data[1] is true
            if (sgn != null) {
                SceneGraphNode node = (SceneGraphNode) data[0];
                selectBookmark(node.getName(), false);
            }
            break;
        case BOOKMARKS_ADD:
            String name = (String) data[0];
            reloadBookmarksTree();
            selectBookmark(name, false);
            break;
        case BOOKMARKS_REMOVE:
        case BOOKMARKS_REMOVE_ALL:
            reloadBookmarksTree();
            break;
        default:
            break;
    }
}
Also used : SceneGraphNode(gaiasky.scenegraph.SceneGraphNode)

Example 20 with SceneGraphNode

use of gaiasky.scenegraph.SceneGraphNode in project gaiasky by langurmonkey.

the class AtmosphereComponent method updateAtmosphericScatteringParams.

/**
 * Updates the atmospheric scattering shader parameters
 *
 * @param mat    The material to update.
 * @param alpha  The opacity value.
 * @param ground Whether it is the ground shader or the atmosphere.
 * @param planet The planet itself, holder of this atmosphere
 */
public void updateAtmosphericScatteringParams(Material mat, float alpha, boolean ground, Planet planet, Vector3d vrOffset) {
    Vector3b transform = planet.translation;
    RotationComponent rc = planet.rc;
    SceneGraphNode sol = planet.parent;
    transform.put(aux3);
    if (vrOffset != null) {
        aux1.set(vrOffset).scl(1 / Constants.M_TO_U);
        aux3.sub(aux1);
    }
    // Distance to planet
    float camHeight = (float) (aux3.len());
    float m_ESun = m_eSun;
    float camHeightGr = camHeight - m_fInnerRadius;
    float atmFactor = (m_fAtmosphereHeight - camHeightGr) / m_fAtmosphereHeight;
    if (!ground && camHeightGr < m_fAtmosphereHeight) {
        // Camera inside atmosphere
        m_ESun += atmFactor * 100f;
    }
    // These are here to get the desired effect inside the atmosphere
    if (mat.has(AtmosphereAttribute.KrESun))
        ((AtmosphereAttribute) mat.get(AtmosphereAttribute.KrESun)).value = m_Kr * m_ESun;
    else
        mat.set(new AtmosphereAttribute(AtmosphereAttribute.KrESun, m_Kr * m_ESun));
    if (mat.has(AtmosphereAttribute.KmESun))
        ((AtmosphereAttribute) mat.get(AtmosphereAttribute.KmESun)).value = m_Km * m_ESun;
    else
        mat.set(new AtmosphereAttribute(AtmosphereAttribute.KmESun, m_Km * m_ESun));
    // Camera height
    if (mat.has(AtmosphereAttribute.CameraHeight))
        ((AtmosphereAttribute) mat.get(AtmosphereAttribute.CameraHeight)).value = camHeight;
    else
        mat.set(new AtmosphereAttribute(AtmosphereAttribute.CameraHeight, camHeight));
    // Planet position
    if (ground) {
        // Camera position must be corrected using the rotation angle of the planet
        aux3.mul(Coordinates.getTransformD(planet.inverseRefPlaneTransform)).rotate(rc.ascendingNode, 0, 1, 0).rotate(-rc.inclination - rc.axialTilt, 0, 0, 1).rotate(-rc.angle, 0, 1, 0);
    }
    ((Vector3Attribute) mat.get(Vector3Attribute.PlanetPos)).value.set(aux3.put(aux));
    // CameraPos = -PlanetPos
    aux3.scl(-1f);
    ((Vector3Attribute) mat.get(Vector3Attribute.CameraPos)).value.set(aux3.put(aux));
    // Light position respect the earth: LightPos = SunPos - EarthPos
    aux3.add(sol.translation).nor();
    if (ground) {
        // Camera position must be corrected using the rotation angle of the planet
        aux3.mul(Coordinates.getTransformD(planet.inverseRefPlaneTransform)).rotate(rc.ascendingNode, 0, 1, 0).rotate(-rc.inclination - rc.axialTilt, 0, 0, 1).rotate(-rc.angle, 0, 1, 0);
    }
    ((Vector3Attribute) mat.get(Vector3Attribute.LightPos)).value.set(aux3.put(aux));
    // Alpha value
    ((AtmosphereAttribute) mat.get(AtmosphereAttribute.Alpha)).value = alpha;
}
Also used : Vector3b(gaiasky.util.math.Vector3b) SceneGraphNode(gaiasky.scenegraph.SceneGraphNode) AtmosphereAttribute(gaiasky.util.gdx.shader.attribute.AtmosphereAttribute)

Aggregations

SceneGraphNode (gaiasky.scenegraph.SceneGraphNode)25 Array (com.badlogic.gdx.utils.Array)7 IFocus (gaiasky.scenegraph.IFocus)6 StarGroup (gaiasky.scenegraph.StarGroup)5 ParticleGroup (gaiasky.scenegraph.ParticleGroup)4 ArrayList (java.util.ArrayList)4 Actor (com.badlogic.gdx.scenes.scene2d.Actor)3 ChangeEvent (com.badlogic.gdx.scenes.scene2d.utils.ChangeListener.ChangeEvent)3 FadeNode (gaiasky.scenegraph.FadeNode)3 ISceneGraph (gaiasky.scenegraph.ISceneGraph)3 IOException (java.io.IOException)3 FileHandle (com.badlogic.gdx.files.FileHandle)2 InputEvent (com.badlogic.gdx.scenes.scene2d.InputEvent)2 NaturalCamera (gaiasky.scenegraph.camera.NaturalCamera)2 AbstractOctreeWrapper (gaiasky.scenegraph.octreewrapper.AbstractOctreeWrapper)2 IParticleRecord (gaiasky.scenegraph.particle.IParticleRecord)2 CatalogInfo (gaiasky.util.CatalogInfo)2 OwnLabel (gaiasky.util.scene2d.OwnLabel)2 Lwjgl3Graphics (com.badlogic.gdx.backends.lwjgl3.Lwjgl3Graphics)1 Stage (com.badlogic.gdx.scenes.scene2d.Stage)1