Example #1
0
    public void CreateScene()
    {
        if (!SpatialUnderstanding.Instance.AllowSpatialUnderstanding)
        {
            return;
        }

        //在扫描阶段完成、场景敲定后,初始化物体放置解析器。
        SpatialUnderstandingDllObjectPlacement.Solver_Init();

        SpatialUnderstandingState.Instance.SpaceQueryDescription = "Generating World";


        List <PlacementQuery> queries = new List <PlacementQuery>();

        if (DrawBuildings)
        {
            //AddRange()方法,可加入多个元素。可以枚举类型或表类型
            queries.AddRange(AddBuildings());
        }

        if (DrawTrees)
        {
            queries.AddRange(AddTrees());
        }


        GetLocationsFromSolver(queries);
    }
Example #2
0
    public void CreateScene()
    {
        // Only if we're enabled
        if (!SpatialUnderstanding.Instance.AllowSpatialUnderstanding)
        {
            return;
        }

        SpatialUnderstandingDllObjectPlacement.Solver_Init();

        SpatialUnderstandingState.Instance.SpaceQueryDescription = "Generating World";

        List <PlacementQuery> queries = new List <PlacementQuery>();

        if (DrawCowboy)
        {
            queries.AddRange(AddCowboy());
        }

        if (DrawBuildings)
        {
            queries.AddRange(AddBuildings());
        }

        if (DrawTrees)
        {
            queries.AddRange(AddTrees());
        }

        GetLocationsFromSolver(queries);
    }
 void OnDestroy()
 {
     if (!String.IsNullOrEmpty(PlacedObjectName))
     {
         SpatialUnderstandingDllObjectPlacement.Solver_RemoveObject(PlacedObjectName);
     }
 }
Example #4
0
    private bool TryPlaceObject(
        out SpatialUnderstandingDllObjectPlacement.ObjectPlacementResult placementResult,
        string placementName,
        PlacementQuery query)
    {
        placementResult = null;
        if (!useSpatialUnderstanding)
        {
            return(false);
        }
        int result = SpatialUnderstandingDllObjectPlacement.Solver_PlaceObject(
            placementName,
            SpatialUnderstanding.Instance.UnderstandingDLL.PinObject(query.placementDefinition),
            (query.placementRules != null) ? query.placementRules.Count : 0,
            ((query.placementRules != null) && (query.placementRules.Count > 0)) ? SpatialUnderstanding.Instance.UnderstandingDLL.PinObject(query.placementRules.ToArray()) : IntPtr.Zero,
            (query.placementConstraints != null) ? query.placementConstraints.Count : 0,
            ((query.placementConstraints != null) && (query.placementConstraints.Count > 0)) ? SpatialUnderstanding.Instance.UnderstandingDLL.PinObject(query.placementConstraints.ToArray()) : IntPtr.Zero,
            SpatialUnderstanding.Instance.UnderstandingDLL.GetStaticObjectPlacementResultPtr());

        if (result > 0)
        {
            placementResult = SpatialUnderstanding.Instance.UnderstandingDLL.GetStaticObjectPlacementResult();
            return(true);
        }
        return(false);
    }
Example #5
0
    private bool TryPlaceObject(
        out SpatialUnderstandingDllObjectPlacement.ObjectPlacementResult placementResult,
        string placementName,
        SpatialUnderstandingDllObjectPlacement.ObjectPlacementDefinition placementDefinition,
        List <Rule> rules = null)
    {
        placementResult = null;
        List <SpatialUnderstandingDllObjectPlacement.ObjectPlacementRule>       placementRules       = new List <SpatialUnderstandingDllObjectPlacement.ObjectPlacementRule>();
        List <SpatialUnderstandingDllObjectPlacement.ObjectPlacementConstraint> placementConstraints = new List <SpatialUnderstandingDllObjectPlacement.ObjectPlacementConstraint>();

        if (rules != null)
        {
            foreach (Rule rule in rules)
            {
                rule.AddTo(placementRules);
                rule.AddTo(placementConstraints);
            }
        }
        int result = SpatialUnderstandingDllObjectPlacement.Solver_PlaceObject(
            placementName,
            SpatialUnderstanding.Instance.UnderstandingDLL.PinObject(placementDefinition),
            placementRules.Count,
            placementRules.Count > 0 ? SpatialUnderstanding.Instance.UnderstandingDLL.PinObject(placementRules.ToArray()) : IntPtr.Zero,
            placementConstraints.Count,
            placementConstraints.Count > 0 ? SpatialUnderstanding.Instance.UnderstandingDLL.PinObject(placementConstraints.ToArray()) : IntPtr.Zero,
            SpatialUnderstanding.Instance.UnderstandingDLL.GetStaticObjectPlacementResultPtr());

        if (result > 0)
        {
            placementResult = SpatialUnderstanding.Instance.UnderstandingDLL.GetStaticObjectPlacementResult();
            return(true);
        }
        return(false);
    }
