This commit is contained in:
Thijs Wenker 2014-07-23 16:59:23 +02:00
commit 9d5c81bd67
51 changed files with 856 additions and 2034 deletions

28
.gitignore vendored
View file

@ -28,31 +28,9 @@ DerivedData
*.hmap
# ignore oculus
interface/external/oculus/*
!interface/external/oculus/readme.txt
# Ignore Sixense
interface/external/sixense/*
!interface/external/sixense/readme.txt
# Ignore Visage
interface/external/visage/*
!interface/external/visage/readme.txt
interface/resources/visage/*
!interface/resources/visage/tracker.cfg
# Ignore Faceplus
interface/external/faceplus/*
!interface/external/faceplus/readme.txt
# Ignore PrioVR
interface/external/priovr/*
!interface/external/priovr/readme.txt
# Ignore RtMidi
interface/external/rtmidi/*
!interface/external/rtmidi/readme.txt
# ignore interface optional externals
interface/external/*/*
!interface/external/*/readme.txt
# Ignore interfaceCache for Linux users
interface/interfaceCache/

View file

@ -2,25 +2,25 @@ Dependencies
===
* [cmake](http://www.cmake.org/cmake/resources/software.html) ~> 2.8.12.2
* [Qt](http://qt-project.org/downloads) ~> 5.2.0
* [zLib](http://www.zlib.net/) ~> 1.2.8
* [glm](http://glm.g-truc.net/0.9.5/index.html) ~> 0.9.5.2
* [qxmpp](https://github.com/qxmpp-project/qxmpp/) ~> 0.7.6
* [OpenSSL](https://www.openssl.org/related/binaries.html) ~> 1.0.1g
* IMPORTANT: OpenSSL 1.0.1g is critical to avoid a security vulnerability.
#####Linux only
* [freeglut](http://freeglut.sourceforge.net/) ~> 2.8.0
* [zLib](http://www.zlib.net/) ~> 1.2.8
#####Windows only
* [GLEW](http://glew.sourceforge.net/) ~> 1.10.0
* [freeglut MSVC](http://www.transmissionzero.co.uk/software/freeglut-devel/) ~> 2.8.1
* [zLib](http://www.zlib.net/) ~> 1.2.8
CMake
===
Hifi uses CMake to generate build files and project files for your platform.
####Qt
In order for CMake to find the Qt5 find modules, you will need to set an ENV variable pointing to your CMake installation.
In order for CMake to find the Qt5 find modules, you will need to set an ENV variable pointing to your Qt installation.
For example, a Qt5 5.2.0 installation to /usr/local/qt5 would require that QT_CMAKE_PREFIX_PATH be set with the following command. This can either be entered directly into your shell session before you build or in your shell profile (e.g.: ~/.bash_profile, ~/.bashrc, ~/.zshrc - this depends on your shell and environment).
@ -70,9 +70,8 @@ Should you choose not to install Qt5 via a package manager that handles dependen
brew install cmake glm openssl
brew install highfidelity/formulas/qt5
brew link qt5 --force
brew install highfidelity/formulas/qxmpp
We have a [homebrew formulas repository](https://github.com/highfidelity/homebrew-formulas) that you can use/tap to install some of the dependencies. In the code block above qt5 and qxmpp are installed from formulas in this repository.
We have a [homebrew formulas repository](https://github.com/highfidelity/homebrew-formulas) that you can use/tap to install some of the dependencies. In the code block above qt5 is installed from a formula in this repository.
*Our [qt5 homebrew formula](https://raw.github.com/highfidelity/homebrew-formulas/master/qt5.rb) is for a patched version of Qt 5.2.0 stable that removes wireless network scanning that can reduce real-time audio performance. We recommended you use this formula to install Qt.*
@ -150,13 +149,10 @@ The recommended route for CMake to find the external dependencies is to place al
-> glm
-> glm
-> glm.hpp
-> gnutls
-> openssl
-> bin
-> include
-> lib
-> qxmpp
-> include
-> lib
-> zlib
-> include
-> lib
@ -218,21 +214,6 @@ This package contains only headers, so there's nothing to add to the PATH.
Be careful with glm. For the folder other libraries would normally call 'include', the folder containing the headers, glm opts to use 'glm'. You will have a glm folder nested inside the top-level glm folder.
#### qxmpp
Download a source-code release from the [qxmpp GitHub page](https://github.com/qxmpp-project/qxmpp/releases).
Start a Visual Studio Command Prompt.
mkdir %HIFI_LIB_DIR%\build
tar xfz qxmpp-0.7.6.tar.gz -C %HIFI_LIB_DIR%\build
cd %HIFI_LIB_DIR%\build\qxmpp-0.7.6
qmake PREFIX=%HIFI_LIB_DIR%\qxmpp # This creates "Makefile"
nmake
nmake install
Add to the PATH: `%HIFI_LIB_DIR%\qxmpp\lib`
#### Build High Fidelity using Visual Studio
Follow the same build steps from the CMake section, but pass a different generator to CMake.
@ -250,7 +231,16 @@ If you need to debug Interface, you can run interface from within Visual Studio
* Set the "Working Directory" for the Interface debugging sessions to the Debug output directory so that your application can load resources. Do this: right click interface and click Properties, choose Debugging from Configuration Properties, set Working Directory to .\Debug
* Now you can run and debug interface through Visual Studio
Optional Components
===
####QXmpp
You can find QXmpp [here](https://github.com/qxmpp-project/qxmpp). The inclusion of the QXmpp enables text chat in the Interface client.
OS X users who tap our [homebrew formulas repository](https://github.com/highfidelity/homebrew-formulas) can install QXmpp via homebrew - `brew install highfidelity/formulas/qxmpp`.
#### Devices
You can support external input/output devices such as Leap Motion, Faceplus, Faceshift PrioVR, RTmidi, SixSense and more by adding each individual SDK in the visible building path. Refer to the readme file available in each device folder in /hifi/interface/external/ for the detailed explanation of the requirements to use the device.
You can support external input/output devices such as Leap Motion, Faceplus, Faceshift, PrioVR, MIDI, Razr Hydra and more by adding each individual SDK in the visible building path. Refer to the readme file available in each device folder in [interface/external/](interface/external) for the detailed explanation of the requirements to use the device.

View file

@ -12,31 +12,13 @@
# Copyright (c) 2014 High Fidelity
#
if (FACEPLUS_LIBRARIES AND FACEPLUS_INCLUDE_DIRS)
# in cache already
set(FACEPLUS_FOUND TRUE)
else (FACEPLUS_LIBRARIES AND FACEPLUS_INCLUDE_DIRS)
find_path(FACEPLUS_INCLUDE_DIRS faceplus.h ${FACEPLUS_ROOT_DIR}/include)
find_path(FACEPLUS_INCLUDE_DIRS faceplus.h ${FACEPLUS_ROOT_DIR}/include)
if (WIN32)
find_library(FACEPLUS_LIBRARIES faceplus.lib ${FACEPLUS_ROOT_DIR}/win32/)
endif (WIN32)
if (FACEPLUS_INCLUDE_DIRS AND FACEPLUS_LIBRARIES)
set(FACEPLUS_FOUND TRUE)
endif (FACEPLUS_INCLUDE_DIRS AND FACEPLUS_LIBRARIES)
if (WIN32)
find_library(FACEPLUS_LIBRARIES faceplus.lib ${FACEPLUS_ROOT_DIR}/win32/)
endif (WIN32)
if (FACEPLUS_FOUND)
if (NOT FACEPLUS_FIND_QUIETLY)
message(STATUS "Found Faceplus... ${FACEPLUS_LIBRARIES}")
endif (NOT FACEPLUS_FIND_QUIETLY)
else ()
if (FACEPLUS_FIND_REQUIRED)
message(FATAL_ERROR "Could not find Faceplus")
endif (FACEPLUS_FIND_REQUIRED)
endif ()
include(FindPackageHandleStandardArgs)
find_package_handle_standard_args(FACEPLUS DEFAULT_MSG FACEPLUS_INCLUDE_DIRS FACEPLUS_LIBRARIES)
# show the FACEPLUS_INCLUDE_DIRS and FACEPLUS_LIBRARIES variables only in the advanced view
mark_as_advanced(FACEPLUS_INCLUDE_DIRS FACEPLUS_LIBRARIES)
endif (FACEPLUS_LIBRARIES AND FACEPLUS_INCLUDE_DIRS)
mark_as_advanced(FACEPLUS_INCLUDE_DIRS FACEPLUS_LIBRARIES)

View file

@ -18,47 +18,27 @@
# See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
#
if (FACESHIFT_LIBRARIES AND FACESHIFT_INCLUDE_DIRS)
# in cache already
set(FACESHIFT_FOUND TRUE)
else ()
find_path(FACESHIFT_INCLUDE_DIRS fsbinarystream.h ${FACESHIFT_ROOT_DIR}/include)
set(FACESHIFT_SEARCH_DIRS "${FACESHIFT_ROOT_DIR}" "$ENV{FACESHIFT_ROOT_DIR}" "$ENV{HIFI_LIB_DIR}/faceshift")
if (APPLE)
find_library(FACESHIFT_LIBRARIES libfaceshift.a ${FACESHIFT_ROOT_DIR}/lib/MacOS/)
elseif (UNIX)
find_library(FACESHIFT_LIBRARIES libfaceshift.a ${FACESHIFT_ROOT_DIR}/lib/UNIX/)
elseif (WIN32)
# For windows, we're going to build the faceshift sources directly into the interface build
# and not link to a prebuilt library. This is because the VS2010 linker doesn't like cross-linking
# between release and debug libraries. If we change that in the future we can make win32 more
# like the other platforms
#find_library(FACESHIFT_LIBRARIES faceshift.lib ${FACESHIFT_ROOT_DIR}/lib/WIN32/)
endif ()
if (WIN32)
# Windows only cares about the headers
if (FACESHIFT_INCLUDE_DIRS)
set(FACESHIFT_FOUND TRUE)
endif (FACESHIFT_INCLUDE_DIRS)
else ()
# Mac and Unix requires libraries
if (FACESHIFT_INCLUDE_DIRS AND FACESHIFT_LIBRARIES)
set(FACESHIFT_FOUND TRUE)
endif (FACESHIFT_INCLUDE_DIRS AND FACESHIFT_LIBRARIES)
endif ()
if (FACESHIFT_FOUND)
if (NOT FACESHIFT_FIND_QUIETLY)
message(STATUS "Found Faceshift... ${FACESHIFT_LIBRARIES}")
endif (NOT FACESHIFT_FIND_QUIETLY)
else ()
if (FACESHIFT_FIND_REQUIRED)
message(FATAL_ERROR "Could not find Faceshift")
endif (FACESHIFT_FIND_REQUIRED)
endif ()
# show the FACESHIFT_INCLUDE_DIRS and FACESHIFT_LIBRARIES variables only in the advanced view
mark_as_advanced(FACESHIFT_INCLUDE_DIRS FACESHIFT_LIBRARIES)
find_path(FACESHIFT_INCLUDE_DIRS fsbinarystream.h PATH_SUFFIXES include HINTS ${FACESHIFT_SEARCH_DIRS})
if (APPLE)
set(ARCH_DIR "MacOS")
elseif (UNIX)
set(ARCH_DIR "UNIX")
elseif (WIN32)
set(ARCH_DIR "Win32")
endif ()
find_library(FACESHIFT_LIBRARY_RELEASE NAME faceshift PATH_SUFFIXES lib/${ARCH_DIR} HINTS ${FACESHIFT_SEARCH_DIRS})
find_library(FACESHIFT_LIBRARY_DEBUG NAME faceshiftd PATH_SUFFIXES lib/${ARCH_DIR} HINTS ${FACESHIFT_SEARCH_DIRS})
include(SelectLibraryConfigurations)
select_library_configurations(FACESHIFT)
set(FACESHIFT_LIBRARIES ${FACESHIFT_LIBRARY})
include(FindPackageHandleStandardArgs)
find_package_handle_standard_args(FACESHIFT DEFAULT_MSG FACESHIFT_INCLUDE_DIRS FACESHIFT_LIBRARIES)
mark_as_advanced(FACESHIFT_INCLUDE_DIRS FACESHIFT_LIBRARIES)

View file

@ -6,7 +6,7 @@
#
# GLEW_FOUND
# GLEW_INCLUDE_DIRS
# GLEW_LIBRARY
# GLEW_LIBRARIES
#
# Created on 2/6/2014 by Stephen Birarda
# Copyright 2014 High Fidelity, Inc.
@ -18,27 +18,21 @@
# See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
#
if (GLEW_INCLUDE_DIRS AND GLEW_LIBRARY)
set(GLEW_FOUND TRUE)
else ()
if (WIN32)
set(WIN_GLEW_SEARCH_DIRS "${GLEW_ROOT_DIR}" "$ENV{GLEW_ROOT_DIR}" "$ENV{HIFI_LIB_DIR}/glew")
find_path(GLEW_INCLUDE_DIRS GL/glew.h PATH_SUFFIXES include HINTS ${WIN_GLEW_SEARCH_DIRS})
find_library(GLEW_LIBRARY glew32s PATH_SUFFIXES "lib/Release/Win32" "lib" HINTS ${WIN_GLEW_SEARCH_DIRS})
endif ()
include(FindPackageHandleStandardArgs)
find_package_handle_standard_args(GLEW DEFAULT_MSG GLEW_INCLUDE_DIRS GLEW_LIBRARY)
if (WIN32)
set(WIN_GLEW_SEARCH_DIRS "${GLEW_ROOT_DIR}" "$ENV{GLEW_ROOT_DIR}" "$ENV{HIFI_LIB_DIR}/glew")
find_path(GLEW_INCLUDE_DIRS GL/glew.h PATH_SUFFIXES include HINTS ${WIN_GLEW_SEARCH_DIRS})
if (GLEW_FOUND)
if (NOT GLEW_FIND_QUIETLY)
message(STATUS "Found GLEW: ${GLEW_LIBRARY}")
endif ()
else ()
if (GLEW_FIND_REQUIRED)
message(FATAL_ERROR "Could not find GLEW")
endif ()
endif ()
endif ()
find_library(GLEW_LIBRARY_RELEASE glew32s PATH_SUFFIXES "lib/Release/Win32" "lib" HINTS ${WIN_GLEW_SEARCH_DIRS})
find_library(GLEW_LIBRARY_DEBUG glew32s PATH_SUFFIXES "lib/Debug/Win32" "lib" HINTS ${WIN_GLEW_SEARCH_DIRS})
include(SelectLibraryConfigurations)
select_library_configurations(GLEW)
endif ()
set(GLEW_LIBRARIES "${GLEW_LIBRARY}")
include(FindPackageHandleStandardArgs)
find_package_handle_standard_args(GLEW DEFAULT_MSG GLEW_INCLUDE_DIRS GLEW_LIBRARIES)
mark_as_advanced(GLEW_INCLUDE_DIRS GLEW_LIBRARIES)

View file

@ -1,67 +1,26 @@
# FindGLM - attempts to locate the glm matrix/vector library.
#
# This module defines the following variables (on success):
# GLM_INCLUDE_DIRS - where to find glm/glm.hpp
# GLM_FOUND - if the library was successfully located
#
# It is trying a few standard installation locations, but can be customized
# with the following variables:
# GLM_ROOT_DIR - root directory of a glm installation
# Headers are expected to be found in either:
# <GLM_ROOT_DIR>/glm/glm.hpp OR
# <GLM_ROOT_DIR>/include/glm/glm.hpp
# This variable can either be a cmake or environment
# variable. Note however that changing the value
# of the environment varible will NOT result in
# re-running the header search and therefore NOT
# adjust the variables set by this module.
# This is a modified version of the FindGLM module included with CMake.
# Copyright 2014 High Fidelity
# FindGLM.cmake
#
#=============================================================================
# Copyright 2012 Carsten Neumann
# Try to find GLM include path.
# Once done this will define
#
# Distributed under the OSI-approved BSD License (the "License");
# see accompanying file Copyright.txt for details.
#
# This software is distributed WITHOUT ANY WARRANTY; without even the
# implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
# See the License for more information.
#=============================================================================
# (To distribute this file outside of CMake, substitute the full
# License text for the above reference.)
# GLM_INCLUDE_DIRS
#
# Created on 7/17/2014 by Stephen Birarda
# Copyright 2014 High Fidelity, Inc.
#
# Distributed under the Apache License, Version 2.0.
# See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
#
if (GLM_INCLUDE_DIR)
set(GLM_INCLUDE_DIRS "${GLM_INCLUDE_DIR}")
set(GLM_FOUND TRUE)
else ()
# default search dirs
set(_glm_HEADER_SEARCH_DIRS "$ENV{HIFI_LIB_DIR}/glm" "/usr/include" "/usr/local/include")
# setup hints for GLM search
set(GLM_HEADER_SEARCH_HINTS "${GLM_ROOT_DIR}" "$ENV{GLM_ROOT_DIR}" "$ENV{HIFI_LIB_DIR}/glm")
# check environment variable
set(_glm_ENV_ROOT_DIR "$ENV{GLM_ROOT_DIR}")
# locate header
find_path(GLM_INCLUDE_DIR "glm/glm.hpp" HINTS ${GLM_HEADER_SEARCH_HINTS})
set(GLM_INCLUDE_DIRS "${GLM_INCLUDE_DIR}")
if (NOT GLM_ROOT_DIR AND _glm_ENV_ROOT_DIR)
set(GLM_ROOT_DIR "${_glm_ENV_ROOT_DIR}")
endif ()
include(FindPackageHandleStandardArgs)
find_package_handle_standard_args(GLM DEFAULT_MSG GLM_INCLUDE_DIRS)
# put user specified location at beginning of search
if (GLM_ROOT_DIR)
set(_glm_HEADER_SEARCH_DIRS "${GLM_ROOT_DIR}" "${GLM_ROOT_DIR}/include" "$ENV{HIFI_LIB_DIR}/glm" ${_glm_HEADER_SEARCH_DIRS})
ENDIF()
# locate header
find_path(GLM_INCLUDE_DIR "glm/glm.hpp" PATHS ${_glm_HEADER_SEARCH_DIRS})
include(FindPackageHandleStandardArgs)
find_package_handle_standard_args(GLM DEFAULT_MSG GLM_INCLUDE_DIR)
if (GLM_FOUND)
set(GLM_INCLUDE_DIRS "${GLM_INCLUDE_DIR}")
if (NOT GLM_FIND_QUIETLY)
MESSAGE(STATUS "GLM_INCLUDE_DIR = ${GLM_INCLUDE_DIR}")
endif (NOT GLM_FIND_QUIETLY)
endif ()
endif ()
mark_as_advanced(GLM_INCLUDE_DIRS)

View file

@ -5,9 +5,8 @@
# Once done this will define
#
# GLUT_FOUND
# GLUT_INCLUDE_DIR
# GLUT_INCLUDE_DIRS
# GLUT_LIBRARIES
# GLUT_DLL_PATH - Optionally defined for Win32, if not in path
#
# Created on 2/6/2014 by Stephen Birarda
# Copyright 2014 High Fidelity, Inc.
@ -19,73 +18,29 @@
# See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
#
if (GLUT_INCLUDE_DIR AND GLUT_LIBRARIES)
set(GLUT_FOUND TRUE)
else ()
if (WIN32)
set(WIN_GLUT_SEARCH_DIRS "${GLUT_ROOT_DIR}" "$ENV{GLUT_ROOT_DIR}" "$ENV{HIFI_LIB_DIR}/freeglut" "${OPENGL_INCLUDE_DIR}")
find_path(GLUT_INCLUDE_DIR GL/glut.h PATH_SUFFIXES include HINTS ${WIN_GLUT_SEARCH_DIRS})
set(GLUT_HINT_DIRS "${GLUT_ROOT_DIR}" "$ENV{GLUT_ROOT_DIR}" "$ENV{HIFI_LIB_DIR}/freeglut")
find_library(GLUT_glut_LIBRARY freeglut PATH_SUFFIXES lib HINTS ${WIN_GLUT_SEARCH_DIRS})
else ()
find_path(GLUT_INCLUDE_DIR GL/glut.h
"${GLUT_LOCATION}/include"
"$ENV{GLUT_LOCATION}/include"
/usr/include
/usr/include/GL
/usr/local/include
/usr/openwin/share/include
/usr/openwin/include
/usr/X11R6/include
/usr/include/X11
/opt/graphics/OpenGL/include
/opt/graphics/OpenGL/contrib/libglut
)
find_library(GLUT_glut_LIBRARY glut
"${GLUT_LOCATION}/lib"
"$ENV{GLUT_LOCATION}/lib"
/usr/lib
/usr/local/lib
/usr/openwin/lib
/usr/X11R6/lib
)
find_library(GLUT_Xi_LIBRARY Xi
"${GLUT_LOCATION}/lib"
"$ENV{GLUT_LOCATION}/lib"
/usr/lib
/usr/local/lib
/usr/openwin/lib
/usr/X11R6/lib
)
find_library(GLUT_Xmu_LIBRARY Xmu
"${GLUT_LOCATION}/lib"
"$ENV{GLUT_LOCATION}/lib"
/usr/lib
/usr/local/lib
/usr/openwin/lib
/usr/X11R6/lib
)
endif ()
if (GLUT_INCLUDE_DIR AND GLUT_glut_LIBRARY)
# Is -lXi and -lXmu required on all platforms that have it?
# If not, we need some way to figure out what platform we are on.
set(GLUT_LIBRARIES ${GLUT_glut_LIBRARY} ${GLUT_Xmu_LIBRARY} ${GLUT_Xi_LIBRARY})
endif ()
include(FindPackageHandleStandardArgs)
find_package_handle_standard_args(GLUT DEFAULT_MSG GLUT_INCLUDE_DIR GLUT_LIBRARIES)
if (WIN32)
set(GLUT_HINT_DIRS "${GLUT_HINT_DIRS}" "${OPENGL_INCLUDE_DIR}")
if (GLUT_FOUND)
if (NOT GLUT_FIND_QUIETLY)
message(STATUS "Found GLUT: ${GLUT_LIBRARIES}")
endif ()
else ()
if (GLUT_FIND_REQUIRED)
message(FATAL_ERROR "Could not find GLUT")
endif ()
endif ()
find_path(GLUT_INCLUDE_DIRS GL/glut.h PATH_SUFFIXES include HINTS ${GLUT_HINT_DIRS})
find_library(GLUT_LIBRARY freeglut PATH_SUFFIXES lib HINTS ${GLUT_HINT_DIRS})
else ()
find_path(GLUT_INCLUDE_DIRS GL/glut.h PATH_SUFFIXES include HINTS ${GLUT_HINT_DIRS})
find_library(GLUT_LIBRARY glut PATH_SUFFIXES lib HINTS ${GLUT_HINT_DIRS})
endif ()
mark_as_advanced(GLUT_glut_LIBRARY GLUT_Xmu_LIBRARY GLUT_Xi_LIBRARY)
include(FindPackageHandleStandardArgs)
endif ()
set(GLUT_LIBRARIES "${GLUT_LIBRARY}" "${XMU_LIBRARY}" "${XI_LIBRARY}")
if (UNIX)
find_library(XI_LIBRARY Xi PATH_SUFFIXES lib HINTS ${GLUT_HINT_DIRS})
find_library(XMU_LIBRARY Xmu PATH_SUFFIXES lib HINTS ${GLUT_HINT_DIRS})
find_package_handle_standard_args(GLUT DEFAULT_MSG GLUT_INCLUDE_DIRS GLUT_LIBRARIES XI_LIBRARY XMU_LIBRARY)
else ()
find_package_handle_standard_args(GLUT DEFAULT_MSG GLUT_INCLUDE_DIRS GLUT_LIBRARIES)
endif ()
mark_as_advanced(GLUT_INCLUDE_DIRS GLUT_LIBRARIES GLUT_LIBRARY XI_LIBRARY XMU_LIBRARY)

View file

@ -12,36 +12,24 @@
# Copyright (c) 2014 High Fidelity
#
if (LEAPMOTION_LIBRARIES AND LEAPMOTION_INCLUDE_DIRS)
# in cache already
set(LEAPMOTION_FOUND TRUE)
else (LEAPMOTION_LIBRARIES AND LEAPMOTION_INCLUDE_DIRS)
set(LEAPMOTION_SEARCH_DIRS "${LEAPMOTION_ROOT_DIR}" "$ENV{HIFI_LIB_DIR}/leapmotion")
set(LEAPMOTION_SEARCH_DIRS "${LEAPMOTION_ROOT_DIR}" "$ENV{HIFI_LIB_DIR}/leapmotion")
find_path(LEAPMOTION_INCLUDE_DIRS Leap.h PATH_SUFFIXES include HINTS ${LEAPMOTION_SEARCH_DIRS})
find_path(LEAPMOTION_INCLUDE_DIRS Leap.h PATH_SUFFIXES include HINTS ${LEAPMOTION_SEARCH_DIRS})
if (WIN32)
find_library(LEAPMOTION_LIBRARIES "lib/x86/Leap.lib" HINTS ${LEAPMOTION_SEARCH_DIRS})
endif (WIN32)
if (APPLE)
find_library(LEAPMOTION_LIBRARIES "lib/libLeap.dylib" HINTS ${LEAPMOTION_SEARCH_DIRS})
endif (APPLE)
if (LEAPMOTION_INCLUDE_DIRS AND LEAPMOTION_LIBRARIES)
set(LEAPMOTION_FOUND TRUE)
endif (LEAPMOTION_INCLUDE_DIRS AND LEAPMOTION_LIBRARIES)
if (WIN32)
find_library(LEAPMOTION_LIBRARY_DEBUG "lib/x86/Leapd.lib" HINTS ${LEAPMOTION_SEARCH_DIRS})
find_library(LEAPMOTION_LIBRARY_RELEASE "lib/x86/Leap.lib" HINTS ${LEAPMOTION_SEARCH_DIRS})
endif (WIN32)
if (APPLE)
find_library(LEAPMOTION_LIBRARY_RELEASE "lib/libLeap.dylib" HINTS ${LEAPMOTION_SEARCH_DIRS})
endif (APPLE)
if (LEAPMOTION_FOUND)
if (NOT LEAPMOTION_FIND_QUIETLY)
message(STATUS "Found LEAPMOTION... ${LEAPMOTION_LIBRARIES}")
endif (NOT LEAPMOTION_FIND_QUIETLY)
else ()
if (LEAPMOTION_FIND_REQUIRED)
message(FATAL_ERROR "Could not find LEAPMOTION")
endif (LEAPMOTION_FIND_REQUIRED)
endif ()
include(SelectLibraryConfigurations)
select_library_configurations(LEAPMOTION)
# show the LEAPMOTION_INCLUDE_DIRS and LEAPMOTION_LIBRARIES variables only in the advanced view
mark_as_advanced(LEAPMOTION_INCLUDE_DIRS LEAPMOTION_LIBRARIES)
set(LEAPMOTION_LIBRARIES "${LEAPMOTION_LIBARIES}")
endif (LEAPMOTION_LIBRARIES AND LEAPMOTION_INCLUDE_DIRS)
include(FindPackageHandleStandardArgs)
find_package_handle_standard_args(LEAPMOTION DEFAULT_MSG LEAPMOTION_INCLUDE_DIRS LEAPMOTION_LIBRARIES)
mark_as_advanced(LEAPMOTION_INCLUDE_DIRS LEAPMOTION_LIBRARIES)

View file

@ -18,52 +18,49 @@
# See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
#
if (LIBOVR_LIBRARIES AND LIBOVR_INCLUDE_DIRS)
# in cache already
set(LIBOVR_FOUND TRUE)
else (LIBOVR_LIBRARIES AND LIBOVR_INCLUDE_DIRS)
set(LIBOVR_SEARCH_DIRS "${LIBOVR_ROOT_DIR}" "$ENV{HIFI_LIB_DIR}/oculus")
set(LIBOVR_SEARCH_DIRS "${LIBOVR_ROOT_DIR}" "$ENV{LIBOVR_ROOT_DIR}" "$ENV{HIFI_LIB_DIR}/oculus")
find_path(LIBOVR_INCLUDE_DIRS OVR.h PATH_SUFFIXES Include HINTS ${LIBOVR_SEARCH_DIRS})
find_path(LIBOVR_UTIL_INCLUDE_DIR Util_Render_Stereo.h PATH_SUFFIXES Src/Util HINTS ${LIBOVR_SEARCH_DIRS})
# add the util include dir to the general include dirs
set(LIBOVR_INCLUDE_DIRS "${LIBOVR_INCLUDE_DIRS}" "${LIBOVR_UTIL_INCLUDE_DIR}")
include(SelectLibraryConfigurations)
if (APPLE)
find_library(LIBOVR_LIBRARY_DEBUG "Lib/MacOS/Debug/libovr.a" HINTS ${LIBOVR_SEARCH_DIRS})
find_library(LIBOVR_LIBRARY_RELEASE "Lib/MacOS/Release/libovr.a" HINTS ${LIBOVR_SEARCH_DIRS})
elseif (UNIX)
find_library(UDEV_LIBRARY_RELEASE udev /usr/lib/x86_64-linux-gnu/)
find_library(XINERAMA_LIBRARY_RELEASE Xinerama /usr/lib/x86_64-linux-gnu/)
find_path(LIBOVR_INCLUDE_DIRS OVR.h PATH_SUFFIXES Include HINTS ${LIBOVR_SEARCH_DIRS})
if (CMAKE_CL_64)
set(LINUX_ARCH_DIR "i386")
else()
set(LINUX_ARCH_DIR "x86_64")
endif()
if (APPLE)
find_library(LIBOVR_LIBRARIES "Lib/MacOS/Release/libovr.a" HINTS ${LIBOVR_SEARCH_DIRS})
elseif (UNIX)
find_library(UDEV_LIBRARY libudev.a /usr/lib/x86_64-linux-gnu/)
find_library(XINERAMA_LIBRARY libXinerama.a /usr/lib/x86_64-linux-gnu/)
if (CMAKE_CL_64)
set(LINUX_ARCH_DIR "i386")
else()
set(LINUX_ARCH_DIR "x86_64")
endif()
find_library(OVR_LIBRARY "Lib/Linux/${CMAKE_BUILD_TYPE}/${LINUX_ARCH_DIR}/libovr.a" HINTS ${LIBOVR_SEARCH_DIRS})
if (UDEV_LIBRARY AND XINERAMA_LIBRARY AND OVR_LIBRARY)
set(LIBOVR_LIBRARIES "${OVR_LIBRARY};${UDEV_LIBRARY};${XINERAMA_LIBRARY}" CACHE INTERNAL "Oculus libraries")
endif (UDEV_LIBRARY AND XINERAMA_LIBRARY AND OVR_LIBRARY)
elseif (WIN32)
find_library(LIBOVR_RELEASE_LIBRARIES "Lib/Win32/libovr.lib" HINTS ${LIBOVR_SEARCH_DIRS})
find_library(LIBOVR_DEBUG_LIBRARIES "Lib/Win32/libovrd.lib" HINTS ${LIBOVR_SEARCH_DIRS})
set(LIBOVR_LIBRARIES "${LIBOVR_RELEASE_LIBRARIES} ${LIBOVR_DEBUG_LIBRARIES}")
endif ()
find_library(LIBOVR_LIBRARY_DEBUG "Lib/Linux/Debug/${LINUX_ARCH_DIR}/libovr.a" HINTS ${LIBOVR_SEARCH_DIRS})
find_library(LIBOVR_LIBRARY_RELEASE "Lib/Linux/Release/${LINUX_ARCH_DIR}/libovr.a" HINTS ${LIBOVR_SEARCH_DIRS})
select_library_configurations(UDEV)
select_library_configurations(XINERAMA)
elseif (WIN32)
find_library(LIBOVR_LIBRARY_DEBUG "Lib/Win32/libovrd.lib" HINTS ${LIBOVR_SEARCH_DIRS})
find_library(LIBOVR_LIBRARY_RELEASE "Lib/Win32/libovr.lib" HINTS ${LIBOVR_SEARCH_DIRS})
endif ()
if (LIBOVR_INCLUDE_DIRS AND LIBOVR_LIBRARIES)
set(LIBOVR_FOUND TRUE)
endif (LIBOVR_INCLUDE_DIRS AND LIBOVR_LIBRARIES)
if (LIBOVR_FOUND)
if (NOT LibOVR_FIND_QUIETLY)
message(STATUS "Found LibOVR: ${LIBOVR_LIBRARIES}")
endif (NOT LibOVR_FIND_QUIETLY)
else (LIBOVR_FOUND)
if (LibOVR_FIND_REQUIRED)
message(FATAL_ERROR "Could not find LibOVR")
endif (LibOVR_FIND_REQUIRED)
endif (LIBOVR_FOUND)
select_library_configurations(LIBOVR)
# show the LIBOVR_INCLUDE_DIRS and LIBOVR_LIBRARIES variables only in the advanced view
mark_as_advanced(LIBOVR_INCLUDE_DIRS LIBOVR_LIBRARIES)
set(LIBOVR_LIBRARIES "${LIBOVR_LIBRARIES}" "${UDEV_LIBRARY}" "${XINERAMA_LIBRARY}")
endif (LIBOVR_LIBRARIES AND LIBOVR_INCLUDE_DIRS)
include(FindPackageHandleStandardArgs)
if (UNIX)
find_package_handle_standard_args(LIBOVR DEFAULT_MSG LIBOVR_INCLUDE_DIRS LIBOVR_UTIL_INCLUDE_DIR LIBOVR_LIBRARIES)
elseif ()
find_package_handle_standard_args(LIBOVR DEFAULT_MSG LIBOVR_INCLUDE_DIRS LIBOVR_UTIL_INCLUDE_DIR LIBOVR_LIBRARIES UDEV_LIBRARY XINERAMA_LIBRARY)
endif ()
mark_as_advanced(LIBOVR_INCLUDE_DIRS LIBOVR_LIBRARIES)

View file

@ -35,43 +35,24 @@ endif ()
if (WIN32)
# http://www.slproweb.com/products/Win32OpenSSL.html
set(_OPENSSL_ROOT_HINTS
${OPENSSL_ROOT_DIR}
$ENV{OPENSSL_ROOT_DIR}
$ENV{HIFI_LIB_DIR}/openssl
set(_OPENSSL_ROOT_HINTS ${OPENSSL_ROOT_DIR} $ENV{OPENSSL_ROOT_DIR} $ENV{HIFI_LIB_DIR}/openssl
"[HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Uninstall\\OpenSSL (32-bit)_is1;Inno Setup: App Path]"
"[HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Uninstall\\OpenSSL (64-bit)_is1;Inno Setup: App Path]"
)
file(TO_CMAKE_PATH "$ENV{PROGRAMFILES}" _programfiles)
set(_OPENSSL_ROOT_PATHS
"${_programfiles}/OpenSSL"
"${_programfiles}/OpenSSL-Win32"
"${_programfiles}/OpenSSL-Win64"
"C:/OpenSSL/"
"C:/OpenSSL-Win32/"
"C:/OpenSSL-Win64/"
)
set(_OPENSSL_ROOT_PATHS "${_programfiles}/OpenSSL" "${_programfiles}/OpenSSL-Win32" "${_programfiles}/OpenSSL-Win64"
"C:/OpenSSL/" "C:/OpenSSL-Win32/" "C:/OpenSSL-Win64/"
)
unset(_programfiles)
set(_OPENSSL_ROOT_HINTS_AND_PATHS
HINTS ${_OPENSSL_ROOT_HINTS}
PATHS ${_OPENSSL_ROOT_PATHS}
)
set(_OPENSSL_ROOT_HINTS_AND_PATHS HINTS ${_OPENSSL_ROOT_HINTS} PATHS ${_OPENSSL_ROOT_PATHS})
else ()
set(_OPENSSL_ROOT_HINTS_AND_PATHS ${OPENSSL_ROOT_DIR} $ENV{OPENSSL_ROOT_DIR} $ENV{HIFI_LIB_DIR}/openssl)
endif ()
find_path(OPENSSL_INCLUDE_DIR
NAMES
openssl/ssl.h
HINTS
${_OPENSSL_ROOT_HINTS_AND_PATHS}
${_OPENSSL_INCLUDEDIR}
PATH_SUFFIXES
include
)
find_path(OPENSSL_INCLUDE_DIR NAMES openssl/ssl.h HINTS ${_OPENSSL_ROOT_HINTS_AND_PATHS} ${_OPENSSL_INCLUDEDIR} PATH_SUFFIXES include)
if(WIN32 AND NOT CYGWIN)
if(MSVC)
if (WIN32 AND NOT CYGWIN)
if (MSVC)
# /MD and /MDd are the standard values - if someone wants to use
# others, the libnames have to change here too
# use also ssl and ssleay32 in debug as fallback for openssl < 0.9.8b
@ -86,49 +67,20 @@ if(WIN32 AND NOT CYGWIN)
# We are using the libraries located in the VC subdir instead of the parent directory eventhough :
# libeay32MD.lib is identical to ../libeay32.lib, and
# ssleay32MD.lib is identical to ../ssleay32.lib
find_library(LIB_EAY_DEBUG
NAMES
libeay32MDd
libeay32d
${_OPENSSL_ROOT_HINTS_AND_PATHS}
PATH_SUFFIXES
"lib"
"VC"
"lib/VC"
find_library(LIB_EAY_DEBUG NAMES libeay32MDd libeay32d
${_OPENSSL_ROOT_HINTS_AND_PATHS} PATH_SUFFIXES "lib" "VC" "lib/VC"
)
find_library(LIB_EAY_RELEASE
NAMES
libeay32MD
libeay32
${_OPENSSL_ROOT_HINTS_AND_PATHS}
PATH_SUFFIXES
"lib"
"VC"
"lib/VC"
find_library(LIB_EAY_RELEASE NAMES libeay32MD libeay32
${_OPENSSL_ROOT_HINTS_AND_PATHS} PATH_SUFFIXES "lib" "VC" "lib/VC"
)
find_library(SSL_EAY_DEBUG
NAMES
ssleay32MDd
ssleay32d
${_OPENSSL_ROOT_HINTS_AND_PATHS}
PATH_SUFFIXES
"lib"
"VC"
"lib/VC"
find_library(SSL_EAY_DEBUG NAMES ssleay32MDd ssleay32d
${_OPENSSL_ROOT_HINTS_AND_PATHS} PATH_SUFFIXES "lib" "VC" "lib/VC"
)
find_library(SSL_EAY_RELEASE
NAMES
ssleay32MD
ssleay32
ssl
${_OPENSSL_ROOT_HINTS_AND_PATHS}
PATH_SUFFIXES
"lib"
"VC"
"lib/VC"
find_library(SSL_EAY_RELEASE NAMES ssleay32MD ssleay32 ssl
${_OPENSSL_ROOT_HINTS_AND_PATHS} PATH_SUFFIXES "lib" "VC" "lib/VC"
)
set(LIB_EAY_LIBRARY_DEBUG "${LIB_EAY_DEBUG}")
@ -140,85 +92,45 @@ if(WIN32 AND NOT CYGWIN)
select_library_configurations(LIB_EAY)
select_library_configurations(SSL_EAY)
set( OPENSSL_LIBRARIES ${SSL_EAY_LIBRARY} ${LIB_EAY_LIBRARY} )
elseif(MINGW)
set(OPENSSL_LIBRARIES ${SSL_EAY_LIBRARY} ${LIB_EAY_LIBRARY})
elseif (MINGW)
# same player, for MinGW
set(LIB_EAY_NAMES libeay32)
set(SSL_EAY_NAMES ssleay32)
if(CMAKE_CROSSCOMPILING)
if (CMAKE_CROSSCOMPILING)
list(APPEND LIB_EAY_NAMES crypto)
list(APPEND SSL_EAY_NAMES ssl)
endif()
find_library(LIB_EAY
NAMES
${LIB_EAY_NAMES}
${_OPENSSL_ROOT_HINTS_AND_PATHS}
PATH_SUFFIXES
"lib"
"lib/MinGW"
endif ()
find_library(LIB_EAY NAMES ${LIB_EAY_NAMES}
${_OPENSSL_ROOT_HINTS_AND_PATHS} PATH_SUFFIXES "lib" "lib/MinGW"
)
find_library(SSL_EAY
NAMES
${SSL_EAY_NAMES}
${_OPENSSL_ROOT_HINTS_AND_PATHS}
PATH_SUFFIXES
"lib"
"lib/MinGW"
find_library(SSL_EAY NAMES ${SSL_EAY_NAMES}
${_OPENSSL_ROOT_HINTS_AND_PATHS} PATH_SUFFIXES "lib" "lib/MinGW"
)
mark_as_advanced(SSL_EAY LIB_EAY)
set( OPENSSL_LIBRARIES ${SSL_EAY} ${LIB_EAY} )
set(OPENSSL_LIBRARIES ${SSL_EAY} ${LIB_EAY})
unset(LIB_EAY_NAMES)
unset(SSL_EAY_NAMES)
else()
else ()
# Not sure what to pick for -say- intel, let's use the toplevel ones and hope someone report issues:
find_library(LIB_EAY
NAMES
libeay32
HINTS
${_OPENSSL_ROOT_HINTS_AND_PATHS}
${_OPENSSL_LIBDIR}
PATH_SUFFIXES
lib
)
find_library(LIB_EAY NAMES libeay32 HINTS ${_OPENSSL_ROOT_HINTS_AND_PATHS} ${_OPENSSL_LIBDIR} PATH_SUFFIXES lib)
find_library(SSL_EAY
NAMES
ssleay32
HINTS
${_OPENSSL_ROOT_HINTS_AND_PATHS}
${_OPENSSL_LIBDIR}
PATH_SUFFIXES
lib
)
find_library(SSL_EAY NAMES ssleay32 HINTS ${_OPENSSL_ROOT_HINTS_AND_PATHS} ${_OPENSSL_LIBDIR} PATH_SUFFIXES lib)
mark_as_advanced(SSL_EAY LIB_EAY)
set( OPENSSL_LIBRARIES ${SSL_EAY} ${LIB_EAY} )
set(OPENSSL_LIBRARIES ${SSL_EAY} ${LIB_EAY})
endif()
else()
find_library(OPENSSL_SSL_LIBRARY
NAMES
ssl
ssleay32
ssleay32MD
HINTS
${_OPENSSL_ROOT_HINTS_AND_PATHS}
${_OPENSSL_LIBDIR}
PATH_SUFFIXES
lib
find_library(OPENSSL_SSL_LIBRARY NAMES ssl ssleay32 ssleay32MD HINTS ${_OPENSSL_ROOT_HINTS_AND_PATHS} ${_OPENSSL_LIBDIR}
PATH_SUFFIXES lib
)
find_library(OPENSSL_CRYPTO_LIBRARY
NAMES
crypto
HINTS
${_OPENSSL_ROOT_HINTS_AND_PATHS}
${_OPENSSL_LIBDIR}
PATH_SUFFIXES
lib
)
find_library(OPENSSL_CRYPTO_LIBRARY NAMES crypto HINTS ${_OPENSSL_ROOT_HINTS_AND_PATHS} ${_OPENSSL_LIBDIR} PATH_SUFFIXES lib)
mark_as_advanced(OPENSSL_CRYPTO_LIBRARY OPENSSL_SSL_LIBRARY)
@ -228,7 +140,7 @@ else()
set(OPENSSL_LIBRARIES ${OPENSSL_SSL_LIBRARY} ${OPENSSL_CRYPTO_LIBRARY})
endif()
endif ()
function(from_hex HEX DEC)
string(TOUPPER "${HEX}" HEX)

View file

@ -1,4 +1,4 @@
# Try to find the PrioVT library
# Try to find the PrioVR library
#
# You must provide a PRIOVR_ROOT_DIR which contains lib and include directories
#
@ -12,31 +12,13 @@
# Copyright (c) 2014 High Fidelity
#
if (PRIOVR_LIBRARIES AND PRIOVR_INCLUDE_DIRS)
# in cache already
set(PRIOVR_FOUND TRUE)
else (PRIOVR_LIBRARIES AND PRIOVR_INCLUDE_DIRS)
find_path(PRIOVR_INCLUDE_DIRS yei_skeletal_api.h ${PRIOVR_ROOT_DIR}/include)
find_path(PRIOVR_INCLUDE_DIRS yei_skeletal_api.h ${PRIOVR_ROOT_DIR}/include)
if (WIN32)
find_library(PRIOVR_LIBRARIES Skeletal_API.lib ${PRIOVR_ROOT_DIR}/lib)
endif (WIN32)
if (PRIOVR_INCLUDE_DIRS AND PRIOVR_LIBRARIES)
set(PRIOVR_FOUND TRUE)
endif (PRIOVR_INCLUDE_DIRS AND PRIOVR_LIBRARIES)
if (WIN32)
find_library(PRIOVR_LIBRARIES Skeletal_API.lib ${PRIOVR_ROOT_DIR}/lib)
endif (WIN32)
if (PRIOVR_FOUND)
if (NOT PRIOVR_FIND_QUIETLY)
message(STATUS "Found PrioVR... ${PRIOVR_LIBRARIES}")
endif (NOT PRIOVR_FIND_QUIETLY)
else ()
if (PRIOVR_FIND_REQUIRED)
message(FATAL_ERROR "Could not find PrioVR")
endif (PRIOVR_FIND_REQUIRED)
endif ()
include(FindPackageHandleStandardArgs)
find_package_handle_standard_args(PRIOVR DEFAULT_MSG PRIOVR_INCLUDE_DIRS PRIOVR_LIBRARIES)
# show the PRIOVR_INCLUDE_DIRS and PRIOVR_LIBRARIES variables only in the advanced view
mark_as_advanced(PRIOVR_INCLUDE_DIRS PRIOVR_LIBRARIES)
endif (PRIOVR_LIBRARIES AND PRIOVR_INCLUDE_DIRS)
mark_as_advanced(PRIOVR_INCLUDE_DIRS PRIOVR_LIBRARIES)

View file

@ -9,7 +9,7 @@
#
# QXMPP_FOUND - system found qxmpp
# QXMPP_INCLUDE_DIRS - the qxmpp include directory
# QXMPP_LIBRARY - Link this to use qxmpp
# QXMPP_LIBRARIES - Link this to use qxmpp
#
# Created on 3/10/2014 by Stephen Birarda
# Copyright 2014 High Fidelity, Inc.
@ -18,17 +18,19 @@
# See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
#
if (QXMPP_LIBRARIES AND QXMPP_INCLUDE_DIRS)
# in cache already
set(QXMPP_FOUND TRUE)
else ()
set(QXMPP_SEARCH_DIRS "${QXMPP_ROOT_DIR}" "$ENV{HIFI_LIB_DIR}/qxmpp")
find_path(QXMPP_INCLUDE_DIR QXmppClient.h PATH_SUFFIXES include/qxmpp HINTS ${QXMPP_SEARCH_DIRS})
set(QXMPP_SEARCH_DIRS "${QXMPP_ROOT_DIR}" "$ENV{HIFI_LIB_DIR}/qxmpp")
find_library(QXMPP_LIBRARY NAMES qxmpp qxmpp0 qxmpp_d PATH_SUFFIXES lib HINTS ${QXMPP_SEARCH_DIRS})
include(FindPackageHandleStandardArgs)
find_package_handle_standard_args(QXMPP DEFAULT_MSG QXMPP_INCLUDE_DIR QXMPP_LIBRARY)
endif ()
find_path(QXMPP_INCLUDE_DIRS QXmppClient.h PATH_SUFFIXES include/qxmpp HINTS ${QXMPP_SEARCH_DIRS})
find_library(QXMPP_LIBRARY_RELEASE NAMES qxmpp PATH_SUFFIXES lib HINTS ${QXMPP_SEARCH_DIRS})
find_library(QXMPP_LIBRARY_DEBUG NAMES qxmpp_d PATH_SUFFIXES lib HINTS ${QXMPP_SEARCH_DIRS})
include(SelectLibraryConfigurations)
select_library_configurations(QXMPP)
set(QXMPP_LIBRARIES "${QXMPP_LIBRARY}")
include(FindPackageHandleStandardArgs)
find_package_handle_standard_args(QXMPP DEFAULT_MSG QXMPP_INCLUDE_DIRS QXMPP_LIBRARIES)
mark_as_advanced(QXMPP_INCLUDE_DIRS QXMPP_LIBRARIES)

View file

@ -9,7 +9,7 @@
#
# RTMIDI_FOUND - system found RtMidi
# RTMIDI_INCLUDE_DIRS - the RtMidi include directory
# RTMIDI_CPP - Include this with src to use RtMidi
# RTMIDI_LIBRARIES - link to this to use RtMidi
#
# Created on 6/30/2014 by Stephen Birarda
# Copyright 2014 High Fidelity, Inc.
@ -18,16 +18,12 @@
# See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
#
if (RTMIDI_LIBRARIES AND RTMIDI_INCLUDE_DIRS)
# in cache already
set(RTMIDI_FOUND TRUE)
else ()
set(RTMIDI_SEARCH_DIRS "${RTMIDI_ROOT_DIR}" "$ENV{HIFI_LIB_DIR}/rtmidi")
find_path(RTMIDI_INCLUDE_DIR RtMidi.h PATH_SUFFIXES include HINTS ${RTMIDI_SEARCH_DIRS})
find_library(RTMIDI_LIBRARY NAMES rtmidi PATH_SUFFIXES lib HINTS ${RTMIDI_SEARCH_DIRS})
include(FindPackageHandleStandardArgs)
find_package_handle_standard_args(RTMIDI DEFAULT_MSG RTMIDI_INCLUDE_DIR RTMIDI_LIBRARY)
endif ()
set(RTMIDI_SEARCH_DIRS "${RTMIDI_ROOT_DIR}" "$ENV{HIFI_LIB_DIR}/rtmidi")
find_path(RTMIDI_INCLUDE_DIRS RtMidi.h PATH_SUFFIXES include HINTS ${RTMIDI_SEARCH_DIRS})
find_library(RTMIDI_LIBRARIES NAMES rtmidi PATH_SUFFIXES lib HINTS ${RTMIDI_SEARCH_DIRS})
include(FindPackageHandleStandardArgs)
find_package_handle_standard_args(RTMIDI DEFAULT_MSG RTMIDI_INCLUDE_DIRS RTMIDI_LIBRARIES)
mark_as_advanced(RTMIDI_INCLUDE_DIRS RTMIDI_LIBRARIES)

View file

@ -18,34 +18,27 @@
# See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
#
if (SIXENSE_LIBRARIES AND SIXENSE_INCLUDE_DIRS)
# in cache already
set(SIXENSE_FOUND TRUE)
else ()
set(SIXENSE_SEARCH_DIRS "${SIXENSE_ROOT_DIR}" "$ENV{HIFI_LIB_DIR}/sixense")
find_path(SIXENSE_INCLUDE_DIRS sixense.h PATH_SUFFIXES include HINTS ${SIXENSE_SEARCH_DIRS})
set(SIXENSE_SEARCH_DIRS "${SIXENSE_ROOT_DIR}" "$ENV{HIFI_LIB_DIR}/sixense")
if (APPLE)
find_library(SIXENSE_LIBRARIES lib/osx_x64/release_dll/libsixense_x64.dylib HINTS ${SIXENSE_SEARCH_DIRS})
elseif (UNIX)
find_library(SIXENSE_LIBRARIES lib/linux_x64/release/libsixense_x64.so HINTS ${SIXENSE_SEARCH_DIRS})
elseif (WIN32)
find_library(SIXENSE_LIBRARIES lib/win32/release_dll/sixense.lib HINTS ${SIXENSE_SEARCH_DIRS})
endif ()
find_path(SIXENSE_INCLUDE_DIRS sixense.h PATH_SUFFIXES include HINTS ${SIXENSE_SEARCH_DIRS})
if (SIXENSE_INCLUDE_DIRS AND SIXENSE_LIBRARIES)
set(SIXENSE_FOUND TRUE)
endif ()
if (SIXENSE_FOUND)
if (NOT SIXENSE_FIND_QUIETLY)
message(STATUS "Found Sixense: ${SIXENSE_LIBRARIES}")
endif (NOT SIXENSE_FIND_QUIETLY)
else ()
if (SIXENSE_FIND_REQUIRED)
message(FATAL_ERROR "Could not find Sixense")
endif (SIXENSE_FIND_REQUIRED)
endif ()
if (APPLE)
find_library(SIXENSE_LIBRARY_RELEASE lib/osx_x64/release_dll/libsixense_x64.dylib HINTS ${SIXENSE_SEARCH_DIRS})
find_library(SIXENSE_LIBRARY_DEBUG lib/osx_x64/debug_dll/libsixensed_x64.dylib HINTS ${SIXENSE_SEARCH_DIRS})
elseif (UNIX)
find_library(SIXENSE_LIBRARY_RELEASE lib/linux_x64/release/libsixense_x64.so HINTS ${SIXENSE_SEARCH_DIRS})
find_library(SIXENSE_LIBRARY_DEBUG lib/linux_x64/debug/libsixensed_x64.so HINTS ${SIXENSE_SEARCH_DIRS})
elseif (WIN32)
find_library(SIXENSE_LIBRARY_RELEASE lib/win32/release_dll/sixense.lib HINTS ${SIXENSE_SEARCH_DIRS})
find_library(SIXENSE_LIBRARY_DEBUG lib/win32/debug_dll/sixensed.lib HINTS ${SIXENSE_SEARCH_DIRS})
endif ()
include(SelectLibraryConfigurations)
select_library_configurations(SIXENSE)
set(SIXENSE_LIBRARIES "${SIXENSE_LIBRARY}")
include(FindPackageHandleStandardArgs)
find_package_handle_standard_args(SIXENSE DEFAULT_MSG SIXENSE_INCLUDE_DIRS SIXENSE_LIBRARIES)
mark_as_advanced(SIXENSE_LIBRARIES SIXENSE_INCLUDE_DIRS)

View file

@ -18,65 +18,40 @@
# See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
#
if (VISAGE_LIBRARIES AND VISAGE_INCLUDE_DIRS)
# in cache already
set(VISAGE_FOUND TRUE)
else ()
find_path(VISAGE_INCLUDE_DIR VisageTracker2.h ${VISAGE_ROOT_DIR}/include)
set(VISAGE_SEARCH_DIRS "${VISAGE_ROOT_DIR}" "$ENV{VISAGE_ROOT_DIR}" "$ENV{HIFI_LIB_DIR}/visage")
find_path(VISAGE_BASE_INCLUDE_DIR VisageTracker2.h PATH_SUFFIXES include HINTS ${VISAGE_SEARCH_DIRS})
if (APPLE)
find_path(VISAGE_XML_INCLUDE_DIR libxml/xmlreader.h HINTS /usr/include/libxml2 ${VISAGE_SEARCH_DIRS})
find_path(VISAGE_OPENCV_INCLUDE_DIR cv.h PATH_SUFFIXES dependencies/OpenCV_MacOSX/include HINTS ${VISAGE_SEARCH_DIRS})
find_path(VISAGE_OPENCV2_INCLUDE_DIR opencv.hpp PATH_SUFFIXES dependencies/OpenCV_MacOSX/include/opencv2 HINTS ${VISAGE_SEARCH_DIRS})
if (APPLE)
find_path(VISAGE_XML_INCLUDE_DIR libxml/xmlreader.h /usr/include/libxml2)
find_path(VISAGE_OPENCV_INCLUDE_DIR cv.h ${VISAGE_ROOT_DIR}/dependencies/OpenCV_MacOSX/include)
find_path(VISAGE_OPENCV2_INCLUDE_DIR opencv.hpp ${VISAGE_ROOT_DIR}/dependencies/OpenCV_MacOSX/include/opencv2)
if (VISAGE_INCLUDE_DIR AND VISAGE_XML_INCLUDE_DIR AND VISAGE_OPENCV_INCLUDE_DIR AND VISAGE_OPENCV2_INCLUDE_DIR)
set(VISAGE_INCLUDE_DIRS
"${VISAGE_INCLUDE_DIR};${VISAGE_XML_INCLUDE_DIR};${VISAGE_OPENCV_INCLUDE_DIR};${VISAGE_OPENCV2_INCLUDE_DIR}"
CACHE INTERNAL "Visage include dirs")
endif (VISAGE_INCLUDE_DIR AND VISAGE_XML_INCLUDE_DIR AND VISAGE_OPENCV_INCLUDE_DIR AND VISAGE_OPENCV2_INCLUDE_DIR)
find_library(VISAGE_CORE_LIBRARY libvscore.a ${VISAGE_ROOT_DIR}/lib)
find_library(VISAGE_VISION_LIBRARY libvsvision.a ${VISAGE_ROOT_DIR}/lib)
find_library(VISAGE_OPENCV_LIBRARY libOpenCV.a ${VISAGE_ROOT_DIR}/dependencies/OpenCV_MacOSX/lib)
if (VISAGE_CORE_LIBRARY AND VISAGE_VISION_LIBRARY AND VISAGE_OPENCV_LIBRARY)
set(VISAGE_LIBRARIES "${VISAGE_CORE_LIBRARY};${VISAGE_VISION_LIBRARY};${VISAGE_OPENCV_LIBRARY}"
CACHE INTERNAL "Visage libraries")
endif (VISAGE_CORE_LIBRARY AND VISAGE_VISION_LIBRARY AND VISAGE_OPENCV_LIBRARY)
elseif (WIN32)
find_path(VISAGE_XML_INCLUDE_DIR libxml/xmlreader.h ${VISAGE_ROOT_DIR}/dependencies/libxml2/include)
find_path(VISAGE_OPENCV_INCLUDE_DIR opencv/cv.h ${VISAGE_ROOT_DIR}/dependencies/OpenCV/include)
find_path(VISAGE_OPENCV2_INCLUDE_DIR cv.h ${VISAGE_ROOT_DIR}/dependencies/OpenCV/include/opencv)
if (VISAGE_INCLUDE_DIR AND VISAGE_XML_INCLUDE_DIR AND VISAGE_OPENCV_INCLUDE_DIR AND VISAGE_OPENCV2_INCLUDE_DIR)
set(VISAGE_INCLUDE_DIRS
"${VISAGE_INCLUDE_DIR};${VISAGE_XML_INCLUDE_DIR};${VISAGE_OPENCV_INCLUDE_DIR};${VISAGE_OPENCV2_INCLUDE_DIR}"
CACHE INTERNAL "Visage include dirs")
endif (VISAGE_INCLUDE_DIR AND VISAGE_XML_INCLUDE_DIR AND VISAGE_OPENCV_INCLUDE_DIR AND VISAGE_OPENCV2_INCLUDE_DIR)
find_library(VISAGE_CORE_LIBRARY vscore.lib ${VISAGE_ROOT_DIR}/lib)
find_library(VISAGE_VISION_LIBRARY vsvision.lib ${VISAGE_ROOT_DIR}/lib)
find_library(VISAGE_OPENCV_LIBRARY opencv_core243.lib ${VISAGE_ROOT_DIR}/dependencies/OpenCV/lib)
if (VISAGE_CORE_LIBRARY AND VISAGE_VISION_LIBRARY AND VISAGE_OPENCV_LIBRARY)
set(VISAGE_LIBRARIES "${VISAGE_CORE_LIBRARY};${VISAGE_VISION_LIBRARY};${VISAGE_OPENCV_LIBRARY}"
CACHE INTERNAL "Visage libraries")
endif (VISAGE_CORE_LIBRARY AND VISAGE_VISION_LIBRARY AND VISAGE_OPENCV_LIBRARY)
endif ()
if (VISAGE_INCLUDE_DIRS AND VISAGE_LIBRARIES)
set(VISAGE_FOUND TRUE)
endif (VISAGE_INCLUDE_DIRS AND VISAGE_LIBRARIES)
if (VISAGE_FOUND)
if (NOT VISAGE_FIND_QUIETLY)
message(STATUS "Found Visage: ${VISAGE_LIBRARIES}")
endif (NOT VISAGE_FIND_QUIETLY)
else (VISAGE_FOUND)
if (VISAGE_FIND_REQUIRED)
message(FATAL_ERROR "Could not find Visage")
endif (VISAGE_FIND_REQUIRED)
endif (VISAGE_FOUND)
# show the VISAGE_INCLUDE_DIRS and VISAGE_LIBRARIES variables only in the advanced view
mark_as_advanced(VISAGE_INCLUDE_DIRS VISAGE_LIBRARIES)
find_library(VISAGE_CORE_LIBRARY NAME vscore PATH_SUFFIXES lib HINTS ${VISAGE_SEARCH_DIRS})
find_library(VISAGE_VISION_LIBRARY NAME vsvision PATH_SUFFIXES lib HINTS ${VISAGE_SEARCH_DIRS})
find_library(VISAGE_OPENCV_LIBRARY NAME OpenCV PATH_SUFFIXES dependencies/OpenCV_MacOSX/lib ${VISAGE_SEARCH_DIRS})
elseif (WIN32)
find_path(VISAGE_XML_INCLUDE_DIR libxml/xmlreader.h PATH_SUFFIXES dependencies/libxml2/include HINTS ${VISAGE_SEARCH_DIRS})
find_path(VISAGE_OPENCV_INCLUDE_DIR opencv/cv.h PATH_SUFFIXES dependencies/OpenCV/include HINTS ${VISAGE_SEARCH_DIRS})
find_path(VISAGE_OPENCV2_INCLUDE_DIR cv.h PATH_SUFFIXES dependencies/OpenCV/include/opencv HINTS ${VISAGE_SEARCH_DIRS})
find_library(VISAGE_CORE_LIBRARY NAME vscore PATH_SUFFIXES lib HINTS ${VISAGE_SEARCH_DIRS})
find_library(VISAGE_VISION_LIBRARY NAME vsvision PATH_SUFFIXES lib HINTS ${VISAGE_SEARCH_DIRS})
find_library(VISAGE_OPENCV_LIBRARY NAME opencv_core243 PATH_SUFFIXES dependencies/OpenCV/lib HINTS ${VISAGE_SEARCH_DIRS})
endif ()
include(FindPackageHandleStandardArgs)
find_package_handle_standard_args(VISAGE DEFAULT_MSG
VISAGE_BASE_INCLUDE_DIR VISAGE_XML_INCLUDE_DIR VISAGE_OPENCV_INCLUDE_DIR VISAGE_OPENCV2_INCLUDE_DIR
VISAGE_CORE_LIBRARY VISAGE_VISION_LIBRARY VISAGE_OPENCV_LIBRARY
)
set(VISAGE_INCLUDE_DIRS "${VISAGE_XML_INCLUDE_DIR}" "${VISAGE_OPENCV_INCLUDE_DIR}" "${VISAGE_OPENCV2_INCLUDE_DIR}" "${VISAGE_BASE_INCLUDE_DIR}")
set(VISAGE_LIBRARIES "${VISAGE_CORE_LIBRARY}" "${VISAGE_VISION_LIBRARY}" "${VISAGE_OPENCV_LIBRARY}")
mark_as_advanced(
VISAGE_INCLUDE_DIRS VISAGE_LIBRARIES
VISAGE_BASE_INCLUDE_DIR VISAGE_XML_INCLUDE_DIR VISAGE_OPENCV_INCLUDE_DIR VISAGE_OPENCV2_INCLUDE_DIR
VISAGE_CORE_LIBRARY VISAGE_VISION_LIBRARY VISAGE_OPENCV_LIBRARY
)

View file

@ -10,174 +10,127 @@
// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
//
var localLightDirections = [ {x: 1.0, y:1.0, z: 0.0}, {x: 0.0, y:1.0, z: 1.0} ];
var localLightColors = [ {x: 0.0, y:1.0, z: 0.0}, {x: 1.0, y:0.0, z: 0.0} ];
var localLightDirections = [ {x: 1.0, y:0.0, z: 0.0}, {x: 0.0, y:0.0, z: 1.0} ];
var localLightColors = [ {x: 0.4, y:0.335, z: 0.266}, {x: 0.4, y:0.335, z: 0.266} ];
var currentSelection = 0;
var currentNumLights = 1;
var currentNumLights = 2;
var maxNumLights = 2;
var currentNumAvatars = 0;
var changeDelta = 0.1;
var lightsDirty = true;
function keyPressEvent(event) {
var choice = parseInt(event.text);
if (event.text == "1") {
currentSelection = 0;
print("light election = " + currentSelection);
currentSelection = 0;
print("light election = " + currentSelection);
}
else if (event.text == "2" ) {
currentSelection = 1;
print("light selection = " + currentSelection);
currentSelection = 1;
print("light selection = " + currentSelection);
}
else if (event.text == "3" ) {
currentSelection = 2;
print("light selection = " + currentSelection);
currentSelection = 2;
print("light selection = " + currentSelection);
}
else if (event.text == "4" ) {
currentSelection = 3;
print("light selection = " + currentSelection);
currentSelection = 3;
print("light selection = " + currentSelection);
}
else if (event.text == "5" ) {
localLightColors[currentSelection].x += changeDelta;
if ( localLightColors[currentSelection].x > 1.0) {
localLightColors[currentSelection].x = 0.0;
}
setAllLightColors();
print("CHANGE RED light " + currentSelection + " color (" + localLightColors[currentSelection].x + ", " + localLightColors[currentSelection].y + ", " + localLightColors[currentSelection].z + " )" );
localLightColors[currentSelection].x += changeDelta;
if ( localLightColors[currentSelection].x > 1.0) {
localLightColors[currentSelection].x = 0.0;
}
lightsDirty = true;
print("CHANGE RED light " + currentSelection + " color (" + localLightColors[currentSelection].x + ", " + localLightColors[currentSelection].y + ", " + localLightColors[currentSelection].z + " )" );
}
else if (event.text == "6" ) {
localLightColors[currentSelection].y += changeDelta;
if ( localLightColors[currentSelection].y > 1.0) {
localLightColors[currentSelection].y = 0.0;
}
setAllLightColors();
print("CHANGE GREEN light " + currentSelection + " color (" + localLightColors[currentSelection].x + ", " + localLightColors[currentSelection].y + ", " + localLightColors[currentSelection].z + " )" );
localLightColors[currentSelection].y += changeDelta;
if ( localLightColors[currentSelection].y > 1.0) {
localLightColors[currentSelection].y = 0.0;
}
lightsDirty = true;
print("CHANGE GREEN light " + currentSelection + " color (" + localLightColors[currentSelection].x + ", " + localLightColors[currentSelection].y + ", " + localLightColors[currentSelection].z + " )" );
}
else if (event.text == "7" ) {
localLightColors[currentSelection].z += changeDelta;
if ( localLightColors[currentSelection].z > 1.0) {
localLightColors[currentSelection].z = 0.0;
}
setAllLightColors();
print("CHANGE BLUE light " + currentSelection + " color (" + localLightColors[currentSelection].x + ", " + localLightColors[currentSelection].y + ", " + localLightColors[currentSelection].z + " )" );
localLightColors[currentSelection].z += changeDelta;
if ( localLightColors[currentSelection].z > 1.0) {
localLightColors[currentSelection].z = 0.0;
}
lightsDirty = true;
print("CHANGE BLUE light " + currentSelection + " color (" + localLightColors[currentSelection].x + ", " + localLightColors[currentSelection].y + ", " + localLightColors[currentSelection].z + " )" );
}
else if (event.text == "8" ) {
localLightDirections[currentSelection].x += changeDelta;
if (localLightDirections[currentSelection].x > 1.0) {
localLightDirections[currentSelection].x = -1.0;
}
setAllLightDirections();
print("PLUS X light " + currentSelection + " direction (" + localLightDirections[currentSelection].x + ", " + localLightDirections[currentSelection].y + ", " + localLightDirections[currentSelection].z + " )" );
localLightDirections[currentSelection].x += changeDelta;
if (localLightDirections[currentSelection].x > 1.0) {
localLightDirections[currentSelection].x = -1.0;
}
lightsDirty = true;
print("PLUS X light " + currentSelection + " direction (" + localLightDirections[currentSelection].x + ", " + localLightDirections[currentSelection].y + ", " + localLightDirections[currentSelection].z + " )" );
}
else if (event.text == "9" ) {
localLightDirections[currentSelection].x -= changeDelta;
if (localLightDirections[currentSelection].x < -1.0) {
localLightDirections[currentSelection].x = 1.0;
}
setAllLightDirections();
print("MINUS X light " + currentSelection + " direction (" + localLightDirections[currentSelection].x + ", " + localLightDirections[currentSelection].y + ", " + localLightDirections[currentSelection].z + " )" );
localLightDirections[currentSelection].x -= changeDelta;
if (localLightDirections[currentSelection].x < -1.0) {
localLightDirections[currentSelection].x = 1.0;
}
lightsDirty = true;
print("MINUS X light " + currentSelection + " direction (" + localLightDirections[currentSelection].x + ", " + localLightDirections[currentSelection].y + ", " + localLightDirections[currentSelection].z + " )" );
}
else if (event.text == "0" ) {
localLightDirections[currentSelection].y += changeDelta;
if (localLightDirections[currentSelection].y > 1.0) {
localLightDirections[currentSelection].y = -1.0;
}
setAllLightDirections();
print("PLUS Y light " + currentSelection + " direction (" + localLightDirections[currentSelection].x + ", " + localLightDirections[currentSelection].y + ", " + localLightDirections[currentSelection].z + " )" );
localLightDirections[currentSelection].y += changeDelta;
if (localLightDirections[currentSelection].y > 1.0) {
localLightDirections[currentSelection].y = -1.0;
}
lightsDirty = true;
print("PLUS Y light " + currentSelection + " direction (" + localLightDirections[currentSelection].x + ", " + localLightDirections[currentSelection].y + ", " + localLightDirections[currentSelection].z + " )" );
}
else if (event.text == "-" ) {
localLightDirections[currentSelection].y -= changeDelta;
if (localLightDirections[currentSelection].y < -1.0) {
localLightDirections[currentSelection].y = 1.0;
}
setAllLightDirections();
print("MINUS Y light " + currentSelection + " direction (" + localLightDirections[currentSelection].x + ", " + localLightDirections[currentSelection].y + ", " + localLightDirections[currentSelection].z + " )" );
localLightDirections[currentSelection].y -= changeDelta;
if (localLightDirections[currentSelection].y < -1.0) {
localLightDirections[currentSelection].y = 1.0;
}
lightsDirty = true;
print("MINUS Y light " + currentSelection + " direction (" + localLightDirections[currentSelection].x + ", " + localLightDirections[currentSelection].y + ", " + localLightDirections[currentSelection].z + " )" );
}
else if (event.text == "," ) {
if (currentNumLights + 1 <= maxNumLights) {
++currentNumLights;
for (var i = 0; i < currentNumAvatars; i++) {
AvatarManager.addAvatarLocalLight(i);
for (var j = 0; j < currentNumLights; j++) {
AvatarManager.setAvatarLightColor(localLightColors[j], j, i);
AvatarManager.setAvatarLightDirection(localLightDirections[j], j, i);
}
}
}
print("ADD LIGHT, number of lights " + currentNumLights);
if (currentNumLights + 1 <= maxNumLights) {
++currentNumLights;
lightsDirty = true;
}
print("ADD LIGHT, number of lights " + currentNumLights);
}
else if (event.text == "." ) {
if (currentNumLights - 1 >= 0 ) {
--currentNumLights;
for (var i = 0; i < currentNumAvatars; i++) {
AvatarManager.removeAvatarLocalLight(i);
for (var j = 0; j < currentNumLights; j++) {
AvatarManager.setAvatarLightColor(localLightColors[j], j, i);
AvatarManager.setAvatarLightDirection(localLightDirections[j], j, i);
}
}
}
print("REMOVE LIGHT, number of lights " + currentNumLights);
if (currentNumLights - 1 >= 0 ) {
--currentNumLights;
lightsDirty = true;
}
print("REMOVE LIGHT, number of lights " + currentNumLights);
}
}
function updateLocalLights()
{
// new avatars, so add lights
var numAvatars = AvatarManager.getNumAvatars();
if (numAvatars != currentNumAvatars) {
for (var i = 0; i < numAvatars; i++) {
var numLights = AvatarManager.getNumLightsInAvatar(i);
// check if new avatar has lights
if (numLights <= 0) {
AvatarManager.addAvatarLocalLight(i);
// set color and direction for new avatar
for (var j = 0; j < maxNumLights; j++) {
AvatarManager.setAvatarLightColor(localLightColors[j], j, i);
AvatarManager.setAvatarLightDirection(localLightDirections[j], j, i);
}
}
}
currentNumAvatars = numAvatars;
}
}
function setAllLightColors()
{
for (var i = 0; i < currentNumAvatars; i++) {
for (var j = 0; j < maxNumLights; j++) {
AvatarManager.setAvatarLightColor(localLightColors[j], j, i);
}
}
}
function setAllLightDirections()
{
for (var i = 0; i < currentNumAvatars; i++) {
for (var j = 0; j < maxNumLights; j++) {
AvatarManager.setAvatarLightDirection(localLightDirections[j], j, i);
}
}
if (lightsDirty) {
var localLights = [];
for (var i = 0; i < currentNumLights; i++) {
localLights.push({ direction: localLightDirections[i], color: localLightColors[i] });
}
AvatarManager.setLocalLights(localLights);
lightsDirty = false;
}
}
// main

View file

@ -58,19 +58,6 @@ foreach(SUBDIR avatar devices renderer ui starfield location scripting voxels pa
set(INTERFACE_SRCS ${INTERFACE_SRCS} "${SUBDIR_SRCS}")
endforeach(SUBDIR)
# windows also includes the faceshift externals, because using a lib doesn't work due to debug/release mismatch
if (WIN32)
set(EXTERNAL_SOURCE_SUBDIRS "faceshift")
endif ()
foreach(EXTERNAL_SOURCE_SUBDIR ${EXTERNAL_SOURCE_SUBDIRS})
file(GLOB_RECURSE SUBDIR_SRCS
"external/${EXTERNAL_SOURCE_SUBDIR}/src/*.cpp"
"external/${EXTERNAL_SOURCE_SUBDIR}/src/*.c"
"external/${EXTERNAL_SOURCE_SUBDIR}/src/*.h")
set(INTERFACE_SRCS ${INTERFACE_SRCS} "${SUBDIR_SRCS}")
endforeach(EXTERNAL_SOURCE_SUBDIR)
find_package(Qt5 COMPONENTS Core Gui Multimedia Network OpenGL Script Svg WebKit WebKitWidgets Xml UiTools)
# grab the ui files in resources/ui
@ -154,7 +141,7 @@ if (SIXENSE_FOUND AND NOT DISABLE_SIXENSE)
if (APPLE OR UNIX)
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -isystem ${SIXENSE_INCLUDE_DIRS}")
endif (APPLE OR UNIX)
target_link_libraries(${TARGET_NAME} "${SIXENSE_LIBRARIES}")
target_link_libraries(${TARGET_NAME} ${SIXENSE_LIBRARIES})
endif (SIXENSE_FOUND AND NOT DISABLE_SIXENSE)
# likewise with Visage library for webcam feature tracking
@ -183,17 +170,15 @@ endif (FACEPLUS_FOUND AND NOT DISABLE_FACEPLUS)
# and with LibOVR for Oculus Rift
if (LIBOVR_FOUND AND NOT DISABLE_LIBOVR)
add_definitions(-DHAVE_LIBOVR)
include_directories(SYSTEM "${LIBOVR_INCLUDE_DIRS}")
if (APPLE OR UNIX)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -isystem ${LIBOVR_INCLUDE_DIRS}")
endif ()
if (WIN32)
target_link_libraries(${TARGET_NAME} optimized "${LIBOVR_RELEASE_LIBRARIES}" debug "${LIBOVR_DEBUG_LIBRARIES}")
else ()
target_link_libraries(${TARGET_NAME} "${LIBOVR_LIBRARIES}")
include_directories(SYSTEM ${LIBOVR_INCLUDE_DIRS})
if (APPLE)
foreach(LIBOVR_DIR ${LIBOVR_INCLUDE_DIRS})
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -isystem ${LIBOVR_DIR}")
endforeach()
endif ()
target_link_libraries(${TARGET_NAME} ${LIBOVR_LIBRARIES})
endif (LIBOVR_FOUND AND NOT DISABLE_LIBOVR)
# and with PrioVR library
@ -208,10 +193,10 @@ if (LEAPMOTION_FOUND AND NOT DISABLE_LEAPMOTION)
add_definitions(-DHAVE_LEAPMOTION)
include_directories(SYSTEM "${LEAPMOTION_INCLUDE_DIRS}")
if (APPLE OR UNIX)
if (APPLE)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -isystem ${LEAPMOTION_INCLUDE_DIRS}")
endif ()
target_link_libraries(${TARGET_NAME} "${LEAPMOTION_LIBRARIES}")
target_link_libraries(${TARGET_NAME} ${LEAPMOTION_LIBRARIES})
endif (LEAPMOTION_FOUND AND NOT DISABLE_LEAPMOTION)
# and with SDL for joysticks
@ -224,23 +209,29 @@ endif (SDL_FOUND AND NOT DISABLE_SDL)
# and with qxmpp for chat
if (QXMPP_FOUND AND NOT DISABLE_QXMPP)
add_definitions(-DHAVE_QXMPP -DQXMPP_STATIC)
include_directories(SYSTEM ${QXMPP_INCLUDE_DIR})
include_directories(SYSTEM "${QXMPP_INCLUDE_DIRS}")
target_link_libraries(${TARGET_NAME} "${QXMPP_LIBRARY}")
target_link_libraries(${TARGET_NAME} ${QXMPP_LIBRARIES})
endif (QXMPP_FOUND AND NOT DISABLE_QXMPP)
# and with RtMidi for RtMidi control
if (RTMIDI_FOUND AND NOT DISABLE_RTMIDI)
add_definitions(-DHAVE_RTMIDI)
include_directories(SYSTEM "${RTMIDI_INCLUDE_DIRS}")
target_link_libraries(${TARGET_NAME} ${RTMIDI_LIBRARIES})
add_definitions(-DHAVE_RTMIDI)
include_directories(SYSTEM ${RTMIDI_INCLUDE_DIR})
target_link_libraries(${TARGET_NAME} "${RTMIDI_LIBRARY}")
if (APPLE)
find_library(CoreMIDI CoreMIDI)
add_definitions(-D__MACOSX_CORE__)
target_link_libraries(${TARGET_NAME} ${CoreMIDI})
endif()
if (APPLE)
find_library(CoreMIDI CoreMIDI)
add_definitions(-D__MACOSX_CORE__)
target_link_libraries(${TARGET_NAME} ${CoreMIDI})
endif()
endif()
# and with Faceshift for depth camera face tracking
if (FACESHIFT_FOUND AND NOT DISABLE_FACESHIFT)
add_definitions(-DHAVE_FACESHIFT)
include_directories(SYSTEM "${FACESHIFT_INCLUDE_DIRS}")
target_link_libraries(${TARGET_NAME} ${FACESHIFT_LIBRARIES})
endif()
# include headers for interface and InterfaceConfig.
@ -248,11 +239,10 @@ include_directories("${PROJECT_SOURCE_DIR}/src" "${PROJECT_BINARY_DIR}/includes"
# include external library headers
# use system flag so warnings are supressed
include_directories(SYSTEM "${FACESHIFT_INCLUDE_DIRS}" "${OPENSSL_INCLUDE_DIR}")
include_directories(SYSTEM "${OPENSSL_INCLUDE_DIR}")
target_link_libraries(
${TARGET_NAME}
"${FACESHIFT_LIBRARIES}"
"${ZLIB_LIBRARIES}"
${OPENSSL_LIBRARIES}
Qt5::Core Qt5::Gui Qt5::Multimedia Qt5::Network Qt5::OpenGL
@ -305,7 +295,7 @@ else (APPLE)
find_package(OpenGL REQUIRED)
find_package(GLUT REQUIRED)
include_directories(SYSTEM "${GLUT_INCLUDE_DIR}")
include_directories(SYSTEM "${GLUT_INCLUDE_DIRS}")
if (${OPENGL_INCLUDE_DIR})
include_directories(SYSTEM "${OPENGL_INCLUDE_DIR}")
@ -324,6 +314,6 @@ else (APPLE)
# add a definition for ssize_t so that windows doesn't bail
add_definitions(-Dssize_t=long)
target_link_libraries(${TARGET_NAME} "${GLEW_LIBRARY}" wsock32.lib opengl32.lib)
target_link_libraries(${TARGET_NAME} "${GLEW_LIBRARIES}" wsock32.lib opengl32.lib)
endif()
endif (APPLE)

View file

@ -1,11 +0,0 @@
cmake_minimum_required(VERSION 2.8)
set(TARGET_NAME faceshift)
project(${TARGET_NAME})
# grab the implemenation and header files
file(GLOB FACESHIFT_SRCS include/*.h src/*.cpp)
include_directories(include)
add_library(${TARGET_NAME} "${FACESHIFT_SRCS}")

View file

@ -1,410 +0,0 @@
#pragma once
#ifndef FSBINARYSTREAM_H
#define FSBINARYSTREAM_H
// ==========================================================================
// Copyright (C) 2012 faceshift AG, and/or its licensors. All rights reserved.
//
// the software is free to use and provided "as is", without warranty of any kind.
// faceshift AG does not make and hereby disclaims any express or implied
// warranties including, but not limited to, the warranties of
// non-infringement, merchantability or fitness for a particular purpose,
// or arising from a course of dealing, usage, or trade practice. in no
// event will faceshift AG and/or its licensors be liable for any lost
// revenues, data, or profits, or special, direct, indirect, or
// consequential damages, even if faceshift AG and/or its licensors has
// been advised of the possibility or probability of such damages.
// ==========================================================================
/**
* Define the HAVE_EIGEN preprocessor define, if you are using the Eigen library, it allows you to easily convert our tracked data from and to eigen
* See fsVector3f and fsQuaternionf for more details
**/
#ifdef HAVE_EIGEN
#include <Eigen/Core>
#include <Eigen/Geometry>
#endif
#ifdef _MSC_VER
#include <memory>
#else
#include <tr1/memory>
#endif
#include <string>
#include <vector>
#include <stdint.h>
/*******************************************************************************************
* This first part of the file contains a definition of the datastructures holding the
* tracking results
******************************************************************************************/
namespace fs {
/**
* A floating point three-vector.
*
* To keep these networking classes as simple as possible, we do not implement the
* vector semantics here, use Eigen for that purpose. The class just holds three named floats,
* and you have to interpret them yourself.
**/
struct fsVector3f {
float x,y,z;
fsVector3f() {}
#ifdef HAVE_EIGEN
explicit fsVector3f(const Eigen::Matrix<float,3,1> &v) : x(v[0]), y(v[1]), z(v[2]) {}
Eigen::Map< Eigen::Matrix<float,3,1> > eigen() const { return Eigen::Map<Eigen::Matrix<float,3,1> >((float*)this); }
#endif
};
/**
* An integer three-vector.
**/
struct fsVector3i {
int32_t x,y,z;
fsVector3i() {}
#ifdef HAVE_EIGEN
explicit fsVector3i(const Eigen::Matrix<int32_t,3,1> &v) : x(v[0]), y(v[1]), z(v[2]) {}
Eigen::Map<Eigen::Matrix<int32_t,3,1> > eigen() const { return Eigen::Map<Eigen::Matrix<int32_t,3,1> >((int32_t*)this); }
#endif
};
/**
* An integer four-vector.
**/
struct fsVector4i {
int32_t x,y,z,w;
fsVector4i() {}
#ifdef HAVE_EIGEN
explicit fsVector4i(const Eigen::Matrix<int32_t,4,1> &v) : x(v[0]), y(v[1]), z(v[2]), w(v[3]) {}
Eigen::Map<Eigen::Matrix<int32_t,4,1,Eigen::DontAlign> > eigen() const { return Eigen::Map<Eigen::Matrix<int32_t,4,1,Eigen::DontAlign> >((int32_t*)this); }
#endif
};
/**
* Structure holding the data of a quaternion.
*
*To keep these networking classes as simple as possible, we do not implement the
* quaternion semantics here. The class just holds four named floats, and you have to interpret them yourself.
*
* If you have Eigen you can just cast this class to an Eigen::Quaternionf and use it.
*
* The quaternion is defined as w+xi+yj+zk
**/
struct fsQuaternionf {
float x,y,z,w;
fsQuaternionf() {}
#ifdef HAVE_EIGEN
explicit fsQuaternionf(const Eigen::Quaternionf &q) : x(q.x()), y(q.y()), z(q.z()), w(q.w()) {}
Eigen::Quaternionf eigen() const { return Eigen::Quaternionf(w,x,y,z); }
#endif
};
/**
* A structure containing the data tracked for a single frame.
**/
class fsTrackingData {
public:
//! time stamp in ms
double m_timestamp;
//! flag whether tracking was successful [0,1]
bool m_trackingSuccessful;
//! head pose
fsQuaternionf m_headRotation;
fsVector3f m_headTranslation;
//! eye gaze in degrees
float m_eyeGazeLeftPitch;
float m_eyeGazeLeftYaw;
float m_eyeGazeRightPitch;
float m_eyeGazeRightYaw;
//! blendshape coefficients
std::vector<float> m_coeffs;
//! marker positions - format specified in faceshift
std::vector< fsVector3f > m_markers;
};
/**
* A structure containing vertex information
*/
class fsVertexData {
public:
//! vertex data
std::vector<fsVector3f> m_vertices;
#ifdef HAVE_EIGEN
Eigen::Map<Eigen::Matrix<float,3,Eigen::Dynamic> > eigen() { return Eigen::Map<Eigen::Matrix<float,3,Eigen::Dynamic> >((float*)m_vertices.data(),3,m_vertices.size()); }
#endif
};
/**
* A strucutre containing mesh information
*/
class fsMeshData {
public:
//! topology (quads)
std::vector<fsVector4i> m_quads;
//! topology (triangles)
std::vector<fsVector3i> m_tris;
//! vertex data
fsVertexData m_vertex_data;
#ifdef HAVE_EIGEN
Eigen::Map<Eigen::Matrix<int32_t,4,Eigen::Dynamic,Eigen::DontAlign> > quads_eigen() { return Eigen::Map<Eigen::Matrix<int32_t,4,Eigen::Dynamic,Eigen::DontAlign> >((int32_t*)m_quads.data(),4,m_quads.size()); }
Eigen::Map<Eigen::Matrix<int32_t,3,Eigen::Dynamic> > tris_eigen() { return Eigen::Map<Eigen::Matrix<int32_t,3,Eigen::Dynamic> >((int32_t*)m_tris.data(),3,m_tris.size()); }
Eigen::Map<Eigen::Matrix<float,3,Eigen::Dynamic> > vertices_eigen() { return m_vertex_data.eigen(); }
#endif
};
/*******************************************************************************************
* Now follows a definition of datastructures encapsulating the network messages
******************************************************************************************/
/** Predeclaration of the message types available in faceshift **/
// Inbound
class fsMsgStartCapturing;
class fsMsgStopCapturing;
class fsMsgCalibrateNeutral;
class fsMsgSendMarkerNames;
class fsMsgSendBlendshapeNames;
class fsMsgSendRig;
// Outbound
class fsMsgTrackingState;
class fsMsgMarkerNames;
class fsMsgBlendshapeNames;
class fsMsgRig;
/**
* Base class of all message that faceshift is sending.
* A class can be queried for its type, using the id() function for use in a switch statement, or by using a dynamic_cast.
**/
class fsMsg {
public:
virtual ~fsMsg() {}
enum MessageType {
// Messages to control faceshift via the network
// These are sent from the client to faceshift
MSG_IN_START_TRACKING = 44344,
MSG_IN_STOP_TRACKING = 44444,
MSG_IN_CALIBRATE_NEUTRAL = 44544,
MSG_IN_SEND_MARKER_NAMES = 44644,
MSG_IN_SEND_BLENDSHAPE_NAMES = 44744,
MSG_IN_SEND_RIG = 44844,
MSG_IN_HEADPOSE_RELATIVE = 44944,
MSG_IN_HEADPOSE_ABSOLUTE = 44945,
// Messages containing tracking information
// These are sent form faceshift to the client application
MSG_OUT_TRACKING_STATE = 33433,
MSG_OUT_MARKER_NAMES = 33533,
MSG_OUT_BLENDSHAPE_NAMES = 33633,
MSG_OUT_RIG = 33733
};
virtual MessageType id() const = 0;
};
typedef std::tr1::shared_ptr<fsMsg> fsMsgPtr;
/*************
* Inbound
***********/
class fsMsgStartCapturing : public fsMsg {
public:
virtual ~fsMsgStartCapturing() {}
virtual MessageType id() const { return MSG_IN_START_TRACKING; }
};
class fsMsgStopCapturing : public fsMsg {
public:
virtual ~fsMsgStopCapturing() {}
virtual MessageType id() const { return MSG_IN_STOP_TRACKING; }
};
class fsMsgCalibrateNeutral : public fsMsg {
public:
virtual ~fsMsgCalibrateNeutral() {}
virtual MessageType id() const { return MSG_IN_CALIBRATE_NEUTRAL; }
};
class fsMsgSendMarkerNames : public fsMsg {
public:
virtual ~fsMsgSendMarkerNames() {}
virtual MessageType id() const { return MSG_IN_SEND_MARKER_NAMES; }
};
class fsMsgSendBlendshapeNames : public fsMsg {
public:
virtual ~fsMsgSendBlendshapeNames() {}
virtual MessageType id() const { return MSG_IN_SEND_BLENDSHAPE_NAMES; }
};
class fsMsgSendRig : public fsMsg {
public:
virtual ~fsMsgSendRig() {}
virtual MessageType id() const { return MSG_IN_SEND_RIG; }
};
class fsMsgHeadPoseRelative : public fsMsg {
public:
virtual ~fsMsgHeadPoseRelative() {}
virtual MessageType id() const { return MSG_IN_HEADPOSE_RELATIVE; }
};
class fsMsgHeadPoseAbsolute : public fsMsg {
public:
virtual ~fsMsgHeadPoseAbsolute() {}
virtual MessageType id() const { return MSG_IN_HEADPOSE_ABSOLUTE; }
};
/*************
* Outbound
***********/
class fsMsgTrackingState : public fsMsg {
public:
virtual ~fsMsgTrackingState() {}
/* */ fsTrackingData & tracking_data() /* */ { return m_tracking_data; }
const fsTrackingData & tracking_data() const { return m_tracking_data; }
virtual MessageType id() const { return MSG_OUT_TRACKING_STATE; }
private:
fsTrackingData m_tracking_data;
};
class fsMsgMarkerNames : public fsMsg {
public:
virtual ~fsMsgMarkerNames() {}
/* */ std::vector<std::string> & marker_names() /* */ { return m_marker_names; }
const std::vector<std::string> & marker_names() const { return m_marker_names; }
virtual MessageType id() const { return MSG_OUT_MARKER_NAMES; }
private:
std::vector<std::string> m_marker_names;
};
class fsMsgBlendshapeNames : public fsMsg {
public:
virtual ~fsMsgBlendshapeNames() {}
/* */ std::vector<std::string> & blendshape_names() /* */ { return m_blendshape_names; }
const std::vector<std::string> & blendshape_names() const { return m_blendshape_names; }
virtual MessageType id() const { return MSG_OUT_BLENDSHAPE_NAMES; }
private:
std::vector<std::string> m_blendshape_names;
};
class fsMsgRig : public fsMsg {
public:
virtual ~fsMsgRig() {}
virtual MessageType id() const { return MSG_OUT_RIG; }
/* */ fsMeshData & mesh() /* */ { return m_mesh; }
const fsMeshData & mesh() const { return m_mesh; }
/* */ std::vector<std::string> & blendshape_names() /* */ { return m_blendshape_names; }
const std::vector<std::string> & blendshape_names() const { return m_blendshape_names; }
/* */ std::vector<fsVertexData> & blendshapes() /* */ { return m_blendshapes; }
const std::vector<fsVertexData> & blendshapes() const { return m_blendshapes; }
private:
//! neutral mesh
fsMeshData m_mesh;
//! blendshape names
std::vector<std::string> m_blendshape_names;
//! blendshapes
std::vector<fsVertexData> m_blendshapes;
};
class fsMsgSignal : public fsMsg {
MessageType m_id;
public:
explicit fsMsgSignal(MessageType id) : m_id(id) {}
virtual ~fsMsgSignal() {}
virtual MessageType id() const { return m_id; }
};
/**
* Class to parse a faceshift data stream, and to create message to write into such a stream
*
* This needs to be connected with your networking methods by calling
*
* void received(int, const char *);
*
* whenever new data is available. After adding received data to the parser you can parse faceshift messages using the
*
* std::tr1::shared_ptr<fsMsg> get_message();
*
* to get the next message, if a full block of data has been received. This should be iterated until no more messages are in the buffer.
*
* You can also use this to encode messages to send back to faceshift. This works by calling the
*
* void encode_message(std::string &msg_out, const fsMsg &msg);
*
* methods (actually the specializations existing for each of our message types). This will encode the message into a
* binary string in msg_out. You then only need to push the resulting string over the network to faceshift.
*
* This class does not handle differences in endianness or other strange things that can happen when pushing data over the network.
* Should you have to adapt this to such a system, then it should be possible to do this by changing only the write_... and read_...
* functions in the accompanying cpp file, but so far there was no need for it.
**/
class fsBinaryStream {
public:
fsBinaryStream();
/**
* Use to push data into the parser. Typically called inside of your network receiver routine
**/
void received(long int, const char *);
/**
* After pushing data, you can try to extract messages from the stream. Process messages until a null pointer is returned.
**/
fsMsgPtr get_message();
/**
* When an invalid message is received, the valid field is set to false. No attempt is made to recover from the problem, you will have to disconnect.
**/
bool valid() const { return m_valid; }
void clear() { m_start = 0; m_end = 0; m_valid=true; }
// Inbound
static void encode_message(std::string &msg_out, const fsMsgTrackingState &msg);
static void encode_message(std::string &msg_out, const fsMsgStartCapturing &msg);
static void encode_message(std::string &msg_out, const fsMsgStopCapturing &msg);
static void encode_message(std::string &msg_out, const fsMsgCalibrateNeutral &msg);
static void encode_message(std::string &msg_out, const fsMsgSendMarkerNames &msg);
static void encode_message(std::string &msg_out, const fsMsgSendBlendshapeNames &msg);
static void encode_message(std::string &msg_out, const fsMsgSendRig &msg);
static void encode_message(std::string &msg_out, const fsMsgHeadPoseRelative &msg);
static void encode_message(std::string &msg_out, const fsMsgHeadPoseAbsolute &msg);
// Outbound
static void encode_message(std::string &msg_out, const fsTrackingData &msg);
static void encode_message(std::string &msg_out, const fsMsgMarkerNames &msg);
static void encode_message(std::string &msg_out, const fsMsgBlendshapeNames &msg);
static void encode_message(std::string &msg_out, const fsMsgRig &msg);
static void encode_message(std::string &msg_out, const fsMsgSignal &msg); // Generic Signal
private:
std::string m_buffer;
long int m_start;
long int m_end;
bool m_valid;
};
}
#endif // FSBINARYSTREAM_H

