Simulated head position

Hi,Alex
I wanted to debug the program without the zSpace screen, but on a normal PC the image is tilted.The development documentation describes a scheme for simulating header Positon.

void SetFrustumHeadPose(IntPtr frustumHandle, Pose headPose)
Pose GetFrustumHeadPose()
Pose GetFrustumHeadPose(IntPtr frustumHandle)

But I did not succeed in using it. Is there any case or script that can help me solve this problem?
(zSpace200,zCore5.0)

Hi there,

Your frustrations are understandable. The plugin isn’t explicitly designed to support custom head poses. If you want to try this regardless, there are two issues to overcome.

Be sure that zcore.EnableAutoStereo is set to false. If it’s set to true, it will constantly overwrite any poses submitted through SetFrustumHeadPose() even if there is no head being tracked.

The frustumHandle argument isn’t readily accessible through ZCore.cs. You could to modify it by adding a public method that returns it for you.

public IntPtr GetFrustumHandle(){
    return GlobalState.Instance.FrustumHandle;
}

Here’s a sample monobehavior that demonstrates setting custom head poses with the above changes applied.

using System;
using UnityEngine;
using zSpace.Core;

public class PoseModifyTest : MonoBehaviour
{

    void Start()
    {
        this._core = GameObject.FindObjectOfType<ZCore>();
        this._core.EnableAutoStereo = false;
        this._frustumHandle = this._core.GetFrustumHandle();
    }

    void Update()
    {
        Matrix4x4 poseMtx = Matrix4x4.TRS(this.transform.position, Quaternion.identity,
            Vector3.one);

        ZCore.Pose customPose =
            new ZCore.Pose(poseMtx, 0.0f, ZCore.CoordinateSpace.Tracker);

        this._core.SetFrustumHeadPose(
            this._frustumHandle, customPose);
    }

    private ZCore _core;
    private IntPtr _frustumHandle;
}

I have not thoroughly tested this, and tracked head poses will still override custom poses, and there could be other caveats I didn’t encounter in my brief experimentation, but hopefully this helps you move forward.

Alex S.

Hi Alex:
I tested the code and printed the header position on the console,and tried to make some changes.It works, but the image doesn’t change, and it’s still tilted.Did you show the image at the right Angle during the test?Or maybe I need to test another strategy.

Yes, the angle changes for me. The pose changes as the position of the GameObject that the script is attached to changes.

The changes will only be visible in zCore’s custom stereo preview window. I suspect that window may not work or be available to you if you’re not using a zSpace display.

In that case, I recommend looking at the script mentioned in this post.

You can use that script to clone zCore’s private internal cameras. When they instantiate on play, tag one of them as the “MainCamera” and you should see the results inside Unity’s standard game view.

Thank you Alex,
I did see the right image through zSpace preview window, and the skewed image was a problem in the game window.