[Bf-blender-cvs] [f35c1a3] HMD_viewport: Added OpenHMD in the build structure, uses WITH_OPENHMD so it can be disabled Has a requirement on libhidapi, cmake checks for that (should be added to install-deps)

TheOnlyJoey noreply at git.blender.org
Wed Mar 16 19:56:53 CET 2016


Commit: f35c1a339dc02325008c4e6a1d1d0b18a5e85dca
Author: TheOnlyJoey
Date:   Wed Mar 16 19:48:05 2016 +0100
Branches: HMD_viewport
https://developer.blender.org/rBf35c1a339dc02325008c4e6a1d1d0b18a5e85dca

Added OpenHMD in the build structure, uses WITH_OPENHMD so it can be disabled
Has a requirement on libhidapi, cmake checks for that (should be added to install-deps)

===================================================================

M	CMakeLists.txt
A	build_files/cmake/Modules/FindHIDAPI.cmake
M	build_files/cmake/macros.cmake
M	extern/CMakeLists.txt
A	extern/openhmd/CMakeLists.txt
A	extern/openhmd/LICENSE
A	extern/openhmd/README.md
A	extern/openhmd/include/openhmd.h
A	extern/openhmd/src/Makefile.am
A	extern/openhmd/src/drv_android/android.c
A	extern/openhmd/src/drv_android/android.h
A	extern/openhmd/src/drv_dummy/dummy.c
A	extern/openhmd/src/drv_external/external.c
A	extern/openhmd/src/drv_oculus_rift/packet.c
A	extern/openhmd/src/drv_oculus_rift/rift.c
A	extern/openhmd/src/drv_oculus_rift/rift.h
A	extern/openhmd/src/fusion.c
A	extern/openhmd/src/fusion.h
A	extern/openhmd/src/log.h
A	extern/openhmd/src/omath.c
A	extern/openhmd/src/omath.h
A	extern/openhmd/src/openhmd.c
A	extern/openhmd/src/openhmdi.h
A	extern/openhmd/src/platform-posix.c
A	extern/openhmd/src/platform-win32.c
A	extern/openhmd/src/platform.h
M	intern/ghost/CMakeLists.txt
M	intern/ghost/intern/GHOST_OpenHMDManager.cpp

===================================================================

diff --git a/CMakeLists.txt b/CMakeLists.txt
index 4010ee6..2823b18 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -353,6 +353,7 @@ if(WIN32)
 	option(WITH_INPUT_IME "Enable Input Method Editor (IME) for complex Asian character input" ON)
 endif()
 option(WITH_INPUT_NDOF "Enable NDOF input devices (SpaceNavigator and friends)" ${_init_INPUT_NDOF})
+option(WITH_OPENHMD "Enable OpenHMD support in Blender (Head Mounted Displays for VR support)" ON)
 option(WITH_RAYOPTIMIZATION	"Enable use of SIMD (SSE) optimizations for the raytracer" ON)
 if(UNIX AND NOT APPLE)
 	option(WITH_INSTALL_PORTABLE "Install redistributeable runtime, otherwise install into CMAKE_INSTALL_PREFIX" ON)
