예제 #1
0
        public void Query_Topology_FindLargePositionsOnWalls()
        {
            // Setup
            //float minHeightOfWallSpace = 1.0f;
            //float minWidthOfWallSpace = 1.5f;
            //float minHeightAboveFloor = 1.5f;
            //float minFacingClearance = 0.5f;

            float minHeightOfWallSpace = 0.5f;
            float minWidthOfWallSpace  = 0.5f;
            float minHeightAboveFloor  = 1f;
            float minFacingClearance   = 0.5f;

            // Only if we're enabled
            if (!SpatialUnderstanding.Instance.AllowSpatialUnderstanding)
            {
                return;
            }

            // Query
            IntPtr resultsTopologyPtr = SpatialUnderstanding.Instance.UnderstandingDLL.PinObject(resultsTopology);
            int    locationCount      = SpatialUnderstandingDllTopology.QueryTopology_FindLargePositionsOnWalls(
                minHeightOfWallSpace, minWidthOfWallSpace, minHeightAboveFloor, minFacingClearance,
                resultsTopology.Length, resultsTopologyPtr);

            // Output
            HandleResults_Topology("Find Large Positions On Walls", locationCount, new Vector3(minWidthOfWallSpace, minHeightOfWallSpace, 0.025f), Color.yellow);
        }
예제 #2
0
    void Update()
    {
        if (SpatialUnderstanding.Instance.ScanState == SpatialUnderstanding.ScanStates.Done && !done)
        {
            SpatialUnderstandingDllTopology.TopologyResult[] result = new SpatialUnderstandingDllTopology.TopologyResult[1];
            System.IntPtr intptr        = SpatialUnderstanding.Instance.UnderstandingDLL.PinObject(result);
            int           locationCount = SpatialUnderstandingDllTopology.QueryTopology_FindLargePositionsOnWalls(0.1f, 0.1f, 0.0f, 0.2f, result.Length, intptr);

            if (locationCount > 0)
            {
                something.transform.position = result[0].position;
                Debug.Log(result[0].position);
                Debug.Log(result[0].length);
                Debug.Log(result[0].width);
                Debug.Log(result[0].normal);
                SpatialUnderstanding.Instance.UnderstandingDLL.UnpinAllObjects();

                done = true;
                Debug.Log("Retrieved spatial understanding position.");
            }
        }

        if (!scanDone && Time.fixedTime > 20.0f)
        {
            SpatialUnderstanding.Instance.RequestFinishScan();
            scanDone = true;
        }
    }
예제 #3
0
    public int RunQuery()
    {
        Results = new SpatialUnderstandingDllTopology.TopologyResult[_queryMaxResultCount];
        SpatialUnderstandingDllTopology.TopologyResult SingleResult = new SpatialUnderstandingDllTopology.TopologyResult();


        IntPtr resultsTopologyPtr = SpatialUnderstanding.Instance.UnderstandingDLL.PinObject(Results);
        IntPtr singleResultPtr    = SpatialUnderstanding.Instance.UnderstandingDLL.PinObject(SingleResult);

        int resultCount = 0;

        switch (Type)
        {
        case STTopologyQueryType.LargePositionsOnWalls:
            resultCount = SpatialUnderstandingDllTopology.QueryTopology_FindLargePositionsOnWalls(MinHeight, MinWidth, Wall_MinHeightAboveFloor, MinFacingClearance, Results.Length, resultsTopologyPtr);
            break;

        case STTopologyQueryType.LargestPositionsOnFloor:
            resultCount = SpatialUnderstandingDllTopology.QueryTopology_FindLargestPositionsOnFloor(Results.Length, resultsTopologyPtr);
            break;

        case STTopologyQueryType.LargestWall:
            resultCount = SpatialUnderstandingDllTopology.QueryTopology_FindLargestWall(singleResultPtr);
            Results     = new SpatialUnderstandingDllTopology.TopologyResult[] { SingleResult };
            break;

        case STTopologyQueryType.PositionsOnFloor:
            resultCount = SpatialUnderstandingDllTopology.QueryTopology_FindPositionsOnFloor(Floor_MinLength, MinWidth, Results.Length, resultsTopologyPtr);
            break;

        case STTopologyQueryType.PositionsOnWalls:
            resultCount = SpatialUnderstandingDllTopology.QueryTopology_FindPositionsOnWalls(MinHeight, MinWidth, Wall_MinHeightAboveFloor, MinFacingClearance, Results.Length, resultsTopologyPtr);
            break;

        case STTopologyQueryType.PositionsSittable:
            resultCount = SpatialUnderstandingDllTopology.QueryTopology_FindPositionsSittable(MinHeight, Sittable_MaxHeight, MinFacingClearance, Results.Length, resultsTopologyPtr);
            break;
        }

        List <SpatialUnderstandingDllTopology.TopologyResult> resultTemp = new List <SpatialUnderstandingDllTopology.TopologyResult>();

        for (int i = 0; i < resultCount; i++)
        {
            resultTemp.Add(Results[i]);
        }

        Results = resultTemp.ToArray();

        _hasRun = true;

        return(resultCount);
    }