diff --git a/examples/SharedMemory/PhysicsServerExample.cpp b/examples/SharedMemory/PhysicsServerExample.cpp index 7ffa48b21..52c8e6097 100644 --- a/examples/SharedMemory/PhysicsServerExample.cpp +++ b/examples/SharedMemory/PhysicsServerExample.cpp @@ -25,6 +25,8 @@ //@todo(erwincoumans) those globals are hacks for a VR demo, move this to Python/pybullet! extern btVector3 gLastPickPos; +bool gEnablePicking=true; +bool gEnableTeleporting=true; btVector3 gVRTeleportPosLocal(0,0,0); btQuaternion gVRTeleportOrnLocal(0,0,0,1); @@ -565,7 +567,11 @@ public: m_childGuiHelper->setVisualizerFlag(flag,enable); } - + void setVisualizerFlagCallback(VisualizerFlagCallback callback) + { + m_childGuiHelper->setVisualizerFlagCallback(callback); + } + GUIHelperInterface* m_childGuiHelper; int m_uidGenerator; @@ -998,6 +1004,10 @@ public: } + + + + const char* m_mp4FileName; virtual void dumpFramesToVideo(const char* mp4FileName) { @@ -2015,28 +2025,31 @@ void PhysicsServerExample::renderScene() } m_physicsServer.renderScene(); - for (int i=0;igetAppInterface()->m_renderer->drawLine(from,toX,color,width); - color=btVector4(0,1,0,1); - m_guiHelper->getAppInterface()->m_renderer->drawLine(from,toY,color,width); - color=btVector4(0,0,1,1); - m_guiHelper->getAppInterface()->m_renderer->drawLine(from,toZ,color,width); + btVector4 color; + color=btVector4(1,0,0,1); + m_guiHelper->getAppInterface()->m_renderer->drawLine(from,toX,color,width); + color=btVector4(0,1,0,1); + m_guiHelper->getAppInterface()->m_renderer->drawLine(from,toY,color,width); + color=btVector4(0,0,1,1); + m_guiHelper->getAppInterface()->m_renderer->drawLine(from,toZ,color,width); + } } } @@ -2132,10 +2145,12 @@ btVector3 PhysicsServerExample::getRayTo(int x,int y) extern int gSharedMemoryKey; + class CommonExampleInterface* PhysicsServerCreateFunc(struct CommonExampleOptions& options) { MultiThreadedOpenGLGuiHelper* guiHelperWrapper = new MultiThreadedOpenGLGuiHelper(options.m_guiHelper->getAppInterface(),options.m_guiHelper); + PhysicsServerExample* example = new PhysicsServerExample(guiHelperWrapper, options.m_sharedMem, @@ -2250,7 +2265,7 @@ void PhysicsServerExample::vrControllerButtonCallback(int controllerId, int butt } - if (button==1) + if (button==1 && gEnableTeleporting) { m_args[0].m_isVrControllerTeleporting[controllerId] = true; } @@ -2262,7 +2277,7 @@ void PhysicsServerExample::vrControllerButtonCallback(int controllerId, int butt else { - if (button == 33) + if (button == 33 && gEnablePicking) { m_args[0].m_isVrControllerPicking[controllerId] = (state != 0); m_args[0].m_isVrControllerReleasing[controllerId] = (state == 0); diff --git a/examples/SharedMemory/SharedMemoryPublic.h b/examples/SharedMemory/SharedMemoryPublic.h index f451e7a79..ef0590e02 100644 --- a/examples/SharedMemory/SharedMemoryPublic.h +++ b/examples/SharedMemory/SharedMemoryPublic.h @@ -495,6 +495,8 @@ enum b3ConfigureDebugVisualizerEnum COV_ENABLE_GUI=1, COV_ENABLE_SHADOWS, COV_ENABLE_WIREFRAME, + COV_ENABLE_VR_TELEPORTING, + COV_ENABLE_VR_PICKING, }; enum eCONNECT_METHOD { diff --git a/examples/SharedMemory/TinyRendererVisualShapeConverter.cpp b/examples/SharedMemory/TinyRendererVisualShapeConverter.cpp index c8d4b92e7..8c03556cf 100644 --- a/examples/SharedMemory/TinyRendererVisualShapeConverter.cpp +++ b/examples/SharedMemory/TinyRendererVisualShapeConverter.cpp @@ -516,7 +516,6 @@ void TinyRendererVisualShapeConverter::convertVisualShapes( btAssert(linkPtr); // TODO: remove if (not doing it now, because diff will be 50+ lines) if (linkPtr) { - const btArray* shapeArray; bool useVisual; int cnt = 0; if (linkPtr->m_visualArray.size() > 0) diff --git a/examples/StandaloneMain/hellovr_opengl_main.cpp b/examples/StandaloneMain/hellovr_opengl_main.cpp index 518fc98e8..c5636f570 100644 --- a/examples/StandaloneMain/hellovr_opengl_main.cpp +++ b/examples/StandaloneMain/hellovr_opengl_main.cpp @@ -367,6 +367,47 @@ void MyKeyboardCallback(int key, int state) prevKeyboardCallback(key,state); } + + + + +#include "../SharedMemory/SharedMemoryPublic.h" +extern bool useShadowMap; +extern int gDebugDrawFlags; + +extern bool gEnablePicking; +extern bool gEnableTeleporting; + +void VRPhysicsServerVisualizerFlagCallback(int flag, bool enable) +{ + if (flag == COV_ENABLE_SHADOWS) + { + useShadowMap = enable; + } + if (flag == COV_ENABLE_GUI) + { + //there is no regular GUI here, but disable the + } + + if (flag==COV_ENABLE_VR_TELEPORTING) + { + gEnableTeleporting = enable; + } + + if (flag == COV_ENABLE_VR_PICKING) + { + gEnablePicking = enable; + } + + if (flag == COV_ENABLE_WIREFRAME) + { + gDebugDrawFlags |= btIDebugDraw::DBG_DrawWireframe; + } else + { + gDebugDrawFlags &= ~btIDebugDraw::DBG_DrawWireframe; + } +} + //----------------------------------------------------------------------------- // Purpose: //----------------------------------------------------------------------------- @@ -418,6 +459,7 @@ bool CMainApplication::BInit() sGuiPtr = new OpenGLGuiHelper(m_app,false); + sGuiPtr->setVisualizerFlagCallback(VRPhysicsServerVisualizerFlagCallback); sGuiPtr->setVRMode(true); //sGuiPtr = new DummyGUIHelper; diff --git a/examples/pybullet/pybullet.c b/examples/pybullet/pybullet.c index 51e40307f..7732a1559 100644 --- a/examples/pybullet/pybullet.c +++ b/examples/pybullet/pybullet.c @@ -6346,6 +6346,8 @@ initpybullet(void) PyModule_AddIntConstant(m, "COV_ENABLE_GUI", COV_ENABLE_GUI); PyModule_AddIntConstant(m, "COV_ENABLE_SHADOWS", COV_ENABLE_SHADOWS); PyModule_AddIntConstant(m, "COV_ENABLE_WIREFRAME", COV_ENABLE_WIREFRAME); + PyModule_AddIntConstant(m, "COV_ENABLE_VR_PICKING", COV_ENABLE_VR_PICKING); + PyModule_AddIntConstant(m, "COV_ENABLE_VR_TELEPORTING", COV_ENABLE_VR_TELEPORTING); PyModule_AddIntConstant(m, "ER_TINY_RENDERER", ER_TINY_RENDERER); PyModule_AddIntConstant(m, "ER_BULLET_HARDWARE_OPENGL", ER_BULLET_HARDWARE_OPENGL);