Example #6
0
    /*
     * Est appelé par SpatialUnderstandingUniqueState
     * Lance la création de la scéne avec ses objets
     */
    public bool CreateScene()
    {
        // Only if we're enabled
        if (!SpatialUnderstanding.Instance.AllowSpatialUnderstanding)
        {
            return(false);
        }

        if (SpatialUnderstandingDllObjectPlacement.Solver_Init() > 0)
        {
            BillboardScript.Instance.SpaceQueryDescription = "Generating World";

            /*Liste des contraintes*/
            List <PlacementQuery> queries = new List <PlacementQuery>();

            if (DrawObjects)
            {
                queries.AddRange(AddObjects());
            }

            GetLocationsFromSolver(queries);
            return(true);
        }
        return(false);
    }
Example #7
0
    public void CreateScene()
    {
        if (!SpatialUnderstanding.Instance.AllowSpatialUnderstanding)
        {
            return;
        }

        if (!solverInit)
        {
            SpatialUnderstandingDllObjectPlacement.Solver_Init();
            solverInit = true;
        }

        List <PlacementQuery> queries = new List <PlacementQuery>();

        queries.AddRange(AddTree());
        Vector3 cameraPos = Camera.main.transform.position;
        Vector3 angles    = Camera.main.transform.eulerAngles;
        Vector3 pos       = new Vector3(cameraPos.x + Mathf.Sin((angles.y) * Mathf.Deg2Rad) * 1.5f,
                                        cameraPos.y,
                                        cameraPos.z + Mathf.Cos((angles.y) * Mathf.Deg2Rad) * 1.5f);
        Quaternion rot = Quaternion.LookRotation(Camera.main.transform.forward, Vector3.up);

        ObjectCollectionManager.Instance.CreateGate(pos, rot); //queries.AddRange(AddGate());
        GetLocationsFromSolver(queries);
    }
Example #8
0
    private PlacementResult PlaceObject(string placementName,
                                        SpatialUnderstandingDllObjectPlacement.ObjectPlacementDefinition placementDefinition,
                                        Vector3 boxFullDims,
                                        ObjectType objType,
                                        List <SpatialUnderstandingDllObjectPlacement.ObjectPlacementRule> placementRules             = null,
                                        List <SpatialUnderstandingDllObjectPlacement.ObjectPlacementConstraint> placementConstraints = null)

    {
        //Solver_PlaceObject()返回0代表失败,返回1代表成功
        //故判断是否大于0,成功则获取放置结果
        //PinObject直接返回指定的物体在内存中的位置
        if (SpatialUnderstandingDllObjectPlacement.Solver_PlaceObject(
                placementName,
                SpatialUnderstanding.Instance.UnderstandingDLL.PinObject(placementDefinition),
                (placementRules != null) ? placementRules.Count : 0,
                ((placementRules != null) && (placementRules.Count > 0)) ? SpatialUnderstanding.Instance.UnderstandingDLL.PinObject(placementRules.ToArray()) : IntPtr.Zero,
                (placementConstraints != null) ? placementConstraints.Count : 0,
                (placementConstraints != null) && (placementConstraints.Count > 0)?SpatialUnderstanding.Instance.UnderstandingDLL.PinObject(placementConstraints.ToArray()):IntPtr.Zero,
                SpatialUnderstanding.Instance.UnderstandingDLL.GetStaticObjectPlacementResultPtr())
            > 0)
        {
            SpatialUnderstandingDllObjectPlacement.ObjectPlacementResult placementResult = SpatialUnderstanding.Instance.UnderstandingDLL.GetStaticObjectPlacementResult();

            return(new PlacementResult(placementResult.Clone() as SpatialUnderstandingDllObjectPlacement.ObjectPlacementResult, boxFullDims, objType));
        }
        return(null);
    }
