Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
63 commits
Select commit Hold shift + click to select a range
e8a64ce
version bump to 3.0.0.6
tebjan Sep 20, 2018
a784087
Merge branch 'master' of https://github.com/xenko3d/xenko
tebjan Sep 20, 2018
a7decbe
added TrackedDevices for OpenVR, other VR APIs return null for now
joreg Sep 24, 2018
c097dca
Merge branch 'master' of https://github.com/xenko3d/xenko
tebjan Sep 24, 2018
b60b013
TrackedDevice collection properties now return empty array, rather th…
joreg Oct 1, 2018
46a7602
renamed Xenko.VirtualReality.TrackedDevice to TrackedItem to not be c…
joreg Oct 1, 2018
8f0dfc8
added BatteryPercentage to TrackedItem
joreg Oct 1, 2018
2b5c591
removed double ToString call and moved serial number getter to constr…
tebjan Oct 7, 2018
0b9f6b5
Merge branch 'master' of https://github.com/xenko3d/xenko
tebjan Oct 7, 2018
44e467c
added TextureOptions to create directx 11 textures with the Shared or…
tebjan Oct 7, 2018
d405caf
SharedKeyedmutex was missing.
tebjan Oct 8, 2018
85e7867
Merge branch 'VRTrackerSupport' into develop
tebjan Oct 8, 2018
afe2dab
Merge branch 'add-texture-shared-handle' into develop
tebjan Oct 8, 2018
9cd61b2
added TextureOptions to create directx 11 textures with the Shared or…
tebjan Oct 8, 2018
82ca022
Merge branch 'texture-add-shared-handle' into develop
tebjan Oct 8, 2018
7510b74
typo in comment
tebjan Oct 8, 2018
18e0d51
Merge branch 'texture-add-shared-handle' into develop
tebjan Oct 8, 2018
0f362f4
removed unnecessary if and also assign IntPrt.Zero in 'None' case.
tebjan Oct 8, 2018
760df08
Merge branch 'texture-add-shared-handle' into develop
tebjan Oct 8, 2018
3ee2687
Merge remote-tracking branch 'upstream/master' into develop
tebjan Oct 8, 2018
6bbf2e9
moved SerialNumber getter back to update since it can change at runti…
joreg Oct 10, 2018
3d56559
added VRDevice.SetTrackingSpace
joreg Oct 10, 2018
8cc7fd6
texture initialization now throws an exception when retrieving of the…
tebjan Oct 10, 2018
b4b9744
reusing same StringBuilder in ever frame to get the SerialNumber
tebjan Oct 10, 2018
2ed2b77
Merge branch 'texture-add-shared-handle' into develop
tebjan Oct 10, 2018
af162e4
Merge branch 'VRTrackerSupport' into develop
tebjan Oct 10, 2018
d88a80b
Merge remote-tracking branch 'upstream/master' into develop
tebjan Oct 10, 2018
69fefe6
windows/d3d11 specific texture sharing options now in #if regions
tebjan Oct 13, 2018
df6c39c
Merge branch 'master' of https://github.com/xenko3d/xenko
tebjan Oct 13, 2018
1584991
exposed MatrixTransform as a property of FastTextRenderer, was hidden…
tebjan Oct 13, 2018
748b787
Merge branch 'texture-add-shared-handle' into develop
tebjan Oct 13, 2018
69ced1b
Merge branch 'fasttextrenderer-add-matrixtransform' into develop
tebjan Oct 13, 2018
79cad5e
cosmetics, removed trailing spaces
Kryptos-FR Oct 17, 2018
2e5a066
Merge remote-tracking branch 'upstream/master'
tebjan Oct 17, 2018
5d4aa22
Merge branch 'fasttextrenderer-add-matrixtransform' into develop
tebjan Oct 17, 2018
c4fff8a
Merge branch 'master' into develop
tebjan Oct 17, 2018
a4eeac9
Merge branch 'master' into develop
tebjan Oct 25, 2018
dfe9c05
moved BatteryPercentage, SerialNumber and DeviceClass from update int…
joreg Oct 25, 2018
5ab34de
fixed line-endings to LF
joreg Oct 26, 2018
6cbc56b
fixed geometry shader with stream out creation and added BufferFlags.…
tebjan Oct 27, 2018
40db5ce
version bump to 3.0.0.7
tebjan Oct 29, 2018
507a0c2
Merge remote-tracking branch 'origin/VRTrackerSupport' into develop
mlf-readonly Oct 29, 2018
8bff7b3
Merge remote-tracking branch 'origin/geometry-shader-streamout-fix' i…
mlf-readonly Oct 29, 2018
88cd9b6
Merge remote-tracking branch 'origin/version-bump-3007' into develop
mlf-readonly Oct 29, 2018
ad27deb
[Graphics] When mixing Dispatch and Draw calls in Direct3D11 the set …
azeno Oct 29, 2018
5caebb2
Merge branch 'pipelinestate-applied-shaders-fix' into develop
azeno Oct 29, 2018
d4ff27c
replaced isStreamOutput with bindFlags
tebjan Oct 30, 2018
818fc28
Merge branch 'geometry-shader-streamout-fix' into develop
tebjan Oct 31, 2018
2f9bdca
Quick fix as suggested by @xen2 in chat to avoid crash in shader comp…
azeno Nov 15, 2018
5ee7bd3
Merge remote-tracking branch 'upstream/master-3.0' into develop
tebjan Nov 15, 2018
77bd139
Revert "Update to C# 7.2 (#264)"
tebjan Nov 15, 2018
011114e
Revert "Update to C# 7.2 (#264)"
tebjan Nov 15, 2018
1fcd1bb
Merge branch 'hotfix-revert-csharp-7.2' into develop
tebjan Nov 15, 2018
6025711
Merge remote-tracking branch 'upstream/master' into develop
tebjan Nov 16, 2018
48da56c
[Audio] Various fixes so that SoundInstance.SetRange() works better
xen2 Nov 22, 2018
50aa277
Merge remote-tracking branch 'upstream/master-3.0' into develop
tebjan Nov 22, 2018
14dc1cf
Merge remote-tracking branch 'virgile/audio-loop-fixes' into develop
tebjan Nov 22, 2018
b9b6a08
added TextureOptions to Texture.Extensions2D
tebjan Nov 22, 2018
6308724
Merge branch 'shared-texture-additions' into develop
tebjan Nov 22, 2018
12dcfb0
Merge remote-tracking branch 'upstream/master-3.0' into develop
tebjan Nov 26, 2018
fe4a44e
Merge remote-tracking branch 'upstream/master-3.0' into develop
tebjan Nov 27, 2018
b3265b3
Merge remote-tracking branch 'upstream/master-3.0' into develop
tebjan Nov 27, 2018
6a207c8
VR tracker support (#213)
joreg Jan 25, 2019
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions sources/engine/Xenko.Graphics/Texture.cs
Original file line number Diff line number Diff line change
Expand Up @@ -382,6 +382,9 @@ public bool IsMultisample
}
}




