Rhinocommon Particle System Class

Sorry, I could not resist…

Was this added recently? Any examples floating around?

1 Like

@stevebaer, do you know anything about this?

Yes, I wrote it :smile:

This class has been in RhinoCommon for a while now. It is primarily set up for drawing a number of similar “particles” and does not have any other particle system functionality that you may be expecting to see (i.e. physics simulations). That being said, physics simulations can use this class to draw the simulation.

1 Like

I guess I would like to know the benefit of using this over say, a point cloud, or even a collection of points. I see the particle can take a size and bitmap id. Does it have specific display attributes?

Particles can be drawn as screen oriented sprites. This is what differentiates these from point clouds or a collection of points. There is logic built into the particle system to draw from back to front based on the view orientation. This is because sprites may have alpha and we need to use a painters algorithm technique for drawing when things like alpha are involved.

Cool. Good stuff to know. Thanks!

That will come in handy! Thx.


p.s. some quick and dirty code:

 readonly PSDisplay psDisplay = new PSDisplay();
 psDisplay.file = img; //img is some .png file path

 //pts is a List of Point3d coming from somewhere else
 foreach(Point3d pt in pts)
   Rhino.Geometry.Particle p = new Rhino.Geometry.Particle();
   p.Location = pt;
   p.Size = 10;
   p.Color = Color.FromArgb(10, 255, 0, 255);

 public class PSDisplay : Rhino.Display.DisplayConduit
    public Rhino.Geometry.ParticleSystem ps = new Rhino.Geometry.ParticleSystem();
    public string file;

    protected override void DrawForeground(Rhino.Display.DrawEventArgs e)
      Bitmap bm = new Bitmap(file);
      Rhino.Display.DisplayBitmap dbm = new Rhino.Display.DisplayBitmap(bm);
      e.Display.DrawParticles(ps, dbm);

at some other point, one should enable or disable the display:

      psDisplay.Enabled = true;
    } else {
      psDisplay.Enabled = false;