Snap Design

From K-3D

Jump to: navigation, search


  • Snapping is a form of special-purpose constraint that takes place between one object (the source) that is being transformed, and one-to-many target objects.
  • Snappable objects are objects that can participate in a snap operation (either source or target).
  • Each snappable object has zero-to-many snap sources, and zero-to-many snap targets. Each snap target represents an allowable end-state for the snap operation. Snap sources are "handles" that can be transformed to conform to a snap target.
  • The result of a "snap" operation is a rigid (move & rotate) transformation that is defined by positioning and orienting one snap source to match the position and orientation of one snap target.
  • Snappable objects may expose any combination of geometric and explicit snap sources and snap targets.
  • Geometric snap sources and snap targets are defined internally to an object and are based on obvious aspects of its geometry, e.g. a plane might define "snap to plane"; a polyhedron might define "snap to point", "snap to face", and "snap to centroid"; and a sphere might define "snap to pole", "snap to equator", and "snap to surface" snap targets. Geometric snap sources can be similarly defined.
  • Explicit snap sources and snap targets can be defined externally (in a file, for example), allowing modelers to define sources and targets specific to a model. Thus, a door/doorframe combination could have "hinge" sources and targets in locations that otherwise wouldn't have any purely geometric significance.
  • Snapping can perform automatic selection of snap source and target, e.g. "pick the source and target that are closest together", or the user can select source and target explicitly, or some combination of the two.
  • It should be possible to "group" snap sources and snap targets into both implicit and user-defined categories, so that some types of source can only "snap" to other specific types of target (e.g. a "chair bottom" source can only be snapped to a "floor" target).
  • Snapping can be performed both interactively, and as part of the visualization pipeline.


  • Snappable nodes implement the k3d::isnappable interface, which provides methods for retrieving the set of snap sources and snap targets for the node.
  • Snap sources implement the k3d::isnap_source interface, which provides methods that return the source position in local coordinates, and the (optional) source orientation in local coordinates.
  • Snap targets implement the k3d::isnap_target interface, which provides methods that return the (optional) target position in local coordinates, and the (optional) target orientation in local coordinates. Each method takes a source position in local coordinates as input, which allows the target to adjust the returned position and orientation accordingly.
Personal tools