Example #9
0
 public void DestroyObjects()
 {
     if (_init)
     {
         SpatialUnderstandingDllObjectPlacement.Solver_RemoveObject(Prefab.name);
     }
 }
 void ResetObjects()
 {
     SpatialUnderstandingDllObjectPlacement.Solver_RemoveAllObjects();
     foreach (GameObject g in GameObject.FindGameObjectsWithTag("TestCube"))
     {
         Destroy(g);
     }
 }
Example #11
0
    private void Update()
    {
        if (m_scanningComplete)
        {
            return;
        }
        switch (m_spatialUnderstandingState)
        {
        case SpatialUnderstandingState.FinalizeScan:
            //TODO: timeout?
            if (!m_spatialUnderstanding.ScanStatsReportStillWorking)
            {
                Debug.Log("Finalizing scan...");
                m_spatialUnderstanding.RequestFinishScan();
                m_spatialUnderstandingState = SpatialUnderstandingState.WaitingForScanCompletion;
            }
            break;

        case SpatialUnderstandingState.WaitingForMeshImport:
            //TODO: timeout?
            if (m_spatialUnderstanding.UnderstandingCustomMesh.IsImportActive == false)
            {
                Debug.Log("Found " + m_spatialUnderstanding.UnderstandingCustomMesh.GetMeshFilters().Count + " meshes (import active=" + m_spatialUnderstanding.UnderstandingCustomMesh.IsImportActive + ")");
                if (!visualizeSpatialMeshes)
                {
                    HideSpatialMappingMeshes();
                }
                if (!visualizeSpatialUnderstandingMeshes)
                {
                    SetSpatialUnderstandingMaterial(occlusionMaterial);
                }
                SurfacePlaneDeformationManager.Instance.SetSpatialMeshFilters(m_spatialUnderstanding.UnderstandingCustomMesh.GetMeshFilters());
                m_spatialUnderstandingState = SpatialUnderstandingState.WaitingForPlacementSolverInit;
            }
            break;

        case SpatialUnderstandingState.WaitingForPlacementSolverInit:
            //TODO: error checking and timeout?
            if (!m_placementSolverInitialized)
            {
                m_placementSolverInitialized = (SpatialUnderstandingDllObjectPlacement.Solver_Init() == 1);
                Debug.Log("Placement Solver initialization " + (m_placementSolverInitialized ? "succeeded" : "FAILED"));
                if (m_placementSolverInitialized)
                {
                    if (OnScanComplete != null)
                    {
                        OnScanComplete();
                    }
                    m_scanningComplete          = true;
                    m_spatialUnderstandingState = SpatialUnderstandingState.Finished;
                }
            }
            break;

        default:
            break;
        }
    }
Example #12
0
    void Reset()
    {
        queryPlacementResults.Clear();

        if (SpatialUnderstanding.Instance.AllowSpatialUnderstanding)
        {
            SpatialUnderstandingDllObjectPlacement.Solver_RemoveAllObjects();
        }
    }
 public void ClearGeometry(bool clearAll = true)
 {
     placementResults.Clear();
     if (SpatialUnderstanding.Instance.AllowSpatialUnderstanding)
     {
         SpatialUnderstandingDllObjectPlacement.Solver_RemoveAllObjects();
     }
     SpatialScanManager.Instance.ObjectPlacementDescription = "";
 }
Example #14
0
 public void Init_Spawner()
 {
     if (SpatialUnderstanding.Instance.ScanState == SpatialUnderstanding.ScanStates.Done)
     {
         SpatialUnderstandingDllObjectPlacement.Solver_Init();
         _init = true;
         Spawn();
     }
 }
