This commit is contained in:
astrojonathan 2016-08-27 06:55:39 -07:00
Родитель 9165385be4
Коммит d60169d71e
27 изменённых файлов: 26752 добавлений и 447 удалений

1152
OculusWrap/Hmd.cs Normal file

Разница между файлами не показана из-за своего большого размера Загрузить разницу

730
OculusWrap/Layers.cs Normal file
Просмотреть файл

@ -0,0 +1,730 @@
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Runtime.InteropServices;
using ovrTextureSwapChain = System.IntPtr;
namespace OculusWrap
{
/// <summary>
/// Handles allocation and deallocation of the list of layer data.
///
/// This class helps reduce the number of unmanaged memory allocations,
/// by remembering which layers were allocated and only deallocating memory again,
/// when those layers change.
///
/// Having to manage a list of different types and different sizes of layers is a
/// new feature in Oculus SDK 0.6.0.0.
/// </summary>
public class Layers :IDisposable
{
/// <summary>
/// Yup, this is a finalizer. It finalizes stuff :p
/// </summary>
~Layers()
{
Dispose(false);
}
#region IDisposable Members
/// <summary>
/// Clean up the allocated HMD.
/// </summary>
public void Dispose()
{
Dispose(true);
GC.SuppressFinalize(this);
}
/// <summary>
/// Dispose pattern implementation of dispose method.
/// </summary>
/// <param name="disposing">True if disposing, false if finalizing.</param>
protected virtual void Dispose(bool disposing)
{
if(Disposed)
return;
if(!disposing)
{
Trace.WriteLine("The Layers with hashcode "+GetHashCode()+" was not disposed and will leak unmanaged memory.");
// This class contains a list of unmanaged data, which cannot be deallocated when finalizing this class,
// because the contained list could have been finalized before this class was finalized.
return;
}
DeallocateUnmanaged();
GC.SuppressFinalize(this);
Disposed = true;
}
/// <summary>
/// Describes if the object has been disposed.
/// </summary>
public bool Disposed
{
get;
private set;
}
#endregion
#region Public methods
/// <summary>
/// Add a new LayerEyeFov layer to the end of the list of layers.
/// </summary>
/// <returns>Added layer.</returns>
public LayerEyeFov AddLayerEyeFov()
{
if(Disposed)
throw new ObjectDisposedException("Layers");
LayerEyeFov layer = new LayerEyeFov();
m_layers.Add(layer);
// Indicate that the list of layers has been modified and the unmanaged data needs to be reallocated.
m_layersChanged = true;
return layer;
}
/// <summary>
/// Add a new LayerQuad layer to the end of the list of layers.
/// </summary>
/// <returns>Added layer.</returns>
public LayerQuad AddLayerQuadHeadLocked()
{
if(Disposed)
throw new ObjectDisposedException("Layers");
LayerQuad layer = new LayerQuad();
layer.Header.Type = OVRTypes.LayerType.Quad;
layer.Header.Flags = OVRTypes.LayerFlags.HeadLocked;
m_layers.Add(layer);
// Indicate that the list of layers has been modified and the unmanaged data needs to be reallocated.
m_layersChanged = true;
return layer;
}
/// <summary>
/// Add a new LayerQuad layer to the end of the list of layers.
/// </summary>
/// <returns>Added layer.</returns>
public LayerQuad AddLayerQuadInWorld()
{
if(Disposed)
throw new ObjectDisposedException("Layers");
LayerQuad layer = new LayerQuad();
layer.Header.Type = OVRTypes.LayerType.Quad;
m_layers.Add(layer);
// Indicate that the list of layers has been modified and the unmanaged data needs to be reallocated.
m_layersChanged = true;
return layer;
}
/// <summary>
/// Remove the layer at the specified index.
/// </summary>
/// <param name="index">Index of the layer to remove.</param>
/// <exception cref="ArgumentOutOfRangeException">Thrown if the specified index is out of range.</exception>
public void Remove(int index)
{
if(Disposed)
throw new ObjectDisposedException("Layers");
if(index >= m_layers.Count)
throw new ArgumentOutOfRangeException("index", "Unable to remove layer index "+index+". Only "+m_layers.Count+" layers exist.");
m_layers.RemoveAt(index);
// Indicate that the list of layers has been modified and the unmanaged data needs to be reallocated.
m_layersChanged = true;
}
/// <summary>
/// Retrieves the layer at the specified index.
/// </summary>
/// <param name="index">Index of the layer to get.</param>
/// <returns>Index at the specified layer.</returns>
/// <exception cref="ArgumentOutOfRangeException">Thrown if the specified index is out of range.</exception>
public object this[int index]
{
get
{
if(Disposed)
throw new ObjectDisposedException("Layers");
if(index < 0)
throw new ArgumentOutOfRangeException("index", "Layer index "+index+" does not exist.");
if(index >= m_layers.Count)
throw new ArgumentOutOfRangeException("index", "Unable to remove layer index "+index+". Only "+m_layers.Count+" layers exist.");
return m_layers[index];
}
}
/// <summary>
/// Returns the number of layers available.
/// </summary>
public int Count
{
get
{
if(Disposed)
throw new ObjectDisposedException("Layers");
return m_layers.Count;
}
}
/// <summary>
/// Retrieves the list of unmanaged layer data, to be passed to ovrHmd_SubmitFrame.
/// </summary>
/// <returns>List of unmanaged layer data.</returns>
public IntPtr GetUnmanagedLayers()
{
if(Disposed)
throw new ObjectDisposedException("Layers");
// If the number of layers have changed, since the last time the unmanaged layers were retrieved.
if(m_layersChanged)
{
AllocateUnmanaged();
m_layersChanged = false;
}
// Copy values from the list of layers to the list of unmanaged layer data.
CopyToUnmanaged();
return m_layerArrayData;
}
#endregion
#region Private methods
/// <summary>
/// Allocate unmanaged memory for each layer.
///
/// Because each layer may be of a different type, the size of each layer may be different.
/// </summary>
private void AllocateUnmanaged()
{
// Clean up previously allocated layers.
DeallocateUnmanaged();
if(m_layers.Count > 0)
{
// Allocate memory for an unmanaged copy of the pointers to the layers of unmanaged data.
int pointerSize = Marshal.SizeOf(typeof(IntPtr));
m_layerArrayData = Marshal.AllocHGlobal(pointerSize*m_layers.Count);
// Allocate unmanaged data for each layer.
for (int count=0; count<m_layers.Count; count++)
{
// If the layer is disabled, it will contain a null layer.
if(m_layers[count] == null)
{
m_layerData.Add(IntPtr.Zero);
continue;
}
//Type layerType = m_layers[count].GetType();
Type layerType = m_layers[count].LayerType;
int layerSize = Marshal.SizeOf(layerType);
IntPtr layerData = Marshal.AllocHGlobal(layerSize);
// Store the unmanaged memory needed to contain the current layer.
m_layerData.Add(layerData);
// Write the pointer, to the current layer, to the unmanaged layer array.
Marshal.WriteIntPtr(m_layerArrayData, pointerSize*count, layerData);
}
}
}
/// <summary>
/// Clean up previously allocated layers.
/// </summary>
private void DeallocateUnmanaged()
{
// Deallocate previously allocated unmanaged layer data.
foreach(IntPtr layerData in m_layerData)
{
if(layerData != IntPtr.Zero)
Marshal.FreeHGlobal(layerData);
}
if(m_layerArrayData != IntPtr.Zero)
{
// Deallocate the unmanaged copy of the pointers to unmanaged layer data.
Marshal.FreeHGlobal(m_layerArrayData);
m_layerArrayData = IntPtr.Zero;
}
m_layerData.Clear();
}
/// <summary>
/// Copies data from the list of layers to the list of unmanaged layer data.
/// </summary>
private void CopyToUnmanaged()
{
for(int layerIndex=0; layerIndex<m_layerData.Count; layerIndex++)
Marshal.StructureToPtr(m_layers[layerIndex].Layer, m_layerData[layerIndex], false);
}
#endregion
#region Private fields
private List<ILayer> m_layers = new List<ILayer>();
private List<IntPtr> m_layerData = new List<IntPtr>();
private IntPtr m_layerArrayData = IntPtr.Zero;
private bool m_layersChanged = false;
#endregion
}
/// <summary>
/// Defines properties shared by all ovrLayer structs, such as LayerEyeFov.
///
/// LayerHeader is used as a base member in these larger structs.
/// This struct cannot be used by itself except for the case that Type is LayerType_Disabled.
/// </summary>
/// <see cref="OVRTypes.LayerType"/>
/// <see cref="OVRTypes.LayerFlags"/>
public class LayerHeader
{
/// <summary>
/// Described by LayerType.
/// </summary>
public OVRTypes.LayerType Type
{
get;
set;
}
/// <summary>
/// Described by LayerFlags.
/// </summary>
public OVRTypes.LayerFlags Flags
{
get;
set;
}
}
/// <summary>
/// Defines the methods needed to convert the managed class to a struct, which can be marshaled to unmanaged memory.
/// </summary>
public interface ILayer
{
/// <summary>
/// Retrieve the layer structure, which is needed to marshal the managed structure to unmanaged memory.
/// </summary>
/// <returns>Layer sturcture needed to marshal the managed structure to unmanaged memory.</returns>
object Layer
{
get;
}
/// <summary>
/// Retrieves the type of layer returned by the call to the GetLayer method.
/// </summary>
Type LayerType
{
get;
}
}
/// <summary>
/// Describes a layer that specifies a monoscopic or stereoscopic view.
///
/// This is the kind of layer that's typically used as layer 0 to Hmd.SubmitFrame,
/// as it is the kind of layer used to render a 3D stereoscopic view.
///
/// Three options exist with respect to mono/stereo texture usage:
/// - ColorTexture[0] and ColorTexture[1] contain the left and right stereo renderings, respectively.
/// Viewport[0] and Viewport[1] refer to ColorTexture[0] and ColorTexture[1], respectively.
/// - ColorTexture[0] contains both the left and right renderings, ColorTexture[1] is NULL,
/// and Viewport[0] and Viewport[1] refer to sub-rects with ColorTexture[0].
/// - ColorTexture[0] contains a single monoscopic rendering, and Viewport[0] and
/// Viewport[1] both refer to that rendering.
/// </summary>
/// <see cref="Hmd.SubmitFrame(uint, Layers)"/>
/// <see cref="Hmd.SubmitFrame(uint, OVRTypes.ViewScaleDesc, Layers)"/>
public class LayerEyeFov :ILayer
{
/// <summary>
/// Creates a new LayerEyeFov.
/// </summary>
public LayerEyeFov()
{
Header = new LayerHeader();
Header.Type = OVRTypes.LayerType.EyeFov;
ColorTexture = new IntPtr[2];
Viewport = new OVRTypes.Recti[2];
Fov = new OVRTypes.FovPort[2];
RenderPose = new OVRTypes.Posef[2];
}
#region ILayer implementation
/// <summary>
/// Retrieve the OVRTypes.LayerEyeFov, which is needed to marshal the managed structure to unmanaged memory.
/// </summary>
/// <returns>OVRTypes.LayerEyeFov containing the same values as this LayerEyeFov.</returns>
object ILayer.Layer
{
get
{
OVRTypes.LayerEyeFov layer = new OVRTypes.LayerEyeFov();
layer.Header.Type = this.Header.Type;
layer.Header.Flags = this.Header.Flags;
layer.ColorTexture = this.ColorTexture;
layer.Viewport = this.Viewport;
layer.Fov = this.Fov;
layer.RenderPose = this.RenderPose;
layer.SensorSampleTime = this.SensorSampleTime;
return layer;
}
}
/// <summary>
/// Retrieves the type of layer returned by the call to the GetLayer method.
/// </summary>
Type ILayer.LayerType
{
get
{
return typeof(OVRTypes.LayerEyeFov);
}
}
#endregion
#region Public properties
/// <summary>
/// Header.Type must be LayerType_EyeFov.
/// </summary>
public LayerHeader Header
{
get;
set;
}
/// <summary>
/// TextureSwapChains for the left and right eye respectively.
///
/// The second one of which can be null for cases described above.
/// </summary>
public ovrTextureSwapChain[] ColorTexture
{
get;
set;
}
/// <summary>
/// Specifies the ColorTexture sub-rect UV coordinates.
///
/// Both Viewport[0] and Viewport[1] must be valid.
/// </summary>
public OVRTypes.Recti[] Viewport
{
get;
set;
}
/// <summary>
/// The viewport field of view.
/// </summary>
public OVRTypes.FovPort[] Fov
{
get;
set;
}
/// <summary>
/// Specifies the position and orientation of each eye view, with the position specified in meters.
/// RenderPose will typically be the value returned from ovr_CalcEyePoses,
/// but can be different in special cases if a different head pose is used for rendering.
/// </summary>
public OVRTypes.Posef[] RenderPose
{
get;
set;
}
/// <summary>
/// Specifies the timestamp when the source ovrPosef (used in calculating RenderPose)
/// was sampled from the SDK. Typically retrieved by calling ovr_GetTimeInSeconds
/// around the instant the application calls ovr_GetTrackingState
/// The main purpose for this is to accurately track app tracking latency.
/// </summary>
public double SensorSampleTime
{
get;
set;
}
#endregion
}
/// <summary>
/// Describes a layer that specifies a monoscopic or stereoscopic view.
/// This uses a direct 3x4 matrix to map from view space to the UV coordinates.
/// It is essentially the same thing as ovrLayerEyeFov but using a much
/// lower level. This is mainly to provide compatibility with specific apps.
/// Unless the application really requires this flexibility, it is usually better
/// to use ovrLayerEyeFov.
///
/// Three options exist with respect to mono/stereo texture usage:
/// - ColorTexture[0] and ColorTexture[1] contain the left and right stereo renderings, respectively.
/// Viewport[0] and Viewport[1] refer to ColorTexture[0] and ColorTexture[1], respectively.
/// - ColorTexture[0] contains both the left and right renderings, ColorTexture[1] is null,
/// and Viewport[0] and Viewport[1] refer to sub-rects with ColorTexture[0].
/// - ColorTexture[0] contains a single monoscopic rendering, and Viewport[0] and
/// Viewport[1] both refer to that rendering.
/// </summary>
/// <see cref="Hmd.SubmitFrame(uint, Layers)"/>
/// <see cref="Hmd.SubmitFrame(uint, OVRTypes.ViewScaleDesc, Layers)"/>
public class LayerEyeMatrix :ILayer
{
/// <summary>
/// Creates a new LayerEyeMatrix.
/// </summary>
public LayerEyeMatrix()
{
Header = new LayerHeader();
Header.Type = OVRTypes.LayerType.EyeMatrix;
ColorTexture = new IntPtr[2];
Viewport = new OVRTypes.Recti[2];
RenderPose = new OVRTypes.Posef[2];
Matrix = new OVRTypes.Matrix4f[2];
}
#region ILayer implementation
/// <summary>
/// Retrieve the OVRTypes.LayerEyeFov, which is needed to marshal the managed structure to unmanaged memory.
/// </summary>
/// <returns>OVRTypes.LayerEyeFov containing the same values as this LayerEyeFov.</returns>
object ILayer.Layer
{
get
{
OVRTypes.LayerEyeMatrix layer = new OVRTypes.LayerEyeMatrix();
layer.Header.Type = this.Header.Type;
layer.Header.Flags = this.Header.Flags;
layer.ColorTexture = this.ColorTexture;
layer.Viewport = this.Viewport;
layer.RenderPose = this.RenderPose;
layer.Matrix = this.Matrix;
layer.SensorSampleTime = this.SensorSampleTime;
return layer;
}
}
/// <summary>
/// Retrieves the type of layer returned by the call to the GetLayer method.
/// </summary>
Type ILayer.LayerType
{
get
{
return typeof(OVRTypes.LayerEyeMatrix);
}
}
#endregion
#region Public properties
/// <summary>
/// Header.Type must be LayerType_EyeFov.
/// </summary>
public LayerHeader Header
{
get;
set;
}
/// <summary>
/// ovrTextureSwapChains for the left and right eye respectively.
///
/// The second one of which can be null for cases described above.
/// </summary>
public ovrTextureSwapChain[] ColorTexture
{
get;
set;
}
/// <summary>
/// Specifies the ColorTexture sub-rect UV coordinates.
///
/// Both Viewport[0] and Viewport[1] must be valid.
/// </summary>
public OVRTypes.Recti[] Viewport
{
get;
set;
}
/// <summary>
/// Specifies the position and orientation of each eye view, with the position specified in meters.
/// RenderPose will typically be the value returned from ovr_CalcEyePoses,
/// but can be different in special cases if a different head pose is used for rendering.
/// </summary>
public OVRTypes.Posef[] RenderPose
{
get;
set;
}
/// <summary>
/// Specifies the mapping from a view-space vector
/// to a UV coordinate on the textures given above.
/// P = (x,y,z,1)*Matrix
/// TexU = P.x/P.z
/// TexV = P.y/P.z
/// </summary>
public OVRTypes.Matrix4f[] Matrix
{
get;
set;
}
/// <summary>
/// Specifies the timestamp when the source OVRTypes.Posef (used in calculating RenderPose)
/// was sampled from the SDK. Typically retrieved by calling ovr_GetTimeInSeconds
/// around the instant the application calls ovr_GetTrackingState
/// The main purpose for this is to accurately track app tracking latency.
/// </summary>
public double SensorSampleTime
{
get;
set;
}
#endregion
}
/// <summary>
/// Describes a layer of Quad type, which is a single quad in world or viewer space.
/// It is used for both ovrLayerType_QuadInWorld and ovrLayerType_QuadHeadLocked.
/// This type of layer represents a single object placed in the world and not a stereo
/// view of the world itself.
///
/// A typical use of ovrLayerType_QuadInWorld is to draw a television screen in a room
/// that for some reason is more convenient to draw as a layer than as part of the main
/// view in layer 0. For example, it could implement a 3D popup GUI that is drawn at a
/// higher resolution than layer 0 to improve fidelity of the GUI.
///
/// A use of ovrLayerType_QuadHeadLocked might be to implement a debug HUD visible in
/// the HMD.
///
/// Quad layers are visible from both sides; they are not back-face culled.
/// </summary>
/// <see cref="Hmd.SubmitFrame(uint, Layers)"/>
/// <see cref="Hmd.SubmitFrame(uint, OVRTypes.ViewScaleDesc, Layers)"/>
public class LayerQuad :ILayer
{
/// <summary>
/// Creates a new LayerQuad.
/// </summary>
public LayerQuad()
{
Header = new LayerHeader();
Header.Type = OVRTypes.LayerType.Quad;
ColorTexture = IntPtr.Zero;
Viewport = new OVRTypes.Recti();
QuadPoseCenter = new OVRTypes.Posef();
QuadSize = new OVRTypes.Vector2f();
}
#region ILayer implementation
/// <summary>
/// Retrieve the OVRTypes.LayerEyeFov, which is needed to marshal the managed structure to unmanaged memory.
/// </summary>
/// <returns>OVRTypes.LayerEyeFov containing the same values as this LayerEyeFov.</returns>
object ILayer.Layer
{
get
{
OVRTypes.LayerQuad layer = new OVRTypes.LayerQuad();
layer.Header.Type = this.Header.Type;
layer.Header.Flags = this.Header.Flags;
layer.ColorTexture = this.ColorTexture;
layer.Viewport = this.Viewport;
layer.QuadPoseCenter = this.QuadPoseCenter;
layer.QuadSize = this.QuadSize;
return layer;
}
}
/// <summary>
/// Retrieves the type of layer returned by the call to the GetLayer method.
/// </summary>
Type ILayer.LayerType
{
get
{
return typeof(OVRTypes.LayerQuad);
}
}
#endregion
#region Public properties
/// <summary>
/// Header.Type must be LayerType.Quad.
/// </summary>
public LayerHeader Header
{
get;
set;
}
/// <summary>
/// Contains a single image, never with any stereo view.
/// </summary>
public ovrTextureSwapChain ColorTexture
{
get;
set;
}
/// <summary>
/// Specifies the ColorTexture sub-rect UV coordinates.
/// </summary>
public OVRTypes.Recti Viewport
{
get;
set;
}
/// <summary>
/// Specifies the orientation and position of the center point of a Quad layer type.
/// The supplied direction is the vector perpendicular to the quad.
/// The position is in real-world meters (not the application's virtual world,
/// the physical world the user is in) and is relative to the "zero" position
/// set by ovr_RecenterTrackingOrigin unless the ovrLayerFlag_HeadLocked flag is used.
/// </summary>
public OVRTypes.Posef QuadPoseCenter
{
get;
set;
}
/// <summary>
/// Width and height (respectively) of the quad in meters.
/// </summary>
public OVRTypes.Vector2f QuadSize
{
get;
set;
}
#endregion
}
}

