Skip to content

Commit

Permalink
Merge pull request #22 from geefr/cherry-pick-fixes
Browse files Browse the repository at this point in the history
Cherry pick fixes
  • Loading branch information
geefr authored Nov 30, 2022
2 parents 7e56043 + e89b0e7 commit 143f267
Show file tree
Hide file tree
Showing 34 changed files with 195 additions and 74 deletions.
31 changes: 31 additions & 0 deletions .github/workflows/ci-android.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
name: CI Android
on:
push:
pull_request:
env:
CMakeVersion: 3.14.x
jobs:
build:
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [ubuntu-latest]
android-platform: [24, latest]
android-abi: [armeabi-v7a, arm64-v8a, x86, x86_64]
build-shared: [ON, OFF]

steps:
- uses: actions/checkout@v2
- name: Setup cmake
uses: jwlawson/[email protected]
with:
cmake-version: ${{ env.CMakeVersion }}
- name: Setup NDK
uses: nttld/setup-ndk@v1
with:
ndk-version: r25
- name: Build and Install VSGVR
shell: bash
run: |
cmake . -DCMAKE_TOOLCHAIN_FILE=$(dirname $(which ndk-build))/build/cmake/android.toolchain.cmake -DANDROID_ABI=${{matrix.android-abi}} -DANDROID_PLATFORM=${{matrix.android-platform}} -DBUILD_SHARED_LIBS=${{matrix.build-shared}} -DCMAKE_INSTALL_PREFIX=./install
cmake --build . --target install --config Release
35 changes: 35 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
name: CI
on:
push:
pull_request:
env:
BuildDocEnabled: ${{ github.event_name == 'push' && github.ref == 'refs/heads/master' }}
CMakeVersion: 3.14.x
jobs:
build:
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [ubuntu-latest, macos-latest, windows-latest]
vulkan-version: [1.3.224.1]
build-shared: [ON, OFF]

steps:
- uses: actions/checkout@v2
- name: Setup cmake
uses: jwlawson/[email protected]
with:
cmake-version: ${{ env.CMakeVersion }}
- name: Install Vulkan SDK
uses: humbletim/[email protected]
with:
version: ${{ matrix.vulkan-version }}
cache: true
- name: Add MSBuild to PATH
uses: microsoft/[email protected]
if: startsWith(matrix.os, 'windows')
- name: Build and Install VSGVR
shell: bash
run: |
cmake . -DBUILD_SHARED_LIBS=${{matrix.build-shared}} -DCMAKE_INSTALL_PREFIX=./install
cmake --build . --target install --config Release
21 changes: 11 additions & 10 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,23 +2,25 @@ cmake_minimum_required(VERSION 3.14)

project(VSGVR)

include(FetchContent)

option( VSGVR_BUILD_EXAMPLES "Whether to build VSGVR examples or not" ON )
option( BUILD_SHARED_LIBS "Build shared libraries" OFF )
option( VSGVR_BUILD_EXAMPLES "Whether to build VSGVR examples" ON )

if( NOT CMAKE_BUILD_TYPE AND NOT MSVC )
set( CMAKE_BUILD_TYPE Release CACHE STRING "Choose the type of build." FORCE )
set_property( CACHE CMAKE_BUILD_TYPE PROPERTY STRINGS "Release" "Debug" "MinSizeRel" "RelWithDebInfo" )
endif()

if( NOT VSGVR_XR_PLATFORM )
# OPENXR_GENERIC - The standard openxr_loader.so, built from deps/openxr
# OPENXR_SYSTEM - Whatever OpenXR is available via find_package
# OPENXR_OCULUS_MODULE - Oculus specific runtime from their Mobile OpenXR SDK
set( VSGVR_XR_PLATFORM "OPENXR_GENERIC" CACHE STRING "The OpenXR loader / platform combination to build" )
set_property( CACHE VSGVR_XR_PLATFORM PROPERTY STRINGS "OPENXR_GENERIC" "OPENXR_OCULUS_MOBILE" )
set_property( CACHE VSGVR_XR_PLATFORM PROPERTY STRINGS "OPENXR_GENERIC" "OPENXR_SYSTEM" "OPENXR_OCULUS_MOBILE" )
endif()

# Compiler/Tool requirements
set( CMAKE_CXX_STANDARD 17 )
set(OpenGL_GL_PREFERENCE GLVND)
set( OpenGL_GL_PREFERENCE GLVND )

# Package/System requirements
if(ANDROID)
Expand All @@ -29,8 +31,12 @@ endif()

