DYTSrouce/src/scene/OEScene.h

61 lines
1.6 KiB
C++

#pragma once
#include <osgEarth/MapNode>
#include <osgEarthUtil/Sky>
#include <osgEarth/Viewpoint>
#include "common/SpdLogger.h"
#include "config.h"
#include "scene/ui/OESceneUI.h"
namespace osgEarth {
namespace Util {
class EarthManipulator;
}
}
class OEScene : public osg::Group {
public:
OEScene();
~OEScene();
void AttachView(osgViewer::View* view);
void DetachView(osgViewer::View* view);
bool AddToScene(osg::Node* node) const;
void SetHomeViewpoint(const osgEarth::Viewpoint& viewpoint, double duration_s);
bool TrackEntity(osg::Node* entity, bool track) const;
osgEarth::MapNode* GetMapNode(void) const {
dyt_check(earthMapNode_.valid());
return earthMapNode_;
}
OESceneUI* GetOrCreateSceneUI();
// Read-only accessor to avoid creating UI during teardown
OESceneUI* GetSceneUI() const {
return sceneUI_.get();
}
osgEarth::Util::EarthManipulator* GetManipulater() const {
return earthManipulator_.get();
}
osg::Viewport* GetViewport() const;
bool ScreenToWorldCoordinate(int x, int y, osg::Vec3d* output) const;
bool Vec3ToLocation(const osg::Vec3& input, osg::Vec3d* output) const;
static const osgEarth::SpatialReference* GetSrs();
private:
void Init();
private:
osg::ref_ptr<osg::Node> earthRootNode_;
osg::ref_ptr<osgEarth::Util::EarthManipulator> earthManipulator_;
osg::ref_ptr<osgEarth::MapNode> earthMapNode_;
osg::ref_ptr<osg::Group> entityRoot_;
osg::ref_ptr<osgEarth::Util::SkyNode> skyDome_;
osg::ref_ptr<OESceneUI> sceneUI_;
osgViewer::View* curentView_ {nullptr};
bool homeViewpointSet_ {false};
};