Search in sources :

Example 1 with Star

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

the class LightPositionUpdater method run.

@Override
public void run(AbstractRenderSystem renderSystem, Array<IRenderable> renderables, ICamera camera) {
    synchronized (lock) {
        int size = renderables.size;
        if (PostProcessorFactory.instance.getPostProcessor().isLightScatterEnabled()) {
            Settings settings = Settings.settings;
            // Compute light positions for light scattering or light
            // glow
            int lightIndex = 0;
            float angleEdgeDeg = camera.getAngleEdge() * MathUtils.radDeg;
            for (int i = size - 1; i >= 0; i--) {
                IRenderable s = renderables.get(i);
                if (s instanceof Star) {
                    Star p = (Star) s;
                    double angle = GaiaSky.instance.cameraManager.getDirection().angle(p.translation);
                    if (lightIndex < nLights && (settings.program.modeCubemap.active || settings.runtime.openVr || angle < angleEdgeDeg)) {
                        Vector3d pos3d = p.translation.put(auxD);
                        // Aberration
                        GlobalResources.applyRelativisticAberration(pos3d, camera);
                        // GravWaves
                        RelativisticEffectsManager.getInstance().gravitationalWavePos(pos3d);
                        Vector3 pos3 = pos3d.put(auxV);
                        float w = settings.graphics.resolution[0];
                        float h = settings.graphics.resolution[1];
                        camera.getCamera().project(pos3, 0, 0, w, h);
                        // Here we **need** to use
                        // Gdx.graphics.getWidth/Height() because we use
                        // camera.project() which uses screen
                        // coordinates only
                        positions[lightIndex * 2] = auxV.x / w;
                        positions[lightIndex * 2 + 1] = auxV.y / h;
                        viewAngles[lightIndex] = (float) p.viewAngleApparent;
                        colors[lightIndex * 3] = p.cc[0];
                        colors[lightIndex * 3 + 1] = p.cc[1];
                        colors[lightIndex * 3 + 2] = p.cc[2];
                        lightIndex++;
                    }
                }
            }
            EventManager.publish(Event.LIGHT_POS_2D_UPDATE, this, lightIndex, positions, viewAngles, colors, glowTex);
        } else {
            EventManager.publish(Event.LIGHT_POS_2D_UPDATE, this, 0, positions, viewAngles, colors, glowTex);
        }
    }
}
Also used : IRenderable(gaiasky.render.IRenderable) Star(gaiasky.scenegraph.Star) Vector3d(gaiasky.util.math.Vector3d) Vector3(com.badlogic.gdx.math.Vector3) Settings(gaiasky.util.Settings)

Aggregations

Vector3 (com.badlogic.gdx.math.Vector3)1 IRenderable (gaiasky.render.IRenderable)1 Star (gaiasky.scenegraph.Star)1 Settings (gaiasky.util.Settings)1 Vector3d (gaiasky.util.math.Vector3d)1