find_package(Vulkan REQUIRED)

set(OpenXR_LIBRARY openxr_loader)
if( VSGVR_XR_PLATFORM STREQUAL "OPENXR_GENERIC" )
add_subdirectory( deps/openxr )
elseif( VSGVR_XR_PLATFORM STREQUAL "OPENXR_SYSTEM" )
find_package(OpenXR REQUIRED)
set(OpenXR_LIBRARY OpenXR::openxr_loader)
elseif( VSGVR_XR_PLATFORM STREQUAL "OPENXR_OCULUS_MOBILE" )
if(NOT ANDROID)
message(FATAL_ERROR "Oculus Mobile SDK is only supported when building for Android")
Expand All @@ -50,12 +56,7 @@ endif()

add_subdirectory( vsgvr )


if( VSGVR_BUILD_EXAMPLES )
add_subdirectory( examples )
endif()

# Copy models into the build dir
configure_file(models/world/world.vsgt ${CMAKE_CURRENT_BINARY_DIR}/world.vsgt COPYONLY)
configure_file(models/controller/controller.vsgt ${CMAKE_CURRENT_BINARY_DIR}/controller.vsgt COPYONLY)
configure_file(models/controller/controller2.vsgt ${CMAKE_CURRENT_BINARY_DIR}/controller2.vsgt COPYONLY)
1 change: 1 addition & 0 deletions examples/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,4 @@ if(ANDROID)
else()
add_subdirectory( generic )
endif()

1 change: 1 addition & 0 deletions examples/generic/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@

add_executable( vsgvr_example_generic main.cpp )
target_link_libraries( vsgvr_example_generic vsg::vsg vsgvr )

35 changes: 33 additions & 2 deletions examples/generic/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,41 @@ int main(int argc, char **argv) {
// set up vsg::Options to pass in filepaths and ReaderWriter's and other IO
// related options to use when reading and writing files.
auto options = vsg::Options::create();
options->paths = vsg::getEnvPaths("VSG_FILE_PATH");
arguments.read(options);

auto vsg_scene = vsg::Group::create();
vsg_scene->addChild(world());

// load the scene graph
// * Load the bulk of the scene from command line, or the built-in world model
// * Always load controllers separately from built-in models
// read any vsg files
for (int i = 1; i < argc; ++i)
{
vsg::Path filename = arguments[i];
auto path = vsg::filePath(filename);
auto object = vsg::read(filename, options);
if (auto node = object.cast<vsg::Node>(); node)
{
vsg_scene->addChild(node);
}
else if (object)
{
std::cerr << "Unable to view object of type " << object->className() << std::endl;
return EXIT_FAILURE;
}
else
{
std::cerr << "Unable to load file " << filename << std::endl;
return EXIT_FAILURE;
}
}

if (vsg_scene->children.size() == 0)
{
std::cerr << "Loading built-in example scene" << std::endl;
vsg_scene->addChild(world());
}

auto controllerNodeLeft = controller();
vsg_scene->addChild(controllerNodeLeft);
Expand Down Expand Up @@ -270,7 +301,7 @@ int main(int argc, char **argv) {
}
catch( const vsg::Exception& e )
{
std::cout << "VSG Exception: " << e.message << std::endl;
std::cerr << "VSG Exception: " << e.message << std::endl;
return EXIT_FAILURE;
}
}
24 changes: 11 additions & 13 deletions readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,16 +34,16 @@ Feature | Status
-----------------------------|--------
Linux Build | Done
Windows Build | Done
Android Build | Bugs in controller position/tracking, otherwise done
Android Build (Oculus) | Done
Android Build (Gneeric) | Done, untested
Code quality / API | Messy, but in roughly the right structure for now
OpenXR Rendering | Working, could do with a cleanup and better vsg integration at some point
OpenXR Input | Not Implemented Yet
OpenXR Input | Not Implemented (But OpenXR API directly accessible)
Controller tracking | Working
Controller models in scene | Working
HMD tracking | Working
Desktop view | Working


## Setup

If you don't have a VR headset there's a couple of options.
Expand Down Expand Up @@ -71,18 +71,18 @@ monado-service

### Android Phone / Tablet

TODO: Once the Android build is functional, it should be possible to use most phones/tablets as an XR display.
These don't directly match how a VR setup works, but should provide basic hardware for rotation/positional tracking (ARCore).