/// <summary>
/// Gets a boolean indicating whether this <see cref="Texture"/> is a using a block compress format (BC1, BC2, BC3, BC4, BC5, BC6H, BC7).
/// </summary>
Expand Down
35 changes: 35 additions & 0 deletions sources/engine/Xenko.VirtualReality/DeviceClass.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
// Copyright (c) Xenko contributors (https://xenko.com)
// Distributed under the MIT license. See the LICENSE.md file in the project root for more information.
namespace Xenko.VirtualReality
{
/// <summary>
/// Describes what kind of object is being tracked at a given ID
/// </summary>
public enum DeviceClass
{
/// <summary>
/// There is no device at this index
/// </summary>
Invalid,
/// <summary>
/// The device at this index is an HMD
/// </summary>
HMD,
/// <summary>
/// The device is a controller
/// </summary>
Controller,
/// <summary>
/// The device is a tracker
/// </summary>
GenericTracker,
/// <summary>
/// The device is a camera, Lighthouse base station, or other device that supplies tracking ground truth.
/// </summary>
TrackingReference,
/// <summary>
/// Accessories that aren't necessarily tracked themselves, but may redirect video output from other tracked devices
/// </summary>
DisplayRedirect
}
}
28 changes: 28 additions & 0 deletions sources/engine/Xenko.VirtualReality/DeviceEnums.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
// Copyright (c) Xenko contributors (https://xenko.com) and Silicon Studio Corp. (https://www.siliconstudio.co.jp)
// Distributed under the MIT license. See the LICENSE.md file in the project root for more information.
namespace Xenko.VirtualReality
{
public enum DeviceState
{
Invalid,
OutOfRange,
Valid,
}

public enum DeviceClass
{
Invalid, //There is no device at this index
HMD, //The device at this index is an HMD
Controller, //The device is a controller
GenericTracker, //The device is a tracker
TrackingReference, //The device is a camera, Lighthouse base station, or other device that supplies tracking ground truth.
DisplayRedirect //Accessories that aren't necessarily tracked themselves, but may redirect video output from other tracked devices
}

public enum TrackingSpace
{
Seated,
Standing,
RawAndUncalibrated
}
}
11 changes: 0 additions & 11 deletions sources/engine/Xenko.VirtualReality/DeviceState.cs

