Files
UnrealEngineUWP/Engine/Source/ThirdParty/OSVRClientKit/include/osvr/RenderKit/RenderKitGraphicsTransforms.h
Nick Whiting ac27794af7 Copying //UE4/Dev-VR to //UE4/Dev-Main (Source: //UE4/Dev-VR @ 3056808)
#lockdown Nick.Penwarden
#rb The Forces of Good and Evil, twixt the realms from which bugs doth come

==========================
MAJOR FEATURES + CHANGES
==========================

Change 3026722 on 2016/06/24 by Chad.Taylor

	IStereoLayers SteamVR initial implementation

Change 3027397 on 2016/06/24 by Chad.Taylor

	SteamVR stereo layer texture updating rework. It now upadtes textures from the render thread and supports "continous update"

Change 3033004 on 2016/06/29 by Nick.Whiting

	Integrating GoogleVR plugin from Google branch

Change 3033248 on 2016/06/29 by Sam.Zamani

	Copying //Tasks/UE4/Dev-VR-Online to Dev-VR (//UE4/Dev-VR)

	Merged up to cl #3029677 from //depot/Partners/Oculus/UE4-Research/4.12-dev/Engine/Source/Runtime/Online/...
	Added PacketHandler module dependency to new OnlineSubsystemOculus module
	Replaced std::move usage with UE equivalent MoveTemp
	Trigger OnLoginStatusChanged delegate during login/logout processing of FOnlineIdentityOculus
	Implemented Oculus unique net id creation from string and byte*
	Added OnlineSubsystemOculus module as a dependency for QAGame testing
	Make sure to always call completion delegates in FOnlineFriendsOculus
	Trigger success OnMatchmakingComplete delegate in FOnlineSessionOculus::StartMatchmaking
	Fixed shadowed variable PlayerId in FOnlineSessionOculus::OnRoomInviteAccepted
	Split out 32/64bit dll dependencies of LibOVRPlatform
	Replaced "unsigned long long" with UE equivalent "uint64"
	Replaced "unsigned int" with UE equivalent "uint32"

Change 3033490 on 2016/06/29 by Jeff.Fisher

	UE-32601
	Changed from Flush to FlushImmediate when switching from rendering one eye buffer to the other on GoogleVR because we are trying to clear the immediate RHI command list.

Change 3034920 on 2016/06/30 by Chad.Taylor

	PSVR ApplyMorpheusReprojection support for separate texture per stereo eye.

Change 3038640 on 2016/07/05 by Chad.Taylor

	Fixing Morpheus "HasValidTrackingPosition" to actually return true when tracking is valid.

Change 3038940 on 2016/07/06 by Nick.Whiting

	Haptics Refactor:  Adding support for multiple types of haptics effect, defined by their data format (curves, buffer, sound waves)

Change 3040512 on 2016/07/06 by Chad.Taylor

	Fix for CopyOverOtherViewportsIfNeeded that was selecting an incorrect FSceneView. This was picking the wrong hmd mesh for render and causing strange flickering.

Change 3041314 on 2016/07/07 by Nick.Whiting

	Extending core hand types for motion tracking controllers to have external camera tracking available, as well as Special_1 - 9 for systems like STEM that have multiple special packs.

Change 3041353 on 2016/07/07 by Nick.Whiting

	Modifying SteamVR HMD detection check to use a lighter weight function that doesn't launch the compositor

Change 3043516 on 2016/07/08 by Chad.Taylor

	PSVR A3D Sound fix

Change 3043808 on 2016/07/08 by Nick.Whiting

	Fixing issue with SteamVR plugin starting while trying to detect connected HMDs, fix for editor quitting when VR Compositor quits

Change 3043840 on 2016/07/09 by Nick.Whiting

	OSVR Updated plugin, from Sensics

Change 3043958 on 2016/07/09 by Nick.Whiting

	Oculus 1.5 Support Integration

Change 3045493 on 2016/07/11 by Ryan.Vance

	Copying //UE4/Dev-VR-InstancedStereo to Dev-VR-Minimal (//UE4/Dev-VR-Minimal)
	PS4 multi-view copy up

Change 3046896 on 2016/07/12 by Ryan.Vance

	#jira UE-30842

	We need to also late update ShadowViewMatrices, otherwise we compute an incorrect volume for translucent lighting which manifests as flickering.
	Note: I'm not bothering to check the r.Shadow.FreezeCamera cvar here, as debugging shadowing *in vr* is probably not a case we need to support.