TODO: Currently vsgvr can be built for Android against the generic OpenXR loader - In theory this means it will work against Monado running on a phone/tablet.
This is however unverified, if you know how to install Monado on a phone, or otherwise have a functional OpenXR runtime on your phone please get in touch.

## Compilation

Required:
* cmake > 3.14
* vulkan sdk
* VulkanSceneGraph
* The OpenXR loader - Included as a git submodule in deps/openxr
* (For model creation) vsgXchange
* The OpenXR loader - From a variety of sources
* OPENXR\_GENERIC - The generic OpenXR loader, included as a git submodule at deps/openxr
* OPENXR\_OCULUS\_MOBILE - The Oculus mobile SDK, available from https://developer.oculus.com/downloads/package/oculus-openxr-mobile-sdk/

```sh
# Ensure submodules are available
Expand All @@ -99,23 +99,21 @@ make
## Models

Models created in Blender
* Controller 'top' is at 0,0 (or just below)
* Controller 'up' is [0,0,-1] in blender space
* Should face 'forward' as normal

Export from blender to gltf:
* Include custom properties
* Include punctual lights
* +Y up

Convert to vsg via `vsgconv model.glb model.vsgt`
* Ensure vsgXchange is built with assimp support (For assimp itself I used vcpkg)
* Ensure a recent build is used for correct lighting (fd35cc2 or newer)#
* Ensure vsgXchange is built with assimp support

## Development Tips


Validation layers from the OpenXR SDK
```
set XR_API_LAYER_PATH="C:/dev/OpenXR-SDK-Source/build/src/api_layers/"
set XR_ENABLE_API_LAYERS=XR_APILAYER_LUNARG_core_validation
```

45 changes: 25 additions & 20 deletions vsgvr/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,31 +1,29 @@

file(GLOB HEADERS ${CMAKE_CURRENT_SOURCE_DIR}/include/vsgvr/*.h )

set( SOURCES
include/vsgvr/actions/OpenXRAction.h
include/vsgvr/actions/OpenXRActionPoseBinding.h
include/vsgvr/actions/OpenXRActionSet.h
include/vsgvr/app/OpenXRViewer.h
include/vsgvr/xr/OpenXRCommon.h
include/vsgvr/xr/OpenXRInstance.h
src/vsgvr/xr/OpenXRInstance.cpp
include/vsgvr/xr/OpenXREventHandler.h
src/vsgvr/xr/OpenXREventHandler.cpp
include/vsgvr/xr/OpenXRTraits.h
src/vsgvr/xr/OpenXRTraits.cpp
include/vsgvr/app/OpenXRViewer.h
src/vsgvr/app/OpenXRViewer.cpp
include/vsgvr/xr/OpenXRGraphicsBindingVulkan.h
src/vsgvr/xr/OpenXRGraphicsBindingVulkan.cpp
include/vsgvr/xr/OpenXRInstance.h
include/vsgvr/xr/OpenXRProjectionMatrix.h
include/vsgvr/xr/OpenXRSession.h
src/vsgvr/xr/OpenXRSession.cpp
include/vsgvr/xr/OpenXRSwapchain.h
src/vsgvr/xr/OpenXRSwapchain.cpp
include/vsgvr/xr/OpenXRTraits.h
include/vsgvr/xr/OpenXRViewMatrix.h
include/vsgvr/xr/OpenXRProjectionMatrix.h

include/vsgvr/actions/OpenXRAction.h
src/vsgvr/actions/OpenXRAction.cpp
include/vsgvr/actions/OpenXRActionSet.h
src/vsgvr/actions/OpenXRActionSet.cpp
include/vsgvr/actions/OpenXRActionPoseBinding.h
src/vsgvr/actions/OpenXRActionPoseBinding.cpp
src/vsgvr/actions/OpenXRActionSet.cpp
src/vsgvr/app/OpenXRViewer.cpp
src/vsgvr/xr/OpenXREventHandler.cpp
src/vsgvr/xr/OpenXRGraphicsBindingVulkan.cpp
src/vsgvr/xr/OpenXRInstance.cpp
src/vsgvr/xr/OpenXRSession.cpp
src/vsgvr/xr/OpenXRSwapchain.cpp
src/vsgvr/xr/OpenXRTraits.cpp
)

if( ANDROID )
Expand All @@ -35,11 +33,18 @@ if( ANDROID )
)
endif()

add_library( vsgvr STATIC ${SOURCES} ${HEADERS} )
add_library( vsgvr ${SOURCES} ${HEADERS} )

target_include_directories(
vsgvr PUBLIC
${CMAKE_CURRENT_SOURCE_DIR}/include
)
target_link_libraries( vsgvr PUBLIC vsg::vsg )
target_link_libraries( vsgvr PUBLIC openxr_loader )
target_link_libraries( vsgvr PUBLIC vsg::vsg ${OpenXR_LIBRARY} )

if(WIN32 AND BUILD_SHARED_LIBS)
target_compile_definitions(vsgvr PRIVATE "VSGVR_DECLSPEC=__declspec(dllexport)")
target_compile_definitions(vsgvr INTERFACE "VSGVR_DECLSPEC=__declspec(dllimport)")
else()
target_compile_definitions( vsgvr PUBLIC "VSGVR_DECLSPEC=" )
endif()

3 changes: 2 additions & 1 deletion vsgvr/include/vsgvr/actions/OpenXRAction.h
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
namespace vsgvr {
class OpenXRInstance;
class OpenXRActionSet;
class VSG_DECLSPEC OpenXRAction : public vsg::Inherit<vsg::Object, OpenXRAction>
class VSGVR_DECLSPEC OpenXRAction : public vsg::Inherit<vsg::Object, OpenXRAction>
{
public:
OpenXRAction(OpenXRActionSet* actionSet, XrActionType actionType, std::string name, std::string localisedName );
Expand All @@ -49,3 +49,4 @@ namespace vsgvr {
XrAction _action;
};
}

3 changes: 2 additions & 1 deletion vsgvr/include/vsgvr/actions/OpenXRActionPoseBinding.h
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ namespace vsgvr {
* An action of type XR_INPUT_ACTION_TYPE_POSE, and an associated action space
* The space will only be valid while a session is running
*/
class VSG_DECLSPEC OpenXRActionPoseBinding : public vsg::Inherit<OpenXRAction, OpenXRActionPoseBinding>
class VSGVR_DECLSPEC OpenXRActionPoseBinding : public vsg::Inherit<OpenXRAction, OpenXRActionPoseBinding>
{
public:
OpenXRActionPoseBinding(OpenXRActionSet* actionSet, std::string name, std::string localisedName);
Expand All @@ -55,3 +55,4 @@ namespace vsgvr {
vsg::mat4 _transform;
};
}

3 changes: 2 additions & 1 deletion vsgvr/include/vsgvr/actions/OpenXRActionSet.h
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

namespace vsgvr {
class OpenXRInstance;
class VSG_DECLSPEC OpenXRActionSet : public vsg::Inherit<vsg::Object, OpenXRActionSet>
class VSGVR_DECLSPEC OpenXRActionSet : public vsg::Inherit<vsg::Object, OpenXRActionSet>
{
public:
OpenXRActionSet(OpenXRInstance* instance, std::string name, std::string localisedName, uint32_t priority = 0);
Expand Down Expand Up @@ -61,3 +61,4 @@ namespace vsgvr {
XrActionSet _actionSet;
};
}

3 changes: 2 additions & 1 deletion vsgvr/include/vsgvr/app/OpenXRViewer.h
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ namespace vsgvr {
* * Any elements in vsg which require a vsg::Window cannot work with this viewer (TODO)
* * While some functions are similar, this class does not directly inherit from vsg::Viewer (TODO)
*/
class VSG_DECLSPEC OpenXRViewer : public vsg::Inherit<vsg::Object, OpenXRViewer>
class VSGVR_DECLSPEC OpenXRViewer : public vsg::Inherit<vsg::Object, OpenXRViewer>
{
public:
/**
Expand Down Expand Up @@ -175,3 +175,4 @@ namespace vsgvr {
std::vector<XrCompositionLayerProjectionView> _layerProjectionViews;
};
}

3 changes: 2 additions & 1 deletion vsgvr/include/vsgvr/xr/OpenXRAndroidTraits.h
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
#include <jni.h>

namespace vsgvr {
class VSG_DECLSPEC OpenXrAndroidTraits : public vsg::Inherit<vsgvr::OpenXrTraits, OpenXrAndroidTraits> {
class VSGVR_DECLSPEC OpenXrAndroidTraits : public vsg::Inherit<vsgvr::OpenXrTraits, OpenXrAndroidTraits> {
public:
OpenXrAndroidTraits();

Expand All @@ -36,3 +36,4 @@ namespace vsgvr {
virtual ~OpenXrAndroidTraits();
};
}

Loading

0 comments on commit 143f267

Please sign in to comment.