Skip to content

Commit

Permalink
解决视点返回home没起作用
Browse files Browse the repository at this point in the history
  • Loading branch information
ytyisme committed Apr 8, 2021
1 parent 368fe01 commit 4ad1244
Show file tree
Hide file tree
Showing 5 changed files with 29 additions and 31 deletions.
2 changes: 1 addition & 1 deletion LoadMap/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ int main(int argc, char *argv[])



auto pScene = GetSceneCore()->GetSceneGraphManager()->CreateSceneGraph(ISceneGraph::SCENEGRAPH_3D);
auto pScene = GetSceneCore()->GetSceneGraphManager()->CreateSceneGraph(ISceneGraph::SCENEGRAPH_USER);
//pScene->GetMap()->GetSpaceEnv()->SetMilkywayVisible(false);
// for(auto one:pScene->GetMap()->GetMapLayers())
// {
Expand Down
12 changes: 6 additions & 6 deletions LoadMap/mainwindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -119,8 +119,8 @@ void MainWindow::on_action_triggered()
IMapLocation* aaaa = dynamic_cast<IMapLocation*>(m_pSceneGraph->GetPlot()->CreateSceneNode("IMapLocation"));
aaaa->SetSceneNode(pSceneRootaaaa);
pSceneRootaaaa->AddSceneNode(pCircle->GetMapSceneNode());
IMapLayer* m_pLayerTest = m_pSceneGraph->GetMap()->CreateLayer("test");
m_pLayerTest->AddSceneNode(aaaa);
// IMapLayer* m_pLayerTest = m_pSceneGraph->GetMap()->CreateLayer("test");
// m_pLayerTest->AddSceneNode(aaaa);

// CMapRectange* pRectangle = new CMapRectange(m_pSceneGraph);

Expand Down Expand Up @@ -182,7 +182,7 @@ void MainWindow::on_action_triggered()
pHudLayout = dynamic_cast<IHudLayout*>(m_pSceneGraph->GetPlot()->CreateSceneNode("IHudLayout"));

pHudText = dynamic_cast<IHudText*>(m_pSceneGraph->GetPlot()->CreateSceneNode("IHudText"));
// m_pSceneGraph->GetMainWindow()->GetMainViewPoint()->GetHud()->AddHudNode(pHudLayout);
m_pSceneGraph->GetMainWindow()->GetMainViewPoint()->GetHud()->AddHudNode(pHudLayout);

auto pHudImage = dynamic_cast<IHudImage*>(m_pSceneGraph->GetPlot()->CreateSceneNode("IHudImage"));
pHudImage->SetImage("Image/ship.png");
Expand Down Expand Up @@ -323,7 +323,7 @@ void MainWindow::on_action_triggered()
pFlash->SetFlashFreq(0.5);
pFlash->SetFlashColor(color);
pLod->AddSceneNode(pScal);
// m_pSceneGraph->GetRoot()->AddSceneNode(pModel);
m_pSceneGraph->GetRoot()->AddSceneNode(pModel);

// ILabel* pLabel = dynamic_cast<ILabel*>(m_pSceneGraph->GetPlot()->CreateSceneNode("ILabel"));
// pLabel->SetCanPick(true);
Expand All @@ -349,8 +349,8 @@ void MainWindow::on_action_triggered()
vLevelInfo.push_back(1e6);

pLod->SetLevelsInfo(vLevelInfo);
// m_pSceneGraph->GetRoot()->AddSceneNode(pSceneRoot);
// return;
m_pSceneGraph->GetRoot()->AddSceneNode(pSceneRoot);
return;
m_pLayer = m_pSceneGraph->GetMap()->CreateLayer("test");
pEarthLocation = dynamic_cast<IMapLocation*>(m_pSceneGraph->GetPlot()->CreateSceneNode("IMapLocation"));
// m_pLayer->AddSceneNode(pEarthLocation);
Expand Down
4 changes: 2 additions & 2 deletions SceneCore/SceneGraph/DealViewPortChange.h
Original file line number Diff line number Diff line change
Expand Up @@ -104,10 +104,10 @@ class ChangeViewPoint:public osg::Operation
};

/// 更改视点
class HomeViewPoint:public osg::Operation
class HomeViewPointOperation:public osg::Operation
{
public:
HomeViewPoint(osgGA::CameraManipulator* pManipulator):m_pManipulator(pManipulator){}
HomeViewPointOperation(osgGA::CameraManipulator* pManipulator):m_pManipulator(pManipulator){}

void operator()(osg::Object*)
{
Expand Down
37 changes: 18 additions & 19 deletions SceneCore/SceneGraph/QtViewPort.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -343,27 +343,26 @@ void QtViewPort::FrameEvent()
}
m_bViewPointChanged=false;
}
}

if(m_bBackHome)
void QtViewPort::HomeViewPoint()
{
switch(m_emType)
{
switch(m_emType)
{
case View_3DMap:
m_p3DEarthManipulator->home(0.);
break;
case View_2DMap:
m_p2DEarthManipulator->home(0.);
break;
case View_Node:
m_pTrackManipulator->home(0.);
break;
case View_Osg:
m_pTrackManipulator->home(0.);
break;
default:
break;
}
m_bBackHome=false;
case View_3DMap:
m_pRender->AddUpdateOperation(new HomeViewPointOperation(m_p3DEarthManipulator));
break;
case View_2DMap:
m_pRender->AddUpdateOperation(new HomeViewPointOperation(m_p2DEarthManipulator));
break;
case View_Node:
m_pRender->AddUpdateOperation(new HomeViewPointOperation(m_pTrackManipulator));
break;
case View_Osg:
m_pRender->AddUpdateOperation(new HomeViewPointOperation(m_pSelfManipulator));
break;
default:
break;
}
}

Expand Down
5 changes: 2 additions & 3 deletions SceneCore/SceneGraph/QtViewPort.h
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ class QtViewPort :public IViewPort,public IOsgViewPoint
/**
* @brief 回到Home视点
*/
void HomeViewPoint(){m_bBackHome=true;}
void HomeViewPoint();
protected:
/// 立体显示模式更改
void StereoChanged(){m_bStereoChanged=true;}
Expand All @@ -72,7 +72,7 @@ class QtViewPort :public IViewPort,public IOsgViewPoint
osg::ref_ptr<CMyEarthManipulator> m_p3DEarthManipulator; ///三维地图操作器
osg::ref_ptr<osgGA::TrackballManipulator> m_pSelfManipulator; /// 没有地图的操作器
osg::ref_ptr<osgGA::NodeTrackerManipulator> m_pTrackManipulator; /// 跟踪操作器
ViewPointType m_emType=View_User;
ViewPointType m_emType=View_Osg;
ViewPointType m_emPreType;
double m_dTimes=0.;
SceneViewPoint m_stViewPoint;
Expand All @@ -83,7 +83,6 @@ class QtViewPort :public IViewPort,public IOsgViewPoint
bool m_bStereoChanged=false;
bool m_bHomePointChanged=false; /// home视点更改
bool m_bViewPointChanged=false; /// 视点更改
bool m_bBackHome=false;
};

#endif // QT_VIEWPORT_H

0 comments on commit 4ad1244

Please sign in to comment.