All: Reformat according to new standard
This commit is contained in:
committed by
Kacper Donat
parent
eafd18dac0
commit
25c3ba7338
@@ -21,76 +21,80 @@
|
||||
***************************************************************************/
|
||||
|
||||
|
||||
|
||||
|
||||
#if BUILD_VR
|
||||
|
||||
#include <App/Application.h>
|
||||
#include <Base/Console.h>
|
||||
# include <App/Application.h>
|
||||
# include <Base/Console.h>
|
||||
|
||||
#include "View3DInventorRiftViewer.h"
|
||||
# include "View3DInventorRiftViewer.h"
|
||||
|
||||
|
||||
using namespace Gui;
|
||||
|
||||
View3DInventorRiftViewer::View3DInventorRiftViewer() : CoinRiftWidget()
|
||||
View3DInventorRiftViewer::View3DInventorRiftViewer()
|
||||
: CoinRiftWidget()
|
||||
{
|
||||
workplace = new SoGroup();
|
||||
|
||||
//translation = new SoTranslation ;
|
||||
//translation->translation.setValue(0,-1,0);
|
||||
//workplace->addChild(translation);
|
||||
// translation = new SoTranslation ;
|
||||
// translation->translation.setValue(0,-1,0);
|
||||
// workplace->addChild(translation);
|
||||
|
||||
rotation1 = new SoRotationXYZ ;
|
||||
rotation1 = new SoRotationXYZ;
|
||||
rotation1->axis.setValue(SoRotationXYZ::X);
|
||||
rotation1->angle.setValue(-std::numbers::pi/2);
|
||||
rotation1->angle.setValue(-std::numbers::pi / 2);
|
||||
workplace->addChild(rotation1);
|
||||
|
||||
rotation2 = new SoRotationXYZ ;
|
||||
rotation2 = new SoRotationXYZ;
|
||||
rotation2->axis.setValue(SoRotationXYZ::Z);
|
||||
rotation2->angle.setValue(0);
|
||||
workplace->addChild(rotation2);
|
||||
|
||||
|
||||
scale = new SoScale ;
|
||||
scale->scaleFactor.setValue(0.001f,0.001f,0.001f); // scale from mm to m as needed by the Rift
|
||||
scale = new SoScale;
|
||||
scale->scaleFactor.setValue(0.001f, 0.001f, 0.001f); // scale from mm to m as needed by the Rift
|
||||
workplace->addChild(scale);
|
||||
|
||||
ParameterGrp::handle hGrp = App::GetApplication().GetParameterGroupByPath("User parameter:BaseApp/Preferences/Oculus");
|
||||
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)
|
||||
);
|
||||
this->setGeometry(
|
||||
hGrp->GetInt("RenderWindowPosX", 100),
|
||||
hGrp->GetInt("RenderWindowPosY", 100),
|
||||
hGrp->GetInt("RenderWindowSizeW", 1920),
|
||||
hGrp->GetInt("RenderWindowSizeH", 1080)
|
||||
);
|
||||
|
||||
|
||||
setBackgroundColor(SbColor(51,51,101));
|
||||
setBackgroundColor(SbColor(51, 51, 101));
|
||||
basePosition = SbVec3f(0.0f, 0.5f, 0.8f);
|
||||
}
|
||||
|
||||
//void saveWinPosition(void)
|
||||
// void saveWinPosition(void)
|
||||
//{
|
||||
//
|
||||
//
|
||||
//
|
||||
//}
|
||||
// }
|
||||
|
||||
View3DInventorRiftViewer::~View3DInventorRiftViewer()
|
||||
{
|
||||
ParameterGrp::handle hGrp = App::GetApplication().GetParameterGroupByPath("User parameter:BaseApp/Preferences/Oculus");
|
||||
ParameterGrp::handle hGrp = App::GetApplication().GetParameterGroupByPath(
|
||||
"User parameter:BaseApp/Preferences/Oculus"
|
||||
);
|
||||
|
||||
// remember last position on close
|
||||
hGrp->SetInt("RenderWindowPosX",pos().x());
|
||||
hGrp->SetInt("RenderWindowPosY",pos().y());
|
||||
hGrp->SetInt("RenderWindowSizeW",size().width());
|
||||
hGrp->SetInt("RenderWindowSizeH",size().height());
|
||||
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());
|
||||
Base::Console()
|
||||
.log("pos: %d %d size: %d %d \n", pos().x(), pos().y(), size().width(), size().height());
|
||||
}
|
||||
|
||||
void View3DInventorRiftViewer::setSceneGraph(SoNode *sceneGraph)
|
||||
void View3DInventorRiftViewer::setSceneGraph(SoNode* sceneGraph)
|
||||
{
|
||||
|
||||
workplace->addChild(sceneGraph);
|
||||
@@ -99,51 +103,57 @@ void View3DInventorRiftViewer::setSceneGraph(SoNode *sceneGraph)
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
void View3DInventorRiftViewer::keyPressEvent(QKeyEvent *event)
|
||||
void View3DInventorRiftViewer::keyPressEvent(QKeyEvent* event)
|
||||
{
|
||||
static const float increment = 0.02; // move two centimeter per key
|
||||
static const float rotIncrement = std::numbers::pi / 4; // move two 90° per key
|
||||
static const float increment = 0.02; // move two centimeter per key
|
||||
static const float rotIncrement = std::numbers::pi / 4; // move two 90° per key
|
||||
|
||||
|
||||
if (event->key() == Qt::Key_Plus) {
|
||||
scale->scaleFactor.setValue(scale->scaleFactor.getValue() * 2.0f) ;
|
||||
} else if (event->key() == Qt::Key_Minus) {
|
||||
scale->scaleFactor.setValue(scale->scaleFactor.getValue() * 0.2f) ;
|
||||
} else if (event->key() == Qt::Key_S) {
|
||||
basePosition += SbVec3f(0,0,increment) ;
|
||||
} else if (event->key() == Qt::Key_W) {
|
||||
basePosition += SbVec3f(0,0,-increment) ;
|
||||
} else if (event->key() == Qt::Key_Up) {
|
||||
basePosition += SbVec3f(0,-increment,0) ;
|
||||
} else if (event->key() == Qt::Key_Down) {
|
||||
basePosition += SbVec3f(0,increment,0) ;
|
||||
} else if (event->key() == Qt::Key_Left) {
|
||||
rotation2->angle.setValue( rotation2->angle.getValue() + rotIncrement);
|
||||
} else if (event->key() == Qt::Key_Right) {
|
||||
rotation2->angle.setValue( rotation2->angle.getValue() - rotIncrement);
|
||||
} else if (event->key() == Qt::Key_A) {
|
||||
basePosition += SbVec3f(-increment,0,0) ;
|
||||
} else if (event->key() == Qt::Key_D) {
|
||||
basePosition += SbVec3f(increment,0,0) ;
|
||||
} else {
|
||||
scale->scaleFactor.setValue(scale->scaleFactor.getValue() * 2.0f);
|
||||
}
|
||||
else if (event->key() == Qt::Key_Minus) {
|
||||
scale->scaleFactor.setValue(scale->scaleFactor.getValue() * 0.2f);
|
||||
}
|
||||
else if (event->key() == Qt::Key_S) {
|
||||
basePosition += SbVec3f(0, 0, increment);
|
||||
}
|
||||
else if (event->key() == Qt::Key_W) {
|
||||
basePosition += SbVec3f(0, 0, -increment);
|
||||
}
|
||||
else if (event->key() == Qt::Key_Up) {
|
||||
basePosition += SbVec3f(0, -increment, 0);
|
||||
}
|
||||
else if (event->key() == Qt::Key_Down) {
|
||||
basePosition += SbVec3f(0, increment, 0);
|
||||
}
|
||||
else if (event->key() == Qt::Key_Left) {
|
||||
rotation2->angle.setValue(rotation2->angle.getValue() + rotIncrement);
|
||||
}
|
||||
else if (event->key() == Qt::Key_Right) {
|
||||
rotation2->angle.setValue(rotation2->angle.getValue() - rotIncrement);
|
||||
}
|
||||
else if (event->key() == Qt::Key_A) {
|
||||
basePosition += SbVec3f(-increment, 0, 0);
|
||||
}
|
||||
else if (event->key() == Qt::Key_D) {
|
||||
basePosition += SbVec3f(increment, 0, 0);
|
||||
}
|
||||
else {
|
||||
|
||||
CoinRiftWidget::keyPressEvent(event);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
// static test code ================================================================================
|
||||
static View3DInventorRiftViewer *window=0;
|
||||
static View3DInventorRiftViewer* window = 0;
|
||||
|
||||
void oculusSetTestScene(View3DInventorRiftViewer *window)
|
||||
void oculusSetTestScene(View3DInventorRiftViewer* window)
|
||||
{
|
||||
assert(window);
|
||||
// An example scene.
|
||||
static const char * inlineSceneGraph[] = {
|
||||
static const char* inlineSceneGraph[] = {
|
||||
"#Inventor V2.1 ascii\n",
|
||||
"\n",
|
||||
"Separator {\n",
|
||||
@@ -184,44 +194,43 @@ void oculusSetTestScene(View3DInventorRiftViewer *window)
|
||||
|
||||
void oculusStop()
|
||||
{
|
||||
//SoDB::finish();
|
||||
if(window){
|
||||
// SoDB::finish();
|
||||
if (window) {
|
||||
delete window;
|
||||
window = 0;
|
||||
ovr_Shutdown();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
bool oculusUp(void)
|
||||
{
|
||||
return window!=0;
|
||||
return window != 0;
|
||||
}
|
||||
|
||||
View3DInventorRiftViewer* oculusStart(void)
|
||||
{
|
||||
//SoDB::init();
|
||||
// SoDB::init();
|
||||
|
||||
//QApplication app(argc, argv);
|
||||
//qAddPostRoutine(cleanup);
|
||||
// QApplication app(argc, argv);
|
||||
// qAddPostRoutine(cleanup);
|
||||
|
||||
// Moved here because of https://developer.oculusvr.com/forums/viewtopic.php?f=17&t=7915&p=108503#p108503
|
||||
// Init libovr.
|
||||
// Moved here because of
|
||||
// https://developer.oculusvr.com/forums/viewtopic.php?f=17&t=7915&p=108503#p108503 Init libovr.
|
||||
if (!ovr_Initialize()) {
|
||||
qDebug() << "Could not initialize Oculus SDK.";
|
||||
return 0;
|
||||
}
|
||||
if(window)
|
||||
if (window) {
|
||||
return window;
|
||||
}
|
||||
|
||||
window = new View3DInventorRiftViewer;
|
||||
window->show();
|
||||
|
||||
|
||||
return window;
|
||||
//return app.exec();
|
||||
// return app.exec();
|
||||
}
|
||||
|
||||
|
||||
|
||||
#endif //BUILD_VR
|
||||
#endif // BUILD_VR
|
||||
|
||||
Reference in New Issue
Block a user