<?xml version="1.0" encoding="utf-8"?>
<feed xmlns="http://www.w3.org/2005/Atom">
	<title type="html"><![CDATA[Infinity Code Forum — Mixed Reality Toolkit?]]></title>
	<link rel="self" href="https://forum.infinity-code.com/extern.php?action=feed&amp;tid=1729&amp;type=atom" />
	<updated>2021-03-30T17:05:25Z</updated>
	<generator>PunBB</generator>
	<id>https://forum.infinity-code.com/viewtopic.php?id=1729</id>
		<entry>
			<title type="html"><![CDATA[Re: Mixed Reality Toolkit?]]></title>
			<link rel="alternate" href="https://forum.infinity-code.com/viewtopic.php?pid=7333#p7333" />
			<content type="html"><![CDATA[<p>I finally worked out a solution that is giving me what I was looking for, hopefully this helps someone down the road.</p><p>Attach this to an empty gameobject</p><div class="codebox"><pre><code>using Microsoft.MixedReality.Toolkit;
using Microsoft.MixedReality.Toolkit.Utilities;
using UnityEngine;

public class GetCoordHandler : MonoBehaviour
{
    private Vector3 gazePoint;

    private void Update()
    {
        // key z in editor, A button on xbox controller
        if (Input.GetKeyDown(KeyCode.Z) || Input.GetKeyDown(KeyCode.Joystick1Button0))
        {
            // make sure we have hit something
            if (CoreServices.InputSystem.GazeProvider.GazeTarget)
            {
                // grab where the gaze pointer is
                gazePoint = CoreServices.InputSystem.GazeProvider.HitInfo.point;
                // convert this position to screen coords and fire the method
                AddMarker(CameraCache.Main.WorldToScreenPoint(gazePoint));
        }
    }
}

private void AddMarker(Vector3 point)
{
    // Get the coordinates under the cursor.
    double lng, lat;
    // custom method that returns the coordinates
    OnlineMapsControlBase.instance.GetCoords_MRTK(point, out lng, out lat);

    // Create a label for the marker.
    string label = &quot;Marker: &quot; + (OnlineMapsMarkerManager.CountItems + 1);
    // Create a new marker.
    OnlineMapsMarkerManager.CreateItem(lng, lat, label);
 }
}</code></pre></div><p>And then we just need a custom method that will use the Vector3 we got from the gaze instead of the mouse</p><div class="codebox"><pre><code> public bool GetCoords_MRTK(Vector2 gazePosition, out double lng, out double lat)
 {
    return GetCoords(gazePosition, out lng, out lat);
 }</code></pre></div>]]></content>
			<author>
				<name><![CDATA[mcb]]></name>
				<uri>https://forum.infinity-code.com/profile.php?id=1341</uri>
			</author>
			<updated>2021-03-30T17:05:25Z</updated>
			<id>https://forum.infinity-code.com/viewtopic.php?pid=7333#p7333</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: Mixed Reality Toolkit?]]></title>
			<link rel="alternate" href="https://forum.infinity-code.com/viewtopic.php?pid=7287#p7287" />
			<content type="html"><![CDATA[<p>True it doesn&#039;t have GPS, but I can get it to render in the headset just fine, its interacting with the terrain that is proving illusive.</p><p>In the editor I can add markers, but running the app, not so much.</p><p>Anyways, I figured it was worth a shot asking</p>]]></content>
			<author>
				<name><![CDATA[mcb]]></name>
				<uri>https://forum.infinity-code.com/profile.php?id=1341</uri>
			</author>
			<updated>2021-03-22T18:03:11Z</updated>
			<id>https://forum.infinity-code.com/viewtopic.php?pid=7287#p7287</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: Mixed Reality Toolkit?]]></title>
			<link rel="alternate" href="https://forum.infinity-code.com/viewtopic.php?pid=7286#p7286" />
			<content type="html"><![CDATA[<p>Hello.</p><p>Unfortunately, I am not developing for AR / VR, and I just do not have these devices to explore it.<br />As far as I know, Hololens simply doesn&#039;t have a GPS to make it work.</p>]]></content>
			<author>
				<name><![CDATA[Alex Vertax]]></name>
				<uri>https://forum.infinity-code.com/profile.php?id=2</uri>
			</author>
			<updated>2021-03-22T17:55:10Z</updated>
			<id>https://forum.infinity-code.com/viewtopic.php?pid=7286#p7286</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Mixed Reality Toolkit?]]></title>
			<link rel="alternate" href="https://forum.infinity-code.com/viewtopic.php?pid=7283#p7283" />
			<content type="html"><![CDATA[<p>Hey devs, curious if you have had a chance to explore implementation with the Hololens MRTK yet? I&#039;m trying to port over some work I have done in webGL and android development with OnlineMaps as my boss now wants to see it in the headset.</p><p>Any guidance or advice you may have to offer would be appreciated as most of what I try to do has no effect yet.</p><p>Currently, I&#039;m trying to get it to where when I click on the terrain with the &quot;pointer&quot; that I return the GPS coordinates and the basic implementation from the atlas of examples isnt working, I assume because there is probably some piece connecting inputs that online maps is expecting and what MRTK is using.</p><p>Thanks in advance for any assistance</p>]]></content>
			<author>
				<name><![CDATA[mcb]]></name>
				<uri>https://forum.infinity-code.com/profile.php?id=1341</uri>
			</author>
			<updated>2021-03-22T16:03:04Z</updated>
			<id>https://forum.infinity-code.com/viewtopic.php?pid=7283#p7283</id>
		</entry>
</feed>
