Hello everyone.

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.
Options

How do you get the vertex data from the spatial meshes?

edited May 2016 in Discussion

I'm trying to be able to do a couple of things.

  1. know where a point intersects the spatial meshes.
  2. place a virtual object on the floor.

I'm not using Unity.

I found the example in the Universal Windows Samples that shows the mesh.

How do I get any of the vertex data out of it, in order to, I guess, do triangle/ray intersection on it? (if this is the best way to find a point on the floor).

This is what I'm trying, but my array is just filled with mostly 0s and extremely large exponent numbers (mostly zeros though).

m_PositionFloats = ToArray(m_surfaceMesh->VertexPositions->Data, &m_PositionFloatsLength);

My ToArray function is defined by:
`

float* ToArray(Windows::Storage::Streams::IBuffer^ buffer, int* len)
{
auto reader = ::Windows::Storage::Streams::DataReader::FromBuffer(buffer);

int length = reader->UnconsumedBufferLength;
unsigned char* data = new unsigned char[length];
memset(data, 0, length);

reader->ReadBytes(Platform::ArrayReference<unsigned char>(&data[0], length));

float* floats = ToFloats(data, length);
*len = length / 2;

delete[]data;

return floats;

}
`

My ToFloats function is defined by:
`

float* ToFloats(unsigned char* data, int length)
{
int floatLength = length / 2;

float* floats = new float[floatLength];

uint16_t * p = reinterpret_cast<uint16_t *>(data);

for (int i = 0; i < floatLength /2; i++)
{
    uint16_t temp = p[i];
    uint16_t in = temp;

    uint32_t t1;
    uint32_t t2;
    uint32_t t3;

    t1 = in & 0x7fff;                       // Non-sign bits 
    t2 = in & 0x8000;                       // Sign bit 
    t3 = in & 0x7c00;                       // Exponent 

    t1 <<= 13;                              // Align mantissa on MSB 
    t2 <<= 16;                              // Shift sign bit into position 
    t3 >>= 8;


    t1 += 0x38000000;                       // Adjust bias 

    t1 = (t3 == 0 ? 0 : t1);                // Denormals-as-zero 

    if (t3 > 0)
    {
        t3 -= 15; // remove exponent bias for 16bit
        t3 += 127; // add exponent bias for 32bit
        t3 <<= 23;
        t1 |= t3;
    }


    t1 |= t2;                               // Re-insert sign bit 


    float f = *reinterpret_cast<float*>(&t1);

    floats[i] = f;
}

return floats;

}

`

Best Answer

Answers

  • Options

    BTW, writing your own physics can be a pretty daunting task. The UWP Marble Maze sample might help. I haven't tried, but you might be able to get the Bullet physics engine to work.

    ===
    This post provided as-is with no warranties and confers no rights. Using information provided is done at own risk.

    (Daddy, what does 'now formatting drive C:' mean?)

  • Options

    Thank you, Patrick. Huge help.

  • Options

    Any idea how to do this in c#? I"m trying to port the spatial meshes example to c# ....

  • Options

    I'm looking for FBX model import into c++ so that I'm not relying on Unity, and I'm interested to hear from anyone doing the same.

Sign In or Register to comment.