Hey all,
I’m having issues with hologram stability.
I’ve got an empty unity scene with a plane world anchored 2 metres from the camera.
When SetFocusPointForFrame is not set, the plane is stable from a distance and fairly stable at arm’s length.
When SetFocusPointForFrame is set, the plane oscillates at arm’s length (1m - 50cm range) and at a distance.
The code is below. Please let me know if I am missing something, but it appears that setting a focus point makes things worse, not better.
Unity version: 2017.3.0p3
Windows SDK: 10.0.16299.0
Many thanks,
Harrison
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using HoloToolkit.Unity.InputModule;
using HoloToolkit.Unity;
using HoloToolkit.Unity.SpatialMapping;
using HoloLensXboxController;
using UnityEngine.XR.WSA.Input;
using UnityEngine.XR.WSA;
using UnityEngine.UI;
public class StabilisingTest : MonoBehaviour
{
// Use this for initialization
public GameObject plane;
GestureRecognizer gr;
GazeStabilizer gs;
Transform CamTran;
public Text Label;
bool focusPointSet = false;
void Start()
{
CamTran = Camera.main.transform;
gs = new GazeStabilizer();
gr = new GestureRecognizer();
gr.SetRecognizableGestures(GestureSettings.Tap);
gr.StartCapturingGestures();
gr.Tapped += Gr_Tapped;
plane.transform.position = CamTran.position + (CamTran.forward * 2f);
WorldAnchorManager.Instance.AttachAnchor(plane);
SpatialMappingManager.Instance.DrawVisualMeshes = false;
SpatialMappingManager.Instance.StopObserver();
}
//https://docs.unity3d.com/550/Documentation/ScriptReference/VR.WSA.HolographicSettings.SetFocusPointForFrame.html
void Update()
{
TappedEventArgs x = new TappedEventArgs();
if (Input.GetKeyDown(KeyCode.T))
Gr_Tapped(x);
var normal = -Camera.main.transform.forward; // Normally the normal is best set to be the opposite of the main camera's forward vector
// If the content is actually all on a plane (like text), set the normal to the normal of the plane
// and ensure the user does not pass through the plane
var position = plane.transform.position;
if(focusPointSet)
{
HolographicSettings.SetFocusPointForFrame(position, normal);
}
}
private void Gr_Tapped(TappedEventArgs obj)
{
if (!focusPointSet)
{
Label.text = "Focus point set!";
focusPointSet = true;
}
else
{
Label.text = "Focus point not set!";
focusPointSet = false;
}
}
}