This file was deleted.

2 changes: 2 additions & 0 deletions sources/engine/Xenko.VirtualReality/DummyDevice.cs
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,8 @@ public class DummyDevice : VRDevice

public override TouchController RightHand => null;

public override TrackedItem[] TrackedItems => new TrackedItem[0];

public override bool CanInitialize => true;

/// <summary>
Expand Down
2 changes: 2 additions & 0 deletions sources/engine/Xenko.VirtualReality/Fove/FoveHmd.cs
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,8 @@ public override void Draw(GameTime gameTime)

public override TouchController RightHand => null;

public override TrackedItem[] TrackedItems => new TrackedItem[0];

public override bool CanInitialize => Fove.Startup() && Fove.IsHardwareReady();
}
}
Expand Down
2 changes: 2 additions & 0 deletions sources/engine/Xenko.VirtualReality/OculusOVR/OculusOvrHmd.cs
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,8 @@ public override DeviceState State

public override TouchController RightHand => rightHandController;

public override TrackedItem[] TrackedItems => new TrackedItem[0];

public override bool CanInitialize
{
get
Expand Down
75 changes: 75 additions & 0 deletions sources/engine/Xenko.VirtualReality/OpenVR/OpenVR.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
#if XENKO_GRAPHICS_API_DIRECT3D11

using System;
using System.Text;
using SharpDX.Direct3D11;
using Valve.VR;
using Xenko.Core;
Expand Down Expand Up @@ -150,6 +151,46 @@ public void Update()
}
}

public class TrackedDevice
{
public TrackedDevice(int trackerIndex)
{
TrackerIndex = trackerIndex;
}

const int StringBuilderSize = 64;
StringBuilder serialNumberStringBuilder = new StringBuilder(StringBuilderSize);
internal string SerialNumber
{
get
{
var error = ETrackedPropertyError.TrackedProp_Success;
serialNumberStringBuilder.Clear();
Valve.VR.OpenVR.System.GetStringTrackedDeviceProperty((uint)TrackerIndex, ETrackedDeviceProperty.Prop_SerialNumber_String, serialNumberStringBuilder, StringBuilderSize, ref error);
if (error == ETrackedPropertyError.TrackedProp_Success)
return serialNumberStringBuilder.ToString();
else
return "";
}
}

internal float BatteryPercentage
{
get
{
var error = ETrackedPropertyError.TrackedProp_Success;
var value = Valve.VR.OpenVR.System.GetFloatTrackedDeviceProperty((uint)TrackerIndex, ETrackedDeviceProperty.Prop_DeviceBatteryPercentage_Float, ref error);
if (error == ETrackedPropertyError.TrackedProp_Success)
return value;
else
return 0;
}
}

internal int TrackerIndex;
internal ETrackedDeviceClass DeviceClass => Valve.VR.OpenVR.System.GetTrackedDeviceClass((uint)TrackerIndex);
}

private static readonly TrackedDevicePose_t[] DevicePoses = new TrackedDevicePose_t[Valve.VR.OpenVR.k_unMaxTrackedDeviceCount];
private static readonly TrackedDevicePose_t[] GamePoses = new TrackedDevicePose_t[Valve.VR.OpenVR.k_unMaxTrackedDeviceCount];

Expand Down Expand Up @@ -226,6 +267,11 @@ public static void Recenter()
Valve.VR.OpenVR.System.ResetSeatedZeroPose();
}

