modify use oe to render
This commit is contained in:
parent
a89e078a1a
commit
be97c3231b
@ -185,7 +185,7 @@ endif()
|
|||||||
SET_TARGET_PROPERTIES(${PROJECT_NAME} PROPERTIES RUNTIME_OUTPUT_DIRECTORY ${ProjectDIR}/bin)
|
SET_TARGET_PROPERTIES(${PROJECT_NAME} PROPERTIES RUNTIME_OUTPUT_DIRECTORY ${ProjectDIR}/bin)
|
||||||
|
|
||||||
TARGET_LINK_LIBRARIES(${PROJECT_NAME})
|
TARGET_LINK_LIBRARIES(${PROJECT_NAME})
|
||||||
#SET(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} /SUBSYSTEM:CONSOLE")
|
SET(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} /SUBSYSTEM:CONSOLE")
|
||||||
|
|
||||||
add_custom_command(TARGET ${PROJECT_NAME}
|
add_custom_command(TARGET ${PROJECT_NAME}
|
||||||
POST_BUILD
|
POST_BUILD
|
||||||
|
@ -24,9 +24,6 @@ OEScene::OEScene() {
|
|||||||
const std::string& basePath = RecourceHelper::Get().GetBasePath().toStdString();
|
const std::string& basePath = RecourceHelper::Get().GetBasePath().toStdString();
|
||||||
pathList.push_back(basePath + "/resources/earth/");
|
pathList.push_back(basePath + "/resources/earth/");
|
||||||
pathList.push_back(basePath + "/resources/textures/");
|
pathList.push_back(basePath + "/resources/textures/");
|
||||||
|
|
||||||
|
|
||||||
logarithmicDepthBuffer_ = std::make_unique<osgEarth::Util::LogarithmicDepthBuffer>();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -36,7 +33,7 @@ void OEScene::InitEventHandle(class OsgView* view) {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
view->GetView()->addEventHandler(new osgEarth::Util::EarthManipulator());
|
//view->GetView()->addEventHandler(new osgEarth::Util::EarthManipulator());
|
||||||
|
|
||||||
view->GetView()->addEventHandler(new osgViewer::HelpHandler);
|
view->GetView()->addEventHandler(new osgViewer::HelpHandler);
|
||||||
}
|
}
|
||||||
@ -47,21 +44,12 @@ void OEScene::AttachView(OsgView* view) {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
//osg::Node* node1 = osgDB::readNodeFile("chaff_bombs.osg");
|
|
||||||
//node1->getOrCreateStateSet()->setMode(GL_LIGHTING, osg::StateAttribute::OFF);
|
|
||||||
//osg::MatrixTransform* mt = new osg::MatrixTransform;
|
|
||||||
//mt->addChild(node1);
|
|
||||||
////GetOceanScene()->addChild(mt);
|
|
||||||
//entityRoot_->addChild(mt);
|
|
||||||
//osg::Vec3 eye(0.0f, 60.f, 50.0f);
|
|
||||||
//mt->setMatrix(osg::Matrix::translate(eye)/* * osg::Matrix::scale(osg::Vec3(10, 10, 10))*/);
|
|
||||||
//////mt->getOrCreateStateSet()-
|
|
||||||
|
|
||||||
earthRootNode_ = osgDB::readNodeFile("triton.earth");
|
earthRootNode_ = osgDB::readNodeFile("triton.earth");
|
||||||
if (!earthRootNode_) {
|
if (!earthRootNode_) {
|
||||||
LOG_ERROR("read earth node(triton.earth) failed");
|
LOG_ERROR("read earth node(triton.earth) failed");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
logarithmicDepthBuffer_ = std::make_unique<osgEarth::Util::LogarithmicDepthBuffer>();
|
||||||
|
|
||||||
earthMapNode_ = osgEarth::MapNode::get(earthRootNode_);
|
earthMapNode_ = osgEarth::MapNode::get(earthRootNode_);
|
||||||
LOG_INFO("earth map node get success: {}", earthMapNode_.valid());
|
LOG_INFO("earth map node get success: {}", earthMapNode_.valid());
|
||||||
@ -83,7 +71,7 @@ void OEScene::AttachView(OsgView* view) {
|
|||||||
osg::Node* node = view->GetView()->getSceneData();
|
osg::Node* node = view->GetView()->getSceneData();
|
||||||
if (nullptr == node) {
|
if (nullptr == node) {
|
||||||
LOG_INFO("view scene data is nullptr, root valid:{}", skyDome_.valid());
|
LOG_INFO("view scene data is nullptr, root valid:{}", skyDome_.valid());
|
||||||
view->GetView()->setSceneData(earthRootNode_);
|
view->GetView()->setSceneData(skyDome_);
|
||||||
} else {
|
} else {
|
||||||
osg::Group* group = node->asGroup();
|
osg::Group* group = node->asGroup();
|
||||||
if (nullptr != group) {
|
if (nullptr != group) {
|
||||||
@ -104,19 +92,18 @@ void OEScene::AttachView(OsgView* view) {
|
|||||||
|
|
||||||
}*/
|
}*/
|
||||||
|
|
||||||
/* skyDome_->attach(view->GetView());
|
skyDome_->attach(view->GetView());
|
||||||
|
|
||||||
skyDome_->setAtmosphereVisible(true);
|
skyDome_->setAtmosphereVisible(true);
|
||||||
skyDome_->setSunVisible(true);
|
skyDome_->setSunVisible(true);
|
||||||
skyDome_->setMoonVisible(true);
|
skyDome_->setMoonVisible(true);
|
||||||
skyDome_->setStarsVisible(true);
|
skyDome_->setStarsVisible(true);
|
||||||
|
|
||||||
skyDome_->setDateTime(osgEarth::DateTime(2024, 12, 24, 12));
|
skyDome_->setDateTime(osgEarth::DateTime(2024, 12, 24, 3));
|
||||||
skyDome_->setSimulationTimeTracksDateTime(true);*/
|
skyDome_->setSimulationTimeTracksDateTime(true);
|
||||||
|
|
||||||
logarithmicDepthBuffer_->install(view->GetView()->getCamera());
|
logarithmicDepthBuffer_->install(view->GetView()->getCamera());
|
||||||
|
|
||||||
//view->GetView()->setRealizeOperation(new osgEarth::GL3RealizeOperation());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void OEScene::DetachView(OsgView* view) {
|
void OEScene::DetachView(OsgView* view) {
|
||||||
|
@ -1054,12 +1054,12 @@
|
|||||||
<context>
|
<context>
|
||||||
<name>QtOsgViewWidget</name>
|
<name>QtOsgViewWidget</name>
|
||||||
<message>
|
<message>
|
||||||
<location filename="../viewer/QtOsgViewWidget.cpp" line="131"/>
|
<location filename="../viewer/QtOsgViewWidget.cpp" line="138"/>
|
||||||
<source>notify</source>
|
<source>notify</source>
|
||||||
<translation type="unfinished"></translation>
|
<translation type="unfinished"></translation>
|
||||||
</message>
|
</message>
|
||||||
<message>
|
<message>
|
||||||
<location filename="../viewer/QtOsgViewWidget.cpp" line="131"/>
|
<location filename="../viewer/QtOsgViewWidget.cpp" line="138"/>
|
||||||
<source>open dyt file failed</source>
|
<source>open dyt file failed</source>
|
||||||
<translation type="unfinished"></translation>
|
<translation type="unfinished"></translation>
|
||||||
</message>
|
</message>
|
||||||
|
@ -58,8 +58,10 @@ void OsgView::InitGraphiceWindow(int x, int y, int width, int height,
|
|||||||
#endif
|
#endif
|
||||||
graphiceWindow_ = osg::GraphicsContext::createGraphicsContext(traits);
|
graphiceWindow_ = osg::GraphicsContext::createGraphicsContext(traits);
|
||||||
|
|
||||||
graphiceWindow_->getState()->setUseModelViewAndProjectionUniforms(true);
|
#if USE_OCEAN
|
||||||
graphiceWindow_->getState()->setUseVertexAttributeAliasing(true);
|
graphiceWindow_->getState()->setUseModelViewAndProjectionUniforms(false);
|
||||||
|
graphiceWindow_->getState()->setUseVertexAttributeAliasing(false);
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
void OsgView::InitView(osgViewer::View* pView) {
|
void OsgView::InitView(osgViewer::View* pView) {
|
||||||
@ -70,11 +72,13 @@ void OsgView::InitView(osgViewer::View* pView) {
|
|||||||
pCamera->setGraphicsContext(graphiceWindow_);
|
pCamera->setGraphicsContext(graphiceWindow_);
|
||||||
const osg::GraphicsContext::Traits* traits = graphiceWindow_->getTraits();
|
const osg::GraphicsContext::Traits* traits = graphiceWindow_->getTraits();
|
||||||
pCamera->setViewport(new osg::Viewport(0, 0, traits->width, traits->height));
|
pCamera->setViewport(new osg::Viewport(0, 0, traits->width, traits->height));
|
||||||
|
#if USE_OCEAN
|
||||||
pCamera->setProjectionMatrixAsPerspective(45.0,
|
pCamera->setProjectionMatrixAsPerspective(45.0,
|
||||||
static_cast<double>(traits->width) /
|
static_cast<double>(traits->width) /
|
||||||
static_cast<double>(traits->height),
|
static_cast<double>(traits->height),
|
||||||
0.1, 1000.0);
|
0.1, 1000.0);
|
||||||
pCamera->setComputeNearFarMode(osg::CullSettings::COMPUTE_NEAR_FAR_USING_PRIMITIVES);
|
pCamera->setComputeNearFarMode(osg::CullSettings::COMPUTE_NEAR_FAR_USING_PRIMITIVES);
|
||||||
|
#endif
|
||||||
view_ = pView;
|
view_ = pView;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -94,9 +98,11 @@ void OsgView::Resize(int x, int y, int width, int height) {
|
|||||||
}
|
}
|
||||||
osg::Camera* pCamera = view_->getCamera();
|
osg::Camera* pCamera = view_->getCamera();
|
||||||
pCamera->setViewport(new osg::Viewport(x, y, width, height));
|
pCamera->setViewport(new osg::Viewport(x, y, width, height));
|
||||||
|
#if USE_OCEAN
|
||||||
pCamera->setProjectionMatrixAsPerspective(45.0,
|
pCamera->setProjectionMatrixAsPerspective(45.0,
|
||||||
static_cast<double>(width) / static_cast<double>(height),
|
static_cast<double>(width) / static_cast<double>(height),
|
||||||
0.1, 1000.0);
|
0.1, 1000.0);
|
||||||
|
#endif
|
||||||
view_->requiresRedraw();
|
view_->requiresRedraw();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -150,8 +156,8 @@ void OsgView::Initialize(OsgCameraManipulator* cameraManipulator) {
|
|||||||
SetCameraManipulator(cameraManipulator);
|
SetCameraManipulator(cameraManipulator);
|
||||||
}
|
}
|
||||||
|
|
||||||
view_->addEventHandler(new osgViewer::StatsHandler);
|
//view_->addEventHandler(new osgViewer::StatsHandler);
|
||||||
view_->addEventHandler(new osgGA::StateSetManipulator(view_->getCamera()->getOrCreateStateSet()));
|
//view_->addEventHandler(new osgGA::StateSetManipulator(view_->getCamera()->getOrCreateStateSet()));
|
||||||
initialized_ = true;
|
initialized_ = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -12,6 +12,9 @@
|
|||||||
#include <QMessageBox>
|
#include <QMessageBox>
|
||||||
#include <QScreen>
|
#include <QScreen>
|
||||||
|
|
||||||
|
#include <osgEarth/EarthManipulator>
|
||||||
|
#include <osgEarth/Viewpoint>
|
||||||
|
|
||||||
#include "app/Application.h"
|
#include "app/Application.h"
|
||||||
#include "common/SpdLogger.h"
|
#include "common/SpdLogger.h"
|
||||||
#include "viewer/OsgView.h"
|
#include "viewer/OsgView.h"
|
||||||
@ -66,20 +69,24 @@ void QtOsgViewWidget::Initialize(void) {
|
|||||||
|
|
||||||
setMouseTracking(true);
|
setMouseTracking(true);
|
||||||
|
|
||||||
//OsgSceneManipulator* manipulator = new OsgSceneManipulator;
|
////OsgSceneManipulator* manipulator = new OsgSceneManipulator;
|
||||||
CameraControlManipulator* manipulator = new CameraControlManipulator;
|
//CameraControlManipulator* manipulator = new CameraControlManipulator;
|
||||||
//osg::Vec3f eye(-256.63, 48.57, 82.19);
|
////osg::Vec3f eye(-256.63, 48.57, 82.19);
|
||||||
//osg::Vec3f center(-164.45, 30.05, 48.14);
|
////osg::Vec3f center(-164.45, 30.05, 48.14);
|
||||||
//osg::Vec3f up(0.33, -0.07, 0.94);
|
////osg::Vec3f up(0.33, -0.07, 0.94);
|
||||||
|
|
||||||
osg::Vec3 eye(0.0f, 300.f, 60.0f);
|
//osg::Vec3 eye(0.0f, 300.f, 60.0f);
|
||||||
osg::Vec3 center(0.0f, 60.0f, 0.0f);
|
//osg::Vec3 center(0.0f, 60.0f, 0.0f);
|
||||||
osg::Vec3 up(0.0f, 0.0f, 1.0f);
|
//osg::Vec3 up(0.0f, 0.0f, 1.0f);
|
||||||
manipulator->setHomePosition(eye, center, up);
|
//manipulator->setHomePosition(eye, center, up);
|
||||||
manipulator->setManipulatorMode(CameraControlManipulator::Roam_ManipulatorMode);
|
//manipulator->setManipulatorMode(CameraControlManipulator::Roam_ManipulatorMode);
|
||||||
manipulator->setVerticalAxisFixed(true);
|
//manipulator->setVerticalAxisFixed(true);
|
||||||
manipulator->setRoamCamera(eye, center, up);
|
//manipulator->setRoamCamera(eye, center, up);
|
||||||
manipulator->setDistance(650.0);
|
//manipulator->setDistance(650.0);
|
||||||
|
|
||||||
|
osgEarth::Util::EarthManipulator* manipulator = new osgEarth::Util::EarthManipulator;
|
||||||
|
osgEarth::Viewpoint vp("home", 107.85, 32.35, 100.0, -2.50, -90.0, 1.5e7);
|
||||||
|
manipulator->setHomeViewpoint(vp, 3.0);
|
||||||
|
|
||||||
|
|
||||||
OsgCameraManipulator* cameraManipulator = new OsgCameraManipulator(manipulator, this);
|
OsgCameraManipulator* cameraManipulator = new OsgCameraManipulator(manipulator, this);
|
||||||
|
Loading…
Reference in New Issue
Block a user