diff --git a/build_files/cmake/Modules/FindHIDAPI.cmake b/build_files/cmake/Modules/FindHIDAPI.cmake
new file mode 100644
index 0000000..86243fb
--- /dev/null
+++ b/build_files/cmake/Modules/FindHIDAPI.cmake
@@ -0,0 +1,47 @@
+# - try to find HIDAPI library
+# from http://www.signal11.us/oss/hidapi/
+#
+# Cache Variables: (probably not for direct use in your scripts)
+#  HIDAPI_INCLUDE_DIR
+#  HIDAPI_LIBRARY
+#
+# Non-cache variables you might use in your CMakeLists.txt:
+#  HIDAPI_FOUND
+#  HIDAPI_INCLUDE_DIRS
+#  HIDAPI_LIBRARIES
+#
+# Requires these CMake modules:
+#  FindPackageHandleStandardArgs (known included with CMake >=2.6.2)
+#
+# Original Author:
+# 2009-2010 Ryan Pavlik <rpavlik at iastate.edu> <abiryan at ryand.net>
+# http://academic.cleardefinition.com
+# Iowa State University HCI Graduate Program/VRAC
+#
+# Copyright Iowa State University 2009-2010.
+# Distributed under the Boost Software License, Version 1.0.
+# (See accompanying file LICENSE_1_0.txt or copy at
+# http://www.boost.org/LICENSE_1_0.txt)
+
+find_library(HIDAPI_LIBRARY
+	NAMES hidapi hidapi-libusb)
+
+find_path(HIDAPI_INCLUDE_DIR
+	NAMES hidapi.h
+	PATH_SUFFIXES
+	hidapi)
+
+include(FindPackageHandleStandardArgs)
+find_package_handle_standard_args(HIDAPI
+	DEFAULT_MSG
+	HIDAPI_LIBRARY
+	HIDAPI_INCLUDE_DIR)
+
+if(HIDAPI_FOUND)
+	set(HIDAPI_LIBRARIES "${HIDAPI_LIBRARY}")
+
+	set(HIDAPI_INCLUDE_DIRS "${HIDAPI_INCLUDE_DIR}")
+endif()
+
+mark_as_advanced(HIDAPI_INCLUDE_DIR HIDAPI_LIBRARY)
+
diff --git a/build_files/cmake/macros.cmake b/build_files/cmake/macros.cmake
index 836f53e..1d487b7 100644
--- a/build_files/cmake/macros.cmake
+++ b/build_files/cmake/macros.cmake
@@ -476,8 +476,9 @@ function(setup_liblinks
 		endif()
 	endif()
 
-	#FIXMELIKEABAWS
-	target_link_libraries(${target} "/usr/local/lib/libopenhmd.a" "/usr/lib/x86_64-linux-gnu/libhidapi-libusb.a" "/usr/lib/x86_64-linux-gnu/libusb-1.0.a" "/lib/x86_64-linux-gnu/libudev.so.1")
+    if(WITH_OPENHMD)
+		target_link_libraries(${target} ${OPENHMD_LIBRARIES} ${HIDAPI_LIBRARY})
+    endif()
 
 	# We put CLEW and CUEW here because OPENSUBDIV_LIBRARIES dpeends on them..
 	if(WITH_CYCLES OR WITH_COMPOSITOR OR WITH_OPENSUBDIV)
@@ -687,6 +688,10 @@ function(SETUP_BLENDER_SORTED_LIBS)
 	if(WITH_INPUT_NDOF)
 		list(APPEND BLENDER_SORTED_LIBS bf_intern_ghostndof3dconnexion)
 	endif()
+
+	if(WITH_OPENHMD)
+		list(APPEND BLENDER_SORTED_LIBS extern_openhmd)
+	endif()
 	
 	if(WITH_MOD_BOOLEAN)
 		list(APPEND BLENDER_SORTED_LIBS extern_carve)
diff --git a/extern/CMakeLists.txt b/extern/CMakeLists.txt
index 1cce7dc..9e6dc14 100644
--- a/extern/CMakeLists.txt
+++ b/extern/CMakeLists.txt
@@ -99,3 +99,7 @@ endif()
 if(WITH_SDL AND WITH_SDL_DYNLOAD)
 	add_subdirectory(sdlew)
 endif()
+
+if(WITH_OPENHMD)
+	add_subdirectory(openhmd)
+endif()
diff --git a/extern/openhmd/CMakeLists.txt b/extern/openhmd/CMakeLists.txt
new file mode 100644
index 0000000..819c487
--- /dev/null
+++ b/extern/openhmd/CMakeLists.txt
@@ -0,0 +1,46 @@
+project(openhmd C CXX)
+set(CMAKE_C_FLAGS "-std=c99")
+
+include_directories(${CMAKE_CURRENT_LIST_DIR}/include)
+
+#source files set just for Android
+set(openhmd_source_files
+	${CMAKE_CURRENT_LIST_DIR}/src/openhmd.c
+	${CMAKE_CURRENT_LIST_DIR}/src/platform-win32.c
+	${CMAKE_CURRENT_LIST_DIR}/src/drv_dummy/dummy.c
+	${CMAKE_CURRENT_LIST_DIR}/src/omath.c
+	${CMAKE_CURRENT_LIST_DIR}/src/platform-posix.c
+	${CMAKE_CURRENT_LIST_DIR}/src/fusion.c
+)   
+
+OPTION(OPENHMD_DRIVER_OCULUS_RIFT "Oculus Rift DK1 and DK2" ON)
+OPTION(OPENHMD_DRIVER_EXTERNAL "External sensor driver" OFF)
+OPTION(OPENHMD_DRIVER_ANDROID "General Android driver" OFF)
+
+if(OPENHMD_DRIVER_OCULUS_RIFT)
+	set(openhmd_source_files ${openhmd_source_files} 
+	${CMAKE_CURRENT_LIST_DIR}/src/drv_oculus_rift/rift.c
+	${CMAKE_CURRENT_LIST_DIR}/src/drv_oculus_rift/packet.c
+	)
+	add_definitions(-DDRIVER_OCULUS_RIFT)
+
+	find_package(HIDAPI REQUIRED)
+	include_directories(${HIDAPI_INCLUDE_DIRS})
+	set(LIBS ${LIBS} ${HIDAPI_LIBRARIES})
+endif(OPENHMD_DRIVER_OCULUS_RIFT)
+
+if (OPENHMD_DRIVER_EXTERNAL)
+	set(openhmd_source_files ${openhmd_source_files} 
+	${CMAKE_CURRENT_LIST_DIR}/src/drv_external/external.c
+	)
+	add_definitions(-DDRIVER_EXTERNAL)
+endif(OPENHMD_DRIVER_EXTERNAL)
+
+if (OPENHMD_DRIVER_ANDROID)
+	set(openhmd_source_files ${openhmd_source_files} 
+	${CMAKE_CURRENT_LIST_DIR}/src/drv_android/android.c
+	)
+	add_definitions(-DDRIVER_ANDROID)
+endif(OPENHMD_DRIVER_ANDROID)
+
+blender_add_lib(extern_openhmd "${openhmd_source_files}" "${openhmd_source_files}" "${LIBS}")
diff --git a/extern/openhmd/LICENSE b/extern/openhmd/LICENSE
new file mode 100644
index 0000000..36b7cd9
--- /dev/null
+++ b/extern/openhmd/LICENSE
@@ -0,0 +1,23 @@
+Boost Software License - Version 1.0 - August 17th, 2003
+
+Permission is hereby granted, free of charge, to any person or organization
+obtaining a copy of the software and accompanying documentation covered by
+this license (the "Software") to use, reproduce, display, distribute,
+execute, and transmit the Software, and to prepare derivative works of the
+Software, and to permit third-parties to whom the Software is furnished to
+do so, all subject to the following:
+
+The copyright notices in the Software and this entire statement, including
+the above license grant, this restriction and the following disclaimer,
+must be included in all copies of the Software, in whole or in part, and
+all derivative works of the Software, unless such copies or derivative
+works are solely in the form of machine-executable object code generated by
+a source language processor.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT
+SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE
+FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE,
+ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
+DEALINGS IN THE SOFTWARE.
diff --git a/extern/openhmd/README.md b/extern/openhmd/README.md
new file mode 100644
index 0000000..f359893
--- /dev/null
+++ b/extern/openhmd/README.md
@@ -0,0 +1,9 @@
+# OpenHMD
+This project aims to provide a Free and Open Source API and drivers for immersive technology, such as head mounted displays with built in head tracking.
+
+# License
+OpenHMD is released under the permissive Boost Software License (see LICENSE for more information), to make sure it can be linked and distributed with both free and non-free software. While it doesn't require contribution from the users, it is still very appreciated.
+
+# Implemented and maintained by TheOnlyJoey (Joey Ferwerda), contact info at thorwork.org if anything goes wrong
+
+
diff --git a/extern/openhmd/include/openhmd.h b/extern/openhmd/include/openhmd.h
new file mode 100644
index 0000000..11c5d36
--- /dev/null
+++ b/extern/openhmd/include/openhmd.h
@@ -0,0 +1,299 @@
+/*
+ * OpenHMD - Free and Open Source API and drivers for immersive technology.
+ * Copyright (C) 2013 Fredrik Hultin.
+ * Copyright (C) 2013 Jakob Bornecrantz.
+ * Distributed under the Boost 1.0 licence, see LICENSE for full text.
+ */
+
+/**
+ * \file openhmd.h
+ * Main header for OpenHMD public API.
+ **/
+
+#ifndef OPENHMD_H
+#define OPENHMD_H
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#ifdef _WIN32
+#ifdef DLL_EXPORT
+#define OHMD_APIENTRY __cdecl
+#define OHMD_APIENTRYDLL __declspec( dllexport )
+#else
+#ifdef OHMD_STATIC
+#define OHMD_APIENTRY __cdecl
+#define OHMD_APIENTRYDLL
+#else
+#define OHMD_APIENTRY __cdecl
+#define OHMD_APIENTRYDLL __declspec( dllimport )
+#endif
+#endif
+#else
+#define OHMD_APIENTRY
+#define OHMD_APIENTRYDLL
+#endif
+
+/** Maximum length of a string, including termination, in OpenHMD. */
+#define OHMD_STR_SIZE 256
+
+/** Return status codes, used for all functions that can return an error. */
+typedef enum {
+	OHMD_S_OK = 0,
+	OHMD_S_UNKNOWN_ERROR = -1,
+	OHMD_S_INVALID_PARAMETER = -2,
+	OHMD_S_UNSUPPORTED = -3,
+
+	/** OHMD_S_USER_RESERVED and below can be used for user purposes, such as errors within ohmd wrappers, etc. */
+	OHMD_S_USER_RESERVED = -16384,
+} ohmd_status;
+
+/** A collection of string value information types, used for getting information with ohmd_list_gets(). */
+typedef enum {
+	OHMD_VENDOR    = 0,
+	OHMD_PRODUCT   = 1,
+	OHMD_PATH      = 2,
+} ohmd_string_value;
+
+/** A collection of float value information types, used for getting and setting information with
+    ohmd_device_getf() and ohmd_device_setf(). */
+typedef enum {
+	/** float[4] (get): Absolute rotation of the device, in space, as a quaternion (x, y, z, w). */
+	OHMD_ROTATION_QUAT                    =  1,
+
+	/** float[16] (get): A "ready to use" OpenGL style 4x4 matrix with a modelview matrix for the
+	    left eye of the HMD. */
+	OHMD_LEFT_EYE_GL_MODELVIEW_MATRIX     =  2,
+	/** float[16] (get): A "ready to use" OpenGL style 4x4 matrix with a modelview matrix for the
+	    right eye of the HMD. */
+	OHMD_RIGHT_EYE_GL_MODELVIEW_MATRIX    =  3,
+
+	/** float[16] (get): A "ready to use" OpenGL style 4x4 matrix with a projection matrix for the
+	    left eye of the HMD. */
+	OHMD_LEFT_EYE_GL_PROJECTION_MATRIX    =  4,
+	/** float[16] (get): A "ready to use" OpenGL style 4x4 matrix with a projection matrix for the
+	    right eye of the HMD. */
+	OHMD_RIGHT_EYE_GL_PROJECTION_MATRIX   =  5,
+
+	/** float[3] (get): A 3-D vector representing the absolute position of the device, in space. */
+	OHM

@@ Diff output truncated at 10240 characters. @@




More information about the Bf-blender-cvs mailing list