Cutting 3D Figures

Hi! I’m new to Processing, so my can question can sound silly, but I want to know how to cut 3D figures. For example, I have a sphere and I want to cut it to make half-sphere or to draw something like craters on its surface. Can somebody help me, please?

The only way I know how to do this is to calculate it yourself. You aren’t going to be able to use the built-in sphere() function for this.

Google something like “java calculate points to draw sphere” for a ton of results. Find an algorithm you like, and then modify it to draw a sphere with parts missing.

The best advice I can give you is to start simple and work your way forward in small steps. Good luck.


Hello @qlvr! Welcome to the forums. :slight_smile:

You have several options to approach this. You can either:

  1. Use the Hemesh library for Processing. Check out this example from Frederik Vanhoutte (creator of the library) for inspiration.
  2. Model it manually using a 3D modelling software, export it as obj, and load the obj file into Processing for you to play with.
  3. Use signed distance functions with GLSL in Processing, which enables you to have boolean operations that you need (union, difference, intersection). Check out this article for an overview.

All approaches have their own pros and cons, but should give you a direction to follow depending on your application. Good luck.

1 Like