Example #15
0
    private bool PlaceObject(
        string placementName,
        GameObject input,
        SpatialUnderstandingDllObjectPlacement.ObjectPlacementDefinition placementDefinition,
        List <SpatialUnderstandingDllObjectPlacement.ObjectPlacementRule> placementRules             = null,
        List <SpatialUnderstandingDllObjectPlacement.ObjectPlacementConstraint> placementConstraints = null,
        bool clearObjectsFirst = true,
        bool isASync           = false)
    {
        isASync = false;
        // Clear objects (if requested)
        if (!isASync && clearObjectsFirst)
        {
        }
        if (!SpatialUnderstanding.Instance.AllowSpatialUnderstanding)
        {
            return(false);
        }

        // New query
        if (SpatialUnderstandingDllObjectPlacement.Solver_PlaceObject(
                placementName,
                SpatialUnderstanding.Instance.UnderstandingDLL.PinObject(placementDefinition),
                (placementRules != null) ? placementRules.Count : 0,
                ((placementRules != null) && (placementRules.Count > 0)) ? SpatialUnderstanding.Instance.UnderstandingDLL.PinObject(placementRules.ToArray()) : IntPtr.Zero,
                (placementConstraints != null) ? placementConstraints.Count : 0,
                ((placementConstraints != null) && (placementConstraints.Count > 0)) ? SpatialUnderstanding.Instance.UnderstandingDLL.PinObject(placementConstraints.ToArray()) : IntPtr.Zero,
                SpatialUnderstanding.Instance.UnderstandingDLL.GetStaticObjectPlacementResultPtr()) > 0)
        {
            SpatialUnderstandingDllObjectPlacement.ObjectPlacementResult placementResult = SpatialUnderstanding.Instance.UnderstandingDLL.GetStaticObjectPlacementResult();
            if (!isASync)
            {
                // Add to instantiation list here

                // If not running async, we can just add the results to the draw list right now
                AppState.Instance.ObjectPlacementDescription = placementName + " (1)";

                placementResults.Add(new PlacementResult(input, 1.0f, placementResult.Clone() as SpatialUnderstandingDllObjectPlacement.ObjectPlacementResult));
                Quaternion thisRotation = Quaternion.LookRotation(placementResult.Forward, placementResult.Up);
                //print("Space Found");
                objectsToMake.Add(new ObjectToInstantiate(input, placementResult.Position, thisRotation));
                //print(objectsToMake.Count);
            }
            else
            {
                queryStatus.QueryResult.Add(placementResult.Clone() as SpatialUnderstandingDllObjectPlacement.ObjectPlacementResult);
            }
            return(true);
        }
        if (!isASync)
        {
            print("No Spaces Found!");
            AppState.Instance.ObjectPlacementDescription = "Placement Failed";
        }
        return(false);
    }
Example #16
0
 public bool InitializeSolver()
 {
     if (IsSolverInitialized || !SpatialUnderstanding.Instance.AllowSpatialUnderstanding)
     {
         return(IsSolverInitialized);
     }
     if (SpatialUnderstandingDllObjectPlacement.Solver_Init() == 1)
     {
         IsSolverInitialized = true;
     }
     return(IsSolverInitialized);
 }
Example #17
0
 static bool Init()
 {
     if (solverInitialized)
     {
         return(true);
     }
     if (SpatialUnderstandingDllObjectPlacement.Solver_Init() == 1)
     {
         solverInitialized = true;
     }
     return(solverInitialized);
 }
Example #18
0
    private IEnumerator InitSolverCoroutine()
    {
        int retval = 0;
        Job job    = new Job(() => { retval = SpatialUnderstandingDllObjectPlacement.Solver_Init(); });

        job.Execute();
        while (!job.Finished())
        {
            yield return(null);
        }
        Debug.Log("Placement Solver initialization " + (retval == 1 ? "succeeded" : "FAILED"));
        m_solverInitialized = true;
    }
Example #19
0
    public void CreateMenu()
    {
        if (!SpatialUnderstanding.Instance.AllowSpatialUnderstanding)
        {
            return;
        }

        if (!solverInit)
        {
            SpatialUnderstandingDllObjectPlacement.Solver_Init();
            solverInit = true;
        }
        GetLocationsFromSolver(AddMenu());
    }
