Allow to build PhysicsServer in VR mode, to see the URDF/SDF robots in proper scale in VR.
Add option to have Z as up-axis for VR examples. Add OpenVR LICENSE + README file Don't crash VR app when no HMD is detected, just exit. For now, don't request debug lines in client, it slows down physics server in VR mode too much.
This commit is contained in:
@@ -2,7 +2,7 @@
|
||||
rem premake4 --with-pe vs2010
|
||||
rem premake4 --bullet2demos vs2010
|
||||
cd build3
|
||||
premake4 --targetdir="../bin" vs2010
|
||||
premake4 --enable_openvr --targetdir="../bin" vs2010
|
||||
rem premake4 --targetdir="../server2bin" vs2010
|
||||
rem cd vs2010
|
||||
rem rename 0_Bullet3Solution.sln 0_server.sln
|
||||
|
||||
@@ -835,7 +835,7 @@ void PhysicsClientExample::stepSimulation(float deltaTime)
|
||||
enqueueCommand(CMD_STEP_FORWARD_SIMULATION);
|
||||
if (m_options != eCLIENTEXAMPLE_SERVER)
|
||||
{
|
||||
enqueueCommand(CMD_REQUEST_DEBUG_LINES);
|
||||
//enqueueCommand(CMD_REQUEST_DEBUG_LINES);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -855,3 +855,4 @@ class CommonExampleInterface* PhysicsClientCreateFunc(struct CommonExampleOpt
|
||||
}
|
||||
return example;
|
||||
}
|
||||
|
||||
|
||||
@@ -306,3 +306,5 @@ class CommonExampleInterface* PhysicsServerCreateFunc(struct CommonExampleOpt
|
||||
return example;
|
||||
|
||||
}
|
||||
|
||||
B3_STANDALONE_EXAMPLE(PhysicsServerCreateFunc)
|
||||
@@ -15,7 +15,8 @@ links {
|
||||
|
||||
language "C++"
|
||||
|
||||
files {
|
||||
myfiles =
|
||||
{
|
||||
"PhysicsClient.cpp",
|
||||
"PhysicsClientSharedMemory.cpp",
|
||||
"PhysicsClientExample.cpp",
|
||||
@@ -24,7 +25,6 @@ files {
|
||||
"PhysicsServerSharedMemory.h",
|
||||
"PhysicsServer.cpp",
|
||||
"PhysicsServer.h",
|
||||
"main.cpp",
|
||||
"PhysicsClientC_API.cpp",
|
||||
"SharedMemoryCommands.h",
|
||||
"SharedMemoryPublic.h",
|
||||
@@ -84,3 +84,61 @@ files {
|
||||
"../ThirdPartyLibs/stb_image/stb_image.cpp",
|
||||
}
|
||||
|
||||
files {
|
||||
myfiles,
|
||||
"main.cpp",
|
||||
}
|
||||
|
||||
|
||||
|
||||
project "App_SharedMemoryPhysics_VR"
|
||||
|
||||
defines {"B3_USE_STANDALONE_EXAMPLE","BT_ENABLE_VR"}
|
||||
|
||||
if _OPTIONS["ios"] then
|
||||
kind "WindowedApp"
|
||||
else
|
||||
kind "ConsoleApp"
|
||||
end
|
||||
|
||||
includedirs {
|
||||
".","../../src", "../ThirdPartyLibs",
|
||||
"../ThirdPartyLibs/openvr/headers",
|
||||
"../ThirdPartyLibs/openvr/samples/shared"
|
||||
}
|
||||
|
||||
links {
|
||||
"Bullet3Common", "BulletDynamics","BulletCollision", "LinearMath","OpenGL_Window","openvr_api"
|
||||
}
|
||||
|
||||
language "C++"
|
||||
|
||||
|
||||
initOpenGL()
|
||||
initGlew()
|
||||
|
||||
|
||||
files
|
||||
{
|
||||
myfiles,
|
||||
"../StandaloneMain/hellovr_opengl_main.cpp",
|
||||
"../ExampleBrowser/OpenGLGuiHelper.cpp",
|
||||
"../ExampleBrowser/GL_ShapeDrawer.cpp",
|
||||
"../ExampleBrowser/CollisionShape2TriangleMesh.cpp",
|
||||
"../ThirdPartyLibs/openvr/samples/shared/lodepng.cpp",
|
||||
"../ThirdPartyLibs/openvr/samples/shared/lodepng.h",
|
||||
"../ThirdPartyLibs/openvr/samples/shared/Matrices.cpp",
|
||||
"../ThirdPartyLibs/openvr/samples/shared/Matrices.h",
|
||||
"../ThirdPartyLibs/openvr/samples/shared/pathtools.cpp",
|
||||
"../ThirdPartyLibs/openvr/samples/shared/pathtools.h",
|
||||
"../ThirdPartyLibs/openvr/samples/shared/Vectors.h",
|
||||
}
|
||||
if os.is("Windows") then
|
||||
libdirs {"../ThirdPartyLibs/openvr/lib/win32"}
|
||||
end
|
||||
|
||||
if os.is("Linux") then initX11() end
|
||||
|
||||
if os.is("MacOSX") then
|
||||
links{"Cocoa.framework"}
|
||||
end
|
||||
@@ -11,6 +11,7 @@
|
||||
#include "BulletCollision/CollisionShapes/btCollisionShape.h"
|
||||
#include "BulletDynamics/Dynamics/btDiscreteDynamicsWorld.h"
|
||||
|
||||
int gSharedMemoryKey = -1;
|
||||
|
||||
//how can you try typing on a keyboard, without seeing it?
|
||||
//it is pretty funny, to see the desktop in VR!
|
||||
@@ -139,7 +140,7 @@ private:
|
||||
SimpleOpenGL3App* m_app;
|
||||
uint32_t m_nWindowWidth;
|
||||
uint32_t m_nWindowHeight;
|
||||
|
||||
bool m_hasContext;
|
||||
|
||||
private: // OpenGL bookkeeping
|
||||
int m_iTrackedControllerCount;
|
||||
@@ -234,6 +235,7 @@ private: // OpenGL bookkeeping
|
||||
//-----------------------------------------------------------------------------
|
||||
CMainApplication::CMainApplication( int argc, char *argv[] )
|
||||
: m_app(NULL)
|
||||
, m_hasContext(false)
|
||||
, m_nWindowWidth( 1280 )
|
||||
, m_nWindowHeight( 720 )
|
||||
, m_unSceneProgramID( 0 )
|
||||
@@ -556,13 +558,16 @@ void CMainApplication::Shutdown()
|
||||
}
|
||||
m_vecRenderModels.clear();
|
||||
|
||||
if( 1)//m_pContext )
|
||||
if( m_hasContext)
|
||||
{
|
||||
glDebugMessageControl( GL_DONT_CARE, GL_DONT_CARE, GL_DONT_CARE, 0, nullptr, GL_FALSE );
|
||||
glDebugMessageCallback(nullptr, nullptr);
|
||||
glDeleteBuffers(1, &m_glSceneVertBuffer);
|
||||
glDeleteBuffers(1, &m_glIDVertBuffer);
|
||||
glDeleteBuffers(1, &m_glIDIndexBuffer);
|
||||
if (m_glSceneVertBuffer)
|
||||
{
|
||||
glDebugMessageControl( GL_DONT_CARE, GL_DONT_CARE, GL_DONT_CARE, 0, nullptr, GL_FALSE );
|
||||
glDebugMessageCallback(nullptr, nullptr);
|
||||
glDeleteBuffers(1, &m_glSceneVertBuffer);
|
||||
glDeleteBuffers(1, &m_glIDVertBuffer);
|
||||
glDeleteBuffers(1, &m_glIDIndexBuffer);
|
||||
}
|
||||
|
||||
if ( m_unSceneProgramID )
|
||||
{
|
||||
@@ -1067,6 +1072,7 @@ void CMainApplication::SetupScene()
|
||||
glDisableVertexAttribArray(0);
|
||||
glDisableVertexAttribArray(1);
|
||||
|
||||
m_hasContext = true;
|
||||
}
|
||||
|
||||
|
||||
@@ -1462,10 +1468,19 @@ void CMainApplication::RenderStereoTargets()
|
||||
m_app->m_instancingRenderer->init();
|
||||
|
||||
|
||||
Matrix4 rotYtoZ = rotYtoZ.identity();
|
||||
|
||||
//some Bullet apps (especially robotics related) require Z as up-axis)
|
||||
if (m_app->getUpAxis()==2)
|
||||
{
|
||||
rotYtoZ.rotateX(-90);
|
||||
}
|
||||
|
||||
// Left Eye
|
||||
{
|
||||
Matrix4 viewMatLeft = m_mat4eyePosLeft * m_mat4HMDPose;
|
||||
|
||||
Matrix4 viewMatLeft = m_mat4eyePosLeft * m_mat4HMDPose * rotYtoZ;
|
||||
|
||||
m_app->m_instancingRenderer->getActiveCamera()->setVRCamera(viewMatLeft.get(),m_mat4ProjectionLeft.get());
|
||||
m_app->m_instancingRenderer->updateCamera();
|
||||
}
|
||||
@@ -1477,8 +1492,9 @@ void CMainApplication::RenderStereoTargets()
|
||||
|
||||
m_app->m_window->startRendering();
|
||||
RenderScene( vr::Eye_Left );
|
||||
|
||||
m_app->drawGrid();
|
||||
DrawGridData gridUp;
|
||||
gridUp.upAxis = m_app->getUpAxis();
|
||||
m_app->drawGrid(gridUp);
|
||||
sExample->stepSimulation(1./60.);
|
||||
sExample->renderScene();
|
||||
|
||||
@@ -1507,7 +1523,7 @@ void CMainApplication::RenderStereoTargets()
|
||||
// Right Eye
|
||||
|
||||
{
|
||||
Matrix4 viewMatRight = m_mat4eyePosRight * m_mat4HMDPose;
|
||||
Matrix4 viewMatRight = m_mat4eyePosRight * m_mat4HMDPose * rotYtoZ;
|
||||
m_app->m_instancingRenderer->getActiveCamera()->setVRCamera(viewMatRight.get(),m_mat4ProjectionRight.get());
|
||||
m_app->m_instancingRenderer->updateCamera();
|
||||
}
|
||||
@@ -1518,7 +1534,7 @@ void CMainApplication::RenderStereoTargets()
|
||||
m_app->m_window->startRendering();
|
||||
RenderScene( vr::Eye_Right );
|
||||
|
||||
m_app->drawGrid();
|
||||
m_app->drawGrid(gridUp);
|
||||
m_app->m_instancingRenderer->setRenderFrameBuffer((unsigned int)rightEyeDesc.m_nRenderFramebufferId);
|
||||
|
||||
m_app->m_renderer->renderScene();
|
||||
|
||||
27
examples/ThirdPartyLibs/openvr/LICENSE
Normal file
27
examples/ThirdPartyLibs/openvr/LICENSE
Normal file
@@ -0,0 +1,27 @@
|
||||
Copyright (c) 2015, Valve Corporation
|
||||
All rights reserved.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without modification,
|
||||
are permitted provided that the following conditions are met:
|
||||
|
||||
1. Redistributions of source code must retain the above copyright notice, this
|
||||
list of conditions and the following disclaimer.
|
||||
|
||||
2. Redistributions in binary form must reproduce the above copyright notice,
|
||||
this list of conditions and the following disclaimer in the documentation and/or
|
||||
other materials provided with the distribution.
|
||||
|
||||
3. Neither the name of the copyright holder nor the names of its contributors
|
||||
may be used to endorse or promote products derived from this software without
|
||||
specific prior written permission.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
||||
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR
|
||||
ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
|
||||
ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
9
examples/ThirdPartyLibs/openvr/README
Normal file
9
examples/ThirdPartyLibs/openvr/README
Normal file
@@ -0,0 +1,9 @@
|
||||
OpenVR is an API and runtime that allows access to VR hardware from multiple
|
||||
vendors without requiring that applications have specific knowledge of the
|
||||
hardware they are targeting. This repository is an SDK that contains the API
|
||||
and samples. The runtime is under SteamVR in Tools on Steam.
|
||||
|
||||
Documentation for the API is available in the wiki: https://github.com/ValveSoftware/openvr/wiki/API-Documentation
|
||||
|
||||
More information on OpenVR and SteamVR can be found on http://steamvr.com
|
||||
|
||||
Reference in New Issue
Block a user