Esempio n. 1
0
    public string CreateAnchor(Vec3 at, string id = null)
    {
        string anchorID = id == null
                        ? Guid.NewGuid().ToString()
                        : id;

        SpatialLocator locator = SpatialLocator.GetDefault();
        SpatialStationaryFrameOfReference stationary = locator.CreateStationaryFrameOfReferenceAtCurrentLocation();
        SpatialAnchor anchor = SpatialAnchor.TryCreateRelativeTo(stationary.CoordinateSystem);
        Pose          pose   = World.FromPerceptionAnchor(anchor);

        Pose newAnchor = pose.ToMatrix().Inverse.Transform(new Pose(at, Quat.Identity));

        anchor = SpatialAnchor.TryCreateRelativeTo(stationary.CoordinateSystem, newAnchor.position, newAnchor.orientation);
        pose   = World.FromPerceptionAnchor(anchor);

        if (anchor != null)
        {
            anchorPoses.Add(anchorID, pose);
        }

        return(anchorStore.TrySave(anchorID, anchor)
                        ? anchorID
                        : null);
    }
Esempio n. 2
0
        public void SetHolographicSpace(HolographicSpace holographicSpace)
        {
            this.holographicSpace = holographicSpace;

            //
            // TODO: Add code here to initialize your content.
            //
            // <<NEW>> Set up Event Sub Send
            this.eventHubSend = new EventHubSend();
            // try to send message as test
            Debug.WriteLine("EventHubSendStart:call");
            this.eventHubSend.EventHubSendStart();

#if DRAW_SAMPLE_CONTENT
            // Initialize the sample hologram.
            spinningCubeRenderer = new SpinningCubeRenderer(deviceResources);

            spatialInputHandler = new SpatialInputHandler();
#endif

            // Use the default SpatialLocator to track the motion of the device.
            locator = SpatialLocator.GetDefault();

            // Be able to respond to changes in the positional tracking state.
            locator.LocatabilityChanged += this.OnLocatabilityChanged;

            // Respond to camera added events by creating any resources that are specific
            // to that camera, such as the back buffer render target view.
            // When we add an event handler for CameraAdded, the API layer will avoid putting
            // the new camera in new HolographicFrames until we complete the deferral we created
            // for that handler, or return from the handler without creating a deferral. This
            // allows the app to take more than one frame to finish creating resources and
            // loading assets for the new holographic camera.
            // This function should be registered before the app creates any HolographicFrames.
            holographicSpace.CameraAdded += this.OnCameraAdded;

            // Respond to camera removed events by releasing resources that were created for that
            // camera.
            // When the app receives a CameraRemoved event, it releases all references to the back
            // buffer right away. This includes render target views, Direct2D target bitmaps, and so on.
            // The app must also ensure that the back buffer is not attached as a render target, as
            // shown in DeviceResources.ReleaseResourcesForBackBuffer.
            holographicSpace.CameraRemoved += this.OnCameraRemoved;

            // The simplest way to render world-locked holograms is to create a stationary reference frame
            // when the app is launched. This is roughly analogous to creating a "world" coordinate system
            // with the origin placed at the device's position as the app is launched.
            referenceFrame = locator.CreateStationaryFrameOfReferenceAtCurrentLocation();

            // Notes on spatial tracking APIs:
            // * Stationary reference frames are designed to provide a best-fit position relative to the
            //   overall space. Individual positions within that reference frame are allowed to drift slightly
            //   as the device learns more about the environment.
            // * When precise placement of individual holograms is required, a SpatialAnchor should be used to
            //   anchor the individual hologram to a position in the real world - for example, a point the user
            //   indicates to be of special interest. Anchor positions do not drift, but can be corrected; the
            //   anchor will use the corrected position starting in the next frame after the correction has
            //   occurred.
        }
Esempio n. 3
0
        public void SetHolographicSpace(HolographicSpace holographicSpace)
        {
            this.holographicSpace = holographicSpace;

            //Task.Factory.StartNew(RunAppScript).Wait();
            try
            {
                host      = new ChakraHost();
                appScript = System.IO.File.ReadAllText(@"Assets/js/app.js");
                host.SetHolographicSpace(this.holographicSpace);
                host.RunScript(appScript);
            }
            catch (Exception ex)
            {
                Debug.WriteLine(ex.Message);
            };

            // Use the default SpatialLocator to track the motion of the device.
            locator = SpatialLocator.GetDefault();

            // Be able to respond to changes in the positional tracking state.
            locator.LocatabilityChanged += this.OnLocatabilityChanged;

            // Respond to camera added events by creating any resources that are specific
            // to that camera, such as the back buffer render target view.
            // When we add an event handler for CameraAdded, the API layer will avoid putting
            // the new camera in new HolographicFrames until we complete the deferral we created
            // for that handler, or return from the handler without creating a deferral. This
            // allows the app to take more than one frame to finish creating resources and
            // loading assets for the new holographic camera.
            // This function should be registered before the app creates any HolographicFrames.
            holographicSpace.CameraAdded += this.OnCameraAdded;

            // Respond to camera removed events by releasing resources that were created for that
            // camera.
            // When the app receives a CameraRemoved event, it releases all references to the back
            // buffer right away. This includes render target views, Direct2D target bitmaps, and so on.
            // The app must also ensure that the back buffer is not attached as a render target, as
            // shown in DeviceResources.ReleaseResourcesForBackBuffer.
            holographicSpace.CameraRemoved += this.OnCameraRemoved;

            // The simplest way to render world-locked holograms is to create a stationary reference frame
            // when the app is launched. This is roughly analogous to creating a "world" coordinate system
            // with the origin placed at the device's position as the app is launched.
            referenceFrame = locator.CreateStationaryFrameOfReferenceAtCurrentLocation();

            // Notes on spatial tracking APIs:
            // * Stationary reference frames are designed to provide a best-fit position relative to the
            //   overall space. Individual positions within that reference frame are allowed to drift slightly
            //   as the device learns more about the environment.
            // * When precise placement of individual holograms is required, a SpatialAnchor should be used to
            //   anchor the individual hologram to a position in the real world - for example, a point the user
            //   indicates to be of special interest. Anchor positions do not drift, but can be corrected; the
            //   anchor will use the corrected position starting in the next frame after the correction has
            //   occurred.
        }
    private void SetHolographicSpace()
    {
        // from Holographic Face Tracking Example
        // Use the default SpatialLocator to track the motion of the device.
        m_locator = SpatialLocator.GetDefault();

        // The simplest way to render world-locked holograms is to create a stationary reference frame
        // when the app is launched. This is roughly analogous to creating a "world" coordinate system
        // with the origin placed at the device's position as the app is launched.
        m_referenceFrame = m_locator.CreateStationaryFrameOfReferenceAtCurrentLocation();
    }