Change 3047272 on 2016/07/12 by Ryan.Vance

	#jira UE-30278

	We need to forward the eye index interpolator along.
	Also removed a superfluous call to resolve view.

Change 3048060 on 2016/07/13 by Nick.Whiting

	Integrating CL 3045721 from //depot/Partners/Google/AndroidVR-DevVR
	Upgrade Android and iOS GVR SDK to the latest.
	Fix the flipped vignette issue when using Unreal's post processing distortion.
	Change the Daydream & Cardboard mode to use scanline racing.
	Deprecate the ability to turn off individual UI elements.

Change 3048151 on 2016/07/13 by Nick.Whiting

	Integrating small controller initialization fix from AndroidVR-DevVR branch

Change 3048363 on 2016/07/13 by Ryan.Vance

	Fix for crash with HMDs when the adapter description isn't found. Crashing case was having monitors plugged into one adapter, and an HMD plugged into another, which caused a gap in AdapterDescription array, which later crashed in FindAdapter.

Change 3048783 on 2016/07/13 by Chad.Taylor

	Fixing up SteamVR's -vr to mimic the same behavior as Oculus and use the appropriate resolution

	#jira UE-30173

Change 3049101 on 2016/07/13 by Chad.Taylor

	Part 2 of: Fixing up SteamVR's -vr to mimic the same behavior as Oculus and use the appropriate resolution.

	Had to defer setting of the viewport size to occur after we have a valid Window.

	#jira UE-30173

Change 3050707 on 2016/07/14 by Nick.Whiting

	Fix for motion controllers on remote clients responding to local motion controllers

Change 3051043 on 2016/07/14 by Nick.Whiting

	Stub funcitonality to allow for rebasing based on other external trackers

Change 3051882 on 2016/07/15 by Nick.Whiting

	Moving OnlineSubsystemOculus to a plugin, instead of a module

Change 3053772 on 2016/07/18 by Chad.Taylor

	Code cleanup: Removing defunct IStereoRendering methods

Change 3054515 on 2016/07/18 by Chad.Taylor

	Changing HMD resolution resizing to no longer occur in "Windowed" mode because its causing an issue in VR Preview

	#jira UE-33341

Change 3056435 on 2016/07/19 by Jeff.Fisher

	UES-2981
	UEVR-13
	Implemented VRHeadsetLost and VRHeadsetReconnected Delegates for Morpheus (Playstation VR).
	https://udn.unrealengine.com/questions/301886/trying-to-use-vrheadsetlost-and-vrheadsetreconnect.html
	#review-3056100 @nick.whiting

Change 3056491 on 2016/07/19 by Chad.Taylor

	Audio thread assertion from HandlePause being called on the game thread. Submitting on behalf of Aaron McLeran

	#jira UE-33360

[CL 3057155 by Nick Whiting in Main branch]
2016-07-20 01:48:44 -04:00

164 lines
7.4 KiB
C++