145
OculusWrap/MirrorTexture.cs Normal file
Просмотреть файл

@ -0,0 +1,145 @@
using System;
using System.Collections.Generic;
using System.Runtime.InteropServices;
using ovrSession = System.IntPtr;
using ovrMirrorTexture = System.IntPtr;
namespace OculusWrap
{
/// <summary>
/// Wrapper for the MirrorTexture type.
/// </summary>
public class MirrorTexture :IDisposable
{
/// <summary>
/// Creates a new MirrorTexture.
/// </summary>
/// <param name="ovr">Interface to Oculus runtime methods.</param>
/// <param name="session">Session of the Hmd owning this mirror texture.</param>
/// <param name="mirrorTexturePtr">Unmanaged mirror texture.</param>
public MirrorTexture(OVRBase ovr, ovrSession session, IntPtr mirrorTexturePtr)
{
if(ovr == null)
throw new ArgumentNullException("ovr");
if(session == null)
throw new ArgumentNullException("session");
if(mirrorTexturePtr == IntPtr.Zero)
throw new ArgumentNullException("mirrorTexturePtr");
OVR = ovr;
Session = session;
MirrorTexturePtr = mirrorTexturePtr;
}
#region IDisposable Members
/// <summary>
/// Clean up the allocated HMD.
/// </summary>
public void Dispose()
{
Dispose(true);
GC.SuppressFinalize(this);
}
/// <summary>
/// Dispose pattern implementation of dispose method.
/// </summary>
/// <param name="disposing">True if disposing, false if finalizing.</param>
protected virtual void Dispose(bool disposing)
{
if(Disposed)
return;
if(MirrorTexturePtr != IntPtr.Zero)
{
OVR.DestroyMirrorTexture(Session, MirrorTexturePtr);
MirrorTexturePtr = IntPtr.Zero;
// Notify subscribers that this object has been disposed.
if(ObjectDisposed != null)
ObjectDisposed(this);
}
GC.SuppressFinalize(this);
Disposed = true;
}
/// <summary>
/// Describes if the object has been disposed.
/// </summary>
public bool Disposed
{
get;
private set;
}
/// <summary>
/// Notifies subscribers when this object has been disposed.
/// </summary>
public event Action<MirrorTexture> ObjectDisposed;
#endregion
#region Public methods
/// <summary>
/// Get a the underlying buffer as any compatible COM interface (similar to QueryInterface)
/// </summary>
/// <param name="iid">Specifies the interface ID of the interface pointer to query the buffer for.</param>
/// <param name="buffer">Returns the COM interface pointer retrieved.</param>
/// <returns>
/// Returns a Result indicating success or failure. In the case of failure, use
/// Wrap.GetLastError to get more information.
/// </returns>
public OVRTypes.Result GetBufferDX(Guid iid, out IntPtr buffer)
{
buffer = IntPtr.Zero;
return OVR.GetMirrorTextureBufferDX(Session, MirrorTexturePtr, iid, ref buffer);
}
/// <summary>
/// Get a the underlying buffer as a GL texture name
/// </summary>
/// <param name="textureId">Specifies the GL texture object name associated with the mirror texture</param>
/// <returns>
/// Returns an OVRTypes.Result indicating success or failure. In the case of failure, use
/// Wrap.GetLastError to get more information.
/// </returns>
public OVRTypes.Result GetBufferGL(out uint textureId)
{
return OVR.GetMirrorTextureBufferGL(Session, MirrorTexturePtr, out textureId);
}
#endregion
#region Public properties
/// <summary>
/// Pointer to unmanaged MirrorTexture.
/// </summary>
public ovrMirrorTexture MirrorTexturePtr
{
get;
private set;
}
#endregion
#region Private properties
/// <summary>
/// Session of the Hmd owning this texture swap chain.
/// </summary>
private ovrSession Session
{
get;
set;
}
/// <summary>
/// Interface to Oculus runtime methods.
/// </summary>
private OVRBase OVR
{
get;
set;
}
#endregion
}
}

