Advice on optimal way to redraw datapoints

Hi, I am working on a 3D scan and mapping project and I’m able to scan a specific environment and redraw it in a virtual map but my map is lacking a bit because I cant get nearly as many datapoints as I want to and this is probably because my code is set to redraw the datapoints everytime in a for loop and I dont think this is efficient. My max datapoints I can attain before my program starts slowing down incredibly is about 12000. Is there an optimal way to get way more datapoints and what should I do if I want to reach like a 100,000 or 500,000 or even a million datapoints.
I’m attaching part of the code of how i plot my data points below

  for(int a = 0; a < data_points.size(); a++)
         {
          new_p = data_points.get(a);
          translate(new_p.x,new_p.y,new_p.z);
          fill(155,50,40);
          noStroke();
          box(4);
          translate(-new_p.x,-new_p.y,-new_p.z);
         }

without the “data_points.get(a)” line the datapoints aren’t visible

to show 1M box with 4 pix wide, ? and same color?
what screen you have???

why not try something easy for your computer?

  stroke(155,50,40);                                         // add kll
  for(int a = 0; a < data_points.size(); a++)  {
          new_p = data_points.get(a);
          point(new_p.x,new_p.y,new_p.z);        // add kll
//          translate(new_p.x,new_p.y,new_p.z);
//          fill(155,50,40);
//          noStroke();
//          box(4);
//          translate(-new_p.x,-new_p.y,-new_p.z);
         }

please report back how much that changed your FPS.


on the other side, i doubt a little bit

runs with 60 scan/sec
so the whole point

can / need NOT to be in a 60 FPS loop.


2 Likes

Can you say more about what your application is? Are you performing a 3D scan on an object? Are you loading a 3D scan file and rendering a model based on the data in P3D?

What is the purpose of the graphic output with box – are you rendering a graphic to save? Is it an interactive view that you are navigating? Is it a preview of a 3D printing process?

There are many ways to make a loop through 1 million datapoints higher performance. Many of them focus on not drawing things that you don’t need to (things that are duplicates, or are occluded. Does your data include duplicates? Is your data a solid or partially solid 3D, with a rear face that is occluded? Are your box fills solid, or translucent?

Another thing you could do is not use translate+box. However, without knowing more about what you are trying to do I’m not sure if I could suggest alternatives.

2 Likes

hey thanks… the “point” function helped us greatly. we haven’t been able to get accurate maps at fast speeds yet so our stepper motor rotates about 5 steps/ sec( 1.5) rotations per minute.
and we normally get about 6000 datapoints in 10 minutes
Heres a picture of a room we mapped


this is an old map and we have made a lot of changes to our dense point cloud.

Our goal is to help robots adjust to moving in (indoor) dynamic environments, so we attach the 3D scanner on top of the robot and redraw the environment being mapped in a virtual environment for visualization and to also help and track the robots path through the environment. But we are more focused on the 3D scanner and 3D environment now. More datapoints mean a more detailed map for navigation.


This is one of our better maps of a room we scanned and recreated. even though its pretty defined, we need more detail, hence more datapoints