/** @file
@brief Header file describing the OSVR graphics transformations interface
@date 2015
@author
Russ Taylor <russ@sensics.com>
<http://sensics.com/osvr>
*/
// Copyright 2015 Sensics, Inc.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
#pragma once
// Internal Includes
#include <osvr/RenderKit/Export.h>
// Library/third-party includes
#include <osvr/Util/ClientReportTypesC.h>
// Standard includes
#include <memory>
namespace osvr {
namespace renderkit {
//=========================================================================
/// Description needed to construct an off-axis projection matrix
typedef struct {
double left;
double right;
double top;
double bottom;
double nearClip; //< Cannot name "near" because Visual Studio keyword
double farClip;
} OSVR_ProjectionMatrix;
//=========================================================================
/// Viewport description with lower-left corner of the screen as (0,0)
struct OSVR_ViewportDescription {
double left; //< Left side of the viewport in pixels
double lower; //< First pixel in the viewport at the bottom.
double width; //< Last pixel in the viewport at the top
double height; //< Last pixel on the right of the viewport in pixels
bool operator==(const OSVR_ViewportDescription& v) const {
return (v.left == left) && (v.lower == lower) &&
(v.width == width) && (v.height == height);
}
bool operator!=(const OSVR_ViewportDescription& v) const {
return (v.left != left) || (v.lower != lower) ||
(v.width != width) || (v.height != height);
}
};
//=========================================================================
// Routines to turn the OSVR_PoseState into ModelView matrices for OpenGL
// and Direct3D. Done in such a way that we don't require the inclusion
// of the native API header files (since most apps will not include all
// of the libraries).
/// Produce an OpenGL ModelView matrix from an OSVR_PoseState.
/// Assumes that the world is described in a right-handed fashion and
/// that we're going to use a right-handed projection matrix.
/// @brief Produce OpenGL ModelView transform from OSVR_PoseState
/// @param state_in Input state from RenderManager.
/// @param OpenGL_out Pointer to 16-element double array that has
/// been allocated by the caller.
/// @return True on success, false on failure (null pointer).
bool OSVR_RENDERMANAGER_EXPORT OSVR_PoseState_to_OpenGL(
double* OpenGL_out, const OSVR_PoseState& state_in);
/// Produce a D3D ModelView matrix from an OSVR_PoseState.
/// Handles transitioning from the right-handed OSVR coordinate
/// system to the left-handed projection matrix that is typical
/// for D3D applications.
/// @brief Produce D3D ModelView transform from OSVR_PoseState
/// @param state_in Input state from RenderManager.
/// @param OpenGL_out Pointer to 16-element double array that has
/// been allocated by the caller.
/// @return True on success, false on failure (null pointer).
bool OSVR_RENDERMANAGER_EXPORT
OSVR_PoseState_to_D3D(float D3D_out[16], const OSVR_PoseState& state_in);
/// Modify the OSVR_PoseState from OSVR to be appropriate for use
/// in a Unity application. OSVR's world is right handed, and Unity's
/// is left handed.
/// @brief Modify OSVR_PoseState for use by Unity.
/// @param state_in Input state from RenderManager.
/// @param state_out Ouput state for use by Unity
/// @return True on success, false on failure (null pointer).
bool OSVR_RENDERMANAGER_EXPORT
OSVR_PoseState_to_Unity(OSVR_PoseState& state_out,
const OSVR_PoseState& state_in);
//=========================================================================
// Routines to turn the 4x4 projection matrices returned as part of the
// RenderCallback class into Projection matrices for OpenGL and
// Direct3D. Done in such a way that we don't require the inclusion of the
// native API header files (since most apps will not include all of the
// libraries).
/// Produce an OpenGL Projection matrix from an OSVR_ProjectionMatrix.
/// Assumes that the world is described in a right-handed fashion and
/// that we're going to use a right-handed projection matrix.
/// @brief Produce OpenGL Projection matrix from OSVR projection info.
/// @param projection_in Input projection description from RenderManager.
/// @param OpenGL_out Pointer to 16-element double array that has
/// been allocated by the caller.
/// @return True on success, false on failure (null pointer).
bool OSVR_RENDERMANAGER_EXPORT OSVR_Projection_to_OpenGL(
double* OpenGL_out, const OSVR_ProjectionMatrix& projection_in);
/// Produce a D3D Projection matrix from an OSVR_ProjectionMatrix.
/// Produces a left-handed projection matrix as is typical
/// for D3D applications.
/// @brief Produce D3D Projection transform from OSVR projection info
/// @param projection_in Input projection description from RenderManager.
/// @param D3D_out Pointer to 16-element float array that has
/// been allocated by the caller.
/// @return True on success, false on failure (null pointer).
bool OSVR_RENDERMANAGER_EXPORT OSVR_Projection_to_D3D(
float D3D_out[16], const OSVR_ProjectionMatrix& projection_in);
/// Produce an Unreal Projection matrix from an OSVR_ProjectionMatrix.
/// Produces a left-handed projection matrix whose Z values are
/// in the opposite order, with Z=0 at the far clipping plane and
/// Z=1 at the near clipping plane. If there is not a far clipping
/// plane defined, then set it to be the same as the near
/// clipping plane before calling this function. If there is not a
/// near clipping plane set, then set it to 1 before calling this
/// function.
/// To put the result into an Unreal FMatrix, do the following:
/// float p[16];
/// OSVR_Projection_to_D3D(p, projection_in);
/// FPlane row1(p[0], p[1], p[2], p[3]);
/// FPlane row2(p[4], p[5], p[6], p[7]);
/// FPlane row3(p[8], p[9], p[10], p[11]);
/// FPlane row4(p[12], p[13], p[14], p[15]);
/// FMatrix ret = FMatrix(row1, row2, row3, row4);
/// @brief Produce Unreal Projection transform from OSVR projection info
/// @param projection_in Input projection description from RenderManager.
/// @param Unreal_out Pointer to 16-element float array that has
/// been allocated by the caller.
/// @return True on success, false on failure (null pointer).
bool OSVR_RENDERMANAGER_EXPORT OSVR_Projection_to_Unreal(
float Unreal_out[16], const OSVR_ProjectionMatrix& projection_in);
} // namespace renderkit
} // namespace osvr