Esempio n. 5
0
 private void OnLocated(SpatialLocator loc, object args)
 {
     if (frame != null || loc.Locatability != SpatialLocatability.PositionalTrackingActive)
     {
         return;
     }
     frame  = loc.CreateStationaryFrameOfReferenceAtCurrentLocation();
     anchor = SpatialAnchor.TryCreateRelativeTo(frame.CoordinateSystem);
     root   = World.FromPerceptionAnchor(anchor).ToMatrix();
     UpdateBounds(center, radius);
 }
Esempio n. 6
0
    //   int reconstructionID = 0;

    // initialization
    void Start()
    {
        locator = SpatialLocator.GetDefault();
        originFrameOfReference = locator.CreateStationaryFrameOfReferenceAtCurrentLocation();
        audioData         = GetComponent <AudioSource>();
        startHeadPosition = Camera.main.transform.position;
        newHeadPosition   = startHeadPosition;
        textMesh.text     = photoCount.ToString();

        Debug.Log("Airtap to start/stop capture");

        //CreateScene("Test");

        CreateFolder();

        gr              = new GestureRecognizer();
        gr.TappedEvent += Tap;
        gr.StartCapturingGestures();
    }
Esempio n. 7
0
        /// <summary>
        /// Initializes a new instance of the <see cref="SeeingSharpHolographicsSpacePainter"/> class.
        /// </summary>
        /// <param name="targetWindow">The target window into which to render.</param>
        public SeeingSharpHolographicsSpacePainter(CoreWindow targetWindow)
        {
            m_targetWindow = targetWindow;

            // Call generic initialization
            //  (choose device, create holographic space)
            InitializeHolographicSpace(targetWindow);

            // Use the default SpatialLocator to track the motion of the device.
            m_spatialLocator = SpatialLocator.GetDefault();

            // Be able to respond to changes in the positional tracking state.
            m_spatialLocator.LocatabilityChanged += this.OnSpatialLocator_LocatabilityChanged;

            // Respond to camera added events by creating any resources that are specific
            // to that camera, such as the back buffer render target view.
            // When we add an event handler for CameraAdded, the API layer will avoid putting
            // the new camera in new HolographicFrames until we complete the deferral we created
            // for that handler, or return from the handler without creating a deferral. This
            // allows the app to take more than one frame to finish creating resources and
            // loading assets for the new holographic camera.
            // This function should be registered before the app creates any HolographicFrames.
            m_holoSpace.CameraAdded += this.OnHoloSpace_CameraAdded;

            // Respond to camera removed events by releasing resources that were created for that
            // camera.
            // When the app receives a CameraRemoved event, it releases all references to the back
            // buffer right away. This includes render target views, Direct2D target bitmaps, and so on.
            // The app must also ensure that the back buffer is not attached as a render target, as
            // shown in DeviceResources.ReleaseResourcesForBackBuffer.
            m_holoSpace.CameraRemoved += this.OnHoloSpace_CameraRemoved;

            // The simplest way to render world-locked holograms is to create a stationary reference frame
            // when the app is launched. This is roughly analogous to creating a "world" coordinate system
            // with the origin placed at the device's position as the app is launched.
            m_referenceFrame = m_spatialLocator.CreateStationaryFrameOfReferenceAtCurrentLocation();
        }
Esempio n. 8
0
 public HoloLensCamera()
 {
     locator = SpatialLocator.GetDefault();
     originalFrameOfReference = locator.CreateStationaryFrameOfReferenceAtCurrentLocation();
 }
 public void ResetReferenceFrame()
 {
     // Allow user to reset the referenceFrame's location
     m_referenceFrame = m_locator.CreateStationaryFrameOfReferenceAtCurrentLocation();
 }
 // Summary:
 //      Handler for manipulation started events. Obtains the stationary frame of reference for the gesture.
 private void OnManipulationStarted(object sender, SpatialManipulationStartedEventArgs e)
 {
     // Manipulation has started - obtain the frame of reference relative to when the gesture began
     stationaryFrameOfReference = spatialLocator.CreateStationaryFrameOfReferenceAtCurrentLocation();
 }