The Mixed Reality Forums here are no longer being used or maintained.
There are a few other places we would like to direct you to for support, both from Microsoft and from the community.
The first way we want to connect with you is our mixed reality developer program, which you can sign up for at https://aka.ms/IWantMR.
For technical questions, please use Stack Overflow, and tag your questions using either hololens or windows-mixed-reality.
If you want to join in discussions, please do so in the HoloDevelopers Slack, which you can join by going to https://aka.ms/holodevelopers, or in our Microsoft Tech Communities forums at https://techcommunity.microsoft.com/t5/mixed-reality/ct-p/MicrosoftMixedReality.
And always feel free to hit us up on Twitter @MxdRealityDev.
Adding spacial mapping to DirectX project in C#
Hey there, I am trying to implement spacial mapping in my DirectX holographic C# project but the only example Microsoft have is in C++. From some searching I can't seem to find any examples in C# and I have never touched C++ so it's going to take me quite a while to get through the explanation and essentially convert it to C#. Has anyone already done this and could provide me with some examples and source code? Or directions on where to start?
Any help is immensely appreciated.
Thanks, Shayne
Best Answer
-
Options
Hi @ShayneKiekebosch ,
The SubResource Data structure is just a buffer describing some buffer array of data you want to pass into the DX Pipeline buffers you have in your shaders. In the case of the C++ UWP Spatial Mapping example it's the texture coordinates. In your C# SharpDX example it just needs to be a DataBox containing those texture coordinates. Pass in the DataBox into the SharpDX.Direct3D11.Buffer.Create() (Upgrade to SharpDX 3.1 in NuGet). Actually I haven't tried the update on HoloLens yet. You can also just pass in the DataBox into the create method as one of the parameters (w/o update).
Again this example shows you how to use the DataBox.
I'll see if I can get an example up this weekend.
Dwight Goins
CAO & Founder| Independent Architect | Trainer and Consultant | Sr. Enterprise Architect
MVP | MCT | MCSD | MCPD | SharePoint TS | MS Virtual TS |Windows 8 App Store Developer | Linux Gentoo Geek | Raspberry Pi Owner | Micro .Net Developer | Kinect For Windows Device Developer
http://dgoins.wordpress.com5
Answers
Hi @ShayneKiekebosch ,
Have you looked at this C# sample. It should help you get started. It's not spatial mapping but it shows how you get a texture and apply it to a cube model. It should show how to use SharpDX so you can convert the calls properly using the Spatial Mapping example.
Dwight Goins
CAO & Founder| Independent Architect | Trainer and Consultant | Sr. Enterprise Architect
MVP | MCT | MCSD | MCPD | SharePoint TS | MS Virtual TS |Windows 8 App Store Developer | Linux Gentoo Geek | Raspberry Pi Owner | Micro .Net Developer | Kinect For Windows Device Developer
http://dgoins.wordpress.com
Thanks for the reply @Dwight_Goins_EE_MVP,
This doesn't really answer my question though. I already have a DirectX holographic project that applies textures etc. I have started converting some of the C++ code but I am now stuck on finding the
D3D11_SUBRESOURCE_DATA bufferBytes = { GetDataFromIBuffer(buffer), 0, 0 };
in the CreateDirectXBuffer method. I can't seem to find the correct one in SharpDX.Direct3D11.
I have found others like the
CD3D11_BUFFER_DESC bufferDescription(buffer->Length, binding);
which was
SharpDX.Direct3D11.BufferDescription = new BufferDescription((int)buffer.Length, binding, ResourceUsage.Default);
in C#.
Hi @ShayneKiekebosch ,
The SubResource Data structure is just a buffer describing some buffer array of data you want to pass into the DX Pipeline buffers you have in your shaders. In the case of the C++ UWP Spatial Mapping example it's the texture coordinates. In your C# SharpDX example it just needs to be a DataBox containing those texture coordinates. Pass in the DataBox into the SharpDX.Direct3D11.Buffer.Create() (Upgrade to SharpDX 3.1 in NuGet). Actually I haven't tried the update on HoloLens yet. You can also just pass in the DataBox into the create method as one of the parameters (w/o update).
Again this example shows you how to use the DataBox.
I'll see if I can get an example up this weekend.
Dwight Goins
CAO & Founder| Independent Architect | Trainer and Consultant | Sr. Enterprise Architect
MVP | MCT | MCSD | MCPD | SharePoint TS | MS Virtual TS |Windows 8 App Store Developer | Linux Gentoo Geek | Raspberry Pi Owner | Micro .Net Developer | Kinect For Windows Device Developer
http://dgoins.wordpress.com