/// <summary> /// Sets the bounding box of a given Cloud-Controller, which has been registered via RegisterController first. /// If the bounding box should be moved (moveToOrigin), this method does not terminate until the movement has happened (via update), /// so this method should not be called in the main thread. /// </summary> public void UpdateBoundingBox(PointCloudLoader controller, BoundingBox boundingBox, BoundingBox tightBoundingBox) { initializedEvent.WaitOne(); boundingBox.MoveAlong(moving); tightBoundingBox.MoveAlong(moving); lock (boundingBoxes) { boundingBoxes[controller] = boundingBox; tightBoundingBoxes[controller] = tightBoundingBox; overallBoundingBox.Lx = Math.Min(overallBoundingBox.Lx, boundingBox.Lx); overallBoundingBox.Ly = Math.Min(overallBoundingBox.Ly, boundingBox.Ly); overallBoundingBox.Lz = Math.Min(overallBoundingBox.Lz, boundingBox.Lz); overallBoundingBox.Ux = Math.Max(overallBoundingBox.Ux, boundingBox.Ux); overallBoundingBox.Uy = Math.Max(overallBoundingBox.Uy, boundingBox.Uy); overallBoundingBox.Uz = Math.Max(overallBoundingBox.Uz, boundingBox.Uz); overallTightBoundingBox.Lx = Math.Min(overallTightBoundingBox.Lx, tightBoundingBox.Lx); overallTightBoundingBox.Ly = Math.Min(overallTightBoundingBox.Ly, tightBoundingBox.Ly); overallTightBoundingBox.Lz = Math.Min(overallTightBoundingBox.Lz, tightBoundingBox.Lz); overallTightBoundingBox.Ux = Math.Max(overallTightBoundingBox.Ux, tightBoundingBox.Ux); overallTightBoundingBox.Uy = Math.Max(overallTightBoundingBox.Uy, tightBoundingBox.Uy); overallTightBoundingBox.Uz = Math.Max(overallTightBoundingBox.Uz, tightBoundingBox.Uz); } if (moveCenterToTransformPosition) { waiterForBoundingBoxUpdate.WaitOne(); } }
/// <summary> /// Registers a PointCloud-Controller (See PointCloudLoader). This should be done in the start-method of the pc-controller and is neccessary for the bounding-box-recalculation. /// The whole cloud will be moved and rendered as soon as for every registererd controller the bounding box was given via UpdateBoundingBox. /// Should be called only once for every controller /// </summary> /// <param name="controller">not null</param> /// <seealso cref="PointCloudLoader"/> public void RegisterController(PointCloudLoader controller) { lock (boundingBoxes) { boundingBoxes[controller] = null; tightBoundingBoxes[controller] = null; } }
/// <summary> /// Creates PointCloudLoader objects for all the point clouds in the given path. /// </summary> public void LoadAll() { if (streamingAssetsAsRoot) { fullPath = Application.streamingAssetsPath + "/" + path; } else { fullPath = path; } DirectoryInfo dir = new DirectoryInfo(fullPath); foreach (DirectoryInfo sub in dir.GetDirectories()) { GameObject go = new GameObject(sub.Name); PointCloudLoader loader = go.AddComponent <PointCloudLoader>(); if (streamingAssetsAsRoot) { loader.streamingAssetsAsRoot = true; loader.cloudPath = path + sub.Name; } else { loader.cloudPath = sub.FullName; } loader.setController = pointset; } }
/// <summary> /// Removes a point cloud /// </summary> public void RemoveRootNode(PointCloudLoader controller, Node node) { lock (pRenderer) { pRenderer.RemoveRootNode(node); boundingBoxes.Remove(controller); } }
/// <summary> /// Adds a root node to the renderer. Should be called by the PC-Controller, which also has to call RegisterController and UpdateBoundingBox. /// </summary> public void AddRootNode(PointCloudLoader controller, Node node, PointCloudMetaData metaData) { initializedEvent.WaitOne(); lock (pRenderer) { pRenderer.AddRootNode(node, controller); } }
/// <summary> /// Creates PointCloudLoader objects for all the point clouds in the given path. /// </summary> public void LoadAll() { DirectoryInfo dir = new DirectoryInfo(path); foreach (DirectoryInfo sub in dir.GetDirectories()) { GameObject go = new GameObject(sub.Name); PointCloudLoader loader = go.AddComponent <PointCloudLoader>(); loader.cloudPath = sub.FullName; loader.setController = pointset; } }