Example #20
0
        public void ClearGeometry(bool clearAll = true)
        {
            placementResults.Clear();
            if (SpatialUnderstanding.Instance.AllowSpatialUnderstanding)
            {
                SpatialUnderstandingDllObjectPlacement.Solver_RemoveAllObjects();
            }
            AppState.Instance.ObjectPlacementDescription = "";

            if (clearAll && (SpaceVisualizer.Instance != null))
            {
                SpaceVisualizer.Instance.ClearGeometry(false);
            }
        }
Example #21
0
    public void CreateScene(int targets)
    {
        if (!SpatialUnderstanding.Instance.AllowSpatialUnderstanding)
        {
            return;
        }

        SpatialUnderstandingDllObjectPlacement.Solver_Init();

        List <PlacementQuery> queries = new List <PlacementQuery>();

        queries.AddRange(AddTargets(targets));
        GetLocationsFromSolver(queries);
    }
Example #22
0
    public void CreateScene()
    {
        // Only if we're enabled
        if (!SpatialUnderstanding.Instance.AllowSpatialUnderstanding)
        {
            return;
        }

        SpatialUnderstandingDllObjectPlacement.Solver_Init();

        SpatialUnderstandingState.Instance.SpaceQueryDescription = "Generating World";

        InvokeRepeating("CreateSceneObjects", spawnTime, spawnTime);
        //CreateSceneObjects();
    }
Example #23
0
        private bool PlaceObject(
            string placementName,
            SpatialUnderstandingDllObjectPlacement.ObjectPlacementDefinition placementDefinition,
            List <SpatialUnderstandingDllObjectPlacement.ObjectPlacementRule> placementRules             = null,
            List <SpatialUnderstandingDllObjectPlacement.ObjectPlacementConstraint> placementConstraints = null,
            bool clearObjectsFirst = true,
            bool isASync           = false)
        {
            // Clear objects (if requested)
            if (!isASync && clearObjectsFirst)
            {
                ClearGeometry();
            }
            if (!SpatialUnderstanding.Instance.AllowSpatialUnderstanding)
            {
                return(false);
            }

            // New query
            if (SpatialUnderstandingDllObjectPlacement.Solver_PlaceObject(
                    placementName,
                    SpatialUnderstanding.Instance.UnderstandingDLL.PinObject(placementDefinition),
                    (placementRules != null) ? placementRules.Count : 0,
                    ((placementRules != null) && (placementRules.Count > 0)) ? SpatialUnderstanding.Instance.UnderstandingDLL.PinObject(placementRules.ToArray()) : IntPtr.Zero,
                    (placementConstraints != null) ? placementConstraints.Count : 0,
                    ((placementConstraints != null) && (placementConstraints.Count > 0)) ? SpatialUnderstanding.Instance.UnderstandingDLL.PinObject(placementConstraints.ToArray()) : IntPtr.Zero,
                    SpatialUnderstanding.Instance.UnderstandingDLL.GetStaticObjectPlacementResultPtr()) > 0)
            {
                SpatialUnderstandingDllObjectPlacement.ObjectPlacementResult placementResult = SpatialUnderstanding.Instance.UnderstandingDLL.GetStaticObjectPlacementResult();
                if (!isASync)
                {
                    // If not running async, we can just add the results to the draw list right now
                    AppState.Instance.ObjectPlacementDescription = placementName + " (1)";
                    float timeDelay = (float)placementResults.Count * AnimatedBox.DelayPerItem;
                    placementResults.Add(new PlacementResult(timeDelay, placementResult.Clone() as SpatialUnderstandingDllObjectPlacement.ObjectPlacementResult));
                }
                else
                {
                    queryStatus.QueryResult.Add(placementResult.Clone() as SpatialUnderstandingDllObjectPlacement.ObjectPlacementResult);
                }
                return(true);
            }
            if (!isASync)
            {
                AppState.Instance.ObjectPlacementDescription = placementName + " (0)";
            }
            return(false);
        }
Example #24
0
    public void CreateScene()
    {
        // Only if we're enabled
        if (!SpatialUnderstanding.Instance.AllowSpatialUnderstanding)
        {
            return;
        }

        SpatialUnderstandingDllObjectPlacement.Solver_Init();

        SpatialUnderstandingState.Instance.SpaceQueryDescription = "Generating World";

        List <PlacementQuery> queries = CreateLocationQueriesForSolver(1, WideBuildingSize, ObjectType.WideBuilding);

        GetLocationsFromSolver(queries);
    }