21
interface/external/faceshift/readme.txt vendored Normal file
View file

@ -0,0 +1,21 @@
Instructions for adding the Faceshift library to Interface
Stephen Birarda, July 18th, 2014
OS X users: You can also use homebrew to get the Faceshift library by tapping our repo - highfidelity/homebrew-formulas
and then calling 'brew install highfidelity/formulas/faceshift'.
You can download the Faceshift SDK from http://download.faceshift.com/faceshift-network.zip.
Create a faceshift folder under interface/externals.
You may optionally choose to place this folder in a location outside the repository (so you can re-use with different checkouts and different projects).
If so our CMake find module expects you to set the ENV variable 'HIFI_LIB_DIR' to a directory containing a subfolder faceshift that contains the lib and include folders.
1. Build a Faceshift static library from the fsbinarystream.cpp file. If you build a release version call it libfaceshift.a. The debug version should be called libfaceshiftd.a. Place this in the lib folder in your Faceshift folder.
2. Copy the fsbinarystream.h header file from the Faceshift SDK into the include folder in your Faceshift folder.
3. Clear your build directory, run cmake and build, and you should be all set.

View file

@ -1,502 +0,0 @@
// ==========================================================================
// Copyright (C) 2012 faceshift AG, and/or its licensors. All rights reserved.
//
// the software is free to use and provided "as is", without warranty of any kind.
// faceshift AG does not make and hereby disclaims any express or implied
// warranties including, but not limited to, the warranties of
// non-infringement, merchantability or fitness for a particular purpose,
// or arising from a course of dealing, usage, or trade practice. in no
// event will faceshift AG and/or its licensors be liable for any lost
// revenues, data, or profits, or special, direct, indirect, or
// consequential damages, even if faceshift AG and/or its licensors has
// been advised of the possibility or probability of such damages.
// ==========================================================================
#include "fsbinarystream.h"
#include <stdio.h>
#include <stdint.h>
#include <string.h>
#define FSNETWORKVERSION 1
#ifdef FS_INTERNAL
#include <common/log.hpp>
#else
#define LOG_RELEASE_ERROR(...) { printf("ERROR: %20s:%6d", __FILE__, __LINE__); printf(__VA_ARGS__); }
#define LOG_RELEASE_WARNING(...) { printf("WARNING: %20s:%6d", __FILE__, __LINE__); printf(__VA_ARGS__); }
#define LOG_RELEASE_INFO(...) { printf("INFO: %20s:%6d", __FILE__, __LINE__); printf(__VA_ARGS__); }
#endif
namespace fs {
// Ids of the submessages for the tracking state
enum BlockId {
BLOCKID_INFO = 101,
BLOCKID_POSE = 102,
BLOCKID_BLENDSHAPES = 103,
BLOCKID_EYES = 104,
BLOCKID_MARKERS = 105
};
typedef long int Size;
struct BlockHeader {
uint16_t id;
uint16_t version;
uint32_t size;
BlockHeader(uint16_t _id=0,
uint32_t _size=0,
uint16_t _version=FSNETWORKVERSION
) : id(_id), version(_version), size(_size) {}
};
// Interprets the data at the position start in buffer as a T and increments start by sizeof(T)
// It should be sufficient to change/overload this function when you are on a wierd endian system
template<class T> bool read_pod(T &value, const std::string &buffer, Size &start) {
if(start+sizeof(T) > buffer.size()) return false;
value = *(const T*)(&buffer[start]);
start += sizeof(T);
return true;
}
bool read_pod(std::string &value, const std::string &buffer, Size &start) {
uint16_t len = 0;
if(!read_pod(len, buffer, start)) return false;
if(start+len>Size(buffer.size())) return false; // check whether we have enough data available
value.resize(len);
memcpy(&(value[0]), &buffer[start], len);
start+=len;
return true;
}
template<class T> bool read_vector(std::vector<T> & values, const std::string & buffer, Size & start) {
uint32_t len = 0;
if( !read_pod(len, buffer, start)) return false;
if( start+len*sizeof(T) > buffer.size() ) return false;
values.resize(len);
for(uint32_t i = 0; i < len; ++i) {
read_pod(values[i],buffer,start);
}
return true;
}
template<class T> bool read_small_vector(std::vector<T> & values, const std::string & buffer, Size & start) {
uint16_t len = 0;
if( !read_pod(len, buffer, start)) return false;
if( start+len*sizeof(T) > buffer.size() ) return false;
values.resize(len);
bool success = true;
for(uint16_t i = 0; i < len; ++i) {
success &= read_pod(values[i],buffer,start);
}
return success;
}
// Adds the bitpattern of the data to the end of the buffer.
// It should be sufficient to change/overload this function when you are on a wierd endian system
template <class T>
void write_pod(std::string &buffer, const T &value) {
Size start = buffer.size();
buffer.resize(start + sizeof(T));
*(T*)(&buffer[start]) = value;
start += sizeof(T);
}
// special write function for strings
void write_pod(std::string &buffer, const std::string &value) {
uint16_t len = uint16_t(value.size()); write_pod(buffer, len);
buffer.append(value);
}
template<class T> void write_vector(std::string & buffer, const std::vector<T> & values) {
uint32_t len = values.size();
write_pod(buffer,len);
for(uint32_t i = 0; i < len; ++i)
write_pod(buffer,values[i]);
}
template<class T> void write_small_vector(std::string & buffer, const std::vector<T> & values) {
uint16_t len = values.size();
write_pod(buffer,len);
for(uint16_t i = 0; i < len; ++i)
write_pod(buffer,values[i]);
}
void update_msg_size(std::string &buffer, Size start) {
*(uint32_t*)(&buffer[start+4]) = buffer.size() - sizeof(BlockHeader) - start;
}
void update_msg_size(std::string &buffer) {
*(uint32_t*)(&buffer[4]) = buffer.size() - sizeof(BlockHeader);
}
static void skipHeader( Size &start) {
start += sizeof(BlockHeader);
}
//! returns whether @param data contains enough data to read the block header
static bool headerAvailable(BlockHeader &header, const std::string &buffer, Size &start, const Size &end) {
if (end-start >= Size(sizeof(BlockHeader))) {
header = *(BlockHeader*)(&buffer[start]);
return true;
} else {
return false;
}
}
//! returns whether @param data contains data for a full block
static bool blockAvailable(const std::string &buffer, Size &start, const Size &end) {
BlockHeader header;
if (!headerAvailable(header, buffer, start, end)) return false;
return end-start >= Size(sizeof(header)+header.size);
}
fsBinaryStream::fsBinaryStream() : m_buffer(), m_start(0), m_end(0), m_valid(true) { m_buffer.resize(64*1024); } // Use a 64kb buffer by default
void fsBinaryStream::received(long int sz, const char *data) {
long int new_end = m_end + sz;
if (new_end > Size(m_buffer.size()) && m_start>0) {
// If newly received block is too large to fit into the buffer, but we already have processed data from the start of the buffer, then
// move memory to the front of the buffer
// The buffer only grows, such that it is always large enough to contain the largest message seen so far.
if (m_end>m_start) memmove(&m_buffer[0], &m_buffer[0] + m_start, m_end - m_start);
m_end = m_end - m_start;
m_start = 0;
new_end = m_end + sz;
}
if (new_end > Size(m_buffer.size())) m_buffer.resize((int)(1.5f * (float)new_end)); // HIFI: to get 1.5 without warnings
memcpy(&m_buffer[0] + m_end, data, sz);
m_end += sz;
}
static bool decodeInfo(fsTrackingData & _trackingData, const std::string &buffer, Size &start) {
bool success = true;
success &= read_pod<double>(_trackingData.m_timestamp, buffer, start);
unsigned char tracking_successfull = 0;
success &= read_pod<unsigned char>( tracking_successfull, buffer, start );
_trackingData.m_trackingSuccessful = bool(tracking_successfull != 0); // HIFI: get rid of windows warning
return success;
}
static bool decodePose(fsTrackingData & _trackingData, const std::string &buffer, Size &start) {
bool success = true;
success &= read_pod(_trackingData.m_headRotation.x, buffer, start);
success &= read_pod(_trackingData.m_headRotation.y, buffer, start);
success &= read_pod(_trackingData.m_headRotation.z, buffer, start);
success &= read_pod(_trackingData.m_headRotation.w, buffer, start);
success &= read_pod(_trackingData.m_headTranslation.x, buffer, start);
success &= read_pod(_trackingData.m_headTranslation.y, buffer, start);
success &= read_pod(_trackingData.m_headTranslation.z, buffer, start);
return success;
}
static bool decodeBlendshapes(fsTrackingData & _trackingData, const std::string &buffer, Size &start) {
return read_vector(_trackingData.m_coeffs, buffer, start);
}
static bool decodeEyeGaze(fsTrackingData & _trackingData, const std::string &buffer, Size &start) {
bool success = true;
success &= read_pod(_trackingData.m_eyeGazeLeftPitch , buffer, start);
success &= read_pod(_trackingData.m_eyeGazeLeftYaw , buffer, start);
success &= read_pod(_trackingData.m_eyeGazeRightPitch, buffer, start);
success &= read_pod(_trackingData.m_eyeGazeRightYaw , buffer, start);
return success;
}
static bool decodeMarkers(fsTrackingData & _trackingData, const std::string &buffer, Size &start) {
return read_small_vector( _trackingData.m_markers, buffer, start );
}
static bool decodeMarkerNames(fsMsgMarkerNames &_msg, const std::string &buffer, Size &start) {
return read_small_vector(_msg.marker_names(), buffer, start);
}
static bool decodeBlendshapeNames(fsMsgBlendshapeNames &_msg, const std::string &buffer, Size &start) {
return read_small_vector(_msg.blendshape_names(), buffer, start);
}
static bool decodeRig(fsMsgRig &_msg, const std::string &buffer, Size &start) {
bool success = true;
success &= read_vector(_msg.mesh().m_quads,buffer,start); // read quads
success &= read_vector(_msg.mesh().m_tris,buffer,start); // read triangles
success &= read_vector(_msg.mesh().m_vertex_data.m_vertices,buffer,start);// read neutral vertices
success &= read_small_vector(_msg.blendshape_names(),buffer,start); // read names
uint16_t bsize = 0;
success &= read_pod(bsize,buffer,start);
_msg.blendshapes().resize(bsize);
for(uint16_t i = 0;i < bsize; i++)
success &= read_vector(_msg.blendshapes()[i].m_vertices,buffer,start); // read blendshapes
return success;
}
bool is_valid_msg(int id) {
switch(id) {
case fsMsg::MSG_IN_START_TRACKING :
case fsMsg::MSG_IN_STOP_TRACKING :
case fsMsg::MSG_IN_CALIBRATE_NEUTRAL :
case fsMsg::MSG_IN_SEND_MARKER_NAMES :
case fsMsg::MSG_IN_SEND_BLENDSHAPE_NAMES:
case fsMsg::MSG_IN_SEND_RIG :
case fsMsg::MSG_IN_HEADPOSE_RELATIVE :
case fsMsg::MSG_IN_HEADPOSE_ABSOLUTE :
case fsMsg::MSG_OUT_TRACKING_STATE :
case fsMsg::MSG_OUT_MARKER_NAMES :
case fsMsg::MSG_OUT_BLENDSHAPE_NAMES :
case fsMsg::MSG_OUT_RIG : return true;
default:
LOG_RELEASE_ERROR("Invalid Message ID %d", id);
return false;
}
}
fsMsgPtr fsBinaryStream::get_message() {
BlockHeader super_block;
if( !headerAvailable(super_block, m_buffer, m_start, m_end) ) return fsMsgPtr();
if (!is_valid_msg(super_block.id)) { LOG_RELEASE_ERROR("Invalid superblock id"); m_valid = false; return fsMsgPtr(); }
if( !blockAvailable( m_buffer, m_start, m_end) ) return fsMsgPtr();
skipHeader(m_start);
long super_block_data_start = m_start;
switch (super_block.id) {
case fsMsg::MSG_IN_START_TRACKING: {
if (super_block.size > 0) { LOG_RELEASE_ERROR("Expected Size to be 0, not %d", super_block.size); m_valid = false; return fsMsgPtr(); }
return fsMsgPtr(new fsMsgStartCapturing() );
}; break;
case fsMsg::MSG_IN_STOP_TRACKING: {
if (super_block.size > 0) { LOG_RELEASE_ERROR("Expected Size to be 0, not %d", super_block.size); m_valid = false; return fsMsgPtr(); }
return fsMsgPtr(new fsMsgStopCapturing() );
}; break;
case fsMsg::MSG_IN_CALIBRATE_NEUTRAL: {
if (super_block.size > 0) { LOG_RELEASE_ERROR("Expected Size to be 0, not %d", super_block.size); m_valid = false; return fsMsgPtr(); }
return fsMsgPtr(new fsMsgCalibrateNeutral() );
}; break;
case fsMsg::MSG_IN_SEND_MARKER_NAMES: {
if (super_block.size > 0) { LOG_RELEASE_ERROR("Expected Size to be 0, not %d", super_block.size); m_valid = false; return fsMsgPtr(); }
return fsMsgPtr(new fsMsgSendMarkerNames() );
}; break;
case fsMsg::MSG_IN_SEND_BLENDSHAPE_NAMES: {
if (super_block.size > 0) { LOG_RELEASE_ERROR("Expected Size to be 0, not %d", super_block.size); m_valid = false; return fsMsgPtr(); }
return fsMsgPtr(new fsMsgSendBlendshapeNames() );
}; break;
case fsMsg::MSG_IN_SEND_RIG: {
if (super_block.size > 0) { LOG_RELEASE_ERROR("Expected Size to be 0, not %d", super_block.size); m_valid = false; return fsMsgPtr(); }
return fsMsgPtr(new fsMsgSendRig() );
}; break;
case fsMsg::MSG_IN_HEADPOSE_RELATIVE: {
if (super_block.size > 0) { LOG_RELEASE_ERROR("Expected Size to be 0, not %d", super_block.size); m_valid = false; return fsMsgPtr(); }
return fsMsgPtr(new fsMsgHeadPoseRelative() );
}; break;
case fsMsg::MSG_IN_HEADPOSE_ABSOLUTE: {
if (super_block.size > 0) { LOG_RELEASE_ERROR("Expected Size to be 0, not %d", super_block.size); m_valid = false; return fsMsgPtr(); }
return fsMsgPtr(new fsMsgHeadPoseAbsolute() );
}; break;
case fsMsg::MSG_OUT_MARKER_NAMES: {
std::tr1::shared_ptr< fsMsgMarkerNames > msg(new fsMsgMarkerNames());
if( !decodeMarkerNames(*msg, m_buffer, m_start )) { LOG_RELEASE_ERROR("Could not decode marker names"); m_valid = false; return fsMsgPtr(); }
uint64_t actual_size = m_start-super_block_data_start;
if( actual_size != super_block.size ) { LOG_RELEASE_ERROR("Block was promised to be of size %d, not %d", super_block.size, actual_size); m_valid = false; return fsMsgPtr(); }
return msg;
}; break;
case fsMsg::MSG_OUT_BLENDSHAPE_NAMES: {
std::tr1::shared_ptr< fsMsgBlendshapeNames > msg(new fsMsgBlendshapeNames() );
if( !decodeBlendshapeNames(*msg, m_buffer, m_start) ) { LOG_RELEASE_ERROR("Could not decode blendshape names"); m_valid = false; return fsMsgPtr(); }
uint64_t actual_size = m_start-super_block_data_start;
if( actual_size != super_block.size ) { LOG_RELEASE_ERROR("Block was promised to be of size %d, not %d", super_block.size, actual_size); m_valid = false; return fsMsgPtr(); }
return msg;
}; break;
case fsMsg::MSG_OUT_TRACKING_STATE: {
BlockHeader sub_block;
uint16_t num_blocks = 0;
if( !read_pod(num_blocks, m_buffer, m_start) ) { LOG_RELEASE_ERROR("Could not read num_blocks"); m_valid = false; return fsMsgPtr(); }
std::tr1::shared_ptr<fsMsgTrackingState> msg = std::tr1::shared_ptr<fsMsgTrackingState>(new fsMsgTrackingState());
for(int i = 0; i < num_blocks; i++) {
if( !headerAvailable(sub_block, m_buffer, m_start, m_end) ) { LOG_RELEASE_ERROR("could not read sub-header %d", i); m_valid = false; return fsMsgPtr(); }
if( !blockAvailable( m_buffer, m_start, m_end) ) { LOG_RELEASE_ERROR("could not read sub-block %d", i); m_valid = false; return fsMsgPtr(); }
skipHeader(m_start);
long sub_block_data_start = m_start;
bool success = true;
switch(sub_block.id) {
case BLOCKID_INFO: success &= decodeInfo( msg->tracking_data(), m_buffer, m_start); break;
case BLOCKID_POSE: success &= decodePose( msg->tracking_data(), m_buffer, m_start); break;
case BLOCKID_BLENDSHAPES: success &= decodeBlendshapes(msg->tracking_data(), m_buffer, m_start); break;
case BLOCKID_EYES: success &= decodeEyeGaze( msg->tracking_data(), m_buffer, m_start); break;
case BLOCKID_MARKERS: success &= decodeMarkers( msg->tracking_data(), m_buffer, m_start); break;
default:
LOG_RELEASE_ERROR("Unexpected subblock id %d", sub_block.id);
m_valid = false; return msg;
break;
}
if(!success) {
LOG_RELEASE_ERROR("Could not decode subblock with id %d", sub_block.id);
m_valid = false; return fsMsgPtr();
}
uint64_t actual_size = m_start-sub_block_data_start;
if( actual_size != sub_block.size ) {
LOG_RELEASE_ERROR("Unexpected number of bytes consumed %d instead of %d for subblock %d id:%d", actual_size, sub_block.size, i, sub_block.id);
m_valid = false; return fsMsgPtr();
}
}
uint64_t actual_size = m_start-super_block_data_start;
if( actual_size != super_block.size ) {
LOG_RELEASE_ERROR("Unexpected number of bytes consumed %d instead of %d", actual_size, super_block.size);
m_valid = false; return fsMsgPtr();
}
return msg;
}; break;
case fsMsg::MSG_OUT_RIG: {
std::tr1::shared_ptr< fsMsgRig > msg(new fsMsgRig() );
if( !decodeRig(*msg, m_buffer, m_start) ) { LOG_RELEASE_ERROR("Could not decode rig"); m_valid = false; return fsMsgPtr(); }
if( m_start-super_block_data_start != super_block.size ) { LOG_RELEASE_ERROR("Could not decode rig unexpected size"); m_valid = false; return fsMsgPtr(); }
return msg;
}; break;
default: {
LOG_RELEASE_ERROR("Unexpected superblock id %d", super_block.id);
m_valid = false; return fsMsgPtr();
}; break;
}
return fsMsgPtr();
}
static void encodeInfo(std::string &buffer, const fsTrackingData & _trackingData) {
BlockHeader header(BLOCKID_INFO, sizeof(double) + 1);
write_pod(buffer, header);
write_pod(buffer, _trackingData.m_timestamp);
unsigned char tracking_successfull = _trackingData.m_trackingSuccessful;
write_pod( buffer, tracking_successfull );
}
static void encodePose(std::string &buffer, const fsTrackingData & _trackingData) {
BlockHeader header(BLOCKID_POSE, sizeof(float)*7);
write_pod(buffer, header);
write_pod(buffer, _trackingData.m_headRotation.x);
write_pod(buffer, _trackingData.m_headRotation.y);
write_pod(buffer, _trackingData.m_headRotation.z);
write_pod(buffer, _trackingData.m_headRotation.w);
write_pod(buffer, _trackingData.m_headTranslation.x);
write_pod(buffer, _trackingData.m_headTranslation.y);
write_pod(buffer, _trackingData.m_headTranslation.z);
}
static void encodeBlendshapes(std::string &buffer, const fsTrackingData & _trackingData) {
uint32_t num_parameters = _trackingData.m_coeffs.size();
BlockHeader header(BLOCKID_BLENDSHAPES, sizeof(uint32_t) + sizeof(float)*num_parameters);
write_pod(buffer, header);
write_pod(buffer, num_parameters);
for(uint32_t i = 0; i < num_parameters; i++)
write_pod(buffer, _trackingData.m_coeffs[i]);
}
static void encodeEyeGaze(std::string &buffer, const fsTrackingData & _trackingData) {
BlockHeader header(BLOCKID_EYES, sizeof(float)*4);
write_pod(buffer, header);
write_pod(buffer, _trackingData.m_eyeGazeLeftPitch );
write_pod(buffer, _trackingData.m_eyeGazeLeftYaw );
write_pod(buffer, _trackingData.m_eyeGazeRightPitch);
write_pod(buffer, _trackingData.m_eyeGazeRightYaw );
}
static void encodeMarkers(std::string &buffer, const fsTrackingData & _trackingData) {
uint16_t numMarkers = _trackingData.m_markers.size();
BlockHeader header(BLOCKID_MARKERS, sizeof(uint16_t) + sizeof(float)*3*numMarkers);
write_pod(buffer, header);
write_pod(buffer, numMarkers);
for(int i = 0; i < numMarkers; i++) {
write_pod(buffer, _trackingData.m_markers[i].x);
write_pod(buffer, _trackingData.m_markers[i].y);
write_pod(buffer, _trackingData.m_markers[i].z);
}
}
// Inbound
void fsBinaryStream::encode_message(std::string &msg_out, const fsMsgTrackingState &msg) {
encode_message(msg_out, msg.tracking_data());
}
void fsBinaryStream::encode_message(std::string &msg_out, const fsMsgStartCapturing &msg) {
BlockHeader header(msg.id());
write_pod(msg_out, header);
}
void fsBinaryStream::encode_message(std::string &msg_out, const fsMsgStopCapturing &msg) {
BlockHeader header(msg.id());
write_pod(msg_out, header);
}
void fsBinaryStream::encode_message(std::string &msg_out, const fsMsgCalibrateNeutral &msg) {
BlockHeader header(msg.id());
write_pod(msg_out, header);
}
void fsBinaryStream::encode_message(std::string &msg_out, const fsMsgSendMarkerNames &msg) {
BlockHeader header(msg.id());
write_pod(msg_out, header);
}
void fsBinaryStream::encode_message(std::string &msg_out, const fsMsgSendBlendshapeNames &msg) {
BlockHeader header(msg.id());
write_pod(msg_out, header);
}
void fsBinaryStream::encode_message(std::string &msg_out, const fsMsgSendRig &msg) {
BlockHeader header(msg.id());
write_pod(msg_out, header);
}
void fsBinaryStream::encode_message(std::string &msg_out, const fsMsgHeadPoseRelative &msg) {
BlockHeader header(msg.id());
write_pod(msg_out, header);
}
void fsBinaryStream::encode_message(std::string &msg_out, const fsMsgHeadPoseAbsolute &msg) {
BlockHeader header(msg.id());
write_pod(msg_out, header);
}
// Outbound
void fsBinaryStream::encode_message(std::string &msg_out, const fsMsgSignal &msg) {
BlockHeader header(msg.id());
write_pod(msg_out, header);
}
void fsBinaryStream::encode_message(std::string &msg_out, const fsTrackingData &tracking_data) {
Size start = msg_out.size();
BlockHeader header(fsMsg::MSG_OUT_TRACKING_STATE);
write_pod(msg_out, header);
uint16_t N_blocks = 5;
write_pod(msg_out, N_blocks);
encodeInfo( msg_out, tracking_data);
encodePose( msg_out, tracking_data);
encodeBlendshapes(msg_out, tracking_data);
encodeEyeGaze( msg_out, tracking_data);
encodeMarkers( msg_out, tracking_data);
update_msg_size(msg_out, start);
}
void fsBinaryStream::encode_message(std::string &msg_out, const fsMsgMarkerNames &msg) {
Size start = msg_out.size();
BlockHeader header(msg.id());
write_pod(msg_out, header);
write_small_vector(msg_out,msg.marker_names());
update_msg_size(msg_out, start);
}
void fsBinaryStream::encode_message(std::string &msg_out, const fsMsgBlendshapeNames &msg) {
Size start = msg_out.size();
BlockHeader header(msg.id());
write_pod(msg_out, header);
write_small_vector(msg_out,msg.blendshape_names());
update_msg_size(msg_out, start);
}
void fsBinaryStream::encode_message(std::string &msg_out, const fsMsgRig &msg) {
Size start = msg_out.size();
BlockHeader header(msg.id());
write_pod(msg_out, header);
write_vector(msg_out, msg.mesh().m_quads); // write quads
write_vector(msg_out, msg.mesh().m_tris);// write triangles
write_vector(msg_out, msg.mesh().m_vertex_data.m_vertices);// write neutral vertices
write_small_vector(msg_out, msg.blendshape_names());// write names
write_pod(msg_out,uint16_t(msg.blendshapes().size()));
for(uint16_t i = 0;i < uint16_t(msg.blendshapes().size()); i++)
write_vector(msg_out, msg.blendshapes()[i].m_vertices); // write blendshapes
update_msg_size(msg_out, start);
}
}

