mariuszhermansdorfer / SandWorm

Augmented Reality Sandbox for Grasshopper & Rhino
MIT License
20 stars 11 forks source link

Create a separate component outputting the point cloud #24

Closed mariuszhermansdorfer closed 3 years ago

mariuszhermansdorfer commented 5 years ago

As mentioned in #1 - we need a dedicated SW component outputting the point cloud

mariuszhermansdorfer commented 4 years ago

Note to self: Point Cloud: https://discourse.mcneel.com/t/grasshopper-pointcloud-on-xyz-grid-c/53571/10 DrawViewportWires: https://discourse.mcneel.com/t/can-drawviewportwires-draw-gh-objects/77494/5

philipbelesky commented 4 years ago

Hey just a heads up that I've made a quick start, of sorts, on this in this branch. Currently itsless focused on the implementation by itself, but rather on setting up a base class or two that can be inherited by both a mesh-producing and point-cloud-producing component and cut down the amount of overlap in reading the basic sensor data, parsing options, logging/timing info etc.

mariuszhermansdorfer commented 4 years ago

I have looked into multiple ways of displaying the point cloud and the fastest by far was to use Rhino's native PC component. The only downside is that GH can't access it directly, so it would be a display only option.

  private PointCloud _cloud;
  private Point3f[] pointCloud;

  pointCloud = new Point3f[trimmedWidth * trimmedHeight];
 _cloud = new PointCloud(pointCloud);

  //Draw all points in this method.
  public override void DrawViewportWires(IGH_PreviewArgs args)
  {
    if (_cloud == null)
      return;

    args.Display.DrawPointCloud(_cloud, 3); // There is an overload which allows to input a color array too
  }
philipbelesky commented 4 years ago

So maybe there should be a parameter on that component (defaulting to off) that writes out a Point3D list if people ever need to manipulate the points further in Grasshopper?

Another option would be to check in with Cam and see if he wouldn't mind us employing the same methods as Tarsier. There would be quite a bit of value in using their GH_PointCloud class and being able to interoperate with their modification/search components.

mariuszhermansdorfer commented 4 years ago

I reached out to Cameron a few weeks ago regarding this. Don't know whether he knew, that you are part of the project at that time, but was still very open to us reusing his code.

Outputting a Point3d list is the slowest possible option. Much better to cast to GH_Point and spit these out. Cameron has posted some extensive test results in this thread.

philipbelesky commented 4 years ago

PC

Basic point cloud output works, although that was a very quick change. Getting the RGB colors and/or coloring the pixels based on analysis will need a bit more work.

Most of the work here has thus far been in trying to abstract out the shared methods between the new and old component. For that reason the merge-in for this one will be somewhat tricky, but new classes will allow me to start making some progress on #25 that should also illuminate how to handle the pixel-coloring in this case as well.

Regarding tarsier and their GH_PointCloud class, as tarsier is GLPv3 we would need to re-license Sandworm to match if the code was included. Would that be OK with you?

mariuszhermansdorfer commented 4 years ago

Very good work happening under the hood there! SandWorm desperately needed some clean-up. I need to finalize a few things for work this week and will have to keep it low-key in the next couple of days or so. Will get back to you as soon as I have more time.