Ejemplo n.º 1
0
    public void Query_Topology_FindPositionOnWall()
    {
        ClearGeometry();

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

        // Setup
        float minHeightOfWallSpace = 0.5f;
        float minWidthOfWallSpace  = 0.75f;
        float minHeightAboveFloor  = 1.25f;
        float minFacingClearance   = 1.5f;

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

        // Output
        HandleResults_Topology("Find Position On Wall", locationCount, new Vector3(minWidthOfWallSpace, minHeightOfWallSpace, 0.025f), Color.blue);
    }
Ejemplo n.º 2
0
    public void InstanciateObjectOnWall2()
    {
        const int QueryResultMaxCount = 512;

        SpatialUnderstandingDllTopology.TopologyResult[] _resultsTopology = new SpatialUnderstandingDllTopology.TopologyResult[QueryResultMaxCount];

        var minWidthOfWallSpace  = 0.1f;
        var minHeightAboveFloor  = 1f;
        var minHeightOfWallSpace = 1f;
        var minFacingClearance   = 0.1f;

        var resultsTopologyPtr = SpatialUnderstanding.Instance.UnderstandingDLL.PinObject(_resultsTopology);

        var locationCount = SpatialUnderstandingDllTopology.QueryTopology_FindPositionsOnWalls(
            minHeightOfWallSpace, minWidthOfWallSpace, minHeightAboveFloor, minFacingClearance,
            _resultsTopology.Length, resultsTopologyPtr);

        if (locationCount > 0)
        {
            Instantiate(this.FloorPrefab,
                        _resultsTopology[0].position,
                        Quaternion.LookRotation(_resultsTopology[0].normal, Vector3.up));
        }
        else
        {
            this.InstructionTextMesh.text = "I can't found the enough space to place the hologram on the Wall.";
        }
    }
Ejemplo n.º 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);
    }
Ejemplo n.º 4
0
    private void InstanciateObjectOnWall()
    {
        const int QueryResultMaxCount = 512;

        SpatialUnderstandingDllTopology.TopologyResult[] _resultsTopology = new SpatialUnderstandingDllTopology.TopologyResult[QueryResultMaxCount];

        var minWidthOfWallSpace  = 0.1f;
        var minHeightAboveFloor  = 1f;
        var minHeightOfWallSpace = 1f;
        var minFacingClearance   = 0.1f;

        var resultsTopologyPtr = SpatialUnderstanding.Instance.UnderstandingDLL.PinObject(_resultsTopology);
        var locationCount      = SpatialUnderstandingDllTopology.QueryTopology_FindPositionsOnWalls(
            minHeightOfWallSpace, minWidthOfWallSpace, minHeightAboveFloor, minFacingClearance,
            _resultsTopology.Length, resultsTopologyPtr);

        if (locationCount > 0)
        {
            Instantiate(this.WallPrefab,
                        _resultsTopology[0].position,
                        Quaternion.LookRotation(_resultsTopology[0].normal, Vector3.up));
        }
    }
Ejemplo n.º 5
0
    private void InstantiatePaintingsOnWalls()
    {
        // Shuffle the Tags List

        // Assign Tags to Paintings
        AssignTagsToPaintings(Keys, Tags, tagCaptions);

        //
        //  ALGORITHM FOR POSITIONING
        //
        // Add every gameobject that I want to show in a list
        GeneralLists();

        const int QueryResultMaxCount = 128;

        SpatialUnderstandingDllTopology.TopologyResult[] _resultsTopology = new SpatialUnderstandingDllTopology.TopologyResult[QueryResultMaxCount];
        var minHeightOfWallSpace = 0.5f;
        var minWidthOfWallSpace  = 0.5f;
        var minHeightAboveFloor  = 1.0f;
        var minFacingClearance   = 0.2f;

        var resultsTopologyPtr = SpatialUnderstanding.Instance.UnderstandingDLL.PinObject(_resultsTopology);
        var locationCount      = SpatialUnderstandingDllTopology.QueryTopology_FindPositionsOnWalls(minHeightOfWallSpace, minWidthOfWallSpace, minHeightAboveFloor, minFacingClearance, _resultsTopology.Length, resultsTopologyPtr);

        int lastIndex = 0;

        if (locationCount > 0)
        {
            //
            // Finding Position and rotation of Paintings
            //

            GlobalVariables.objPositions.Add(_resultsTopology[0].position);// first painting
            GlobalVariables.objRotations.Add(Quaternion.LookRotation(_resultsTopology[0].normal, Vector3.up));

            // last topology index is zero
            int paintCounter = 0;
            // for the rest paintings
            for (int i = 1; i < allPaintings.Count; i++)
            {
                // Checking every topology location
                for (int j = lastIndex + 1; j < locationCount; j++)
                {
                    // Check if this GameObject is too close with with the previous one
                    if (IsDistanceBetween(i, _resultsTopology[j].position))
                    {
                        // Assign positions
                        Vector3    pos = new Vector3(_resultsTopology[j].position.x, _resultsTopology[j].position.y, _resultsTopology[j].position.z);
                        Quaternion rot = Quaternion.LookRotation(_resultsTopology[j].normal, Vector3.up);

                        GlobalVariables.objPositions.Add(pos);
                        GlobalVariables.objRotations.Add(rot);// first painting

                        lastIndex = j;
                        break;
                    }
                }
            }

            for (int z = 0; z < allPaintings.Count; z++)
            {
                // Instantiate PAINTINGS
                if ((z - 1) % 3 == 0)
                {
                    paintingChildren[paintCounter].transform.position = GlobalVariables.objPositions[z];
                    paintingChildren[paintCounter].transform.rotation = GlobalVariables.objRotations[z];
                    InstantiatePaintingWithCaption(paintingChildren[paintCounter], paintingCaptions[paintCounter], Paintings[paintCounter]);

                    paintCounter++;
                }
                else
                {
                    // Position TAGS
                    if (z % 3 == 0)
                    {
                        paintingChildren[z / 3].GetComponent <ShowTags>().PositionTag(0, GlobalVariables.objPositions[z], GlobalVariables.objRotations[z]);
                    }
                    else
                    {
                        paintingChildren[z / 3].GetComponent <ShowTags>().PositionTag(1, GlobalVariables.objPositions[z], GlobalVariables.objRotations[z]);
                    }
                }
            }

            // Position the bag and its children
            bag.transform.position = new Vector3(0, 0, 1.0f);
            bag.transform.rotation = Quaternion.LookRotation(Vector3.forward);

            bag.GetComponent <TagsMenu>().PositionBag();

            // Instantiate Bars now that I have the Sizes of the painting objects (or box colliders)
            foreach (GameObject child in paintingChildren)
            {
                child.GetComponent <ShowTags>().InstantiateBars();
            }

            progressBar.SetActive(true);
            gameObject.GetComponent <GamingManager>().enabled = true;
        }
        else
        {
            this.InstructionTextMesh.text = "I can't find enough space to place the painting.";
        }
    }