Example #25
0
 private bool _PlaceGameObject(string name, SpatialUnderstandingDllObjectPlacement.ObjectPlacementDefinition placementDefinition, List <SpatialUnderstandingDllObjectPlacement.ObjectPlacementRule> placementRules = null, List <SpatialUnderstandingDllObjectPlacement.ObjectPlacementConstraint> placementConstraints = null)
 {
     return
         (
         SpatialUnderstandingDllObjectPlacement.Solver_PlaceObject
         (
             name,
             SpatialUnderstanding.Instance.UnderstandingDLL.PinObject(placementDefinition),
             (placementRules != null) ? placementRules.Count : 0,
             ((placementRules != null) && (placementRules.Count > 0)) ? SpatialUnderstanding.Instance.UnderstandingDLL.PinObject(placementRules.ToArray()) : System.IntPtr.Zero,
             (placementConstraints != null) ? placementConstraints.Count : 0,
             ((placementConstraints != null) && (placementConstraints.Count > 0)) ? SpatialUnderstanding.Instance.UnderstandingDLL.PinObject(placementConstraints.ToArray()) : System.IntPtr.Zero,
             SpatialUnderstanding.Instance.UnderstandingDLL.GetStaticObjectPlacementResultPtr()
         ) > 0
         );
 }
Example #26
0
    public void CreateScene()
    {
        Debug.Log("Create scene");
        // Only if we're enabled
        if (!SpatialUnderstanding.Instance.AllowSpatialUnderstanding)
        {
            return;
        }

        SpatialUnderstandingDllObjectPlacement.Solver_Init();

        Debug.Log("Generating World");

        List <PlacementQuery> queries = CreateLocationQueriesForSolver(1, GuitarSize, ObjectType.Cube);

        GetLocationsFromSolver(queries);
    }
Example #27
0
    void CreateScene()
    {
        // DLLの初期化
        SpatialUnderstandingDllObjectPlacement.Solver_Init();

        var halfBoxDims = boxFullDims * .5f;
        // 他のオブジェクトから離す距離
        var disctanceFromOtherObjects = halfBoxDims.x > halfBoxDims.z ? halfBoxDims.x * 3f : halfBoxDims.z * 3f;
        // 作成したいオブジェクトの数
        var desiredLocationCount = 3;

        for (int i = 0; i < desiredLocationCount; ++i)
        {
            // ルールの作成(複数追加可能)
            var placementRules = new List <SpatialUnderstandingDllObjectPlacement.ObjectPlacementRule>();
            placementRules.Add(SpatialUnderstandingDllObjectPlacement.ObjectPlacementRule.Create_AwayFromOtherObjects(disctanceFromOtherObjects));

            // 制約の作成(複数追加可能)
            var placementConstraints = new List <SpatialUnderstandingDllObjectPlacement.ObjectPlacementConstraint>();
            placementConstraints.Add(SpatialUnderstandingDllObjectPlacement.ObjectPlacementConstraint.Create_AwayFromOtherObjects());

            // 定義の作成(1つだけ)
            SpatialUnderstandingDllObjectPlacement.ObjectPlacementDefinition placementDefinition = SpatialUnderstandingDllObjectPlacement.ObjectPlacementDefinition.Create_OnFloor(halfBoxDims);

            int ret = SpatialUnderstandingDllObjectPlacement.Solver_PlaceObject(
                "my placement",
                SpatialUnderstanding.Instance.UnderstandingDLL.PinObject(placementDefinition),
                placementRules.Count,
                SpatialUnderstanding.Instance.UnderstandingDLL.PinObject(placementRules.ToArray()),
                placementConstraints.Count,
                SpatialUnderstanding.Instance.UnderstandingDLL.PinObject(placementConstraints.ToArray()),
                SpatialUnderstanding.Instance.UnderstandingDLL.GetStaticObjectPlacementResultPtr()
                );

            if (ret > 0)
            {
                SpatialUnderstandingDllObjectPlacement.ObjectPlacementResult placementResult = SpatialUnderstanding.Instance.UnderstandingDLL.GetStaticObjectPlacementResult();

                var rotation = Quaternion.LookRotation(placementResult.Forward, Vector3.up);
                var obj      = Instantiate(toPlaceObj, placementResult.Position, rotation);

                print("Placed:" + obj.transform.position);
            }
        }
    }
