forked from microsoft/MixedRealityToolkit-Unity
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathSpatialUnderstandingDllTopology.cs
143 lines (133 loc) · 8.81 KB
/
SpatialUnderstandingDllTopology.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License. See LICENSE in the project root for license information.
using UnityEngine;
using System.Collections;
using System.Runtime.InteropServices;
using System;
using System.Collections.Generic;
namespace HoloToolkit.Unity
{
/// <summary>
/// Encapsulates the topology queries of the understanding DLL.
/// These queries will not be valid until after scanning is finalized.
/// </summary>
public static class SpatialUnderstandingDllTopology
{
/// <summary>
/// Result of a topology query. Typically results return an array
/// of these structures.
/// </summary>
[StructLayout(LayoutKind.Sequential, Pack = 1)]
public struct TopologyResult
{
public Vector3 position;
public Vector3 normal;
public float width;
public float length;
};
// Functions
/// <summary>
/// Finds spaces on walls meeting the criteria specified by the parameters.
/// </summary>
/// <param name="minHeightOfWallSpace">Minimum height of space to be found by the query</param>
/// <param name="minWidthOfWallSpace">Minimum width of space to be found by the query</param>
/// <param name="minHeightAboveFloor">Minimum distance above the floor for the bottom edge of the space</param>
/// <param name="minFacingClearance">Minimum amount of space in front of the space</param>
/// <param name="locationCount">Number of location results supplied by the user in locationData</param>
/// <param name="locationData">Location result array of TopologyResult to be filled with the spaces found by the query</param>
/// <returns>Number of spaces found by the query. This value is limited by the number of results supplied by the caller (locationCount)</returns>
// Queries (topology)
[DllImport("SpatialUnderstanding", CallingConvention = CallingConvention.Cdecl)]
public static extern int QueryTopology_FindPositionsOnWalls(
[In] float minHeightOfWallSpace,
[In] float minWidthOfWallSpace,
[In] float minHeightAboveFloor,
[In] float minFacingClearance,
[In] int locationCount, // Pass in the space allocated in locationData
[In, Out] IntPtr locationData); // TopologyResult
/// <summary>
/// Finds only large spaces on walls meeting the criteria specified by the parameters.
/// </summary>
/// <param name="minHeightOfWallSpace">Minimum height of space to be found by the query</param>
/// <param name="minWidthOfWallSpace">Minimum width of space to be found by the query</param>
/// <param name="minHeightAboveFloor">Minimum distance above the floor for the bottom edge of the space</param>
/// <param name="minFacingClearance">Minimum amount of space in front of the space</param>
/// <param name="locationCount">Number of location results supplied by the user in locationData</param>
/// <param name="locationData">Location result array of TopologyResult to be filled with the spaces found by the query</param>
/// <returns>Number of spaces found by the query. This value is limited by the number of results supplied by the caller (locationCount)</returns>
[DllImport("SpatialUnderstanding", CallingConvention = CallingConvention.Cdecl)]
public static extern int QueryTopology_FindLargePositionsOnWalls(
[In] float minHeightOfWallSpace,
[In] float minWidthOfWallSpace,
[In] float minHeightAboveFloor,
[In] float minFacingClearance,
[In] int locationCount, // Pass in the space allocated in locationData
[In, Out] IntPtr locationData); // TopologyResult
/// <summary>
/// Finds the largest wall
/// </summary>
/// <param name="wall">Pointer to a TopologyResult structure, to be filled with the found wall</param>
/// <returns>Zero if fails, one if success</returns>
[DllImport("SpatialUnderstanding", CallingConvention = CallingConvention.Cdecl)]
public static extern int QueryTopology_FindLargestWall(
[In, Out] IntPtr wall); // TopologyResult
/// <summary>
/// Finds spaces on the floor meeting the criteria specified by the parameters.
/// </summary>
/// <param name="minLengthOfFloorSpace">Minimum length of space to be found by the query</param>
/// <param name="minWidthOfFloorSpace">Minimum width of space to be found by the query</param>
/// <param name="locationCount">Number of location results supplied by the user in locationData</param>
/// <param name="locationData">Location result array of TopologyResult to be filled with the spaces found by the query</param>
/// <returns>Number of spaces found by the query. This value is limited by the number of results supplied by the caller (locationCount)</returns>
[DllImport("SpatialUnderstanding", CallingConvention = CallingConvention.Cdecl)]
public static extern int QueryTopology_FindPositionsOnFloor(
[In] float minLengthOfFloorSpace,
[In] float minWidthOfFloorSpace,
[In] int locationCount, // Pass in the space allocated in locationData
[In, Out] IntPtr locationData); // TopologyResult
/// <summary>
/// Finds the largest spaces on the floor
/// </summary>
/// <param name="locationCount">Number of location results supplied by the user in locationData</param>
/// <param name="locationData">Location result array of TopologyResult to be filled with the spaces found by the query</param>
/// <returns>Number of spaces found by the query. This value is limited by the number of results supplied by the caller (locationCount)</returns>
[DllImport("SpatialUnderstanding", CallingConvention = CallingConvention.Cdecl)]
public static extern int QueryTopology_FindLargestPositionsOnFloor(
[In] int locationCount, // Pass in the space allocated in locationData
[In, Out] IntPtr locationData); // TopologyResult
/// <summary>
/// Finds good spaces for sitting or placing objects on surfaces.
/// </summary>
/// <param name="minHeight">Minimum height above the floor for a space</param>
/// <param name="maxHeight">Maximum height above the floor for a space</param>
/// <param name="minFacingClearance">Minimum clearance for the space above the placement surface (minimum space height)</param>
/// <param name="locationCount">Number of location results supplied by the user in locationData</param>
/// <param name="locationData">Location result array of TopologyResult to be filled with the spaces found by the query</param>
/// <returns>Number of spaces found by the query. This value is limited by the number of results supplied by the caller (locationCount)</returns>
[DllImport("SpatialUnderstanding", CallingConvention = CallingConvention.Cdecl)]
public static extern int QueryTopology_FindPositionsSittable(
[In] float minHeight,
[In] float maxHeight,
[In] float minFacingClearance,
[In] int locationCount, // Pass in the space allocated in locationData
[In, Out] IntPtr locationData); // TopologyResult
/// <summary>
/// Finds only large spaces on platforms meeting the criteria specified by the parameters.
/// </summary>
/// <param name="minHeight">Minimum height above the floor for a space</param>
/// <param name="maxHeight">Maximum height above the floor for a space</param>
/// <param name="minFacingClearance">Minimum clearance for the space above the placement surface (minimum space height)</param>
/// <param name="minWidth">Minimum required width on placement surface</param>
/// <param name="locationCount">Number of location results supplied by the user in locationData</param>
/// <param name="locationData">Location result array of TopologyResult to be filled with the spaces found by the query</param>
/// <returns>Number of spaces found by the query. This value is limited by the number of results supplied by the caller (locationCount)</returns>
[DllImport("SpatialUnderstanding")]
public static extern int QueryTopology_FindLargePositionsSittable(
[In] float minHeight,
[In] float maxHeight,
[In] float minFacingClearance,
[In] float minWidth,
[In] int locationCount, // Pass in the space allocated in locationData
[In, Out] IntPtr locationData); // TopologyResult
}
}