public static void SetTrackingSpace(ETrackingUniverseOrigin space)
{
Valve.VR.OpenVR.Compositor.SetTrackingSpace(space);
}

public static DeviceState GetControllerPose(int controllerIndex, out Matrix pose, out Vector3 velocity, out Vector3 angVelocity)
{
return GetControllerPoseUnsafe(controllerIndex, out pose, out velocity, out angVelocity);
Expand Down Expand Up @@ -268,6 +314,35 @@ private static unsafe DeviceState GetControllerPoseUnsafe(int controllerIndex, o
return DeviceState.Invalid;
}

public static DeviceState GetTrackerPose(int trackerIndex, out Matrix pose, out Vector3 velocity, out Vector3 angVelocity)
{
return GetTrackerPoseUnsafe(trackerIndex, out pose, out velocity, out angVelocity);
}

private static unsafe DeviceState GetTrackerPoseUnsafe(int trackerIndex, out Matrix pose, out Vector3 velocity, out Vector3 angVelocity)
{
pose = Matrix.Identity;
velocity = Vector3.Zero;
angVelocity = Vector3.Zero;
var index = trackerIndex;

Utilities.CopyMemory((IntPtr)Interop.Fixed(ref pose), (IntPtr)Interop.Fixed(ref DevicePoses[index].mDeviceToAbsoluteTracking), Utilities.SizeOf<HmdMatrix34_t>());
Utilities.CopyMemory((IntPtr)Interop.Fixed(ref velocity), (IntPtr)Interop.Fixed(ref DevicePoses[index].vVelocity), Utilities.SizeOf<HmdVector3_t>());
Utilities.CopyMemory((IntPtr)Interop.Fixed(ref angVelocity), (IntPtr)Interop.Fixed(ref DevicePoses[index].vAngularVelocity), Utilities.SizeOf<HmdVector3_t>());

var state = DeviceState.Invalid;
if (DevicePoses[index].bDeviceIsConnected && DevicePoses[index].bPoseIsValid)
{
state = DeviceState.Valid;
}
else if (DevicePoses[index].bDeviceIsConnected && !DevicePoses[index].bPoseIsValid && DevicePoses[index].eTrackingResult == ETrackingResult.Running_OutOfRange)
{
state = DeviceState.OutOfRange;
}

return state;
}

public static DeviceState GetHeadPose(out Matrix pose, out Vector3 linearVelocity, out Vector3 angularVelocity)
{
return GetHeadPoseUnsafe(out pose, out linearVelocity, out angularVelocity);
Expand Down
14 changes: 14 additions & 0 deletions sources/engine/Xenko.VirtualReality/OpenVR/OpenVrHmd.cs
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ internal class OpenVRHmd : VRDevice
private DeviceState state;
private OpenVRTouchController leftHandController;
private OpenVRTouchController rightHandController;
private OpenVRTrackedDevice[] trackedDevices;
private bool needsMirror;
private Matrix currentHead;
private Vector3 currentHeadPos;
Expand Down Expand Up @@ -55,6 +56,10 @@ public override void Enable(GraphicsDevice device, GraphicsDeviceManager graphic

leftHandController = new OpenVRTouchController(TouchControllerHand.Left);
rightHandController = new OpenVRTouchController(TouchControllerHand.Right);

trackedDevices = new OpenVRTrackedDevice[Valve.VR.OpenVR.k_unMaxTrackedDeviceCount];
for (int i=0; i<trackedDevices.Length; i++)
trackedDevices[i] = new OpenVRTrackedDevice(i);
}

public override VROverlay CreateOverlay(int width, int height, int mipLevels, int sampleCount)
Expand All @@ -75,6 +80,8 @@ public override void Update(GameTime gameTime)
{
LeftHand.Update(gameTime);
RightHand.Update(gameTime);
foreach (var tracker in trackedDevices)
tracker.Update(gameTime);
}

public override void ReadEyeParameters(Eyes eye, float near, float far, ref Vector3 cameraPosition, ref Matrix cameraRotation, bool ignoreHeadRotation, bool ignoreHeadPosition, out Matrix view, out Matrix projection)
Expand Down Expand Up @@ -122,6 +129,11 @@ public override void Recenter()
OpenVR.Recenter();
}

public override void SetTrackingSpace(TrackingSpace space)
{
OpenVR.SetTrackingSpace((Valve.VR.ETrackingUniverseOrigin)space);
}

public override DeviceState State => state;

public override Vector3 HeadPosition => currentHeadPos;
Expand All @@ -136,6 +148,8 @@ public override void Recenter()

public override TouchController RightHand => rightHandController;

public override TrackedItem[] TrackedItems => trackedDevices;

public override Texture MirrorTexture { get; protected set; }

public override float RenderFrameScaling { get; set; } = 1.4f;
Expand Down
63 changes: 63 additions & 0 deletions sources/engine/Xenko.VirtualReality/OpenVR/OpenVrTrackedDevice.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
// Copyright (c) Xenko contributors (https://xenko.com)
// Distributed under the MIT license. See the LICENSE.md file in the project root for more information.
#if XENKO_GRAPHICS_API_DIRECT3D11

using System;
using Xenko.Core.Mathematics;
using Xenko.Games;

namespace Xenko.VirtualReality
{
internal class OpenVRTrackedDevice : TrackedItem
{
private readonly int id;
private OpenVR.TrackedDevice trackedDevice;
private DeviceState internalState;
private Vector3 currentPos;
private Vector3 currentLinearVelocity;
private Vector3 currentAngularVelocity;
private Quaternion currentRot;

internal OpenVRTrackedDevice(int index)
{
trackedDevice = new OpenVR.TrackedDevice(index);
}

public override void Update(GameTime gameTime)
{
if (trackedDevice != null)
{
Matrix mat;
Vector3 vel, angVel;
internalState = OpenVR.GetTrackerPose(trackedDevice.TrackerIndex, out mat, out vel, out angVel);
if (internalState != DeviceState.Invalid)
{
Vector3 scale;
mat.Decompose(out scale, out currentRot, out currentPos);
currentLinearVelocity = vel;
currentAngularVelocity = new Vector3(MathUtil.DegreesToRadians(angVel.X), MathUtil.DegreesToRadians(angVel.Y), MathUtil.DegreesToRadians(angVel.Z));
}
}

base.Update(gameTime);
}

public override Vector3 Position => currentPos;

public override Quaternion Rotation => currentRot;

public override Vector3 LinearVelocity => currentLinearVelocity;

public override Vector3 AngularVelocity => currentAngularVelocity;

public override DeviceState State => internalState;

public override DeviceClass Class => (DeviceClass)trackedDevice.DeviceClass;

public override string SerialNumber => trackedDevice.SerialNumber;

public override float BatteryPercentage => trackedDevice.BatteryPercentage;
}
}

#endif
35 changes: 35 additions & 0 deletions sources/engine/Xenko.VirtualReality/TrackedItem.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
// Copyright (c) Xenko contributors (https://xenko.com)
// Distributed under the MIT license. See the LICENSE.md file in the project root for more information.
using System;
using Xenko.Core.Mathematics;
using Xenko.Games;

namespace Xenko.VirtualReality
{
public abstract class TrackedItem : IDisposable
{
public abstract Vector3 Position { get; }

public abstract Quaternion Rotation { get; }

public abstract Vector3 LinearVelocity { get; }

public abstract Vector3 AngularVelocity { get; }

public abstract DeviceState State { get; }

public abstract DeviceClass Class { get; }

public abstract string SerialNumber { get; }

public abstract float BatteryPercentage { get; }

public virtual void Update(GameTime time)
{
}

public virtual void Dispose()
{
}
}
}
23 changes: 23 additions & 0 deletions sources/engine/Xenko.VirtualReality/TrackingSpace.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
// Copyright (c) Xenko contributors (https://xenko.com)
// Distributed under the MIT license. See the LICENSE.md file in the project root for more information.
namespace Xenko.VirtualReality
{
/// <summary>
/// Identifies which style of tracking origin the application wants to use for the poses it is requesting
/// </summary>
public enum TrackingSpace
{
/// <summary>
/// Poses are provided relative to the seated zero pose
/// </summary>
Seated,
/// <summary>
/// Poses are provided relative to the safe bounds configured by the user
/// </summary>
Standing,
/// <summary>
/// Poses are provided in the coordinate system defined by the driver. It has Y up and is unified for devices of the same driver. You usually don't want this one.
/// </summary>
RawAndUncalibrated
}
}
Loading