Разница между файлами не показана из-за своего большого размера Загрузить разницу

Разница между файлами не показана из-за своего большого размера Загрузить разницу

Разница между файлами не показана из-за своего большого размера Загрузить разницу

Разница между файлами не показана из-за своего большого размера Загрузить разницу

Разница между файлами не показана из-за своего большого размера Загрузить разницу

Разница между файлами не показана из-за своего большого размера Загрузить разницу

9713
OculusWrap/OVR.cs Normal file

Разница между файлами не показана из-за своего большого размера Загрузить разницу

Просмотреть файл

@ -0,0 +1,70 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ProjectGuid>{737A81A8-553C-49A9-8F17-5ADF691A56B2}</ProjectGuid>
<OutputType>Library</OutputType>
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>OculusWrap</RootNamespace>
<AssemblyName>OculusWrap</AssemblyName>
<TargetFrameworkVersion>v4.5</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
<SccProjectName>SAK</SccProjectName>
<SccLocalPath>SAK</SccLocalPath>
<SccAuxPath>SAK</SccAuxPath>
<SccProvider>SAK</SccProvider>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<OutputPath>..\bin\Debug\</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
<AllowUnsafeBlocks>false</AllowUnsafeBlocks>
<DocumentationFile>..\bin\Debug\OculusWrap.XML</DocumentationFile>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<DebugType>pdbonly</DebugType>
<Optimize>true</Optimize>
<OutputPath>..\bin\Release\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
<DocumentationFile>..\bin\Release\OculusWrap.XML</DocumentationFile>
</PropertyGroup>
<ItemGroup>
<Reference Include="System" />
<Reference Include="System.Core" />
<Reference Include="Microsoft.CSharp" />
</ItemGroup>
<ItemGroup>
<Compile Include="Hmd.cs" />
<Compile Include="Layers.cs" />
<Compile Include="MirrorTexture.cs" />
<Compile Include="OVR Classes\OVR32Unsafe.cs" />
<Compile Include="OVR Classes\OVR64Unsafe.cs" />
<Compile Include="OVR Classes\OVR64.cs" />
<Compile Include="OVR Classes\OVR32.cs" />
<Compile Include="OVR Classes\OVRBase.cs" />
<Compile Include="OVR Classes\OVRTypes.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="TextureSwapChain.cs" />
<Compile Include="Wrap.cs" />
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<PropertyGroup>
<PreBuildEvent>
</PreBuildEvent>
</PropertyGroup>
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
Other similar extension points exist, see Microsoft.Common.targets.
<Target Name="BeforeBuild">
</Target>
<Target Name="AfterBuild">
</Target>
-->
</Project>

Просмотреть файл

@ -0,0 +1,36 @@
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
// General Information about an assembly is controlled through the following
// set of attributes. Change these attribute values to modify the information
// associated with an assembly.
[assembly: AssemblyTitle("OculusWrap")]
[assembly: AssemblyDescription(".NET wrapper for Oculus Rift SDK version 1.3.2")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("https://oculuswrap.codeplex.com/")]
[assembly: AssemblyProduct("OculusWrap")]
[assembly: AssemblyCopyright("Microsoft Public License (Ms-PL), November 2014")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]
// Setting ComVisible to false makes the types in this assembly not visible
// to COM components. If you need to access a type in this assembly from
// COM, set the ComVisible attribute to true on that type.
[assembly: ComVisible(false)]
// The following GUID is for the ID of the typelib if this project is exposed to COM
[assembly: Guid("5a53c444-66b2-448f-ad4e-520a10310f0b")]
// Version information for an assembly consists of the following four values:
//
// Major Version
// Minor Version
// Build Number
// Revision
//
// You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("2.3.2.1")]
[assembly: AssemblyFileVersion("2.3.2.1")]

Просмотреть файл

@ -0,0 +1,213 @@
using System;
using System.Collections.Generic;
using System.Runtime.InteropServices;
using ovrSession = System.IntPtr;
using ovrTextureSwapChain = System.IntPtr;
namespace OculusWrap
{
/// <summary>
/// Wrapper for the TextureSwapChain type.
/// </summary>
public class TextureSwapChain :IDisposable
{
/// <summary>
/// Creates a new TextureSwapChain.
/// </summary>
/// <param name="ovr">Interface to Oculus runtime methods.</param>
/// <param name="session">Session of the Hmd owning this texture swap chain.</param>
/// <param name="textureSwapChainPtr">Unmanaged texture swap chain.</param>
public TextureSwapChain(OVRBase ovr, ovrSession session, ovrTextureSwapChain textureSwapChainPtr)
{
if(ovr == null)
throw new ArgumentNullException("ovr");
if(session == null)
throw new ArgumentNullException("session");
if(textureSwapChainPtr == IntPtr.Zero)
throw new ArgumentNullException("textureSwapChain");
OVR = ovr;
Session = session;
TextureSwapChainPtr = textureSwapChainPtr;
}
#region IDisposable Members
/// <summary>
/// Clean up the allocated HMD.
/// </summary>
public void Dispose()
{
Dispose(true);
GC.SuppressFinalize(this);
}
/// <summary>
/// Dispose pattern implementation of dispose method.
/// </summary>
/// <param name="disposing">True if disposing, false if finalizing.</param>
protected virtual void Dispose(bool disposing)
{
if(Disposed)
return;
if(TextureSwapChainPtr != IntPtr.Zero)
{
OVR.DestroyTextureSwapChain(Session, TextureSwapChainPtr);
TextureSwapChainPtr = IntPtr.Zero;
// Notify subscribers that this object has been disposed.
if(ObjectDisposed != null)
ObjectDisposed(this);
}
GC.SuppressFinalize(this);
Disposed = true;
}
/// <summary>
/// Describes if the object has been disposed.
/// </summary>
public bool Disposed
{
get;
private set;
}
/// <summary>
/// Notifies subscribers when this object has been disposed.
/// </summary>
public event Action<TextureSwapChain> ObjectDisposed;
#endregion
#region Public methods
/// <summary>
/// Gets the number of buffers in the TextureSwapChain.
/// </summary>
/// <param name="length">Returns the number of buffers in the specified chain.</param>
/// <returns>Returns an ovrResult for which the return code is negative upon error. </returns>
public OVRTypes.Result GetLength(out int length)
{
if(Disposed)
throw new ObjectDisposedException("TextureSwapChain");
return OVR.GetTextureSwapChainLength(Session, TextureSwapChainPtr, out length);
}
/// <summary>
/// Gets the current index in the TextureSwapChain.
/// </summary>
/// <param name="index">Returns the current (free) index in specified chain.</param>
/// <returns>Returns an ovrResult for which the return code is negative upon error. </returns>
public OVRTypes.Result GetCurrentIndex(out int index)
{
if(Disposed)
throw new ObjectDisposedException("TextureSwapChain");
return OVR.GetTextureSwapChainCurrentIndex(Session, TextureSwapChainPtr, out index);
}
/// <summary>
/// Gets the description of the buffers in the TextureSwapChain
/// </summary>
/// <param name="textureSwapChainDescription">Returns the description of the specified chain.</param>
/// <returns>Returns an ovrResult for which the return code is negative upon error. </returns>
public OVRTypes.Result GetDescription(out OVRTypes.TextureSwapChainDesc textureSwapChainDescription)
{
if(Disposed)
throw new ObjectDisposedException("TextureSwapChain");
OVRTypes.TextureSwapChainDesc textureSwapChainDesc = new OVRTypes.TextureSwapChainDesc();
OVRTypes.Result result = OVR.GetTextureSwapChainDesc(Session, TextureSwapChainPtr, ref textureSwapChainDesc);
textureSwapChainDescription = textureSwapChainDesc;
return result;
}
/// <summary>
/// Commits any pending changes to a TextureSwapChain, and advances its current index
/// </summary>
/// <returns>
/// Returns an ovrResult for which the return code is negative upon error.
/// Failures include but aren't limited to:
/// - Result.TextureSwapChainFull: ovr_CommitTextureSwapChain was called too many times on a texture swapchain without calling submit to use the chain.
/// </returns>
public OVRTypes.Result Commit()
{
if(Disposed)
throw new ObjectDisposedException("TextureSwapChain");
return OVR.CommitTextureSwapChain(Session, TextureSwapChainPtr);
}
/// <summary>
/// Get a specific buffer within the chain as any compatible COM interface (similar to QueryInterface)
/// </summary>
/// <param name="index">
/// Specifies the index within the chain to retrieve. Must be between 0 and length (see GetTextureSwapChainLength),
/// or may pass -1 to get the buffer at the CurrentIndex location. (Saving a call to GetTextureSwapChainCurrentIndex).
/// </param>
/// <param name="iid">Specifies the interface ID of the interface pointer to query the buffer for.</param>
/// <param name="buffer">Returns the COM interface pointer retrieved.</param>
/// <returns>
/// Returns an ovrResult indicating success or failure. In the case of failure, use
/// Wrap.GetLastError to get more information.
/// </returns>
public OVRTypes.Result GetBufferDX(int index, Guid iid, out IntPtr buffer)
{
buffer = IntPtr.Zero;
return OVR.GetTextureSwapChainBufferDX(Session, TextureSwapChainPtr, index, iid, ref buffer);
}
/// <summary>
/// Get a specific buffer within the chain as a GL texture name
/// </summary>
/// <param name="index">
/// Specifies the index within the chain to retrieve. Must be between 0 and length (see GetTextureSwapChainLength)
/// or may pass -1 to get the buffer at the CurrentIndex location. (Saving a call to GetTextureSwapChainCurrentIndex)
/// </param>
/// <param name="textureId">Returns the GL texture object name associated with the specific index requested</param>
/// <returns>
/// Returns an OVRTypes.Result indicating success or failure. In the case of failure, use
/// Wrap.GetLastError to get more information.
/// </returns>
public OVRTypes.Result GetBufferGL(int index, out uint textureId)
{
return OVR.GetTextureSwapChainBufferGL(Session, TextureSwapChainPtr, index, out textureId);
}
#endregion
#region Public properties
/// <summary>
/// Pointer to unmanaged SwapTextureSet.
/// </summary>
public ovrTextureSwapChain TextureSwapChainPtr
{
get;
private set;
}
#endregion
#region Private properties
/// <summary>
/// Session of the Hmd owning this texture swap chain.
/// </summary>
private ovrSession Session
{
get;
set;
}
/// <summary>
/// Interface to Oculus runtime methods.
/// </summary>
private OVRBase OVR
{
get;
set;
}
#endregion
}
}

