Esempio n. 1
0
        public void Query_Shape_FindShapeHalfDims(string shapeName)
        {
            // Only if we're enabled
            if (!SpatialUnderstanding.Instance.AllowSpatialUnderstanding)
            {
                return;
            }

            // Query
            IntPtr resultsShapePtr = SpatialUnderstanding.Instance.UnderstandingDLL.PinObject(resultsShape);
            int    shapeCount      = SpatialUnderstandingDllShapes.QueryShape_FindShapeHalfDims(
                shapeName,
                resultsShape.Length, resultsShapePtr);

            // Output
            HandleResults_Shape("Find Shape Min/Max '" + shapeName + "'", shapeCount, Color.blue, new Vector3(0.25f, 0.025f, 0.25f));
        }
Esempio n. 2
0
    public int RunQuery()
    {
        Results = new SpatialUnderstandingDllShapes.ShapeResult[_queryMaxResultCount];

        IntPtr resultsShapePtr = SpatialUnderstanding.Instance.UnderstandingDLL.PinObject(Results);

        int shapeCount = 0;

        if (String.IsNullOrEmpty(ShapeName))
        {
            Debug.LogError("Empty shape name, cannot run query.");
            return(0);
        }

        switch (Type)
        {
        case STShapeQueryType.ShapeBounds:
            shapeCount = SpatialUnderstandingDllShapes.QueryShape_FindShapeHalfDims(ShapeName, Results.Length, resultsShapePtr);
            break;

        case STShapeQueryType.PositionsOnShape:
            shapeCount = SpatialUnderstandingDllShapes.QueryShape_FindPositionsOnShape(ShapeName, _minRadius, Results.Length, resultsShapePtr);
            break;
        }

        List <SpatialUnderstandingDllShapes.ShapeResult> resultTemp = new List <SpatialUnderstandingDllShapes.ShapeResult>();

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

        Results = resultTemp.ToArray();

        _hasRun = true;

        return(shapeCount);
    }
Esempio n. 3
0
    //Examples of ways to et locations and store them in location list.
    private IEnumerator GetSpawnLocations()
    {
        yield return(new WaitForSeconds(3));

        //IntPtr resultsTopologyPtr = SpatialUnderstanding.Instance.UnderstandingDLL.PinObject(resultsTopology);
        //int locationCount = SpatialUnderstandingDllTopology.QueryTopology_FindLargestPositionsOnFloor(
        //    resultsTopology.Length, resultsTopologyPtr);
        //Debug.Log(locationCount);
        //Debug.Log(resultsTopology[0].position);

        //END OF TEST EXAMPLES.. FINDING LOCATIONS FOR THE FLOOR NOW.
        SpatialUnderstandingDllObjectPlacement.Solver_RemoveAllObjects();
        SpaceVisualizer.Instance.ClearGeometry();
        IntPtr resultsTopologyPtr = SpatialUnderstanding.Instance.UnderstandingDLL.PinObject(resultsTopology);
        int    locationCount      = SpatialUnderstandingDllTopology.QueryTopology_FindPositionsOnFloor(
            GameManager.Instance.shipManager.shipMaxHeight, GameManager.Instance.shipManager.shipMinHeight,
            resultsTopology.Length, resultsTopologyPtr);

        foreach (SpatialUnderstandingDllTopology.TopologyResult potentialShipFloor in resultsTopology)
        {
            SpatialLocation shipFloor = new SpatialLocation();
            shipFloor.position = potentialShipFloor.position;
            shipFloor.normal   = potentialShipFloor.normal;
            shipFloor.name     = "shipFloor"; // this sould be a descriptive name of what positin is.
            spatialLocationList.Add(shipFloor);
        }

        // GETTING SPAWN LOCATION FOR GRID
        //    SpaceVisualizer.Instance.ClearGeometry();
        //    resultsTopologyPtr = SpatialUnderstanding.Instance.UnderstandingDLL.PinObject(resultsTopology);
        //    locationCount = SpatialUnderstandingDllTopology.QueryTopology_FindLargestPositionsOnFloor(
        //resultsTopology.Length, resultsTopologyPtr);

        //    SpatialLocation gridSittingLoc = new SpatialLocation();
        //    gridSittingLoc.position = resultsTopology[0].position;
        //    gridSittingLoc.normal = resultsTopology[0].normal;
        //    gridSittingLoc.name = "gridSittingLoc"; // this sould be a descriptive name of what positin is.
        //    spatialLocationList.Add(gridSittingLoc);


        //SpatialUnderstandingDllObjectPlacement.Solver_RemoveAllObjects();
        //SpaceVisualizer.Instance.ClearGeometry();
        //float sitMinHeight = 0f;
        //float sitMaxHeight = 1.2f;
        //float sitMinFacingClearance = 2f;
        //SpatialUnderstandingDllObjectPlacement.Solver_RemoveAllObjects();
        //resultsTopologyPtr = SpatialUnderstanding.Instance.UnderstandingDLL.PinObject(resultsTopology);
        //int locationCount3 = SpatialUnderstandingDllTopology.QueryTopology_FindPositionsSittable(
        //    sitMinHeight, sitMaxHeight, sitMinFacingClearance,
        //    resultsTopology.Length, resultsTopologyPtr);
        //SpatialLocation gridSittingLoc = new SpatialLocation();
        //gridSittingLoc.position = resultsTopology[0].position;
        //gridSittingLoc.normal = resultsTopology[0].normal;
        //gridSittingLoc.name = "gridSittingLoc"; // this sould be a descriptive name of what positin is.
        //spatialLocationList.Add(gridSittingLoc);



        SpatialUnderstandingDllObjectPlacement.Solver_RemoveAllObjects();
        SpaceVisualizer.Instance.ClearGeometry();
        IntPtr resultsShapePtr = SpatialUnderstanding.Instance.UnderstandingDLL.PinObject(resultsShape);
        int    shapeCount      = SpatialUnderstandingDllShapes.QueryShape_FindShapeHalfDims(
            "Grid",
            resultsShape.Length, resultsShapePtr);

        Debug.Log(resultsShape[0].position);
        Debug.Log(resultsShape[0].halfDims);
        SpatialLocation gridSittingLoc = new SpatialLocation();

        gridSittingLoc.position = resultsShape[0].position;
        gridSittingLoc.normal   = resultsShape[0].halfDims;
        gridSittingLoc.name     = "gridSittingLoc"; // this sould be a descriptive name of what positin is.
        spatialLocationList.Add(gridSittingLoc);
        yield return(null);
    }