View file

@ -11,16 +11,18 @@
// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
//
// the maximum number of local lights to apply
const int MAX_LOCAL_LIGHTS = 2;
// the color of each local light
uniform vec4 localLightColors[MAX_LOCAL_LIGHTS];
// the direction of each local light
uniform vec4 localLightDirections[MAX_LOCAL_LIGHTS];
// the diffuse texture
uniform sampler2D diffuseMap;
// local lights
const int MAX_LOCAL_LIGHTS = 2; // 2 lights for now, will probably need more later on
uniform int numLocalLights;
uniform vec3 localLightDirections[MAX_LOCAL_LIGHTS];
uniform vec3 localLightColors[MAX_LOCAL_LIGHTS];
// the interpolated position
varying vec4 position;
@ -28,23 +30,18 @@ varying vec4 position;
varying vec4 normal;
void main(void) {
// compute the base color based on OpenGL lighting model
// add up the local lights
vec4 normalizedNormal = normalize(normal);
float diffuse = dot(normalizedNormal, gl_LightSource[0].position);
float facingLight = step(0.0, diffuse);
// the local light that is always present
vec4 totalLocalLight = vec4(0.0, 0.0, 0.0, 1.0);
for (int i = 0; i < numLocalLights; i++) {
float localDiffuse = dot(normalizedNormal, vec4(localLightDirections[i], 1.0));
float localLight = step(0.0, localDiffuse);
float localLightVal = localDiffuse * localLight;
totalLocalLight += (localLightVal * vec4( localLightColors[i], 0.0));
vec4 localLight = vec4(0.0, 0.0, 0.0, 0.0);
for (int i = 0; i < MAX_LOCAL_LIGHTS; i++) {
localLight += localLightColors[i] * max(0.0, dot(normalizedNormal, localLightDirections[i]));
}
// compute the base color based on OpenGL lighting model
float diffuse = dot(normalizedNormal, gl_LightSource[0].position);
float facingLight = step(0.0, diffuse);
vec4 base = gl_Color * (gl_FrontLightModelProduct.sceneColor + gl_FrontLightProduct[0].ambient +
gl_FrontLightProduct[0].diffuse * (diffuse * facingLight) + totalLocalLight);
gl_FrontLightProduct[0].diffuse * (diffuse * facingLight) + localLight);
// compute the specular component (sans exponent)
float specular = facingLight * max(0.0, dot(normalize(gl_LightSource[0].position - normalize(vec4(position.xyz, 0.0))),

View file

@ -11,6 +11,15 @@
// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
//
// the maximum number of local lights to apply
const int MAX_LOCAL_LIGHTS = 2;
// the color of each local light
uniform vec4 localLightColors[MAX_LOCAL_LIGHTS];
// the direction of each local light
uniform vec4 localLightDirections[MAX_LOCAL_LIGHTS];
// the diffuse texture
uniform sampler2D diffuseMap;
@ -34,9 +43,15 @@ void main(void) {
int shadowIndex = int(dot(step(vec3(position.z), shadowDistances), vec3(1.0, 1.0, 1.0)));
vec3 shadowTexCoord = vec3(dot(gl_EyePlaneS[shadowIndex], position), dot(gl_EyePlaneT[shadowIndex], position),
dot(gl_EyePlaneR[shadowIndex], position));
// add up the local lights
vec4 normalizedNormal = normalize(normal);
vec4 localLight = vec4(0.0, 0.0, 0.0, 0.0);
for (int i = 0; i < MAX_LOCAL_LIGHTS; i++) {
localLight += localLightColors[i] * max(0.0, dot(normalizedNormal, localLightDirections[i]));
}
// compute the base color based on OpenGL lighting model
vec4 normalizedNormal = normalize(normal);
float diffuse = dot(normalizedNormal, gl_LightSource[0].position);
float facingLight = step(0.0, diffuse) * 0.25 *
(shadow2D(shadowMap, shadowTexCoord + vec3(-shadowScale, -shadowScale, 0.0)).r +
@ -44,7 +59,7 @@ void main(void) {
shadow2D(shadowMap, shadowTexCoord + vec3(shadowScale, -shadowScale, 0.0)).r +
shadow2D(shadowMap, shadowTexCoord + vec3(shadowScale, shadowScale, 0.0)).r);
vec4 base = gl_Color * (gl_FrontLightModelProduct.sceneColor + gl_FrontLightProduct[0].ambient +
gl_FrontLightProduct[0].diffuse * (diffuse * facingLight));
gl_FrontLightProduct[0].diffuse * (diffuse * facingLight) + localLight);
// compute the specular component (sans exponent)
float specular = facingLight * max(0.0, dot(normalize(gl_LightSource[0].position - normalize(vec4(position.xyz, 0.0))),

View file

@ -11,6 +11,15 @@
// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
//
// the maximum number of local lights to apply
const int MAX_LOCAL_LIGHTS = 2;
// the color of each local light
uniform vec4 localLightColors[MAX_LOCAL_LIGHTS];
// the direction of each local light
uniform vec4 localLightDirections[MAX_LOCAL_LIGHTS];
// the diffuse texture
uniform sampler2D diffuseMap;
@ -46,10 +55,16 @@ void main(void) {
vec3 shadowTexCoord = vec3(dot(gl_EyePlaneS[shadowIndex], interpolatedPosition),
dot(gl_EyePlaneT[shadowIndex], interpolatedPosition),
dot(gl_EyePlaneR[shadowIndex], interpolatedPosition));
// compute the base color based on OpenGL lighting model
// add up the local lights
vec4 viewNormal = vec4(normalizedTangent * localNormal.x +
normalizedBitangent * localNormal.y + normalizedNormal * localNormal.z, 0.0);
vec4 localLight = vec4(0.0, 0.0, 0.0, 0.0);
for (int i = 0; i < MAX_LOCAL_LIGHTS; i++) {
localLight += localLightColors[i] * max(0.0, dot(viewNormal, localLightDirections[i]));
}
// compute the base color based on OpenGL lighting model
float diffuse = dot(viewNormal, gl_LightSource[0].position);
float facingLight = step(0.0, diffuse) * 0.25 *
(shadow2D(shadowMap, shadowTexCoord + vec3(-shadowScale, -shadowScale, 0.0)).r +
@ -57,7 +72,7 @@ void main(void) {
shadow2D(shadowMap, shadowTexCoord + vec3(shadowScale, -shadowScale, 0.0)).r +
shadow2D(shadowMap, shadowTexCoord + vec3(shadowScale, shadowScale, 0.0)).r);
vec4 base = gl_Color * (gl_FrontLightModelProduct.sceneColor + gl_FrontLightProduct[0].ambient +
gl_FrontLightProduct[0].diffuse * (diffuse * facingLight));
gl_FrontLightProduct[0].diffuse * (diffuse * facingLight) + localLight);
// compute the specular component (sans exponent)
float specular = facingLight * max(0.0, dot(normalize(gl_LightSource[0].position -

View file

@ -11,6 +11,15 @@
// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
//
// the maximum number of local lights to apply
const int MAX_LOCAL_LIGHTS = 2;
// the color of each local light
uniform vec4 localLightColors[MAX_LOCAL_LIGHTS];
// the direction of each local light
uniform vec4 localLightDirections[MAX_LOCAL_LIGHTS];
// the diffuse texture
uniform sampler2D diffuseMap;
@ -50,9 +59,15 @@ void main(void) {
dot(gl_EyePlaneT[shadowIndex], interpolatedPosition),
dot(gl_EyePlaneR[shadowIndex], interpolatedPosition));
// compute the base color based on OpenGL lighting model
// add up the local lights
vec4 viewNormal = vec4(normalizedTangent * localNormal.x +
normalizedBitangent * localNormal.y + normalizedNormal * localNormal.z, 0.0);
vec4 localLight = vec4(0.0, 0.0, 0.0, 0.0);
for (int i = 0; i < MAX_LOCAL_LIGHTS; i++) {
localLight += localLightColors[i] * max(0.0, dot(viewNormal, localLightDirections[i]));
}
// compute the base color based on OpenGL lighting model
float diffuse = dot(viewNormal, gl_LightSource[0].position);
float facingLight = step(0.0, diffuse) * 0.25 *
(shadow2D(shadowMap, shadowTexCoord + vec3(-shadowScale, -shadowScale, 0.0)).r +
@ -60,7 +75,7 @@ void main(void) {
shadow2D(shadowMap, shadowTexCoord + vec3(shadowScale, -shadowScale, 0.0)).r +
shadow2D(shadowMap, shadowTexCoord + vec3(shadowScale, shadowScale, 0.0)).r);
vec4 base = gl_Color * (gl_FrontLightModelProduct.sceneColor + gl_FrontLightProduct[0].ambient +
gl_FrontLightProduct[0].diffuse * (diffuse * facingLight));
gl_FrontLightProduct[0].diffuse * (diffuse * facingLight) + localLight);
// compute the specular component (sans exponent)
float specular = facingLight * max(0.0, dot(normalize(gl_LightSource[0].position -

View file

@ -11,6 +11,15 @@
// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
//
// the maximum number of local lights to apply
const int MAX_LOCAL_LIGHTS = 2;
// the color of each local light
uniform vec4 localLightColors[MAX_LOCAL_LIGHTS];
// the direction of each local light
uniform vec4 localLightDirections[MAX_LOCAL_LIGHTS];
// the diffuse texture
uniform sampler2D diffuseMap;
@ -38,8 +47,14 @@ void main(void) {
vec3 shadowTexCoord = vec3(dot(gl_EyePlaneS[shadowIndex], position), dot(gl_EyePlaneT[shadowIndex], position),
dot(gl_EyePlaneR[shadowIndex], position));
// compute the base color based on OpenGL lighting model
// add up the local lights
vec4 normalizedNormal = normalize(normal);
vec4 localLight = vec4(0.0, 0.0, 0.0, 0.0);
for (int i = 0; i < MAX_LOCAL_LIGHTS; i++) {
localLight += localLightColors[i] * max(0.0, dot(normalizedNormal, localLightDirections[i]));
}
// compute the base color based on OpenGL lighting model
float diffuse = dot(normalizedNormal, gl_LightSource[0].position);
float facingLight = step(0.0, diffuse) * 0.25 *
(shadow2D(shadowMap, gl_TexCoord[1].stp + vec3(-shadowScale, -shadowScale, 0.0)).r +
@ -47,7 +62,7 @@ void main(void) {
shadow2D(shadowMap, gl_TexCoord[1].stp + vec3(shadowScale, -shadowScale, 0.0)).r +
shadow2D(shadowMap, gl_TexCoord[1].stp + vec3(shadowScale, shadowScale, 0.0)).r);
vec4 base = gl_Color * (gl_FrontLightModelProduct.sceneColor + gl_FrontLightProduct[0].ambient +
gl_FrontLightProduct[0].diffuse * (diffuse * facingLight));
gl_FrontLightProduct[0].diffuse * (diffuse * facingLight) + localLight);
// compute the specular component (sans exponent)
float specular = facingLight * max(0.0, dot(normalize(gl_LightSource[0].position - normalize(vec4(position.xyz, 0.0))),

View file

@ -11,6 +11,15 @@
// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
//
// the maximum number of local lights to apply
const int MAX_LOCAL_LIGHTS = 2;
// the color of each local light
uniform vec4 localLightColors[MAX_LOCAL_LIGHTS];
// the direction of each local light
uniform vec4 localLightDirections[MAX_LOCAL_LIGHTS];
// the diffuse texture
uniform sampler2D diffuseMap;
@ -32,19 +41,20 @@ void main(void) {
vec3 normalizedBitangent = normalize(cross(normalizedNormal, normalizedTangent));
vec3 localNormal = vec3(texture2D(normalMap, gl_TexCoord[0].st)) * 2.0 - vec3(1.0, 1.0, 1.0);
// compute the base color based on OpenGL lighting model
// add up the local lights
vec4 viewNormal = vec4(normalizedTangent * localNormal.x +
normalizedBitangent * localNormal.y + normalizedNormal * localNormal.z, 0.0);
vec4 localLight = vec4(0.0, 0.0, 0.0, 0.0);
for (int i = 0; i < MAX_LOCAL_LIGHTS; i++) {
localLight += localLightColors[i] * max(0.0, dot(viewNormal, localLightDirections[i]));
}
// compute the base color based on OpenGL lighting model
float diffuse = dot(viewNormal, gl_LightSource[0].position);
float facingLight = step(0.0, diffuse);
float localDiffuse = dot(viewNormal, gl_LightSource[1].position);
float localLight = step(0.0, localDiffuse);
vec4 base = gl_Color * (gl_FrontLightModelProduct.sceneColor + gl_FrontLightProduct[0].ambient +
gl_FrontLightProduct[0].diffuse * (diffuse * facingLight) + gl_FrontLightProduct[1].diffuse * (localDiffuse * localLight));
gl_FrontLightProduct[0].diffuse * (diffuse * facingLight) + localLight);
// compute the specular component (sans exponent)
float specular = facingLight * max(0.0, dot(normalize(gl_LightSource[0].position -
normalize(vec4(vec3(interpolatedPosition), 0.0))), viewNormal));

View file

@ -11,6 +11,15 @@
// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
//
// the maximum number of local lights to apply
const int MAX_LOCAL_LIGHTS = 2;
// the color of each local light
uniform vec4 localLightColors[MAX_LOCAL_LIGHTS];
// the direction of each local light
uniform vec4 localLightDirections[MAX_LOCAL_LIGHTS];
// the diffuse texture
uniform sampler2D diffuseMap;
@ -35,13 +44,19 @@ void main(void) {
vec3 normalizedBitangent = normalize(cross(normalizedNormal, normalizedTangent));
vec3 localNormal = vec3(texture2D(normalMap, gl_TexCoord[0].st)) * 2.0 - vec3(1.0, 1.0, 1.0);
// compute the base color based on OpenGL lighting model
// add up the local lights
vec4 viewNormal = vec4(normalizedTangent * localNormal.x +
normalizedBitangent * localNormal.y + normalizedNormal * localNormal.z, 0.0);
vec4 localLight = vec4(0.0, 0.0, 0.0, 0.0);
for (int i = 0; i < MAX_LOCAL_LIGHTS; i++) {
localLight += localLightColors[i] * max(0.0, dot(viewNormal, localLightDirections[i]));
}
// compute the base color based on OpenGL lighting model
float diffuse = dot(viewNormal, gl_LightSource[0].position);
float facingLight = step(0.0, diffuse);
vec4 base = gl_Color * (gl_FrontLightModelProduct.sceneColor + gl_FrontLightProduct[0].ambient +
gl_FrontLightProduct[0].diffuse * (diffuse * facingLight));
gl_FrontLightProduct[0].diffuse * (diffuse * facingLight) + localLight);
// compute the specular component (sans exponent)
float specular = facingLight * max(0.0, dot(normalize(gl_LightSource[0].position -

View file

@ -11,6 +11,15 @@
// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
//
// the maximum number of local lights to apply
const int MAX_LOCAL_LIGHTS = 2;
// the color of each local light
uniform vec4 localLightColors[MAX_LOCAL_LIGHTS];
// the direction of each local light
uniform vec4 localLightDirections[MAX_LOCAL_LIGHTS];
// the diffuse texture
uniform sampler2D diffuseMap;
@ -27,8 +36,14 @@ varying vec4 position;
varying vec4 normal;
void main(void) {
// compute the base color based on OpenGL lighting model
// add up the local lights
vec4 normalizedNormal = normalize(normal);
vec4 localLight = vec4(0.0, 0.0, 0.0, 0.0);
for (int i = 0; i < MAX_LOCAL_LIGHTS; i++) {
localLight += localLightColors[i] * max(0.0, dot(normalizedNormal, localLightDirections[i]));
}
// compute the base color based on OpenGL lighting model
float diffuse = dot(normalizedNormal, gl_LightSource[0].position);
float facingLight = step(0.0, diffuse) * 0.25 *
(shadow2D(shadowMap, gl_TexCoord[1].stp + vec3(-shadowScale, -shadowScale, 0.0)).r +
@ -36,7 +51,7 @@ void main(void) {
shadow2D(shadowMap, gl_TexCoord[1].stp + vec3(shadowScale, -shadowScale, 0.0)).r +
shadow2D(shadowMap, gl_TexCoord[1].stp + vec3(shadowScale, shadowScale, 0.0)).r);
vec4 base = gl_Color * (gl_FrontLightModelProduct.sceneColor + gl_FrontLightProduct[0].ambient +
gl_FrontLightProduct[0].diffuse * (diffuse * facingLight));
gl_FrontLightProduct[0].diffuse * (diffuse * facingLight) + localLight);
// compute the specular component (sans exponent)
float specular = facingLight * max(0.0, dot(normalize(gl_LightSource[0].position - normalize(vec4(position.xyz, 0.0))),

View file

@ -11,6 +11,15 @@
// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
//
// the maximum number of local lights to apply
const int MAX_LOCAL_LIGHTS = 2;
// the color of each local light
uniform vec4 localLightColors[MAX_LOCAL_LIGHTS];
// the direction of each local light
uniform vec4 localLightDirections[MAX_LOCAL_LIGHTS];
// the diffuse texture
uniform sampler2D diffuseMap;
@ -38,9 +47,15 @@ void main(void) {
vec3 normalizedBitangent = normalize(cross(normalizedNormal, normalizedTangent));
vec3 localNormal = vec3(texture2D(normalMap, gl_TexCoord[0].st)) * 2.0 - vec3(1.0, 1.0, 1.0);
// compute the base color based on OpenGL lighting model
// add up the local lights
vec4 viewNormal = vec4(normalizedTangent * localNormal.x +
normalizedBitangent * localNormal.y + normalizedNormal * localNormal.z, 0.0);
vec4 localLight = vec4(0.0, 0.0, 0.0, 0.0);
for (int i = 0; i < MAX_LOCAL_LIGHTS; i++) {
localLight += localLightColors[i] * max(0.0, dot(viewNormal, localLightDirections[i]));
}
// compute the base color based on OpenGL lighting model
float diffuse = dot(viewNormal, gl_LightSource[0].position);
float facingLight = step(0.0, diffuse) * 0.25 *
(shadow2D(shadowMap, gl_TexCoord[1].stp + vec3(-shadowScale, -shadowScale, 0.0)).r +
@ -48,7 +63,7 @@ void main(void) {
shadow2D(shadowMap, gl_TexCoord[1].stp + vec3(shadowScale, -shadowScale, 0.0)).r +
shadow2D(shadowMap, gl_TexCoord[1].stp + vec3(shadowScale, shadowScale, 0.0)).r);
vec4 base = gl_Color * (gl_FrontLightModelProduct.sceneColor + gl_FrontLightProduct[0].ambient +
gl_FrontLightProduct[0].diffuse * (diffuse * facingLight));
gl_FrontLightProduct[0].diffuse * (diffuse * facingLight) + localLight);
// compute the specular component (sans exponent)
float specular = facingLight * max(0.0, dot(normalize(gl_LightSource[0].position -

View file

@ -11,6 +11,15 @@
// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
//
// the maximum number of local lights to apply
const int MAX_LOCAL_LIGHTS = 2;
// the color of each local light
uniform vec4 localLightColors[MAX_LOCAL_LIGHTS];
// the direction of each local light
uniform vec4 localLightDirections[MAX_LOCAL_LIGHTS];
// the diffuse texture
uniform sampler2D diffuseMap;
@ -41,9 +50,15 @@ void main(void) {
vec3 normalizedBitangent = normalize(cross(normalizedNormal, normalizedTangent));
vec3 localNormal = vec3(texture2D(normalMap, gl_TexCoord[0].st)) * 2.0 - vec3(1.0, 1.0, 1.0);
// compute the base color based on OpenGL lighting model
// add up the local lights
vec4 viewNormal = vec4(normalizedTangent * localNormal.x +
normalizedBitangent * localNormal.y + normalizedNormal * localNormal.z, 0.0);
vec4 localLight = vec4(0.0, 0.0, 0.0, 0.0);
for (int i = 0; i < MAX_LOCAL_LIGHTS; i++) {
localLight += localLightColors[i] * max(0.0, dot(viewNormal, localLightDirections[i]));
}
// compute the base color based on OpenGL lighting model
float diffuse = dot(viewNormal, gl_LightSource[0].position);
float facingLight = step(0.0, diffuse) * 0.25 *
(shadow2D(shadowMap, gl_TexCoord[1].stp + vec3(-shadowScale, -shadowScale, 0.0)).r +
@ -51,7 +66,7 @@ void main(void) {
shadow2D(shadowMap, gl_TexCoord[1].stp + vec3(shadowScale, -shadowScale, 0.0)).r +
shadow2D(shadowMap, gl_TexCoord[1].stp + vec3(shadowScale, shadowScale, 0.0)).r);
vec4 base = gl_Color * (gl_FrontLightModelProduct.sceneColor + gl_FrontLightProduct[0].ambient +
gl_FrontLightProduct[0].diffuse * (diffuse * facingLight));
gl_FrontLightProduct[0].diffuse * (diffuse * facingLight) + localLight);
// compute the specular component (sans exponent)
float specular = facingLight * max(0.0, dot(normalize(gl_LightSource[0].position -

View file

@ -11,6 +11,15 @@
// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
//
// the maximum number of local lights to apply
const int MAX_LOCAL_LIGHTS = 2;
// the color of each local light
uniform vec4 localLightColors[MAX_LOCAL_LIGHTS];
// the direction of each local light
uniform vec4 localLightDirections[MAX_LOCAL_LIGHTS];
// the diffuse texture
uniform sampler2D diffuseMap;
@ -30,8 +39,14 @@ varying vec4 position;
varying vec4 normal;
void main(void) {
// compute the base color based on OpenGL lighting model
// add up the local lights
vec4 normalizedNormal = normalize(normal);
vec4 localLight = vec4(0.0, 0.0, 0.0, 0.0);
for (int i = 0; i < MAX_LOCAL_LIGHTS; i++) {
localLight += localLightColors[i] * max(0.0, dot(normalizedNormal, localLightDirections[i]));
}
// compute the base color based on OpenGL lighting model
float diffuse = dot(normalizedNormal, gl_LightSource[0].position);
float facingLight = step(0.0, diffuse) * 0.25 *
(shadow2D(shadowMap, gl_TexCoord[1].stp + vec3(-shadowScale, -shadowScale, 0.0)).r +
@ -39,7 +54,7 @@ void main(void) {
shadow2D(shadowMap, gl_TexCoord[1].stp + vec3(shadowScale, -shadowScale, 0.0)).r +
shadow2D(shadowMap, gl_TexCoord[1].stp + vec3(shadowScale, shadowScale, 0.0)).r);
vec4 base = gl_Color * (gl_FrontLightModelProduct.sceneColor + gl_FrontLightProduct[0].ambient +
gl_FrontLightProduct[0].diffuse * (diffuse * facingLight));
gl_FrontLightProduct[0].diffuse * (diffuse * facingLight) + localLight);
// compute the specular component (sans exponent)
float specular = facingLight * max(0.0, dot(normalize(gl_LightSource[0].position - normalize(vec4(position.xyz, 0.0))),

View file

@ -10,11 +10,15 @@
// Distributed under the Apache License, Version 2.0.
// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
//
// the maximum number of local lights to apply
const int MAX_LOCAL_LIGHTS = 2;
uniform int numLocalLights;
uniform vec3 localLightDirections[MAX_LOCAL_LIGHTS];
uniform vec3 localLightColors[MAX_LOCAL_LIGHTS];
// the color of each local light
uniform vec4 localLightColors[MAX_LOCAL_LIGHTS];
// the direction of each local light
uniform vec4 localLightDirections[MAX_LOCAL_LIGHTS];
// the diffuse texture
uniform sampler2D diffuseMap;
@ -29,23 +33,18 @@ varying vec4 position;
varying vec4 normal;
void main(void) {
// compute the base color based on OpenGL lighting model
// add up the local lights
vec4 normalizedNormal = normalize(normal);
float diffuse = dot(normalizedNormal, gl_LightSource[0].position);
float facingLight = step(0.0, diffuse);
// the local light that is always present
vec4 totalLocalLight = vec4(0.0, 0.0, 0.0, 1.0);
for (int i = 0; i < numLocalLights; i++) {
float localDiffuse = dot(normalizedNormal, vec4(localLightDirections[i], 1.0));
float localLight = step(0.0, localDiffuse);
float localLightVal = localDiffuse * localLight;
totalLocalLight += (localLightVal * vec4( localLightColors[i], 0.0));
vec4 localLight = vec4(0.0, 0.0, 0.0, 0.0);
for (int i = 0; i < MAX_LOCAL_LIGHTS; i++) {
localLight += localLightColors[i] * max(0.0, dot(normalizedNormal, localLightDirections[i]));
}
// compute the base color based on OpenGL lighting model
float diffuse = dot(normalizedNormal, gl_LightSource[0].position);
float facingLight = step(0.0, diffuse);
vec4 base = gl_Color * (gl_FrontLightModelProduct.sceneColor + gl_FrontLightProduct[0].ambient +
gl_FrontLightProduct[0].diffuse * (diffuse * facingLight) + totalLocalLight);
gl_FrontLightProduct[0].diffuse * (diffuse * facingLight) + localLight);
// compute the specular component (sans exponent)
float specular = facingLight * max(0.0, dot(normalize(gl_LightSource[0].position - normalize(vec4(position.xyz, 0.0))),

View file

@ -2601,7 +2601,9 @@ void Application::updateShadowMap() {
glViewport(0, 0, _glWidget->width(), _glWidget->height());
}
const GLfloat WHITE_SPECULAR_COLOR[] = { 1.0f, 1.0f, 1.0f, 1.0f };
const GLfloat WORLD_AMBIENT_COLOR[] = { 0.525f, 0.525f, 0.6f };
const GLfloat WORLD_DIFFUSE_COLOR[] = { 0.6f, 0.525f, 0.525f };
const GLfloat WORLD_SPECULAR_COLOR[] = { 0.94f, 0.94f, 0.737f, 1.0f };
const GLfloat NO_SPECULAR_COLOR[] = { 0.0f, 0.0f, 0.0f, 1.0f };
void Application::setupWorldLight() {
@ -2613,13 +2615,10 @@ void Application::setupWorldLight() {
glm::vec3 sunDirection = getSunDirection();
GLfloat light_position0[] = { sunDirection.x, sunDirection.y, sunDirection.z, 0.0 };
glLightfv(GL_LIGHT0, GL_POSITION, light_position0);
GLfloat ambient_color[] = { 0.7f, 0.7f, 0.8f };
glLightfv(GL_LIGHT0, GL_AMBIENT, ambient_color);
GLfloat diffuse_color[] = { 0.8f, 0.7f, 0.7f };
glLightfv(GL_LIGHT0, GL_DIFFUSE, diffuse_color);
glLightfv(GL_LIGHT0, GL_SPECULAR, WHITE_SPECULAR_COLOR);
glMaterialfv(GL_FRONT, GL_SPECULAR, WHITE_SPECULAR_COLOR);
glLightfv(GL_LIGHT0, GL_AMBIENT, WORLD_AMBIENT_COLOR);
glLightfv(GL_LIGHT0, GL_DIFFUSE, WORLD_DIFFUSE_COLOR);
glLightfv(GL_LIGHT0, GL_SPECULAR, WORLD_SPECULAR_COLOR);
glMaterialfv(GL_FRONT, GL_SPECULAR, WORLD_SPECULAR_COLOR);
glMateriali(GL_FRONT, GL_SHININESS, 96);
}
@ -2797,7 +2796,7 @@ void Application::displaySide(Camera& whichCamera, bool selfAvatarOnly) {
}
// restore default, white specular
glMaterialfv(GL_FRONT, GL_SPECULAR, WHITE_SPECULAR_COLOR);
glMaterialfv(GL_FRONT, GL_SPECULAR, WORLD_SPECULAR_COLOR);
_nodeBoundsDisplay.draw();
@ -3629,6 +3628,9 @@ ScriptEngine* Application::loadScript(const QString& scriptName, bool loadScript
scriptEngine->getModelsScriptingInterface()->setPacketSender(&_modelEditSender);
scriptEngine->getModelsScriptingInterface()->setModelTree(_models.getTree());
// model has some custom types
Model::registerMetaTypes(scriptEngine->getEngine());
// hook our avatar object into this script engine
scriptEngine->setAvatarData(_myAvatar, "MyAvatar"); // leave it as a MyAvatar class to expose thrust features

View file

@ -258,6 +258,8 @@ public:
/// the view matrix translation.
void updateUntranslatedViewMatrix(const glm::vec3& viewMatrixTranslation = glm::vec3());
const glm::mat4& getUntranslatedViewMatrix() const { return _untranslatedViewMatrix; }
/// Loads a view matrix that incorporates the specified model translation without the precision issues that can
/// result from matrix multiplication at high translation magnitudes.
void loadTranslatedViewMatrix(const glm::vec3& translation);

View file

@ -18,7 +18,8 @@
const float HAIR_DAMPING = 0.99f;
const float CONSTRAINT_RELAXATION = 10.0f;
const float HAIR_ACCELERATION_COUPLING = 0.025f;
const float HAIR_ANGULAR_VELOCITY_COUPLING = 0.10f;
const float HAIR_ANGULAR_VELOCITY_COUPLING = 0.01f;
const float HAIR_ANGULAR_ACCELERATION_COUPLING = 0.001f;
const float HAIR_MAX_LINEAR_ACCELERATION = 4.0f;
const float HAIR_STIFFNESS = 0.005f;
const glm::vec3 HAIR_COLOR1(0.98f, 0.92f, 0.843f);
@ -36,6 +37,7 @@ Hair::Hair(int strands,
_radius(radius),
_acceleration(0.0f),
_angularVelocity(0.0f),
_angularAcceleration(0.0f),
_gravity(0.0f)
{
_hairPosition = new glm::vec3[_strands * _links];
@ -127,13 +129,15 @@ void Hair::simulate(float deltaTime) {
const float ANGULAR_VELOCITY_MIN = 0.001f;
if (glm::length(_angularVelocity) > ANGULAR_VELOCITY_MIN) {
glm::vec3 yawVector = _hairPosition[vertexIndex];
glm::vec3 angularVelocity = _angularVelocity * HAIR_ANGULAR_VELOCITY_COUPLING;
glm::vec3 angularAcceleration = _angularAcceleration * HAIR_ANGULAR_ACCELERATION_COUPLING;
yawVector.y = 0.f;
if (glm::length(yawVector) > EPSILON) {
float radius = glm::length(yawVector);
yawVector = glm::normalize(yawVector);
float angle = atan2f(yawVector.x, -yawVector.z) + PI;
glm::vec3 delta = glm::vec3(-1.f, 0.f, 0.f) * glm::angleAxis(angle, glm::vec3(0, 1, 0));
_hairPosition[vertexIndex] -= delta * radius * _angularVelocity.y * HAIR_ANGULAR_VELOCITY_COUPLING * deltaTime;
_hairPosition[vertexIndex] -= delta * radius * (angularVelocity.y - angularAcceleration.y) * deltaTime;
}
glm::vec3 pitchVector = _hairPosition[vertexIndex];
pitchVector.x = 0.f;
@ -142,7 +146,7 @@ void Hair::simulate(float deltaTime) {
pitchVector = glm::normalize(pitchVector);
float angle = atan2f(pitchVector.y, -pitchVector.z) + PI;
glm::vec3 delta = glm::vec3(0.0f, 1.0f, 0.f) * glm::angleAxis(angle, glm::vec3(1, 0, 0));
_hairPosition[vertexIndex] -= delta * radius * _angularVelocity.x * HAIR_ANGULAR_VELOCITY_COUPLING * deltaTime;
_hairPosition[vertexIndex] -= delta * radius * (angularVelocity.x - angularAcceleration.x) * deltaTime;
}
glm::vec3 rollVector = _hairPosition[vertexIndex];
rollVector.z = 0.f;
@ -151,7 +155,7 @@ void Hair::simulate(float deltaTime) {
pitchVector = glm::normalize(rollVector);
float angle = atan2f(rollVector.x, rollVector.y) + PI;
glm::vec3 delta = glm::vec3(-1.0f, 0.0f, 0.f) * glm::angleAxis(angle, glm::vec3(0, 0, 1));
_hairPosition[vertexIndex] -= delta * radius * _angularVelocity.z * HAIR_ANGULAR_VELOCITY_COUPLING * deltaTime;
_hairPosition[vertexIndex] -= delta * radius * (angularVelocity.z - angularAcceleration.z) * deltaTime;
}
}

View file

@ -40,6 +40,7 @@ public:
void render();
void setAcceleration(const glm::vec3& acceleration) { _acceleration = acceleration; }
void setAngularVelocity(const glm::vec3& angularVelocity) { _angularVelocity = angularVelocity; }
void setAngularAcceleration(const glm::vec3& angularAcceleration) { _angularAcceleration = angularAcceleration; }
void setGravity(const glm::vec3& gravity) { _gravity = gravity; }
private:
@ -58,6 +59,7 @@ private:
int* _hairConstraints;
glm::vec3 _acceleration;
glm::vec3 _angularVelocity;
glm::vec3 _angularAcceleration;
glm::vec3 _gravity;

View file

@ -391,12 +391,15 @@ Menu::Menu() :
addCheckableActionToQMenuAndActionHash(avatarOptionsMenu, MenuOption::CollideAsRagdoll);
addCheckableActionToQMenuAndActionHash(avatarOptionsMenu, MenuOption::LookAtVectors, 0, false);
#ifdef HAVE_FACESHIFT
addCheckableActionToQMenuAndActionHash(avatarOptionsMenu,
MenuOption::Faceshift,
0,
true,
appInstance->getFaceshift(),
SLOT(setTCPEnabled(bool)));
#endif
#ifdef HAVE_FACEPLUS
addCheckableActionToQMenuAndActionHash(avatarOptionsMenu, MenuOption::Faceplus, 0, true,
appInstance->getFaceplus(), SLOT(updateEnabled()));

View file

@ -52,6 +52,8 @@ Avatar::Avatar() :
_lastVelocity(0.0f, 0.0f, 0.0f),
_acceleration(0.0f, 0.0f, 0.0f),
_angularVelocity(0.0f, 0.0f, 0.0f),
_lastAngularVelocity(0.0f, 0.0f, 0.0f),
_angularAcceleration(0.0f, 0.0f, 0.0f),
_lastOrientation(),
_leanScale(0.5f),
_scale(1.0f),
@ -60,7 +62,6 @@ Avatar::Avatar() :
_mouseRayDirection(0.0f, 0.0f, 0.0f),
_moving(false),
_collisionGroups(0),
_numLocalLights(0),
_initialized(false),
_shouldRenderBillboard(true)
{
@ -151,7 +152,8 @@ void Avatar::simulate(float deltaTime) {
if (Menu::getInstance()->isOptionChecked(MenuOption::StringHair)) {
PerformanceTimer perfTimer("hair");
_hair.setAcceleration(getAcceleration() * getHead()->getFinalOrientationInWorldFrame());
_hair.setAngularVelocity(getAngularVelocity() + getHead()->getAngularVelocity() * getHead()->getFinalOrientationInWorldFrame());
_hair.setAngularVelocity((getAngularVelocity() + getHead()->getAngularVelocity()) * getHead()->getFinalOrientationInWorldFrame());
_hair.setAngularAcceleration(getAngularAcceleration() * getHead()->getFinalOrientationInWorldFrame());
_hair.setGravity(Application::getInstance()->getEnvironment()->getGravity(getPosition()) * getHead()->getFinalOrientationInWorldFrame());
_hair.simulate(deltaTime);
}
@ -187,6 +189,7 @@ void Avatar::updateAcceleration(float deltaTime) {
glm::quat orientation = getOrientation();
glm::quat delta = glm::inverse(_lastOrientation) * orientation;
_angularVelocity = safeEulerAngles(delta) * (1.f / deltaTime);
_angularAcceleration = (_angularVelocity - _lastAngularVelocity) * (1.f / deltaTime);
_lastOrientation = getOrientation();
}
@ -245,19 +248,9 @@ void Avatar::render(const glm::vec3& cameraPosition, RenderMode renderMode) {
// local lights directions and colors
getSkeletonModel().setNumLocalLights(_numLocalLights);
getHead()->getFaceModel().setNumLocalLights(_numLocalLights);
for (int i = 0; i < MAX_LOCAL_LIGHTS; i++) {
glm::vec3 normalized = glm::normalize(_localLightDirections[i]);
// body
getSkeletonModel().setLocalLightColor(_localLightColors[i], i);
getSkeletonModel().setLocalLightDirection(normalized, i);
// head
getHead()->getFaceModel().setLocalLightColor(_localLightColors[i], i);
getHead()->getFaceModel().setLocalLightDirection(_localLightDirections[i], i);
}
const QVector<Model::LocalLight>& localLights = Application::getInstance()->getAvatarManager().getLocalLights();
_skeletonModel.setLocalLights(localLights);
getHead()->getFaceModel().setLocalLights(localLights);
// render body
if (Menu::getInstance()->isOptionChecked(MenuOption::Avatars)) {
@ -926,36 +919,3 @@ void Avatar::setShowDisplayName(bool showDisplayName) {
}
void Avatar::setLocalLightDirection(const glm::vec3& direction, int lightIndex) {
_localLightDirections[lightIndex] = direction;
}
void Avatar::setLocalLightColor(const glm::vec3& color, int lightIndex) {
_localLightColors[lightIndex] = color;
}
void Avatar::addLocalLight() {
if (_numLocalLights + 1 <= MAX_LOCAL_LIGHTS) {
++_numLocalLights;
}
}
void Avatar::removeLocalLight() {
if (_numLocalLights - 1 >= 0) {
--_numLocalLights;
}
}
int Avatar::getNumLocalLights() {
return _numLocalLights;
}
glm::vec3 Avatar::getLocalLightDirection(int lightIndex) {
return _localLightDirections[lightIndex];
}
glm::vec3 Avatar::getLocalLightColor(int lightIndex) {
return _localLightColors[lightIndex];
}

View file

@ -152,6 +152,8 @@ public:
glm::vec3 getAcceleration() const { return _acceleration; }
glm::vec3 getAngularVelocity() const { return _angularVelocity; }
glm::vec3 getAngularAcceleration() const { return _angularAcceleration; }
/// Scales a world space position vector relative to the avatar position and scale
/// \param vector position to be scaled. Will store the result
@ -159,14 +161,7 @@ public:
public slots:
void updateCollisionGroups();
void setLocalLightDirection(const glm::vec3& direction, int lightIndex);
void setLocalLightColor(const glm::vec3& color, int lightIndex);
void addLocalLight();
void removeLocalLight();
int getNumLocalLights();
glm::vec3 getLocalLightDirection(int lightIndex);
glm::vec3 getLocalLightColor(int lightIndex);
signals:
void collisionWithAvatar(const QUuid& myUUID, const QUuid& theirUUID, const CollisionInfo& collision);
@ -179,6 +174,8 @@ protected:
glm::vec3 _lastVelocity;
glm::vec3 _acceleration;
glm::vec3 _angularVelocity;
glm::vec3 _lastAngularVelocity;
glm::vec3 _angularAcceleration;
glm::quat _lastOrientation;
float _leanScale;
float _scale;
@ -189,11 +186,6 @@ protected:
bool _moving; ///< set when position is changing
quint32 _collisionGroups;
// always-present local lighting for the avatar
glm::vec3 _localLightDirections[MAX_LOCAL_LIGHTS];
glm::vec3 _localLightColors[MAX_LOCAL_LIGHTS];
int _numLocalLights;
// protected methods...
glm::vec3 getBodyRightDirection() const { return getOrientation() * IDENTITY_RIGHT; }

View file

@ -159,58 +159,21 @@ void AvatarManager::clearOtherAvatars() {
_myAvatar->clearLookAtTargetAvatar();
}
Avatar* AvatarManager::getAvatarFromIndex(int avatarIndex) {
Avatar* avatar = NULL;
int numAvatars = _avatarHash.count();
if (avatarIndex < numAvatars) {
QUuid key = (_avatarHash.keys())[avatarIndex];
const AvatarSharedPointer& avatarPointer = _avatarHash.value(key);
avatar = static_cast<Avatar*>(avatarPointer.data());
void AvatarManager::setLocalLights(const QVector<Model::LocalLight>& localLights) {
if (QThread::currentThread() != thread()) {
QMetaObject::invokeMethod(this, "setLocalLights", Q_ARG(const QVector<Model::LocalLight>&, localLights));
return;
}
return avatar;
_localLights = localLights;
}
void AvatarManager::addAvatarLocalLight(int avatarIndex) {
Avatar* avatar = getAvatarFromIndex(avatarIndex);
if (avatar) {
avatar->addLocalLight();
QVector<Model::LocalLight> AvatarManager::getLocalLights() const {
if (QThread::currentThread() != thread()) {
QVector<Model::LocalLight> result;
QMetaObject::invokeMethod(const_cast<AvatarManager*>(this), "getLocalLights", Qt::BlockingQueuedConnection,
Q_RETURN_ARG(QVector<Model::LocalLight>, result));
return result;
}
return _localLights;
}
void AvatarManager::removeAvatarLocalLight(int avatarIndex) {
Avatar* avatar = getAvatarFromIndex(avatarIndex);
if (avatar) {
avatar->removeLocalLight();
}
}
void AvatarManager::setAvatarLightDirection(const glm::vec3& direction, int lightIndex, int avatarIndex) {
Avatar* avatar = getAvatarFromIndex(avatarIndex);
if (avatar) {
avatar->setLocalLightDirection(direction, lightIndex);
}
}
void AvatarManager::setAvatarLightColor(const glm::vec3& color, int lightIndex, int avatarIndex) {
Avatar* avatar = getAvatarFromIndex(avatarIndex);
if (avatar) {
avatar->setLocalLightColor(color, lightIndex);
}
}
int AvatarManager::getNumLightsInAvatar(int avatarIndex) {
int numLights = 0;
Avatar* avatar = getAvatarFromIndex(avatarIndex);
if (avatar) {
numLights = avatar->getNumLocalLights();
}
return numLights;
}
int AvatarManager::getNumAvatars() {
return _avatarHash.count();
}

View file

@ -37,13 +37,8 @@ public:
void clearOtherAvatars();
public slots:
void setAvatarLightColor(const glm::vec3& color, int lightIndex, int avatarIndex);
void setAvatarLightDirection(const glm::vec3& direction, int lightIndex, int avatarIndex);
void removeAvatarLocalLight(int avatarIndex);
void addAvatarLocalLight(int avatarIndex);
int getNumLightsInAvatar(int avatarIndex);
int getNumAvatars();
Q_INVOKABLE void setLocalLights(const QVector<Model::LocalLight>& localLights);
Q_INVOKABLE QVector<Model::LocalLight> getLocalLights() const;
private:
AvatarManager(const AvatarManager& other);
@ -53,13 +48,13 @@ private:
AvatarSharedPointer newSharedAvatar();
Avatar* getAvatarFromIndex(int avatarIndex);
// virtual override
AvatarHash::iterator erase(const AvatarHash::iterator& iterator);
QVector<AvatarSharedPointer> _avatarFades;
QSharedPointer<MyAvatar> _myAvatar;
QVector<Model::LocalLight> _localLights;
};
#endif // hifi_AvatarManager_h

View file

@ -187,7 +187,8 @@ void MyAvatar::simulate(float deltaTime) {
PerformanceTimer perfTimer("hair");
if (Menu::getInstance()->isOptionChecked(MenuOption::StringHair)) {
_hair.setAcceleration(getAcceleration() * getHead()->getFinalOrientationInWorldFrame());
_hair.setAngularVelocity(getAngularVelocity() + getHead()->getAngularVelocity() * getHead()->getFinalOrientationInWorldFrame());
_hair.setAngularVelocity((getAngularVelocity() + getHead()->getAngularVelocity()) * getHead()->getFinalOrientationInWorldFrame());
_hair.setAngularAcceleration(getAngularAcceleration() * getHead()->getFinalOrientationInWorldFrame());
_hair.setGravity(Application::getInstance()->getEnvironment()->getGravity(getPosition()) * getHead()->getFinalOrientationInWorldFrame());
_hair.simulate(deltaTime);
}

View file

@ -19,7 +19,10 @@
#include "Menu.h"
#include "Util.h"
#ifdef HAVE_FACESHIFT
using namespace fs;
#endif
using namespace std;
const quint16 FACESHIFT_PORT = 33433;
@ -48,6 +51,7 @@ Faceshift::Faceshift() :
_longTermAverageEyeYaw(0.0f),
_longTermAverageInitialized(false)
{
#ifdef HAVE_FACESHIFT
connect(&_tcpSocket, SIGNAL(connected()), SLOT(noteConnected()));
connect(&_tcpSocket, SIGNAL(error(QAbstractSocket::SocketError)), SLOT(noteError(QAbstractSocket::SocketError)));
connect(&_tcpSocket, SIGNAL(readyRead()), SLOT(readFromSocket()));
@ -56,20 +60,27 @@ Faceshift::Faceshift() :
connect(&_udpSocket, SIGNAL(readyRead()), SLOT(readPendingDatagrams()));
_udpSocket.bind(FACESHIFT_PORT);
#endif
}
void Faceshift::init() {
#ifdef HAVE_FACESHIFT
setTCPEnabled(Menu::getInstance()->isOptionChecked(MenuOption::Faceshift));
#endif
}
bool Faceshift::isConnectedOrConnecting() const {
return _tcpSocket.state() == QAbstractSocket::ConnectedState ||
(_tcpRetryCount == 0 && _tcpSocket.state() != QAbstractSocket::UnconnectedState);
(_tcpRetryCount == 0 && _tcpSocket.state() != QAbstractSocket::UnconnectedState);
}
bool Faceshift::isActive() const {
#ifdef HAVE_FACESHIFT
const quint64 ACTIVE_TIMEOUT_USECS = 1000000;
return (usecTimestampNow() - _lastTrackingStateReceived) < ACTIVE_TIMEOUT_USECS;
#else
return false;
#endif
}
void Faceshift::update() {
@ -97,12 +108,14 @@ void Faceshift::update() {
}
void Faceshift::reset() {
#ifdef HAVE_FACESHIFT
if (_tcpSocket.state() == QAbstractSocket::ConnectedState) {
string message;
fsBinaryStream::encode_message(message, fsMsgCalibrateNeutral());
send(message);
}
_longTermAverageInitialized = false;
#endif
}
void Faceshift::updateFakeCoefficients(float leftBlink, float rightBlink, float browUp,
@ -138,11 +151,13 @@ void Faceshift::connectSocket() {
}
void Faceshift::noteConnected() {
#ifdef HAVE_FACESHIFT
qDebug("Faceshift: Connected.");
// request the list of blendshape names
string message;
fsBinaryStream::encode_message(message, fsMsgSendBlendshapeNames());
send(message);
#endif
}
void Faceshift::noteError(QAbstractSocket::SocketError error) {
@ -179,6 +194,7 @@ void Faceshift::send(const std::string& message) {
}
void Faceshift::receive(const QByteArray& buffer) {
#ifdef HAVE_FACESHIFT
_stream.received(buffer.size(), buffer.constData());
fsMsgPtr msg;
for (fsMsgPtr msg; (msg = _stream.get_message()); ) {
@ -259,4 +275,5 @@ void Faceshift::receive(const QByteArray& buffer) {
break;
}
}
#endif
}

View file

@ -15,7 +15,9 @@
#include <QTcpSocket>
#include <QUdpSocket>
#ifdef HAVE_FACESHIFT
#include <fsbinarystream.h>
#endif
#include "FaceTracker.h"
@ -24,7 +26,6 @@ class Faceshift : public FaceTracker {
Q_OBJECT
public:
Faceshift();
void init();
@ -88,7 +89,11 @@ private:
QTcpSocket _tcpSocket;
QUdpSocket _udpSocket;
#ifdef HAVE_FACESHIFT
fs::fsBinaryStream _stream;
#endif
bool _tcpEnabled;
int _tcpRetryCount;
bool _tracking;
@ -123,6 +128,7 @@ private:
float _longTermAverageEyePitch;
float _longTermAverageEyeYaw;
bool _longTermAverageInitialized;
};
#endif // hifi_Faceshift_h

View file

@ -15,7 +15,7 @@
#ifdef HAVE_LIBOVR
#include <OVR.h>
#include "../src/Util/Util_Render_Stereo.h"
#include <Util_Render_Stereo.h>
#endif
#include "renderer/ProgramObject.h"

View file

@ -11,6 +11,7 @@
#include <QMetaType>
#include <QRunnable>
#include <QScriptEngine>
#include <QThreadPool>
#include <glm/gtx/transform.hpp>
@ -19,6 +20,7 @@
#include <CapsuleShape.h>
#include <GeometryUtil.h>
#include <PhysicsEntity.h>
#include <RegisteredMetaTypes.h>
#include <ShapeCollider.h>
#include <SphereShape.h>
@ -31,6 +33,23 @@ static int modelPointerTypeId = qRegisterMetaType<QPointer<Model> >();
static int weakNetworkGeometryPointerTypeId = qRegisterMetaType<QWeakPointer<NetworkGeometry> >();
static int vec3VectorTypeId = qRegisterMetaType<QVector<glm::vec3> >();
static QScriptValue localLightToScriptValue(QScriptEngine* engine, const Model::LocalLight& light) {
QScriptValue object = engine->newObject();
object.setProperty("direction", vec3toScriptValue(engine, light.direction));
object.setProperty("color", vec3toScriptValue(engine, light.color));
return object;
}
static void localLightFromScriptValue(const QScriptValue& value, Model::LocalLight& light) {
vec3FromScriptValue(value.property("direction"), light.direction);
vec3FromScriptValue(value.property("color"), light.color);
}
void Model::registerMetaTypes(QScriptEngine* engine) {
qScriptRegisterMetaType(engine, localLightToScriptValue, localLightFromScriptValue);
qScriptRegisterSequenceMetaType<QVector<Model::LocalLight> >(engine);
}
Model::Model(QObject* parent) :
QObject(parent),
_scale(1.0f, 1.0f, 1.0f),
@ -85,17 +104,18 @@ ProgramObject Model::_skinCascadedShadowNormalSpecularMapProgram;
ProgramObject Model::_skinShadowProgram;
int Model::_normalMapTangentLocation;
int Model::_normalSpecularMapTangentLocation;
int Model::_shadowNormalMapTangentLocation;
int Model::_shadowNormalSpecularMapTangentLocation;
int Model::_cascadedShadowNormalMapTangentLocation;
int Model::_cascadedShadowNormalSpecularMapTangentLocation;
int Model::_cascadedShadowMapDistancesLocation;
int Model::_cascadedShadowNormalMapDistancesLocation;
int Model::_cascadedShadowSpecularMapDistancesLocation;
int Model::_cascadedShadowNormalSpecularMapDistancesLocation;
Model::Locations Model::_locations;
Model::Locations Model::_normalMapLocations;
Model::Locations Model::_specularMapLocations;
Model::Locations Model::_normalSpecularMapLocations;
Model::Locations Model::_shadowMapLocations;
Model::Locations Model::_shadowNormalMapLocations;
Model::Locations Model::_shadowSpecularMapLocations;
Model::Locations Model::_shadowNormalSpecularMapLocations;
Model::Locations Model::_cascadedShadowMapLocations;
Model::Locations Model::_cascadedShadowNormalMapLocations;
Model::Locations Model::_cascadedShadowSpecularMapLocations;
Model::Locations Model::_cascadedShadowNormalSpecularMapLocations;
Model::SkinLocations Model::_skinLocations;
Model::SkinLocations Model::_skinNormalMapLocations;
@ -141,15 +161,13 @@ void Model::setOffset(const glm::vec3& offset) {
_snappedToCenter = false;
}
void Model::initSkinProgram(ProgramObject& program, Model::SkinLocations& locations,
void Model::initProgram(ProgramObject& program, Model::Locations& locations,
int specularTextureUnit, int shadowTextureUnit) {
program.bind();
locations.clusterMatrices = program.uniformLocation("clusterMatrices");
locations.clusterIndices = program.attributeLocation("clusterIndices");
locations.clusterWeights = program.attributeLocation("clusterWeights");
locations.tangent = program.attributeLocation("tangent");
locations.shadowDistances = program.uniformLocation("shadowDistances");
locations.localLightColors = program.uniformLocation("localLightColors");
locations.localLightDirections = program.uniformLocation("localLightDirections");
program.setUniformValue("diffuseMap", 0);
program.setUniformValue("normalMap", 1);
program.setUniformValue("specularMap", specularTextureUnit);
@ -157,6 +175,17 @@ void Model::initSkinProgram(ProgramObject& program, Model::SkinLocations& locati
program.release();
}
void Model::initSkinProgram(ProgramObject& program, Model::SkinLocations& locations,
int specularTextureUnit, int shadowTextureUnit) {
initProgram(program, locations, specularTextureUnit, shadowTextureUnit);
program.bind();
locations.clusterMatrices = program.uniformLocation("clusterMatrices");
locations.clusterIndices = program.attributeLocation("clusterIndices");
locations.clusterWeights = program.attributeLocation("clusterWeights");
program.release();
}
QVector<JointState> Model::createJointStates(const FBXGeometry& geometry) {
QVector<JointState> jointStates;
foreach (const FBXJoint& joint, geometry.joints) {
@ -193,9 +222,7 @@ void Model::init() {
_program.addShaderFromSourceFile(QGLShader::Fragment, Application::resourcesPath() + "shaders/model.frag");
_program.link();
_program.bind();
_program.setUniformValue("diffuseMap", 0);
_program.release();
initProgram(_program, _locations);
_normalMapProgram.addShaderFromSourceFile(QGLShader::Vertex,
Application::resourcesPath() + "shaders/model_normal_map.vert");
@ -203,11 +230,7 @@ void Model::init() {
Application::resourcesPath() + "shaders/model_normal_map.frag");
_normalMapProgram.link();
_normalMapProgram.bind();
_normalMapProgram.setUniformValue("diffuseMap", 0);
_normalMapProgram.setUniformValue("normalMap", 1);
_normalMapTangentLocation = _normalMapProgram.attributeLocation("tangent");
_normalMapProgram.release();
initProgram(_normalMapProgram, _normalMapLocations);
_specularMapProgram.addShaderFromSourceFile(QGLShader::Vertex,
Application::resourcesPath() + "shaders/model.vert");
@ -215,10 +238,7 @@ void Model::init() {
Application::resourcesPath() + "shaders/model_specular_map.frag");
_specularMapProgram.link();
_specularMapProgram.bind();
_specularMapProgram.setUniformValue("diffuseMap", 0);
_specularMapProgram.setUniformValue("specularMap", 1);
_specularMapProgram.release();
initProgram(_specularMapProgram, _specularMapLocations);
_normalSpecularMapProgram.addShaderFromSourceFile(QGLShader::Vertex,
Application::resourcesPath() + "shaders/model_normal_map.vert");
@ -226,12 +246,7 @@ void Model::init() {
Application::resourcesPath() + "shaders/model_normal_specular_map.frag");
_normalSpecularMapProgram.link();
_normalSpecularMapProgram.bind();
_normalSpecularMapProgram.setUniformValue("diffuseMap", 0);
_normalSpecularMapProgram.setUniformValue("normalMap", 1);
_normalSpecularMapProgram.setUniformValue("specularMap", 2);
_normalSpecularMapTangentLocation = _normalSpecularMapProgram.attributeLocation("tangent");
_normalSpecularMapProgram.release();
initProgram(_normalSpecularMapProgram, _normalSpecularMapLocations, 2);
_shadowMapProgram.addShaderFromSourceFile(QGLShader::Vertex, Application::resourcesPath() + "shaders/model.vert");
@ -239,10 +254,7 @@ void Model::init() {
"shaders/model_shadow_map.frag");
_shadowMapProgram.link();
_shadowMapProgram.bind();
_shadowMapProgram.setUniformValue("diffuseMap", 0);
_shadowMapProgram.setUniformValue("shadowMap", 1);
_shadowMapProgram.release();
initProgram(_shadowMapProgram, _shadowMapLocations);
_shadowNormalMapProgram.addShaderFromSourceFile(QGLShader::Vertex,
Application::resourcesPath() + "shaders/model_normal_map.vert");
@ -250,12 +262,7 @@ void Model::init() {
Application::resourcesPath() + "shaders/model_shadow_normal_map.frag");
_shadowNormalMapProgram.link();
_shadowNormalMapProgram.bind();
_shadowNormalMapProgram.setUniformValue("diffuseMap", 0);
_shadowNormalMapProgram.setUniformValue("normalMap", 1);
_shadowNormalMapProgram.setUniformValue("shadowMap", 2);
_shadowNormalMapTangentLocation = _shadowNormalMapProgram.attributeLocation("tangent");
_shadowNormalMapProgram.release();
initProgram(_shadowNormalMapProgram, _shadowNormalMapLocations, 1, 2);
_shadowSpecularMapProgram.addShaderFromSourceFile(QGLShader::Vertex,
Application::resourcesPath() + "shaders/model.vert");
@ -263,11 +270,7 @@ void Model::init() {
Application::resourcesPath() + "shaders/model_shadow_specular_map.frag");
_shadowSpecularMapProgram.link();
_shadowSpecularMapProgram.bind();
_shadowSpecularMapProgram.setUniformValue("diffuseMap", 0);
_shadowSpecularMapProgram.setUniformValue("specularMap", 1);
_shadowSpecularMapProgram.setUniformValue("shadowMap", 2);
_shadowSpecularMapProgram.release();
initProgram(_shadowSpecularMapProgram, _shadowSpecularMapLocations, 1, 2);
_shadowNormalSpecularMapProgram.addShaderFromSourceFile(QGLShader::Vertex,
Application::resourcesPath() + "shaders/model_normal_map.vert");
@ -275,13 +278,7 @@ void Model::init() {
Application::resourcesPath() + "shaders/model_shadow_normal_specular_map.frag");
_shadowNormalSpecularMapProgram.link();
_shadowNormalSpecularMapProgram.bind();
_shadowNormalSpecularMapProgram.setUniformValue("diffuseMap", 0);
_shadowNormalSpecularMapProgram.setUniformValue("normalMap", 1);
_shadowNormalSpecularMapProgram.setUniformValue("specularMap", 2);
_shadowNormalSpecularMapProgram.setUniformValue("shadowMap", 3);
_shadowNormalSpecularMapTangentLocation = _shadowNormalSpecularMapProgram.attributeLocation("tangent");
_shadowNormalSpecularMapProgram.release();
initProgram(_shadowNormalSpecularMapProgram, _shadowNormalSpecularMapLocations, 2, 3);
_cascadedShadowMapProgram.addShaderFromSourceFile(QGLShader::Vertex, Application::resourcesPath() +
@ -290,11 +287,7 @@ void Model::init() {
"shaders/model_cascaded_shadow_map.frag");
_cascadedShadowMapProgram.link();
_cascadedShadowMapProgram.bind();
_cascadedShadowMapProgram.setUniformValue("diffuseMap", 0);
_cascadedShadowMapProgram.setUniformValue("shadowMap", 1);
_cascadedShadowMapDistancesLocation = _cascadedShadowMapProgram.uniformLocation("shadowDistances");
_cascadedShadowMapProgram.release();
initProgram(_cascadedShadowMapProgram, _cascadedShadowMapLocations);
_cascadedShadowNormalMapProgram.addShaderFromSourceFile(QGLShader::Vertex,
Application::resourcesPath() + "shaders/model_normal_map.vert");
@ -302,13 +295,7 @@ void Model::init() {
Application::resourcesPath() + "shaders/model_cascaded_shadow_normal_map.frag");
_cascadedShadowNormalMapProgram.link();
_cascadedShadowNormalMapProgram.bind();
_cascadedShadowNormalMapProgram.setUniformValue("diffuseMap", 0);
_cascadedShadowNormalMapProgram.setUniformValue("normalMap", 1);
_cascadedShadowNormalMapProgram.setUniformValue("shadowMap", 2);
_cascadedShadowNormalMapDistancesLocation = _cascadedShadowNormalMapProgram.uniformLocation("shadowDistances");
_cascadedShadowNormalMapTangentLocation = _cascadedShadowNormalMapProgram.attributeLocation("tangent");
_cascadedShadowNormalMapProgram.release();
initProgram(_cascadedShadowNormalMapProgram, _cascadedShadowNormalMapLocations, 1, 2);
_cascadedShadowSpecularMapProgram.addShaderFromSourceFile(QGLShader::Vertex,
Application::resourcesPath() + "shaders/model.vert");
@ -316,12 +303,7 @@ void Model::init() {
Application::resourcesPath() + "shaders/model_cascaded_shadow_specular_map.frag");
_cascadedShadowSpecularMapProgram.link();
_cascadedShadowSpecularMapProgram.bind();
_cascadedShadowSpecularMapProgram.setUniformValue("diffuseMap", 0);
_cascadedShadowSpecularMapProgram.setUniformValue("specularMap", 1);
_cascadedShadowSpecularMapProgram.setUniformValue("shadowMap", 2);
_cascadedShadowSpecularMapDistancesLocation = _cascadedShadowSpecularMapProgram.uniformLocation("shadowDistances");
_cascadedShadowSpecularMapProgram.release();
initProgram(_cascadedShadowSpecularMapProgram, _cascadedShadowSpecularMapLocations, 1, 2);
_cascadedShadowNormalSpecularMapProgram.addShaderFromSourceFile(QGLShader::Vertex,
Application::resourcesPath() + "shaders/model_normal_map.vert");
@ -329,15 +311,7 @@ void Model::init() {
Application::resourcesPath() + "shaders/model_cascaded_shadow_normal_specular_map.frag");
_cascadedShadowNormalSpecularMapProgram.link();
_cascadedShadowNormalSpecularMapProgram.bind();
_cascadedShadowNormalSpecularMapProgram.setUniformValue("diffuseMap", 0);
_cascadedShadowNormalSpecularMapProgram.setUniformValue("normalMap", 1);
_cascadedShadowNormalSpecularMapProgram.setUniformValue("specularMap", 2);
_cascadedShadowNormalSpecularMapProgram.setUniformValue("shadowMap", 3);
_cascadedShadowNormalSpecularMapDistancesLocation =
_cascadedShadowNormalSpecularMapProgram.uniformLocation("shadowDistances");
_cascadedShadowNormalSpecularMapTangentLocation = _cascadedShadowNormalSpecularMapProgram.attributeLocation("tangent");
_cascadedShadowNormalSpecularMapProgram.release();
initProgram(_cascadedShadowNormalSpecularMapProgram, _cascadedShadowNormalSpecularMapLocations, 2, 3);
_shadowProgram.addShaderFromSourceFile(QGLShader::Vertex, Application::resourcesPath() + "shaders/model_shadow.vert");
@ -609,6 +583,17 @@ bool Model::render(float alpha, RenderMode mode, bool receiveShadows) {
glEnable(GL_CULL_FACE);
if (mode == SHADOW_RENDER_MODE) {
glCullFace(GL_FRONT);
} else if (mode == DEFAULT_RENDER_MODE) {
// update the local lights
for (int i = 0; i < MAX_LOCAL_LIGHTS; i++) {
if (i < _localLights.size()) {
_localLightDirections[i] = glm::normalize(Application::getInstance()->getUntranslatedViewMatrix() *
glm::vec4(_rotation * _localLights.at(i).direction, 0.0f));
} else {
_localLightColors[i] = glm::vec4();
}
}
}
}
@ -1384,10 +1369,9 @@ void Model::renderMeshes(float alpha, RenderMode mode, bool translucent, bool re
const_cast<QOpenGLBuffer&>(networkMesh.vertexBuffer).bind();
ProgramObject* program = &_program;
Locations* locations = &_locations;
ProgramObject* skinProgram = &_skinProgram;
SkinLocations* skinLocations = &_skinLocations;
int tangentLocation = _normalMapTangentLocation;
int shadowDistancesLocation = _cascadedShadowMapDistancesLocation;
GLenum specularTextureUnit = 0;
GLenum shadowTextureUnit = 0;
if (mode == SHADOW_RENDER_MODE) {
@ -1400,41 +1384,40 @@ void Model::renderMeshes(float alpha, RenderMode mode, bool translucent, bool re
if (receiveShadows) {
if (cascadedShadows) {
program = &_cascadedShadowNormalSpecularMapProgram;
locations = &_cascadedShadowNormalSpecularMapLocations;
skinProgram = &_skinCascadedShadowNormalSpecularMapProgram;
skinLocations = &_skinCascadedShadowNormalSpecularMapLocations;
tangentLocation = _cascadedShadowNormalSpecularMapTangentLocation;
shadowDistancesLocation = _cascadedShadowNormalSpecularMapDistancesLocation;
} else {
program = &_shadowNormalSpecularMapProgram;
locations = &_shadowNormalSpecularMapLocations;
skinProgram = &_skinShadowNormalSpecularMapProgram;
skinLocations = &_skinShadowNormalSpecularMapLocations;
tangentLocation = _shadowNormalSpecularMapTangentLocation;
}
shadowTextureUnit = GL_TEXTURE3;
} else {
program = &_normalSpecularMapProgram;
locations = &_normalSpecularMapLocations;
skinProgram = &_skinNormalSpecularMapProgram;
skinLocations = &_skinNormalSpecularMapLocations;
tangentLocation = _normalSpecularMapTangentLocation;
}
specularTextureUnit = GL_TEXTURE2;
} else if (receiveShadows) {
if (cascadedShadows) {
program = &_cascadedShadowNormalMapProgram;
locations = &_cascadedShadowNormalMapLocations;
skinProgram = &_skinCascadedShadowNormalMapProgram;
skinLocations = &_skinCascadedShadowNormalMapLocations;
tangentLocation = _cascadedShadowNormalMapTangentLocation;
shadowDistancesLocation = _cascadedShadowNormalMapDistancesLocation;
} else {
program = &_shadowNormalMapProgram;
locations = &_shadowNormalMapLocations;
skinProgram = &_skinShadowNormalMapProgram;
skinLocations = &_skinShadowNormalMapLocations;
tangentLocation = _shadowNormalMapTangentLocation;
}
shadowTextureUnit = GL_TEXTURE2;
} else {
program = &_normalMapProgram;
locations = &_normalMapLocations;
skinProgram = &_skinNormalMapProgram;
skinLocations = &_skinNormalMapLocations;
}
@ -1442,17 +1425,19 @@ void Model::renderMeshes(float alpha, RenderMode mode, bool translucent, bool re
if (receiveShadows) {
if (cascadedShadows) {
program = &_cascadedShadowSpecularMapProgram;
locations = &_cascadedShadowSpecularMapLocations;
skinProgram = &_skinCascadedShadowSpecularMapProgram;
skinLocations = &_skinCascadedShadowSpecularMapLocations;
shadowDistancesLocation = _cascadedShadowSpecularMapDistancesLocation;
} else {
program = &_shadowSpecularMapProgram;
locations = &_shadowSpecularMapLocations;
skinProgram = &_skinShadowSpecularMapProgram;
skinLocations = &_skinShadowSpecularMapLocations;
}
shadowTextureUnit = GL_TEXTURE2;
} else {
program = &_specularMapProgram;
locations = &_specularMapLocations;
skinProgram = &_skinSpecularMapProgram;
skinLocations = &_skinSpecularMapLocations;
}
@ -1461,10 +1446,12 @@ void Model::renderMeshes(float alpha, RenderMode mode, bool translucent, bool re
} else if (receiveShadows) {
if (cascadedShadows) {
program = &_cascadedShadowMapProgram;
locations = &_cascadedShadowMapLocations;
skinProgram = &_skinCascadedShadowMapProgram;
skinLocations = &_skinCascadedShadowMapLocations;
} else {
program = &_shadowMapProgram;
locations = &_shadowMapLocations;
skinProgram = &_skinShadowMapProgram;
skinLocations = &_skinShadowMapLocations;
}
@ -1473,6 +1460,7 @@ void Model::renderMeshes(float alpha, RenderMode mode, bool translucent, bool re
const MeshState& state = _meshStates.at(i);
ProgramObject* activeProgram = program;
Locations* activeLocations = locations;
glPushMatrix();
Application::getInstance()->loadTranslatedViewMatrix(_translation);
@ -1489,27 +1477,22 @@ void Model::renderMeshes(float alpha, RenderMode mode, bool translucent, bool re
skinProgram->enableAttributeArray(skinLocations->clusterIndices);
skinProgram->enableAttributeArray(skinLocations->clusterWeights);
activeProgram = skinProgram;
tangentLocation = skinLocations->tangent;
if (cascadedShadows) {
program->setUniform(skinLocations->shadowDistances, Application::getInstance()->getShadowDistances());
}
activeLocations = skinLocations;
// local light uniforms
skinProgram->setUniformValue("numLocalLights", _numLocalLights);
skinProgram->setUniformArray("localLightDirections", _localLightDirections, MAX_LOCAL_LIGHTS);
skinProgram->setUniformArray("localLightColors", _localLightColors, MAX_LOCAL_LIGHTS);
} else {
glMultMatrixf((const GLfloat*)&state.clusterMatrices[0]);
program->bind();
if (cascadedShadows) {
program->setUniform(shadowDistancesLocation, Application::getInstance()->getShadowDistances());
}
}
if (cascadedShadows) {
activeProgram->setUniform(activeLocations->shadowDistances, Application::getInstance()->getShadowDistances());
}
activeProgram->setUniformValueArray(activeLocations->localLightDirections,
(const GLfloat*)_localLightDirections, MAX_LOCAL_LIGHTS, 4);
if (mesh.blendshapes.isEmpty()) {
if (!(mesh.tangents.isEmpty() || mode == SHADOW_RENDER_MODE)) {
activeProgram->setAttributeBuffer(tangentLocation, GL_FLOAT, vertexCount * 2 * sizeof(glm::vec3), 3);
activeProgram->enableAttributeArray(tangentLocation);
activeProgram->setAttributeBuffer(activeLocations->tangent, GL_FLOAT, vertexCount * 2 * sizeof(glm::vec3), 3);
activeProgram->enableAttributeArray(activeLocations->tangent);
}
glColorPointer(3, GL_FLOAT, 0, (void*)(vertexCount * 2 * sizeof(glm::vec3) +
mesh.tangents.size() * sizeof(glm::vec3)));
@ -1518,8 +1501,8 @@ void Model::renderMeshes(float alpha, RenderMode mode, bool translucent, bool re
} else {
if (!(mesh.tangents.isEmpty() || mode == SHADOW_RENDER_MODE)) {
activeProgram->setAttributeBuffer(tangentLocation, GL_FLOAT, 0, 3);
activeProgram->enableAttributeArray(tangentLocation);
activeProgram->setAttributeBuffer(activeLocations->tangent, GL_FLOAT, 0, 3);
activeProgram->enableAttributeArray(activeLocations->tangent);
}
glColorPointer(3, GL_FLOAT, 0, (void*)(mesh.tangents.size() * sizeof(glm::vec3)));
glTexCoordPointer(2, GL_FLOAT, 0, (void*)((mesh.tangents.size() + mesh.colors.size()) * sizeof(glm::vec3)));
@ -1557,6 +1540,12 @@ void Model::renderMeshes(float alpha, RenderMode mode, bool translucent, bool re
glMaterialfv(GL_FRONT, GL_SPECULAR, (const float*)&specular);
glMaterialf(GL_FRONT, GL_SHININESS, part.shininess);
for (int k = 0; k < qMin(MAX_LOCAL_LIGHTS, _localLights.size()); k++) {
_localLightColors[k] = glm::vec4(_localLights.at(k).color, 1.0f) * diffuse;
}
activeProgram->setUniformValueArray(activeLocations->localLightColors,
(const GLfloat*)_localLightColors, MAX_LOCAL_LIGHTS, 4);
Texture* diffuseMap = networkPart.diffuseTexture.data();
if (mesh.isEye && diffuseMap) {
diffuseMap = (_dilatedTextures[i][j] =
@ -1607,7 +1596,7 @@ void Model::renderMeshes(float alpha, RenderMode mode, bool translucent, bool re
glBindTexture(GL_TEXTURE_2D, 0);
glActiveTexture(GL_TEXTURE0);
activeProgram->disableAttributeArray(tangentLocation);
activeProgram->disableAttributeArray(activeLocations->tangent);
}
if (specularTextureUnit) {
@ -1632,20 +1621,6 @@ void Model::renderMeshes(float alpha, RenderMode mode, bool translucent, bool re
}
}
void Model::setLocalLightDirection(const glm::vec3& direction, int lightIndex) {
assert(lightIndex >= 0 && lightIndex < MAX_LOCAL_LIGHTS);
_localLightDirections[lightIndex] = direction;
}
void Model::setLocalLightColor(const glm::vec3& color, int lightIndex) {
assert(lightIndex >= 0 && lightIndex < MAX_LOCAL_LIGHTS);
_localLightColors[lightIndex] = color;
}
void Model::setNumLocalLights(int numLocalLights) {
_numLocalLights = numLocalLights;
}
void AnimationHandle::setURL(const QUrl& url) {
if (_url != url) {
_animation = Application::getInstance()->getAnimationCache()->getAnimation(_url = url);

View file

@ -26,6 +26,8 @@
#include "ProgramObject.h"
#include "TextureCache.h"
class QScriptEngine;
class AnimationHandle;
class Shape;
@ -40,6 +42,9 @@ class Model : public QObject, public PhysicsEntity {
public:
/// Registers the script types associated with models.
static void registerMetaTypes(QScriptEngine* engine);
Model(QObject* parent = NULL);
virtual ~Model();
@ -145,9 +150,14 @@ public:
/// Sets blended vertices computed in a separate thread.
void setBlendedVertices(const QVector<glm::vec3>& vertices, const QVector<glm::vec3>& normals);
void setLocalLightDirection(const glm::vec3& direction, int lightIndex);
void setLocalLightColor(const glm::vec3& color, int lightIndex);
void setNumLocalLights(int numLocalLights);
class LocalLight {
public:
glm::vec3 color;
glm::vec3 direction;
};
void setLocalLights(const QVector<LocalLight>& localLights) { _localLights = localLights; }
const QVector<LocalLight>& getLocalLights() const { return _localLights; }
void setShowTrueJointTransforms(bool show) { _showTrueJointTransforms = show; }
@ -165,10 +175,8 @@ protected:
bool _snappedToCenter; /// are we currently snapped to center
bool _showTrueJointTransforms;
glm::vec3 _localLightDirections[MAX_LOCAL_LIGHTS];
glm::vec3 _localLightColors[MAX_LOCAL_LIGHTS];
int _numLocalLights;
QVector<LocalLight> _localLights;
QVector<JointState> _jointStates;
class MeshState {
@ -250,6 +258,9 @@ private:
QList<AnimationHandlePointer> _runningAnimations;
glm::vec4 _localLightColors[MAX_LOCAL_LIGHTS];
glm::vec4 _localLightDirections[MAX_LOCAL_LIGHTS];
static ProgramObject _program;
static ProgramObject _normalMapProgram;
static ProgramObject _specularMapProgram;
@ -296,13 +307,35 @@ private:
static int _cascadedShadowSpecularMapDistancesLocation;
static int _cascadedShadowNormalSpecularMapDistancesLocation;
class SkinLocations {
class Locations {
public:
int localLightColors;
int localLightDirections;
int tangent;
int shadowDistances;
};
static Locations _locations;
static Locations _normalMapLocations;
static Locations _specularMapLocations;
static Locations _normalSpecularMapLocations;
static Locations _shadowMapLocations;
static Locations _shadowNormalMapLocations;
static Locations _shadowSpecularMapLocations;
static Locations _shadowNormalSpecularMapLocations;
static Locations _cascadedShadowMapLocations;
static Locations _cascadedShadowNormalMapLocations;
static Locations _cascadedShadowSpecularMapLocations;
static Locations _cascadedShadowNormalSpecularMapLocations;
static void initProgram(ProgramObject& program, Locations& locations,
int specularTextureUnit = 1, int shadowTextureUnit = 1);
class SkinLocations : public Locations {
public:
int clusterMatrices;
int clusterIndices;
int clusterWeights;
int tangent;
int shadowDistances;
int clusterWeights;
};
static SkinLocations _skinLocations;
@ -326,6 +359,8 @@ private:
Q_DECLARE_METATYPE(QPointer<Model>)
Q_DECLARE_METATYPE(QWeakPointer<NetworkGeometry>)
Q_DECLARE_METATYPE(QVector<glm::vec3>)
Q_DECLARE_METATYPE(Model::LocalLight)
Q_DECLARE_METATYPE(QVector<Model::LocalLight>)
/// Represents a handle to a model animation.
class AnimationHandle : public QObject {

View file

@ -828,19 +828,19 @@ void Stats::display(
}
// draw local light stats
int numLocalLights = myAvatar->getNumLocalLights();
QVector<Model::LocalLight> localLights = Application::getInstance()->getAvatarManager().getLocalLights();
verticalOffset = 400;
horizontalOffset = 20;
char buffer[128];
for (int i = 0; i < numLocalLights; i++) {
glm::vec3 lightDirection = myAvatar->getLocalLightDirection(i);
for (int i = 0; i < localLights.size(); i++) {
glm::vec3 lightDirection = localLights.at(i).direction;
snprintf(buffer, sizeof(buffer), "Light %d direction (%.2f, %.2f, %.2f)", i, lightDirection.x, lightDirection.y, lightDirection.z);
drawText(horizontalOffset, verticalOffset, scale, rotation, font, buffer, color);
verticalOffset += STATS_PELS_PER_LINE;
glm::vec3 lightColor = myAvatar->getLocalLightColor(i);
glm::vec3 lightColor = localLights.at(i).color;
snprintf(buffer, sizeof(buffer), "Light %d color (%.2f, %.2f, %.2f)", i, lightColor.x, lightColor.y, lightColor.z);
drawText(horizontalOffset, verticalOffset, scale, rotation, font, buffer, color);