private void LoadHierarchy()
        {
            try {
                if (!cloudPath.Contains("http") && !cloudPath.EndsWith("/"))
                {
                    cloudPath = cloudPath + "/";
                }

                PointCloudMetaData metaData = CloudLoader.LoadMetaData(cloudPath, false);

                setController.UpdateBoundingBox(this, metaData.boundingBox, metaData.tightBoundingBox);

                rootNode = CloudLoader.LoadHierarchyOnly(metaData);

                setController.AddRootNode(this, rootNode, metaData);
            } catch (System.IO.FileNotFoundException ex)
            {
                Debug.LogError("Could not find file: " + ex.FileName);
            } catch (System.IO.DirectoryNotFoundException ex)
            {
                Debug.LogError("Could not find directory: " + ex.Message);
            } catch (Exception ex) {
                Debug.LogError(ex + Thread.CurrentThread.Name);
            }
        }
Exemple #2
0
        //This loads bounding boxes and also point cloud meta data (if showpoints is enabled).
        //The meshes itself have to be created on the MainThread, so if it's necessary,
        //this function only sets the flag _createMesh, which will be used later
        private void LoadBoundingBoxes()
        {
            BoundingBox overallBoundingBox = new BoundingBox(double.PositiveInfinity, double.PositiveInfinity, double.PositiveInfinity,
                                                             double.NegativeInfinity, double.NegativeInfinity, double.NegativeInfinity);

            foreach (PointCloudLoader loader in _loaders)
            {
                string path = loader.cloudPath;
                if (!path.EndsWith("/"))
                {
                    path += "/";
                }
                PointCloudMetaData metaData           = CloudLoader.LoadMetaData(path, false);
                BoundingBox        currentBoundingBox = metaData.tightBoundingBox;
                overallBoundingBox.Lx = Math.Min(overallBoundingBox.Lx, currentBoundingBox.Lx);
                overallBoundingBox.Ly = Math.Min(overallBoundingBox.Ly, currentBoundingBox.Ly);
                overallBoundingBox.Lz = Math.Min(overallBoundingBox.Lz, currentBoundingBox.Lz);
                overallBoundingBox.Ux = Math.Max(overallBoundingBox.Ux, currentBoundingBox.Ux);
                overallBoundingBox.Uy = Math.Max(overallBoundingBox.Uy, currentBoundingBox.Uy);
                overallBoundingBox.Uz = Math.Max(overallBoundingBox.Uz, currentBoundingBox.Uz);

                if (_showPoints)
                {
                    Node rootNode = new Node("", metaData, metaData.boundingBox, null);
                    CloudLoader.LoadPointsForNode(rootNode);
                    _nodes.Add(rootNode);
                }
            }
            if (_setToPreview.moveCenterToTransformPosition)
            {
                Vector3d moving = -overallBoundingBox.Center();
                overallBoundingBox.MoveAlong(moving);
                foreach (Node n  in _nodes)
                {
                    n.BoundingBox.MoveAlong(moving);
                }
            }
            _currentBB = overallBoundingBox;
            if (_showPoints)
            {
                _createMesh = true;
            }
            else
            {
                _loaders = null;
                _nodes   = null;
            }
        }
        /// <summary>
        /// The Unity Start() method
        /// </summary>
        void Start()
        {
            this.ARCaptLoader = new CloudLoader("ARCAPT_USERNAME", "ARCAPT_API_KEY");
            StartCoroutine(this.ARCaptLoader.LoadCollections());

            this.TextMessages        = GameObject.Find("TextMessages").GetComponent <Text>();
            this.DropdownCollections = GameObject.Find("DropdownCollections").GetComponent <Dropdown>();
            this.DropdownModels      = GameObject.Find("DropdownModels").GetComponent <Dropdown>();

            this.DropdownCollections.onValueChanged.AddListener(delegate
            {
                DropdownCollectionValueChanged(this.DropdownCollections);
            });

            this.DropdownModels.onValueChanged.AddListener(delegate
            {
                DropdownModelValueChanged(this.DropdownModels);
            });
        }
        private void LoadHierarchy()
        {
            try {
                if (!cloudPath.EndsWith("\\"))
                {
                    cloudPath = cloudPath + "\\";
                }

                PointCloudMetaData metaData = CloudLoader.LoadMetaData(cloudPath, false);

                setController.UpdateBoundingBox(this, metaData.boundingBox);

                Node rootNode = CloudLoader.LoadHierarchyOnly(metaData);

                setController.AddRootNode(rootNode);
            } catch (Exception ex) {
                Debug.LogError(ex);
            }
        }
Exemple #5
0
        //Loads the complete point cloud
        private void LoadFile()
        {
            try {
                Debug.Log("Loading file");
                fileLoading = true;
                if (!cloudPath.EndsWith("\\"))
                {
                    cloudPath = cloudPath + "\\";
                }

                metaData = CloudLoader.LoadMetaData(cloudPath, moveToOrigin);

                rootNode = CloudLoader.LoadPointCloud(metaData);

                Debug.Log("Finished Loading");

                fileLoading = false;
            } catch (Exception ex) {
                Debug.LogError(ex);
            }
        }
Exemple #6
0
    protected override IEnumerator ActivateCoroutine()
    {
        //Change the max tilt angle of the camera
        GameObject playerObj = GameObject.FindGameObjectWithTag("Player");
        Player     player    = playerObj.GetComponent <Player>();

        player.ChangeTiltAngle(85.0f);

        Debug.Log("Activating points");
        //create/activate pointcloudsetrealtimecontroller
        SerializableModel pointsData = siteData as SerializableModel;

        Debug.Log("Loading points " + pointsData.name);

        Debug.Log("Initializing mesh");

        mesh                   = this.gameObject.AddComponent <GeoTriMeshConfiguration>();
        mesh.pointRadius       = 5;
        mesh.renderCircles     = true;
        mesh.screenSize        = true;
        mesh.interpolation     = InterpolationMode.OFF;
        mesh.reloadingPossible = true;


        Debug.Log("Initializing set");

        set = this.gameObject.AddComponent <PointCloudSetRealTimeController>();
        set.moveCenterToTransformPosition = true;
        set.pointBudget         = 4294967295;
        set.minNodeSize         = 10;
        set.nodesLoadedPerFrame = 15;
        set.nodesGOsPerFrame    = 30;
        set.meshConfiguration   = mesh;
        set.cacheSizeInPoints   = 3000000;
        set.userCamera          = CAVECameraRig.frustumCamera;

        Debug.Log("Initializing controller");

        //create dynamicloadercontroller
        controller               = this.gameObject.AddComponent <DynamicLoaderController>();
        controller.cloudPath     = GetCacheDirectory(pointsData.file);
        controller.setController = set;
        set.userCamera           = CAVECameraRig.frustumCamera;

        yield return(null);

        if (this.spoi != null)
        {
            try {
                string cloudPath = GetCacheDirectory(pointsData.file);
                if (!cloudPath.EndsWith("\\"))
                {
                    cloudPath = cloudPath + "\\";
                }

                PointCloudMetaData md = CloudLoader.LoadMetaData(cloudPath, false);
                this.spoi.Delete();
                this.spoi = new ShapefilePOI(this.siteData.custom.shapefilePath, -md.boundingBox.Center().ToFloatVector());
            } catch (Exception ex) {
                Debug.LogError(ex);
            }
        }
    }