Shapes 3D

This library is useful for any one wishing to do some 3D graphics/games programming in P3D or OPENGL modes. It not only provides a number of 3D shapes but enables simple creation of a 3D terrain and user controllable camera that can traverse over the terrain. Movement on the terrain can be clamped to prevent moving off the edges or wrapped so that as you move off the terrain your position is wrapped to the other side. The terrain class has a method to create a height map based on perlin noise that is seamless, this gives the impression of travelling over an infinite world.

As of version 2.0.0 the library provides a method to enable shape selection and thus user interaction. It uses an off-screen P3D buffer to perform a colour picking algorithm.

The library only uses available Processing methods to access the OpenGL commands so should be compatible with future releases of Processing.

Shapes available include:

  • Ellipsoid (a sphere that can be stretched in all 3 axis)
  • Toroid (a circular doughnut that can have an elliptical cross-section)
  • Helix (similar to the toroid with extra feature of user defined number of spirals)
  • Cone (can be squashed to have elliptical opening)
  • BezShape (based on a 360o rotation of a Bezier curve of any degree)
  • Tube (can have different elliptical openings at each end)
  • BezTube (variable profile tube that follows a Bezier curve in 3D space)
  • PathTube (variable profile tube that follows a used defined curve in 3D space)
  • Extrusion (user defined 2D cross-section extruded along a user defined 3D path)
  • Box (variable size in 3D, each face can have its own texture/colour and be visible/invisible)

Images can be used to texture any of these shapes and all (apart from Cone and Box) support texture tiling. In the case of the Cone the texture is applied as if the image was draped over the point of the cone. The Box supports up to 6 textures (one per face) if a face does not have a texture it will be shown with the colour set for that face).

All shapes can be drawn using any combination of wireframe, coloured and textured modes. In the case of the Box each face can have its own drawing mode.

The examples shown on this website were all created using Processing 1.5.1 and its P3D renderer because Processing 2.0 no longer supports the export of Java applets that use OpenGL. The library includes current versions of all the examples plus others created since the library was updated to be Processing 2.0 compatible.