/* osgEarth
 * Copyright 2025 Pelican Mapping
 * MIT License
 */

#include "GLSkyOptions"
#include <osgEarth/Sky>
#include <osgEarth/PhongLightingEffect>
#include <osg/MatrixTransform>

namespace osg {
    class Light;
    class LightSource;
}

namespace osgEarth { namespace GLSky
{
    using namespace osgEarth;
    using namespace osgEarth::Util;

    /**
     * Node that roots the silverlining adapter.
     */
    class GLSkyNode : public SkyNode
    {
    public:
        GLSkyNode(const GLSkyOptions& options);

    public: // SkyNode

        osg::Light* getSunLight() const { return _light.get(); }

        void attach(osg::View* view, int lightNum);

        void onSetEphemeris();
        void onSetDateTime();
        void onSetReferencePoint();

        void traverse(osg::NodeVisitor& nv) override;

    protected:
        virtual ~GLSkyNode();

    private:
        void construct();

        osg::ref_ptr<osg::LightSource>    _lightSource;
        osg::ref_ptr<osg::Light>          _light;
        osg::ref_ptr<PhongLightingEffect> _lighting;
        GLSkyOptions                      _options;
    };

} } // namespace osgEarth::Drivers::GLSky
