From 4c7fb2d0f0d9687aa7ee5547c3a771b50d7ff253 Mon Sep 17 00:00:00 2001 From: jriegel Date: Wed, 17 Sep 2014 15:01:28 +0200 Subject: [PATCH] FreeCAD-VR: Upright position and remembering render window position --- src/Gui/View3DInventorRiftViewer.cpp | 73 ++++++++++++++++++++++++++++ src/Gui/View3DInventorRiftViewer.h | 15 +++++- src/Gui/View3DInventorViewer.cpp | 2 +- 3 files changed, 88 insertions(+), 2 deletions(-) diff --git a/src/Gui/View3DInventorRiftViewer.cpp b/src/Gui/View3DInventorRiftViewer.cpp index 06a2cc9f4..f4f647ba6 100644 --- a/src/Gui/View3DInventorRiftViewer.cpp +++ b/src/Gui/View3DInventorRiftViewer.cpp @@ -26,12 +26,85 @@ #if BUILD_VR +#include #include "View3DInventorRiftViewer.h" +#include #define new DEBUG_CLIENTBLOCK using namespace Gui; +View3DInventorRiftViewer::View3DInventorRiftViewer() : CoinRiftWidget() +{ + workplace = new SoGroup(); + translation = new SoTranslation ; + rotation = new SoRotationXYZ ; + rotation->axis.setValue(SoRotationXYZ::X); + rotation->angle.setValue(M_PI/4); + workplace->addChild(rotation); + + + scale = new SoScale ; + scale->scaleFactor.setValue(0.01f,0.01f,0.01f); // scale from mm to m as neede by the Rift + workplace->addChild(scale); + + ParameterGrp::handle hGrp = App::GetApplication().GetParameterGroupByPath("User parameter:BaseApp/Preferences/Oculus"); + + this->setGeometry( hGrp->GetInt("RenderWindowPosX",100) , + hGrp->GetInt("RenderWindowPosY",100) , + hGrp->GetInt("RenderWindowSizeW",1920) , + hGrp->GetInt("RenderWindowSizeH",1080) + ); + + +} + +//void saveWinPostion(void) +//{ +// +// +// +//} + +View3DInventorRiftViewer::~View3DInventorRiftViewer() +{ + ParameterGrp::handle hGrp = App::GetApplication().GetParameterGroupByPath("User parameter:BaseApp/Preferences/Oculus"); + + // remeber last postion on close + hGrp->SetInt("RenderWindowPosX",pos().x()); + hGrp->SetInt("RenderWindowPosY",pos().y()); + hGrp->SetInt("RenderWindowSizeW",size().width()); + hGrp->SetInt("RenderWindowSizeH",size().height()); + + Base::Console().Log("pos: %d %d size: %d %d \n",pos().x(),pos().y(), + size().width(),size().height()); +} + +void View3DInventorRiftViewer::setSceneGraph(SoNode *sceneGraph) +{ + + workplace->addChild(sceneGraph); + + CoinRiftWidget::setSceneGraph(workplace); +} + + + + +void View3DInventorRiftViewer::keyPressEvent(QKeyEvent *event) +{ + if ((event->key() == Qt::Key_Delete + || event->key() == Qt::Key_Backspace)) { + ; // TODO + } else { + CoinRiftWidget::keyPressEvent(event); + } +} + + + + +// static test code ================================================================================ static View3DInventorRiftViewer *window=0; void oculusSetTestScene(View3DInventorRiftViewer *window) diff --git a/src/Gui/View3DInventorRiftViewer.h b/src/Gui/View3DInventorRiftViewer.h index 3f08b720c..6c33ec235 100644 --- a/src/Gui/View3DInventorRiftViewer.h +++ b/src/Gui/View3DInventorRiftViewer.h @@ -31,7 +31,20 @@ namespace Gui { class View3DInventorRiftViewer : public CoinRiftWidget { - +public: + View3DInventorRiftViewer(); + ~View3DInventorRiftViewer(); + + virtual void setSceneGraph(SoNode *sceneGraph); + +protected: + SoGroup *workplace; + SoTranslation *translation; + SoRotationXYZ *rotation; + SoScale *scale; + +protected: + void keyPressEvent(QKeyEvent *); }; diff --git a/src/Gui/View3DInventorViewer.cpp b/src/Gui/View3DInventorViewer.cpp index 82df6e8b3..1a98287ed 100644 --- a/src/Gui/View3DInventorViewer.cpp +++ b/src/Gui/View3DInventorViewer.cpp @@ -1650,7 +1650,7 @@ void View3DInventorViewer::viewVR(void) if(oculusUp()) oculusStop(); else{ -#if 1 +#if 0 // start and load the simple test scene: oculusSetTestScene(oculusStart()); #else