476
OculusWrap/Wrap.cs Normal file
Просмотреть файл

@ -0,0 +1,476 @@
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.IO;
using System.Runtime.InteropServices;
using ovrBool = System.Byte;
namespace OculusWrap
{
/// <summary>
/// Provides access to methods that are independent of an HMD, as well as a method used to create a new Hmd object.
/// </summary>
public class Wrap :IDisposable
{
/// <summary>
/// Creates a new Wrap instance.
/// </summary>
/// <param name="useUnsafeImplementation">
/// When set to true, the Oculus runtime will be loaded using the unsafe implementation.
///
/// The unsafe implementation provides a faster execution, by bypassing the managed security checks that are normally
/// performed when transitioning from managed to unmanaged code.
///
/// Use the unsafe implementation with extreme care. Incorrect use can create security weaknesses.
/// </param>
/// <see cref="https://msdn.microsoft.com/en-us/library/62a3eyh4(v=vs.100).aspx"/>
public Wrap(bool useUnsafeImplementation=false)
{
if(useUnsafeImplementation)
{
if(Environment.Is64BitProcess)
OVR = new OVR64Unsafe();
else
OVR = new OVR32Unsafe();
}
else
{
if(Environment.Is64BitProcess)
OVR = new OVR64();
else
OVR = new OVR32();
}
}
/// <summary>
/// Cleans up unmanaged resources.
/// </summary>
~Wrap()
{
Dispose(false);
}
#region IDisposable Members
/// <summary>
/// Clean up unmanaged resources.
/// </summary>
public void Dispose()
{
Dispose(true);
GC.SuppressFinalize(this);
}
/// <summary>
/// Dispose pattern implementation of dispose method.
/// </summary>
/// <param name="disposing">True if disposing, false if finalizing.</param>
protected virtual void Dispose(bool disposing)
{
if(Disposed)
return;
// Ensure that all created HMDs have been disposed.
foreach(Hmd hmd in CreatedHmds)
{
if(!hmd.Disposed)
hmd.Dispose();
}
CreatedHmds.Clear();
if(Initialized)
Shutdown();
// Deallocate unmanaged memory again.
FreeHGlobal(ref m_eyePosesPtr);
OVR.Dispose();
OVR = null;
Disposed = true;
}
/// <summary>
/// Describes if the object has been disposed.
/// </summary>
public bool Disposed
{
get;
private set;
}
#endregion
/// <summary>
/// Interface to Oculus runtime methods.
/// </summary>
private OVRBase OVR
{
get;
set;
}
#region Public methods
/// <summary>
/// Detects Oculus Runtime and Device Status
///
/// Checks for Oculus Runtime and Oculus HMD device status without loading the LibOVRRT
/// shared library. This may be called before ovr_Initialize() to help decide whether or
/// not to initialize LibOVR.
/// </summary>
/// <param name="timeoutMsec">Specifies a timeout to wait for HMD to be attached or 0 to poll.</param>
/// <returns>Returns a DetectResult object indicating the result of detection.</returns>
/// <see cref="OVRTypes.DetectResult"/>
public OVRTypes.DetectResult Detect(int timeoutMsec)
{
return OVR.Detect(timeoutMsec);
}
/// <summary>
/// Initializes all Oculus functionality.
/// </summary>
/// <param name="initializationParameters">
/// Initialization parameters to pass to the ovr_Initialize call.
/// </param>
/// <remarks>
/// Library init/shutdown, must be called around all other OVR code.
/// No other functions calls besides ovr_InitializeRenderingShim are allowed
/// before ovr_Initialize succeeds or after ovr_Shutdown.
/// </remarks>
public bool Initialize(OVRTypes.InitParams initializationParameters=null)
{
if(Initialized)
throw new InvalidOperationException("The Oculus wrapper has already been initialized.");
/*
// Ensure that the DllOvr.dll is loaded, using the bitness matching that of the current process.
LoadDllOvr();
*/
OVRTypes.Result success = OVR.Initialize(initializationParameters);
if(success < OVRTypes.Result.Success)
return false;
Initialized = true;
return true;
}
/// <summary>
/// Shuts down all Oculus functionality.
/// </summary>
public bool Shutdown()
{
if(!Initialized && !RenderingShimInitialized)
return true;
OVR.Shutdown();
/*
// Unload previously loaded DllOVr.dll.
UnloadDllOvr();
*/
Initialized = false;
RenderingShimInitialized = false;
return true;
}
/// <summary>
/// Returns version string representing libOVR version. Static, so
/// string remains valid for app lifespan
/// </summary>
/// <remarks>
/// Use Marshal.PtrToStringAnsi() to retrieve version string.
/// </remarks>
public string GetVersionString()
{
IntPtr versionPtr = OVR.GetVersionString();
string version = Marshal.PtrToStringAnsi(versionPtr);
return version;
}
/// <summary>
/// Send a message string to the system tracing mechanism if enabled (currently Event Tracing for Windows)
/// </summary>
/// <param name="level">
/// One of the ovrLogLevel constants.
/// </param>
/// <param name="message">
/// A string.
/// </param>
/// <returns>
/// Returns the length of the message, or -1 if message is too large
/// </returns>
public int TraceMessage(OVRTypes.LogLevel level, string message)
{
return OVR.TraceMessage(level, message);
}
/// <summary>
/// Creates a handle to an HMD.
///
/// Upon success the returned Hmd must be eventually freed with Dispose() when it is no longer needed.
/// </summary>
/// <param name="graphicsLuid">
/// Provides a system specific graphics adapter identifier that locates which
/// graphics adapter has the HMD attached. This must match the adapter used by the application
/// or no rendering output will be possible. This is important for stability on multi-adapter systems. An
/// application that simply chooses the default adapter will not run reliably on multi-adapter systems.
/// </param>
public Hmd Hmd_Create(out OVRTypes.GraphicsLuid graphicsLuid)
{
IntPtr hmdPtr = IntPtr.Zero;
graphicsLuid = new OVRTypes.GraphicsLuid();
OVRTypes.Result result = OVR.Create(ref hmdPtr, ref graphicsLuid);
if(result < OVRTypes.Result.Success)
return null;
Hmd hmd = new Hmd(OVR, hmdPtr);
// Ensure that this created HMD is disposed, when this Wrap class is being disposed.
CreatedHmds.Add(hmd);
return hmd;
}
/// <summary>
/// Returns last error for HMD state. Returns null for no error.
///
/// String is valid until next call or GetLastError or HMD is destroyed.
/// Pass null hmd to get global errors (during create etc).
/// </summary>
public OVRBase.ErrorInfo GetLastError()
{
OVRTypes.ErrorInfo errorInfo;
OVR.GetLastErrorInfo(out errorInfo);
return errorInfo;
}
/// <summary>
/// Used to generate projection from ovrEyeDesc::Fov.
/// </summary>
public OVRBase.Matrix4f Matrix4f_Projection(OVRBase.FovPort fov, float znear, float zfar, OVRBase.ProjectionModifier projectionModifier)
{
return OVR.Matrix4f_Projection(fov, znear, zfar, projectionModifier);
}
/// <summary>
/// Extracts the required data from the result of ovrMatrix4f_Projection.
/// </summary>
/// <param name="projection">Specifies the project matrix from which to extract ovrTimewarpProjectionDesc.</param>
/// <param name="projectionModFlags">A combination of the ProjectionModifier flags.</param>
/// <returns>Returns the extracted ovrTimewarpProjectionDesc.</returns>
/// <see cref="OVRTypes.TimewarpProjectionDesc"/>
public OVRBase.TimewarpProjectionDesc TimewarpProjectionDesc_FromProjection(OVRBase.Matrix4f projection, OVRBase.ProjectionModifier projectionModFlags)
{
return OVR.TimewarpProjectionDesc_FromProjection(projection, projectionModFlags);
}
/// <summary>
/// Used for 2D rendering, Y is down
/// orthoScale = 1.0f / pixelsPerTanAngleAtCenter
/// orthoDistance = distance from camera, such as 0.8m
/// </summary>
public OVRBase.Matrix4f Matrix4f_OrthoSubProjection(OVRBase.Matrix4f projection, OVRBase.Vector2f orthoScale, float orthoDistance, float eyeViewAdjustX)
{
return OVR.Matrix4f_OrthoSubProjection(projection, orthoScale, orthoDistance, eyeViewAdjustX);
}
/// <summary>
/// Computes offset eye poses based on headPose returned by ovrTrackingState.
/// </summary>
/// <param name="headPose">
/// Indicates the HMD position and orientation to use for the calculation.
/// </param>
/// <param name="hmdToEyeViewOffset">
/// Can be ovrEyeRenderDesc.HmdToEyeViewOffset returned from
/// ovrHmd_GetRenderDesc. For monoscopic rendering, use a vector that is the average
/// of the two vectors for both eyes.
/// </param>
/// <param name="outEyePoses">
/// If outEyePoses are used for rendering, they should be passed to
/// SubmitFrame in LayerEyeFov.RenderPose or LayerEyeFovDepth.RenderPose.
/// </param>
public void CalcEyePoses(OVRBase.Posef headPose, OVRBase.Vector3f[] hmdToEyeViewOffset, ref OVRBase.Posef[] outEyePoses)
{
if(hmdToEyeViewOffset.Length != 2)
throw new ArgumentException("The hmdToEyeViewOffset argument must contain 2 elements.", "hmdToEyeViewOffset");
if(outEyePoses.Length != 2)
throw new ArgumentException("The outEyePoses argument must contain 2 elements.", "outEyePoses");
if(m_eyePosesPtr == IntPtr.Zero)
{
// Allocate and copy managed struct to unmanaged memory.
m_poseFSize = Marshal.SizeOf(typeof(OVRBase.Posef));
m_eyePosesPtr = Marshal.AllocHGlobal(m_poseFSize*2);
}
OVR.CalcEyePoses(headPose, hmdToEyeViewOffset, m_eyePosesPtr);
outEyePoses[0] = (OVRBase.Posef) Marshal.PtrToStructure(m_eyePosesPtr, typeof(OVRBase.Posef));
outEyePoses[1] = (OVRBase.Posef) Marshal.PtrToStructure(m_eyePosesPtr+m_poseFSize, typeof(OVRBase.Posef));
}
/// <summary>
/// Returns global, absolute high-resolution time in seconds. This is the same
/// value as used in sensor messages.
/// </summary>
public double GetTimeInSeconds()
{
return OVR.GetTimeInSeconds();
}
/// <summary>
/// Tracking poses provided by the SDK come in a right-handed coordinate system. If an application
/// is passing in ovrProjection_LeftHanded into Matrix4f_Projection, then it should also use
/// this function to flip the HMD tracking poses to be left-handed.
///
/// While this utility function is intended to convert a left-handed ovrPosef into a right-handed
/// coordinate system, it will also work for converting right-handed to left-handed since the
/// flip operation is the same for both cases.
/// </summary>
/// <param name="pose">Pose that is right-handed</param>
public OVRBase.Posef Posef_FlipHandedness(OVRBase.Posef pose)
{
OVRTypes.Posef inputOutputPose = pose;
OVR.Posef_FlipHandedness(ref inputOutputPose, ref inputOutputPose);
return inputOutputPose;
}
/*
/// <summary>
/// Waits until the specified absolute time.
/// </summary>
/// <remarks>
/// This function may be removed in a future version.
/// </remarks>
public double WaitTillTime(double absTime)
{
return OVRBase.WaitTillTime(absTime);
}
*/
#endregion
#region Public properties
/// <summary>
/// Determines if InitializeRenderingShim() has been called, without calling Shutdown().
/// </summary>
public bool RenderingShimInitialized
{
get;
private set;
}
/// <summary>
/// Determines if Initialize() has been called, without calling Shutdown().
/// </summary>
public bool Initialized
{
get;
private set;
}
#endregion
#region Private helper methods
/// <summary>
/// Frees the memory at the specified pointer and sets the pointer to IntPtr.Zero.
/// </summary>
/// <param name="pointer">Pointer to memory that will be freed.</param>
/// <remarks>
/// This method is used to free memory previously allocated by a call to Marshal.AllocHGlobal(...).
/// </remarks>
private void FreeHGlobal(ref IntPtr pointer)
{
if(pointer != IntPtr.Zero)
{
Marshal.FreeHGlobal(pointer);
pointer = IntPtr.Zero;
}
}
#endregion
/*
#region Private methods
/// <summary>
/// This method is used to load the DllOVR.dll into memory, before calling any of it's DllImported methods.
///
/// This is done to allow loading an x86 version of the DllOvr.dll, for an x86 process, or an x64 version of it,
/// for an x64 process.
/// </summary>
private void LoadDllOvr()
{
if(DllOvrPtr == IntPtr.Zero)
{
// Retrieve the folder of the OculusWrap.dll.
string executingAssemblyFolder = Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().Location);
string subfolder;
if(Environment.Is64BitProcess)
subfolder = "x64";
else
subfolder = "x86";
string filename = Path.Combine(executingAssemblyFolder, subfolder, OVR. DllOvrDll);
// Check that the DllOvrDll file exists.
bool exists = File.Exists(filename);
if(!exists)
throw new DllNotFoundException("Unable to load the file \""+filename+"\", the file wasn't found.");
DllOvrPtr = OVR.LoadLibrary(filename);
if(DllOvrPtr == IntPtr.Zero)
{
int win32Error = Marshal.GetLastWin32Error();
throw new Win32Exception(win32Error, "Unable to load the file \""+filename+"\", LoadLibrary reported error code: "+win32Error+".");
}
}
}
/// <summary>
/// Frees previously loaded DllOvr.dll, from process memory.
/// </summary>
private void UnloadDllOvr()
{
if(DllOvrPtr != IntPtr.Zero)
{
bool success = OVR.FreeLibrary(DllOvrPtr);
if(success)
DllOvrPtr = IntPtr.Zero;
}
}
#endregion
*/
#region Private properties
/// <summary>
/// Pointer to the DllOvr module, after it has been loaded, using a call to OVR.LoadLibrary.
/// </summary>
private IntPtr DllOvrPtr
{
get;
set;
}
/// <summary>
/// Set of created HMDs.
/// </summary>
/// <remarks>
/// This set is used to ensure that all created HMDs are also disposed.
/// </remarks>
private HashSet<Hmd> CreatedHmds
{
get
{
return m_createdHmds;
}
}
#endregion
#region Private fields
private HashSet<Hmd> m_createdHmds = new HashSet<Hmd>();
private IntPtr m_eyePosesPtr = IntPtr.Zero;
private int m_poseFSize = 0;
#endregion
}
}