Example #28
0
    public void CreateScene()
    {
        // Only if we're enabled
        if (!SpatialUnderstanding.Instance.AllowSpatialUnderstanding)
        {
            return;
        }
        //Calls the Solver after Spatial is finalized
        SpatialUnderstandingDllObjectPlacement.Solver_Init();

        SpatialUnderstandingState.Instance.SpaceQueryDescription = "Bottle Cowboy is Generating World";

        List <PlacementQuery> queries = new List <PlacementQuery>();

        if (DrawObject)
        {
            queries.AddRange(AddObjects());
        }

        GetLocationsFromSolver(queries);
    }
Example #29
0
 IEnumerator ObjectPlacement()
 {
     SpawnInformation.PlacementQuery query = SpawnInformation.QueryByPlacementType(PlacementType, HalfDims);
     //Mit Definition nicht so sicher (Online-Beispiel ist falsch bzw. nicht komplett)
     if (SpatialUnderstandingDllObjectPlacement.Solver_PlaceObject(Prefab.name,
                                                                   _understandingDll.PinObject(query.PlacementDefinition),
                                                                   query.PlacementRules != null?query.PlacementRules.Count:0,
                                                                   _understandingDll.PinObject(query.PlacementRules.ToArray()),
                                                                   query.PlacementConstraints != null ? query.PlacementConstraints.Count : 0,
                                                                   _understandingDll.PinObject(query.PlacementConstraints.ToArray()),
                                                                   _understandingDll.GetStaticObjectPlacementResultPtr()) > 0)
     {
         SpatialUnderstandingDllObjectPlacement.ObjectPlacementResult placementResult =
             _understandingDll.GetStaticObjectPlacementResult();
         Quaternion rot = Quaternion.LookRotation(placementResult.Forward, Vector3.up);
         Instantiate(Prefab, placementResult.Position, rot);
     }
     else
     {
         Debug.Log("Couldn't spawn object");
     }
     yield return(null);
 }
Example #30
0
 private PlacementResult PlaceObject(string placementName,
                                     SpatialUnderstandingDllObjectPlacement.ObjectPlacementDefinition placementDefinition,
                                     Vector3 boxFullDims,
                                     ObjectType objType,
                                     List <SpatialUnderstandingDllObjectPlacement.ObjectPlacementRule> placementRules             = null,
                                     List <SpatialUnderstandingDllObjectPlacement.ObjectPlacementConstraint> placementConstraints = null)
 {
     // New query
     if (SpatialUnderstandingDllObjectPlacement.Solver_PlaceObject(
             placementName,
             SpatialUnderstanding.Instance.UnderstandingDLL.PinObject(placementDefinition),
             (placementRules != null) ? placementRules.Count : 0,
             ((placementRules != null) && (placementRules.Count > 0)) ? SpatialUnderstanding.Instance.UnderstandingDLL.PinObject(placementRules.ToArray()) : IntPtr.Zero,
             (placementConstraints != null) ? placementConstraints.Count : 0,
             ((placementConstraints != null) && (placementConstraints.Count > 0)) ? SpatialUnderstanding.Instance.UnderstandingDLL.PinObject(placementConstraints.ToArray()) : IntPtr.Zero,
             SpatialUnderstanding.Instance.UnderstandingDLL.GetStaticObjectPlacementResultPtr()) > 0)
     {
         SpatialUnderstandingDllObjectPlacement.ObjectPlacementResult placementResult = SpatialUnderstanding.Instance.UnderstandingDLL.GetStaticObjectPlacementResult();
         Debug.Log("TO BE Placed:---------" + (objType == ObjectType.Menu ? "turtorial":"object"));
         return(new PlacementResult(placementResult.Clone() as SpatialUnderstandingDllObjectPlacement.ObjectPlacementResult, boxFullDims, objType));
     }
     Debug.Log("Not Placed:-----------" + (objType == ObjectType.Menu ? "turtorial":"object"));
     return(null);
 }