Ejemplo n.º 1
0
        /// <summary>
        /// Creates the Game Object(s) containing the points of this node.
        /// Vertices and Colors have to be set before calling this function (via SetPoints)! This function has to be called from the main thread!
        /// </summary>
        /// <param name="configuration">The MeshConfiguration which should be used for creating the Game Objects</param>
        public void CreateGameObjects(MeshConfiguration configuration)
        {
            int max = configuration.GetMaximumPointsPerMesh();

            if (verticesToStore.Length <= max)
            {
                gameObjects.Add(configuration.CreateGameObject(metaData.cloudName + "/" + "r" + name + " (" + verticesToStore.Length + ")", verticesToStore, colorsToStore, boundingBox));
            }
            else
            {
                int       amount       = Math.Min(max, verticesToStore.Length);
                int       index        = 0; //name index
                Vector3[] restVertices = verticesToStore;
                Color[]   restColors   = colorsToStore;
                while (amount > 0)
                {
                    Vector3[] vertices = restVertices.Take(amount).ToArray();
                    Color[]   colors   = restColors.Take(amount).ToArray();;
                    restVertices = restVertices.Skip(amount).ToArray();
                    restColors   = restColors.Skip(amount).ToArray();
                    gameObjects.Add(configuration.CreateGameObject(metaData.cloudName + "/" + "r" + name + "_" + index + " (" + vertices.Length + ")", vertices, colors, boundingBox));
                    amount = Math.Min(max, vertices.Length);
                    index++;
                }
            }
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Creates the Game Object(s) containing the points of this node.
        /// Vertices and Colors have to be set before calling this function (via SetPoints)! This function has to be called from the main thread!
        /// </summary>
        /// <param name="configuration">The MeshConfiguration which should be used for creating the Game Objects</param>
        public void CreateGameObjects(MeshConfiguration configuration)
        {
            //var script = GameObject.FindGameObjectWithTag("MeshConfig").GetComponent<GeoQuadMeshConfiguration>();
            //if (script.holdername.Contains(metaData.cloudName))
            //{
            int max = configuration.GetMaximumPointsPerMesh();

            if (verticesToStore.Length <= max)
            {
                gameObjects.Add(configuration.CreateGameObject(metaData.cloudName + "/" + "r" + name + " (" + verticesToStore.Length + ")", verticesToStore, colorsToStore, boundingBox));
            }
            else
            {
                int       amount       = Math.Min(max, verticesToStore.Length);
                int       index        = 0; //name index
                Vector3[] restVertices = verticesToStore;
                Color[]   restColors   = colorsToStore;
                while (amount > 0)
                {
                    Vector3[] vertices = restVertices.Take(amount).ToArray();
                    Color[]   colors   = restColors.Take(amount).ToArray();;
                    restVertices = restVertices.Skip(amount).ToArray();
                    restColors   = restColors.Skip(amount).ToArray();
                    gameObjects.Add(configuration.CreateGameObject(metaData.cloudName + "/" + "r" + name + "_" + index + " (" + vertices.Length + ")", vertices, colors, boundingBox));
                    amount = Math.Min(max, vertices.Length);
                    index++;
                }
            }
            //}
        }
Ejemplo n.º 3
0
 /// <summary>
 /// Removes the GameObjects of this node. Has to be called from the main thread.
 /// </summary>
 /// <param name="config">The MeshConfiguration which should be used for removing the Game Objects</param>
 public void RemoveGameObjects(MeshConfiguration config)
 {
     foreach (GameObject go in gameObjects)
     {
         config.RemoveGameObject(go);
     }
     gameObjects.Clear();
 }
Ejemplo n.º 4
0
 public StaticRenderer(MeshConfiguration config)
 {
     rootNodes       = new List <Node>();
     toLoad          = new Queue <Node>();
     toDisplay       = new Queue <Node>();
     toRemove        = new Queue <Node>();
     nodePointcounts = new Dictionary <Node, uint>();
     this.config     = config;
 }
Ejemplo n.º 5
0
 public StaticRenderer(AbstractPointCloudSet pcset, MeshConfiguration config)
 {
     this.pcset      = pcset;
     rootNodes       = new List <Node>();
     toLoad          = new Queue <Node>();
     toDisplay       = new Queue <Node>();
     toRemove        = new Queue <Node>();
     nodePointcounts = new Dictionary <Node, uint>();
     this.config     = config;
 }
Ejemplo n.º 6
0
 /// <summary>
 /// Removes the GameObjects of this node. Has to be called from the main thread.
 /// </summary>
 /// <param name="config">The MeshConfiguration which should be used for removing the Game Objects</param>
 public void RemoveGameObjects(MeshConfiguration config)
 {
     /*var script = GameObject.FindGameObjectWithTag("MeshConfig").GetComponent<GeoQuadMeshConfiguration>();
      * if (script.holdername.Contains(metaData.cloudName))
      * {*/
     foreach (GameObject go in gameObjects)
     {
         config.RemoveGameObject(go);
     }
     gameObjects.Clear();
 }
Ejemplo n.º 7
0
 /// <summary>
 /// Creates GameObjects for this node and all its (grand-)children. Useable for displaying a whole point cloud at once.
 /// Vertices and Colors have to be set before calling this function (via SetPoints) for this object and all its children! This function has to be called from the main thread!
 /// </summary>
 /// <param name="configuration">The MeshConfiguration which should be used for creating the Game Objects</param>
 public void CreateAllGameObjects(MeshConfiguration configuration)
 {
     CreateGameObjects(configuration);
     for (int i = 0; i < 8; i++)
     {
         if (children[i] != null)
         {
             children[i].CreateAllGameObjects(configuration);
         }
     }
 }
Ejemplo n.º 8
0
 /// <summary>
 /// Creates a new V2Renderer and starts all the threads
 /// </summary>
 /// <param name="minNodeSize">Minimum Node Size</param>
 /// <param name="pointBudget">Point Budget</param>
 /// <param name="nodesLoadedPerFrame">Maximum number of nodes loaded per frame</param>
 /// <param name="nodesGOsperFrame">Maximum number of nodes for which GameObjects should be created per frame</param>
 /// <param name="camera">User Camera</param>
 /// <param name="config">MeshConfiguration, defining how the points should be rendered</param>
 /// <param name="cacheSize">Size of cache in points</param>
 public V2Renderer(int minNodeSize, uint pointBudget, uint nodesLoadedPerFrame, uint nodesGOsperFrame, Camera camera, MeshConfiguration config, uint cacheSize)
 {
     rootNodes     = new List <Node>();
     this.camera   = camera;
     this.config   = config;
     cache         = new V2Cache(cacheSize);
     loadingThread = new V2LoadingThread(cache);
     loadingThread.Start();
     traversalThread = new V2TraversalThread(this, loadingThread, rootNodes, minNodeSize, pointBudget, nodesLoadedPerFrame, nodesGOsperFrame, cache);
     traversalThread.Start();
 }
Ejemplo n.º 9
0
 /// <summary>
 /// Removes the GameObjects of this node and all child nodes. Has to be called from the main thread.
 /// </summary>
 /// <param name="config">The MeshConfiguration which should be used for removing the Game Objects</param>
 public void RemoveAllGameObjects(MeshConfiguration config)
 {
     RemoveGameObjects(config);
     for (int i = 0; i < 8; i++)
     {
         if (children[i] != null)
         {
             children[i].RemoveAllGameObjects(config);
         }
     }
 }
Ejemplo n.º 10
0
 /// <summary>
 /// Creates a new V2Renderer and starts all the threads
 /// </summary>
 /// <param name="minNodeSize">Minimum Node Size</param>
 /// <param name="pointBudget">Point Budget</param>
 /// <param name="nodesLoadedPerFrame">Maximum number of nodes loaded per frame</param>
 /// <param name="nodesGOsperFrame">Maximum number of nodes for which GameObjects should be created per frame</param>
 /// <param name="camera">User Camera</param>
 /// <param name="config">MeshConfiguration, defining how the points should be rendered</param>
 /// <param name="cacheSize">Size of cache in points</param>
 public V2Renderer(int minNodeSize, uint pointBudget, uint nodesLoadedPerFrame, uint nodesGOsperFrame, Camera camera, MeshConfiguration config, uint cacheSize)
 {
     rootNodes     = new List <Node>();
     holders       = GameObject.FindGameObjectWithTag("MeshConfig").GetComponent <GeoQuadMeshConfiguration>().holders;
     this.camera   = camera;
     this.config   = config;
     cache         = new V2Cache(cacheSize);
     loadingThread = new V2LoadingThread(cache, holders);
     loadingThread.Start();
     traversalThread = new V2TraversalThread(this, loadingThread, rootNodes, minNodeSize, pointBudget, nodesLoadedPerFrame, nodesGOsperFrame, cache);
     traversalThread.Start();
 }
Ejemplo n.º 11
0
        private Queue <Node> toDeleteExternal; //Nodes that have been scheduled for removal via removeRoot

        /// <summary>
        /// Creates a new V2Renderer and starts all the threads
        /// </summary>
        /// <param name="minNodeSize">Minimum Node Size</param>
        /// <param name="pointBudget">Point Budget</param>
        /// <param name="nodesLoadedPerFrame">Maximum number of nodes loaded per frame</param>
        /// <param name="nodesGOsperFrame">Maximum number of nodes for which GameObjects should be created per frame</param>
        /// <param name="camera">User Camera</param>
        /// <param name="config">MeshConfiguration, defining how the points should be rendered</param>
        /// <param name="cacheSize">Size of cache in points</param>
        public V2Renderer(AbstractPointCloudSet pcset, int minNodeSize, uint pointBudget, uint nodesLoadedPerFrame, uint nodesGOsperFrame, Camera camera, MeshConfiguration config, uint cacheSize)
        {
            this.pcset    = pcset;
            rootNodes     = new List <Node>();
            this.camera   = camera;
            this.config   = config;
            cache         = new V2Cache(cacheSize);
            loadingThread = new V2LoadingThread(cache);
            loadingThread.Start();
            traversalThread = new V2TraversalThread(pcset.gameObject, this, loadingThread, rootNodes, minNodeSize, pointBudget, nodesLoadedPerFrame, nodesGOsperFrame, cache);
            traversalThread.Start();
            toDeleteExternal = new Queue <Node>();
        }