Просмотреть файл

@ -94,12 +94,6 @@
"Entry"
{
"MsmKey" = "8:_1FB34019A2BB833F8A78F4A5DD649B46"
"OwnerKey" = "8:_E4879226D6D83943BD08C790A06A6CE8"
"MsmSig" = "8:_UNDEFINED"
}
"Entry"
{
"MsmKey" = "8:_1FB34019A2BB833F8A78F4A5DD649B46"
"OwnerKey" = "8:_C8587868B7CBE34B812ABAF42AD6B76F"
"MsmSig" = "8:_UNDEFINED"
}
@ -322,12 +316,6 @@
"Entry"
{
"MsmKey" = "8:_C4CE830CB9E8782845AD0F7B87BFC29A"
"OwnerKey" = "8:_E4879226D6D83943BD08C790A06A6CE8"
"MsmSig" = "8:_UNDEFINED"
}
"Entry"
{
"MsmKey" = "8:_C4CE830CB9E8782845AD0F7B87BFC29A"
"OwnerKey" = "8:_C8587868B7CBE34B812ABAF42AD6B76F"
"MsmSig" = "8:_UNDEFINED"
}
@ -400,12 +388,6 @@
"Entry"
{
"MsmKey" = "8:_D93A7B2E15343867F818E236CEC55B31"
"OwnerKey" = "8:_E4879226D6D83943BD08C790A06A6CE8"
"MsmSig" = "8:_UNDEFINED"
}
"Entry"
{
"MsmKey" = "8:_D93A7B2E15343867F818E236CEC55B31"
"OwnerKey" = "8:_C8587868B7CBE34B812ABAF42AD6B76F"
"MsmSig" = "8:_UNDEFINED"
}
@ -435,7 +417,7 @@
}
"Entry"
{
"MsmKey" = "8:_E4879226D6D83943BD08C790A06A6CE8"
"MsmKey" = "8:_F1A679CEA7E1F5622338F71AD2965077"
"OwnerKey" = "8:_8C920A1E441C49CCA1D5048846532EFC"
"MsmSig" = "8:_UNDEFINED"
}
@ -490,12 +472,6 @@
"Entry"
{
"MsmKey" = "8:_UNDEFINED"
"OwnerKey" = "8:_E4879226D6D83943BD08C790A06A6CE8"
"MsmSig" = "8:_UNDEFINED"
}
"Entry"
{
"MsmKey" = "8:_UNDEFINED"
"OwnerKey" = "8:_C8587868B7CBE34B812ABAF42AD6B76F"
"MsmSig" = "8:_UNDEFINED"
}
@ -559,6 +535,12 @@
"OwnerKey" = "8:_160B3E5C3E05956FCA7BE66D661C8CBC"
"MsmSig" = "8:_UNDEFINED"
}
"Entry"
{
"MsmKey" = "8:_UNDEFINED"
"OwnerKey" = "8:_F1A679CEA7E1F5622338F71AD2965077"
"MsmSig" = "8:_UNDEFINED"
}
}
"Configurations"
{
@ -1121,7 +1103,7 @@
{
"AssemblyRegister" = "3:1"
"AssemblyIsInGAC" = "11:FALSE"
"AssemblyAsmDisplayName" = "8:WWTCore, Version=5.5.2.0, Culture=neutral, processorArchitecture=MSIL"
"AssemblyAsmDisplayName" = "8:WWTCore, Version=5.5.3.0, Culture=neutral, processorArchitecture=MSIL"
"ScatterAssemblies"
{
"_6CEC7289FDAA9242F4124E5D1FD353CF"
@ -1618,20 +1600,20 @@
"IsDependency" = "11:TRUE"
"IsolateTo" = "8:"
}
"{9F6F8455-1EF1-4B85-886A-4223BCC8E7F7}:_E4879226D6D83943BD08C790A06A6CE8"
"{9F6F8455-1EF1-4B85-886A-4223BCC8E7F7}:_F1A679CEA7E1F5622338F71AD2965077"
{
"AssemblyRegister" = "3:1"
"AssemblyIsInGAC" = "11:FALSE"
"AssemblyAsmDisplayName" = "8:SharpOVR, Version=0.6.0.4, Culture=neutral, processorArchitecture=MSIL"
"AssemblyAsmDisplayName" = "8:OculusWrap, Version=2.3.2.1, Culture=neutral, processorArchitecture=MSIL"
"ScatterAssemblies"
{
"_E4879226D6D83943BD08C790A06A6CE8"
"_F1A679CEA7E1F5622338F71AD2965077"
{
"Name" = "8:SharpOVR.dll"
"Name" = "8:OculusWrap.dll"
"Attributes" = "3:512"
}
}
"SourcePath" = "8:SharpOVR.dll"
"SourcePath" = "8:OculusWrap.dll"
"TargetName" = "8:"
"Tag" = "8:"
"Folder" = "8:_8994134A3002496B9ACD2171AA6B2439"
@ -1945,15 +1927,15 @@
{
"Name" = "8:Microsoft Visual Studio"
"ProductName" = "8:WorldWide Telescope"
"ProductCode" = "8:{412B591F-3F86-4A1C-9DF6-854892DE27BB}"
"PackageCode" = "8:{4DEE67B6-D524-47C0-8954-F7198B574E42}"
"ProductCode" = "8:{04314A17-E721-43F2-93D0-9918E7CF0504}"
"PackageCode" = "8:{6EC1DDF2-C788-47C9-8C69-75F6C4E95309}"
"UpgradeCode" = "8:{543D9051-C7F5-4C6B-BEA5-6CA148C8487F}"
"AspNetVersion" = "8:4.0.30319.0"
"RestartWWWService" = "11:FALSE"
"RemovePreviousVersions" = "11:TRUE"
"DetectNewerInstalledVersion" = "11:TRUE"
"InstallAllUsers" = "11:TRUE"
"ProductVersion" = "8:5.5.03"
"ProductVersion" = "8:5.5.04"
"Manufacturer" = "8:WorldWide Telescope"
"ARPHELPTELEPHONE" = "8:"
"ARPHELPLINK" = "8:"

Просмотреть файл

@ -1,7 +1,7 @@

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio 2013
VisualStudioVersion = 12.0.31101.0
# Visual Studio 14
VisualStudioVersion = 14.0.25420.1
MinimumVisualStudioVersion = 10.0.40219.1
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "WWTExplorer", "WWTExplorer3d\WWTExplorer.csproj", "{733C84E7-58F2-4E09-AC82-58AFD7E7BDD3}"
EndProject
@ -20,6 +20,8 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = ".nuget", ".nuget", "{E5ACF4
.nuget\NuGet.targets = .nuget\NuGet.targets
EndProjectSection
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "OculusWrap", "OculusWrap\OculusWrap.csproj", "{737A81A8-553C-49A9-8F17-5ADF691A56B2}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
@ -98,6 +100,26 @@ Global
{6C205CAA-423D-48B8-813B-E586E105C71B}.Release|Win32.ActiveCfg = Release|Any CPU
{6C205CAA-423D-48B8-813B-E586E105C71B}.Release|x64.ActiveCfg = Release|Any CPU
{6C205CAA-423D-48B8-813B-E586E105C71B}.Release|x86.ActiveCfg = Release|Any CPU
{737A81A8-553C-49A9-8F17-5ADF691A56B2}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{737A81A8-553C-49A9-8F17-5ADF691A56B2}.Debug|Any CPU.Build.0 = Debug|Any CPU
{737A81A8-553C-49A9-8F17-5ADF691A56B2}.Debug|Mixed Platforms.ActiveCfg = Debug|Any CPU
{737A81A8-553C-49A9-8F17-5ADF691A56B2}.Debug|Mixed Platforms.Build.0 = Debug|Any CPU
{737A81A8-553C-49A9-8F17-5ADF691A56B2}.Debug|Win32.ActiveCfg = Debug|Any CPU
{737A81A8-553C-49A9-8F17-5ADF691A56B2}.Debug|Win32.Build.0 = Debug|Any CPU
{737A81A8-553C-49A9-8F17-5ADF691A56B2}.Debug|x64.ActiveCfg = Debug|Any CPU
{737A81A8-553C-49A9-8F17-5ADF691A56B2}.Debug|x64.Build.0 = Debug|Any CPU
{737A81A8-553C-49A9-8F17-5ADF691A56B2}.Debug|x86.ActiveCfg = Debug|Any CPU
{737A81A8-553C-49A9-8F17-5ADF691A56B2}.Debug|x86.Build.0 = Debug|Any CPU
{737A81A8-553C-49A9-8F17-5ADF691A56B2}.Release|Any CPU.ActiveCfg = Release|Any CPU
{737A81A8-553C-49A9-8F17-5ADF691A56B2}.Release|Any CPU.Build.0 = Release|Any CPU
{737A81A8-553C-49A9-8F17-5ADF691A56B2}.Release|Mixed Platforms.ActiveCfg = Release|Any CPU
{737A81A8-553C-49A9-8F17-5ADF691A56B2}.Release|Mixed Platforms.Build.0 = Release|Any CPU
{737A81A8-553C-49A9-8F17-5ADF691A56B2}.Release|Win32.ActiveCfg = Release|Any CPU
{737A81A8-553C-49A9-8F17-5ADF691A56B2}.Release|Win32.Build.0 = Release|Any CPU
{737A81A8-553C-49A9-8F17-5ADF691A56B2}.Release|x64.ActiveCfg = Release|Any CPU
{737A81A8-553C-49A9-8F17-5ADF691A56B2}.Release|x64.Build.0 = Release|Any CPU
{737A81A8-553C-49A9-8F17-5ADF691A56B2}.Release|x86.ActiveCfg = Release|Any CPU
{737A81A8-553C-49A9-8F17-5ADF691A56B2}.Release|x86.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE

Разница между файлами не показана из-за своего большого размера Загрузить разницу

Просмотреть файл

@ -1,140 +0,0 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Runtime.InteropServices;
using System.Text;
using System.Threading.Tasks;
namespace TerraViewer
{
class Oculus
{
}
public enum RenderAPIType
{
/// <summary>
/// No API
/// </summary>
None = 0,
/// <summary>
/// OpenGL
/// </summary>
OpenGL = 1,
/// <summary>
/// OpenGL ES
/// </summary>
Android_GLES = 2,
/// <summary>
/// DirectX 11.
/// </summary>
D3D11 = 5,
/// <summary>
/// Count of enumerated elements.
/// </summary>
Count = 4
}
[StructLayout(LayoutKind.Sequential)]
public struct Sizei
{
public Sizei(int width, int height)
{
this.Width = width;
this.Height = height;
}
public int Width,
Height;
}
[StructLayout(LayoutKind.Sequential, Pack = 4)]
public struct TextureHeader
{
/// <summary>
/// The API type to which this texture belongs.
/// </summary>
public RenderAPIType API;
/// <remarks>
/// Size of this texture in pixels.
/// </remarks>
public Sizei TextureSize;
}
[StructLayout(LayoutKind.Sequential)]
public struct D3D11TextureData
{
/// <summary>
/// General device settings.
/// </summary>
public TextureHeader Header;
/// <summary>
/// The D3D11 texture containing the undistorted eye image.
/// </summary>
/// <remarks>
/// ID3D11Texture2D
/// </remarks>
public IntPtr Texture;
/// <summary>
/// The D3D11 shader resource view for this texture.
/// </summary>
/// <remarks>
/// ID3D11ShaderResourceView
/// </remarks>
public IntPtr ShaderResourceView;
};
public struct Texture
{
/// <summary>
/// API-independent header.
/// </summary>
public TextureHeader Header;
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 8)]
public IntPtr[] PlatformData;
}
public class SwapTextureSetD3D
{
private SharpOVR.SwapTextureSet SwapTextureSet;
public SwapTextureSetD3D(IntPtr swapTextureSetPtr)
{
SwapTextureSet = (SharpOVR.SwapTextureSet)Marshal.PtrToStructure(swapTextureSetPtr, typeof(SharpOVR.SwapTextureSet));
// Allocate the list of managed textures.
Textures = new D3D11TextureData[SwapTextureSet.TextureCount];
// The size of the OVR.D3D11.D3D11TextureData is defined as a C++ union between the
// OVR.Texture and the OVR.D3D11.D3D11TextureData type. As the OVR.Texture is larger
// than the size of the OVR.D3D11.D3D11TextureData, the size of the OVR.Texture is
// used to determine the unmanaged size of the OVR.D3D11.D3D11TextureData.
int textureSize = Marshal.SizeOf(typeof(Texture));
for (int textureIndex = 0; textureIndex < SwapTextureSet.TextureCount; textureIndex++)
{
// Copy the contents of the unmanaged texture to the list of managed textures.
Textures[textureIndex] = (D3D11TextureData)Marshal.PtrToStructure(SwapTextureSet.Textures + textureSize * textureIndex, typeof(D3D11TextureData));
}
}
/// <summary>
/// Array of textures.
/// </summary>
public IList<D3D11TextureData> Textures
{
get;
private set;
}
}
}

Просмотреть файл

@ -0,0 +1,70 @@
using OculusWrap;
using SharpDX;
using SharpDX.Direct3D11;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace TerraViewer
{
public class EyeTexture : IDisposable
{
#region IDisposable Members
/// <summary>
/// Dispose contained fields.
/// </summary>
public void Dispose()
{
if (SwapTextureSet != null)
{
SwapTextureSet.Dispose();
SwapTextureSet = null;
}
if (Textures != null)
{
foreach (Texture2D texture in Textures)
texture.Dispose();
Textures = null;
}
if (RenderTargetViews != null)
{
foreach (RenderTargetView renderTargetView in RenderTargetViews)
renderTargetView.Dispose();
RenderTargetViews = null;
}
if (DepthBuffer != null)
{
DepthBuffer.Dispose();
DepthBuffer = null;
}
if (DepthStencilView != null)
{
DepthStencilView.Dispose();
DepthStencilView = null;
}
}
#endregion
public Texture2DDescription Texture2DDescription;
public TextureSwapChain SwapTextureSet;
public Texture2D[] Textures;
public RenderTargetView[] RenderTargetViews;
public Texture2DDescription DepthBufferDescription;
public Texture2D DepthBuffer;
public Viewport Viewport;
public DepthStencilView DepthStencilView;
public OVRTypes.FovPort FieldOfView;
public OVRTypes.Sizei TextureSize;
public OVRTypes.Recti ViewportSize;
public OVRTypes.EyeRenderDesc RenderDescription;
public OVRTypes.Vector3f HmdToEyeViewOffset;
}
}

Просмотреть файл

@ -0,0 +1,149 @@
using OculusWrap;
using SharpDX;
using SharpDX.Direct3D11;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace TerraViewer
{
public static class SharpDXHelpers
{
/// <summary>
/// Convert a Vector4 to a Vector3
/// </summary>
/// <param name="vector4">Vector4 to convert to a Vector3.</param>
/// <returns>Vector3 based on the X, Y and Z coordinates of the Vector4.</returns>
public static Vector3 ToVector3(this Vector4 vector4)
{
return new Vector3(vector4.X, vector4.Y, vector4.Z);
}
/// <summary>
/// Convert an ovrVector3f to SharpDX Vector3.
/// </summary>
/// <param name="ovrVector3f">ovrVector3f to convert to a SharpDX Vector3.</param>
/// <returns>SharpDX Vector3, based on the ovrVector3f.</returns>
public static Vector3 ToVector3(this OVRTypes.Vector3f ovrVector3f)
{
return new Vector3(ovrVector3f.X, ovrVector3f.Y, ovrVector3f.Z);
}
/// <summary>
/// Convert an ovrMatrix4f to a SharpDX Matrix.
/// </summary>
/// <param name="ovrMatrix4f">ovrMatrix4f to convert to a SharpDX Matrix.</param>
/// <returns>SharpDX Matrix, based on the ovrMatrix4f.</returns>
public static Matrix ToMatrix(this OVRTypes.Matrix4f ovrMatrix4f)
{
return new Matrix(ovrMatrix4f.M11, ovrMatrix4f.M12, ovrMatrix4f.M13, ovrMatrix4f.M14, ovrMatrix4f.M21, ovrMatrix4f.M22, ovrMatrix4f.M23, ovrMatrix4f.M24, ovrMatrix4f.M31, ovrMatrix4f.M32, ovrMatrix4f.M33, ovrMatrix4f.M34, ovrMatrix4f.M41, ovrMatrix4f.M42, ovrMatrix4f.M43, ovrMatrix4f.M44);
}
/// <summary>
/// Converts an ovrQuatf to a SharpDX Quaternion.
/// </summary>
public static Quaternion ToQuaternion(OVRTypes.Quaternionf ovrQuatf)
{
return new Quaternion(ovrQuatf.X, ovrQuatf.Y, -ovrQuatf.Z, ovrQuatf.W);
}
/// <summary>
/// Creates a TextureSwapChainDesc, based on a specified SharpDX texture description.
/// </summary>
/// <param name="texture2DDescription">SharpDX texture description.</param>
/// <returns>TextureSwapChainDesc, based on the SharpDX texture description.</returns>
public static OVRTypes.TextureSwapChainDesc CreateTextureSwapChainDescription(Texture2DDescription texture2DDescription)
{
OVRTypes.TextureSwapChainDesc textureSwapChainDescription = new OVRTypes.TextureSwapChainDesc();
textureSwapChainDescription.Type = OVRTypes.TextureType.Texture2D;
textureSwapChainDescription.Format = GetTextureFormat(texture2DDescription.Format);
textureSwapChainDescription.ArraySize = (int)texture2DDescription.ArraySize;
textureSwapChainDescription.Width = (int)texture2DDescription.Width;
textureSwapChainDescription.Height = (int)texture2DDescription.Height;
textureSwapChainDescription.MipLevels = (int)texture2DDescription.MipLevels;
textureSwapChainDescription.SampleCount = (int)texture2DDescription.SampleDescription.Count;
textureSwapChainDescription.StaticImage = 0;
textureSwapChainDescription.MiscFlags = GetTextureMiscFlags(texture2DDescription, false);
textureSwapChainDescription.BindFlags = GetTextureBindFlags(texture2DDescription.BindFlags);
return textureSwapChainDescription;
}
/// <summary>
/// Translates a DirectX texture format into an Oculus SDK texture format.
/// </summary>
/// <param name="textureFormat">DirectX texture format to translate into an Oculus SDK texture format.</param>
/// <returns>
/// Oculus SDK texture format matching the specified textureFormat or OVRTypes.TextureFormat.Unknown if a match count not be found.
/// </returns>
public static OVRTypes.TextureFormat GetTextureFormat(SharpDX.DXGI.Format textureFormat)
{
switch (textureFormat)
{
case SharpDX.DXGI.Format.B5G6R5_UNorm: return OVRTypes.TextureFormat.B5G6R5_UNORM;
case SharpDX.DXGI.Format.B5G5R5A1_UNorm: return OVRTypes.TextureFormat.B5G5R5A1_UNORM;
case SharpDX.DXGI.Format.R8G8B8A8_UNorm: return OVRTypes.TextureFormat.R8G8B8A8_UNORM;
case SharpDX.DXGI.Format.R8G8B8A8_UNorm_SRgb: return OVRTypes.TextureFormat.R8G8B8A8_UNORM_SRGB;
case SharpDX.DXGI.Format.B8G8R8A8_UNorm: return OVRTypes.TextureFormat.B8G8R8A8_UNORM;
case SharpDX.DXGI.Format.B8G8R8A8_UNorm_SRgb: return OVRTypes.TextureFormat.B8G8R8A8_UNORM_SRGB;
case SharpDX.DXGI.Format.B8G8R8X8_UNorm: return OVRTypes.TextureFormat.B8G8R8X8_UNORM;
case SharpDX.DXGI.Format.B8G8R8X8_UNorm_SRgb: return OVRTypes.TextureFormat.B8G8R8X8_UNORM_SRGB;
case SharpDX.DXGI.Format.R16G16B16A16_Float: return OVRTypes.TextureFormat.R16G16B16A16_FLOAT;
case SharpDX.DXGI.Format.D16_UNorm: return OVRTypes.TextureFormat.D16_UNORM;
case SharpDX.DXGI.Format.D24_UNorm_S8_UInt: return OVRTypes.TextureFormat.D24_UNORM_S8_UINT;
case SharpDX.DXGI.Format.D32_Float: return OVRTypes.TextureFormat.D32_FLOAT;
case SharpDX.DXGI.Format.D32_Float_S8X24_UInt: return OVRTypes.TextureFormat.D32_FLOAT_S8X24_UINT;
case SharpDX.DXGI.Format.R8G8B8A8_Typeless: return OVRTypes.TextureFormat.R8G8B8A8_UNORM;
case SharpDX.DXGI.Format.R16G16B16A16_Typeless: return OVRTypes.TextureFormat.R16G16B16A16_FLOAT;
default: return OVRTypes.TextureFormat.UNKNOWN;
}
}
/// <summary>
/// Creates a set of TextureMiscFlags, based on a specified SharpDX texture description and a mip map generation flag.
/// </summary>
/// <param name="texture2DDescription">SharpDX texture description.</param>
/// <param name="allowGenerateMips">
/// When set, allows generation of the mip chain on the GPU via the GenerateMips
/// call. This flag requires that RenderTarget binding also be specified.
/// </param>
/// <returns>Created TextureMiscFlags, based on the specified SharpDX texture description and mip map generation flag.</returns>
public static OVRTypes.TextureMiscFlags GetTextureMiscFlags(Texture2DDescription texture2DDescription, bool allowGenerateMips)
{
OVRTypes.TextureMiscFlags results = OVRTypes.TextureMiscFlags.None;
if (texture2DDescription.Format == SharpDX.DXGI.Format.R8G8B8A8_Typeless || texture2DDescription.Format == SharpDX.DXGI.Format.R16G16B16A16_Typeless)
results |= OVRTypes.TextureMiscFlags.DX_Typeless;
if (texture2DDescription.BindFlags.HasFlag(BindFlags.RenderTarget) && allowGenerateMips)
results |= OVRTypes.TextureMiscFlags.AllowGenerateMips;
return results;
}
/// <summary>
/// Retrieves a list of flags matching the specified DirectX texture binding flags.
/// </summary>
/// <param name="bindFlags">DirectX texture binding flags to translate into Oculus SDK texture binding flags.</param>
/// <returns>Oculus SDK texture binding flags matching the specified bindFlags.</returns>
public static OVRTypes.TextureBindFlags GetTextureBindFlags(SharpDX.Direct3D11.BindFlags bindFlags)
{
OVRTypes.TextureBindFlags result = OVRTypes.TextureBindFlags.None;
if (bindFlags.HasFlag(SharpDX.Direct3D11.BindFlags.DepthStencil))
result |= OVRTypes.TextureBindFlags.DX_DepthStencil;
if (bindFlags.HasFlag(SharpDX.Direct3D11.BindFlags.RenderTarget))
result |= OVRTypes.TextureBindFlags.DX_RenderTarget;
if (bindFlags.HasFlag(SharpDX.Direct3D11.BindFlags.UnorderedAccess))
result |= OVRTypes.TextureBindFlags.DX_DepthStencil;
return result;
}
}
}

Просмотреть файл

@ -30,8 +30,8 @@ using System.Resources;
// Build Number
// Revision
//
[assembly: AssemblyVersion("5.5.03.1")]
[assembly: AssemblyFileVersion("5.5.03.1")]
[assembly: AssemblyVersion("5.5.04.1")]
[assembly: AssemblyFileVersion("5.5.04.1")]
[assembly: NeutralResourcesLanguageAttribute("en-US")]
[assembly: System.Windows.Media.DisableDpiAwareness]

Двоичные данные
WWTExplorer3d/Resources/Pano Stitch small.png Normal file

Двоичный файл не отображается.

После

Ширина:  |  Высота:  |  Размер: 20 MiB

Двоичные данные
WWTExplorer3d/Resources/WelcomeLogo.png Normal file

Двоичный файл не отображается.

После

Ширина:  |  Высота:  |  Размер: 11 KiB

109
WWTExplorer3d/TourEdit.Designer.cs сгенерированный
Просмотреть файл

@ -51,29 +51,33 @@ namespace TerraViewer
// pinUp
//
this.pinUp.Enabled = false;
this.pinUp.Location = new System.Drawing.Point(675, 110);
this.pinUp.Location = new System.Drawing.Point(719, 154);
this.pinUp.MaximumSize = new System.Drawing.Size(75, 35);
this.pinUp.MinimumSize = new System.Drawing.Size(75, 35);
this.pinUp.Size = new System.Drawing.Size(75, 35);
this.pinUp.TabIndex = 12;
this.pinUp.Visible = false;
//
// tourStopList
//
this.tourStopList.AllowMultipleSelection = false;
this.tourStopList.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
| System.Windows.Forms.AnchorStyles.Left)
| System.Windows.Forms.AnchorStyles.Right)));
this.tourStopList.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
| System.Windows.Forms.AnchorStyles.Left)
| System.Windows.Forms.AnchorStyles.Right)));
this.tourStopList.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(20)))), ((int)(((byte)(22)))), ((int)(((byte)(31)))));
this.tourStopList.ColCount = 3;
this.tourStopList.Location = new System.Drawing.Point(72, 8);
this.tourStopList.ColCount = 5;
this.tourStopList.HitType = TerraViewer.TourStopList.HitPosition.Default;
this.tourStopList.Location = new System.Drawing.Point(108, 12);
this.tourStopList.Margin = new System.Windows.Forms.Padding(0);
this.tourStopList.MaximumSize = new System.Drawing.Size(4096, 475);
this.tourStopList.MinimumSize = new System.Drawing.Size(100, 65);
this.tourStopList.MaximumSize = new System.Drawing.Size(6144, 731);
this.tourStopList.MinimumSize = new System.Drawing.Size(150, 100);
this.tourStopList.MultipleSelection = false;
this.tourStopList.Name = "tourStopList";
this.tourStopList.Paginator = null;
this.tourStopList.RowCount = 1;
this.tourStopList.RowCount = 2;
this.tourStopList.SelectedItem = -1;
this.tourStopList.ShowAddButton = true;
this.tourStopList.Size = new System.Drawing.Size(557, 105);
this.tourStopList.Size = new System.Drawing.Size(836, 162);
this.tourStopList.TabIndex = 2;
this.tourStopList.ThumbnailSize = TerraViewer.ThumbnailSize.Small;
this.toolTip.SetToolTip(this.tourStopList, "Slides");
@ -100,9 +104,10 @@ namespace TerraViewer
this.AddText.ForeColor = System.Drawing.Color.White;
this.AddText.Image = global::TerraViewer.Properties.Resources.tool_icon_text_24;
this.AddText.ImageAlign = System.Drawing.ContentAlignment.TopCenter;
this.AddText.Location = new System.Drawing.Point(637, 63);
this.AddText.Location = new System.Drawing.Point(956, 97);
this.AddText.Margin = new System.Windows.Forms.Padding(4, 5, 4, 5);
this.AddText.Name = "AddText";
this.AddText.Size = new System.Drawing.Size(54, 45);
this.AddText.Size = new System.Drawing.Size(81, 69);
this.AddText.TabIndex = 7;
this.AddText.Text = "Text";
this.AddText.TextAlign = System.Drawing.ContentAlignment.BottomCenter;
@ -116,11 +121,12 @@ namespace TerraViewer
this.EditTourProperties.DialogResult = System.Windows.Forms.DialogResult.None;
this.EditTourProperties.ImageDisabled = null;
this.EditTourProperties.ImageEnabled = null;
this.EditTourProperties.Location = new System.Drawing.Point(632, 4);
this.EditTourProperties.MaximumSize = new System.Drawing.Size(140, 33);
this.EditTourProperties.Location = new System.Drawing.Point(948, 6);
this.EditTourProperties.Margin = new System.Windows.Forms.Padding(6, 8, 6, 8);
this.EditTourProperties.MaximumSize = new System.Drawing.Size(210, 51);
this.EditTourProperties.Name = "EditTourProperties";
this.EditTourProperties.Selected = false;
this.EditTourProperties.Size = new System.Drawing.Size(112, 33);
this.EditTourProperties.Size = new System.Drawing.Size(168, 51);
this.EditTourProperties.TabIndex = 3;
this.EditTourProperties.Text = "Tour Properties";
this.EditTourProperties.Click += new System.EventHandler(this.EditTourProperties_Click);
@ -132,9 +138,10 @@ namespace TerraViewer
this.AddShape.ForeColor = System.Drawing.Color.White;
this.AddShape.Image = global::TerraViewer.Properties.Resources.tool_icon_shape_24;
this.AddShape.ImageAlign = System.Drawing.ContentAlignment.TopCenter;
this.AddShape.Location = new System.Drawing.Point(691, 63);
this.AddShape.Location = new System.Drawing.Point(1036, 97);
this.AddShape.Margin = new System.Windows.Forms.Padding(4, 5, 4, 5);
this.AddShape.Name = "AddShape";
this.AddShape.Size = new System.Drawing.Size(54, 45);
this.AddShape.Size = new System.Drawing.Size(81, 69);
this.AddShape.TabIndex = 8;
this.AddShape.Text = "Shapes";
this.AddShape.TextAlign = System.Drawing.ContentAlignment.BottomCenter;
@ -149,9 +156,10 @@ namespace TerraViewer
this.AddPicture.ForeColor = System.Drawing.Color.White;
this.AddPicture.Image = global::TerraViewer.Properties.Resources.tool_icon_picture_24;
this.AddPicture.ImageAlign = System.Drawing.ContentAlignment.TopCenter;
this.AddPicture.Location = new System.Drawing.Point(745, 63);
this.AddPicture.Location = new System.Drawing.Point(1118, 97);
this.AddPicture.Margin = new System.Windows.Forms.Padding(4, 5, 4, 5);
this.AddPicture.Name = "AddPicture";
this.AddPicture.Size = new System.Drawing.Size(54, 45);
this.AddPicture.Size = new System.Drawing.Size(81, 69);
this.AddPicture.TabIndex = 9;
this.AddPicture.Text = "Picture";
this.AddPicture.TextAlign = System.Drawing.ContentAlignment.BottomCenter;
@ -165,9 +173,10 @@ namespace TerraViewer
this.AddVideo.ForeColor = System.Drawing.Color.White;
this.AddVideo.Image = global::TerraViewer.Properties.Resources.tool_icon_video_24;
this.AddVideo.ImageAlign = System.Drawing.ContentAlignment.TopCenter;
this.AddVideo.Location = new System.Drawing.Point(745, 63);
this.AddVideo.Location = new System.Drawing.Point(1118, 97);
this.AddVideo.Margin = new System.Windows.Forms.Padding(4, 5, 4, 5);
this.AddVideo.Name = "AddVideo";
this.AddVideo.Size = new System.Drawing.Size(54, 45);
this.AddVideo.Size = new System.Drawing.Size(81, 69);
this.AddVideo.TabIndex = 6;
this.AddVideo.Text = "Video";
this.AddVideo.TextAlign = System.Drawing.ContentAlignment.BottomCenter;
@ -182,11 +191,12 @@ namespace TerraViewer
this.SaveTour.DialogResult = System.Windows.Forms.DialogResult.None;
this.SaveTour.ImageDisabled = null;
this.SaveTour.ImageEnabled = null;
this.SaveTour.Location = new System.Drawing.Point(739, 4);
this.SaveTour.MaximumSize = new System.Drawing.Size(140, 33);
this.SaveTour.Location = new System.Drawing.Point(1108, 6);
this.SaveTour.Margin = new System.Windows.Forms.Padding(6, 8, 6, 8);
this.SaveTour.MaximumSize = new System.Drawing.Size(210, 51);
this.SaveTour.Name = "SaveTour";
this.SaveTour.Selected = false;
this.SaveTour.Size = new System.Drawing.Size(67, 33);
this.SaveTour.Size = new System.Drawing.Size(100, 51);
this.SaveTour.TabIndex = 4;
this.SaveTour.Text = " Save";
this.SaveTour.Click += new System.EventHandler(this.SaveTour_Click);
@ -195,9 +205,10 @@ namespace TerraViewer
//
this.Preview.BackColor = System.Drawing.Color.Transparent;
this.Preview.Image = global::TerraViewer.Properties.Resources.button_play_normal;
this.Preview.Location = new System.Drawing.Point(4, 16);
this.Preview.Location = new System.Drawing.Point(6, 25);
this.Preview.Margin = new System.Windows.Forms.Padding(4, 5, 4, 5);
this.Preview.Name = "Preview";
this.Preview.Size = new System.Drawing.Size(64, 64);
this.Preview.Size = new System.Drawing.Size(96, 98);
this.Preview.TabIndex = 8;
this.Preview.TabStop = false;
this.Preview.EnabledChanged += new System.EventHandler(this.Preview_EnabledChanged);
@ -212,27 +223,30 @@ namespace TerraViewer
this.MusicTrack.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));
this.MusicTrack.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(56)))), ((int)(((byte)(63)))), ((int)(((byte)(85)))));
this.MusicTrack.Enabled = false;
this.MusicTrack.Location = new System.Drawing.Point(808, 10);
this.MusicTrack.MaximumSize = new System.Drawing.Size(193, 46);
this.MusicTrack.MinimumSize = new System.Drawing.Size(193, 46);
this.MusicTrack.Location = new System.Drawing.Point(1212, 15);
this.MusicTrack.Margin = new System.Windows.Forms.Padding(6, 8, 6, 8);
this.MusicTrack.MaximumSize = new System.Drawing.Size(290, 71);
this.MusicTrack.MinimumSize = new System.Drawing.Size(290, 71);
this.MusicTrack.Mute = false;
this.MusicTrack.Name = "MusicTrack";
this.MusicTrack.Size = new System.Drawing.Size(193, 46);
this.MusicTrack.Size = new System.Drawing.Size(290, 71);
this.MusicTrack.TabIndex = 10;
this.MusicTrack.Target = null;
this.MusicTrack.TrackType = TerraViewer.AudioType.Music;
this.MusicTrack.Load += new System.EventHandler(this.MusicTrack_Load);
//
// VoiceTrack
//
this.VoiceTrack.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));
this.VoiceTrack.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(56)))), ((int)(((byte)(63)))), ((int)(((byte)(85)))));
this.VoiceTrack.Enabled = false;
this.VoiceTrack.Location = new System.Drawing.Point(808, 68);
this.VoiceTrack.MaximumSize = new System.Drawing.Size(193, 46);
this.VoiceTrack.MinimumSize = new System.Drawing.Size(193, 46);
this.VoiceTrack.Location = new System.Drawing.Point(1212, 105);
this.VoiceTrack.Margin = new System.Windows.Forms.Padding(6, 8, 6, 8);
this.VoiceTrack.MaximumSize = new System.Drawing.Size(290, 71);
this.VoiceTrack.MinimumSize = new System.Drawing.Size(290, 71);
this.VoiceTrack.Mute = false;
this.VoiceTrack.Name = "VoiceTrack";
this.VoiceTrack.Size = new System.Drawing.Size(193, 46);
this.VoiceTrack.Size = new System.Drawing.Size(290, 71);
this.VoiceTrack.TabIndex = 11;
this.VoiceTrack.Target = null;
this.VoiceTrack.TrackType = TerraViewer.AudioType.Voice;
@ -241,10 +255,12 @@ namespace TerraViewer
//
this.ShowSafeArea.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));
this.ShowSafeArea.BackColor = System.Drawing.Color.Transparent;
this.ShowSafeArea.BackgroundImageLayout = System.Windows.Forms.ImageLayout.None;
this.ShowSafeArea.Checked = false;
this.ShowSafeArea.Location = new System.Drawing.Point(632, 35);
this.ShowSafeArea.Location = new System.Drawing.Point(948, 54);
this.ShowSafeArea.Margin = new System.Windows.Forms.Padding(6, 8, 6, 8);
this.ShowSafeArea.Name = "ShowSafeArea";
this.ShowSafeArea.Size = new System.Drawing.Size(112, 25);
this.ShowSafeArea.Size = new System.Drawing.Size(168, 38);
this.ShowSafeArea.TabIndex = 5;
this.ShowSafeArea.Text = "Show Safe Area";
this.ShowSafeArea.CheckedChanged += new System.EventHandler(this.ShowSafeArea_CheckedChanged);
@ -255,9 +271,10 @@ namespace TerraViewer
this.runTimeLabel.BackColor = System.Drawing.Color.Transparent;
this.runTimeLabel.Font = new System.Drawing.Font("Segoe UI", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
this.runTimeLabel.ForeColor = System.Drawing.Color.White;
this.runTimeLabel.Location = new System.Drawing.Point(9, 83);
this.runTimeLabel.Location = new System.Drawing.Point(14, 128);
this.runTimeLabel.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0);
this.runTimeLabel.Name = "runTimeLabel";
this.runTimeLabel.Size = new System.Drawing.Size(54, 13);
this.runTimeLabel.Size = new System.Drawing.Size(82, 23);
this.runTimeLabel.TabIndex = 0;
this.runTimeLabel.Text = "Run Time";
//
@ -267,9 +284,10 @@ namespace TerraViewer
this.totalTimeText.BackColor = System.Drawing.Color.Transparent;
this.totalTimeText.Font = new System.Drawing.Font("Segoe UI", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
this.totalTimeText.ForeColor = System.Drawing.Color.White;
this.totalTimeText.Location = new System.Drawing.Point(22, 101);
this.totalTimeText.Location = new System.Drawing.Point(33, 155);
this.totalTimeText.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0);
this.totalTimeText.Name = "totalTimeText";
this.totalTimeText.Size = new System.Drawing.Size(28, 13);
this.totalTimeText.Size = new System.Drawing.Size(41, 23);
this.totalTimeText.TabIndex = 1;
this.totalTimeText.Text = "3:34";
//
@ -277,19 +295,21 @@ namespace TerraViewer
//
this.Dome.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));
this.Dome.BackColor = System.Drawing.Color.Transparent;
this.Dome.BackgroundImageLayout = System.Windows.Forms.ImageLayout.None;
this.Dome.Checked = false;
this.Dome.Location = new System.Drawing.Point(739, 35);
this.Dome.Location = new System.Drawing.Point(1108, 54);
this.Dome.Margin = new System.Windows.Forms.Padding(6, 8, 6, 8);
this.Dome.Name = "Dome";
this.Dome.Size = new System.Drawing.Size(65, 25);
this.Dome.Size = new System.Drawing.Size(98, 38);
this.Dome.TabIndex = 6;
this.Dome.Text = "Dome";
this.Dome.CheckedChanged += new System.EventHandler(this.Dome_CheckedChanged);
//
// TourEditTab
//
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
this.AutoScaleDimensions = new System.Drawing.SizeF(9F, 20F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size(1008, 123);
this.ClientSize = new System.Drawing.Size(1512, 189);
this.Controls.Add(this.Dome);
this.Controls.Add(this.totalTimeText);
this.Controls.Add(this.runTimeLabel);
@ -304,6 +324,7 @@ namespace TerraViewer
this.Controls.Add(this.AddText);
this.Controls.Add(this.tourStopList);
this.Controls.Add(this.AddVideo);
this.Margin = new System.Windows.Forms.Padding(6, 8, 6, 8);
this.Name = "TourEditTab";
this.Text = "Create";
this.FormClosed += new System.Windows.Forms.FormClosedEventHandler(this.TourEditTab_FormClosed);

Просмотреть файл

@ -112,15 +112,15 @@
<value>2.0</value>
</resheader>
<resheader name="reader">
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<metadata name="toolTip.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
<metadata name="toolTip.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
<value>238, 17</value>
</metadata>
<metadata name="PlayerTimer.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
<metadata name="PlayerTimer.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
<value>17, 17</value>
</metadata>
</root>

Просмотреть файл

@ -203,9 +203,6 @@
<Reference Include="SharpDX.Toolkit.Graphics">
<HintPath>$(SharpDXPackageBinDir)\SharpDX.Toolkit.Graphics.dll</HintPath>
</Reference>
<Reference Include="SharpOVR">
<HintPath>..\packages\SharpOVR.0.6.0.4\lib\SharpOVR.dll</HintPath>
</Reference>
<Reference Include="System">
<Name>System</Name>
</Reference>
@ -237,7 +234,8 @@
<Compile Include="ExportSTL.Designer.cs">
<DependentUpon>ExportSTL.cs</DependentUpon>
</Compile>
<Compile Include="Oculus.cs" />
<Compile Include="Ovr\EyeTexture.cs" />
<Compile Include="Ovr\SharpDXHelpers.cs" />
<Compile Include="Properties\Resources.Designer.cs">
<AutoGen>True</AutoGen>
<DesignTime>True</DesignTime>
@ -2465,6 +2463,10 @@
<WCFMetadata Include="Service References\" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\OculusWrap\OculusWrap.csproj">
<Project>{737a81a8-553c-49a9-8f17-5adf691a56b2}</Project>
<Name>OculusWrap</Name>
</ProjectReference>
<ProjectReference Include="..\WWTCore\WWTCore\WWTCore.csproj">
<Project>{6c205caa-423d-48b8-813b-e586e105c71b}</Project>
<Name>WWTCore</Name>

Просмотреть файл

@ -7,5 +7,4 @@
<package id="SharpDX.DXGI" version="2.6.3" targetFramework="net451" />
<package id="SharpDX.Toolkit" version="2.6.3" targetFramework="net451" />
<package id="SharpDX.Toolkit.Graphics" version="2.6.3" targetFramework="net451" />
<package id="SharpOVR" version="0.6.0.4" targetFramework="net451" />
</packages>