Constructive solid geometry

From DmWiki

Constructive Solid Geometry, (CSG), is a technique of creating models by using mathematical operations like addition and subtraction on 3D shapes. For example, one could subtract a cylinder from a box to create a box with a cylindrical hole in it.

There are three basic CSG operations:

  • Union (addition): Combines two shapes into one. Does not change the shapes, just allows them to be manipulated as a group, e.g. for more CSG operations.
  • Difference (subtraction): Removes one shape from another, leaving a hole - for example, subtracting a cylinder from a box as mentioned above.
  • Intersection (multiplication): Keeps only those areas where two shapes overlap. For instance, placing two spheres so that they overlap slightly and performing a CSG intersection would leave a lens-shaped object behind.

In graphics based on triangles, as most game engines are, the basic CSG entity is the plane. All other objects can be created by taking the intersection of several planes. For instance, a box is created by the intersection of six planes, each corresponding to one side of the box.

Most level editors support basic CSG (at least union and difference, sometimes called 'group' and 'carve'); many do not support intersection.

In order to render a CSG object, it must be converted from a list of planes and CSG operations into actual triangles. This process is complex and is one of the most difficult parts of creating a good CSG implementation.

See also

This article is a stub. You can help improve the article by expanding it.


DevMaster navigation