

Object snap plug-ins are derived from class Osnap. At 3ds max startup it will load any object snap plug-ins (those with a DLS extension). The 3ds max scene has a single object called the Osnap Manager. By deriving a class from Osnap and implement its methods a developer can seamlessly provide this functionality in MAX. A developer of a procedural sphere object might want to provide additional snaps for center point and quadrant points. For example, the built in snap system provides the ability to snap to points such as vertices, endpoints, midpoints, etc. Objects snaps are a plug-in type that allow objects to provide the 3ds max snapping system with additional points that may be snapped to. This topic presents information on object snapping in MAX. See Also: Class Osnap, Class IOSnapManager, Class HitMesh, Class OsnapHit, Class OsnapMarker, Structure SnapInfo, Class Interface, Class ViewExp.
MAXSNAP PLUGIN CODE
The main code where snapping is handled for Geometric Objects, Shape Objects, Cameras, Lights and Helpers is available in \MAXSDK\SAMLES\SNAPS\XMESH\XMESH.CPP. P[0 = vpt->SnapPoint(m,m, NULL, SNAP_IN_3D) A change that developers will need to make is that any mouse procs which will be calling ViewExp::SnapPoint() will need to add a call to ViewExp::SnapPreview() as in the following code fragment from \MAXSDK\SAMPLES\OBJECTS\CYL.CPP. The ViewExp::SnapPoint() method has been enhanced in 3ds Max 2.0 to work with the new object snap system. Handling Snap Preview and Point Snap in Creation Procedures The most important one returns a pointer to the Osnap Manager.

OsnapHit - This class encapsulates the data required to record a snapped point.Developers who implement osnaps need to record hits with the osnap manager. IOsnapManager - This class provides an interface to the Osnap Manager.This method is the workhorse of object snap plugins and is responsible for computing, allocating and recording its hits.

When the scene is traversed, each object which passes the input test will be passed into the Snap() method. It's the job of the ValidInput() method to filter out uninteresting nodes in the scene. Typically, an instance of this class will only make sense for certain object types. Conceptually, the osnap class represents a "rule" for locating points in an object's local space. Osnap - This is the base class for creating osnap plugins.The following are the main classes associated with creating object snap plugins. For example, a door object might have a special snap mode that always snaps to the hinge point. This system allows developers to implement very specific snapping behaviors. For instance, the sphere above would register the center and quadrant points. If the object snap plugins do want to snap to the object type, they can register a set of points to snap to. Tangent and Perpendicular snaps only respond to Spline objects. For example, NURBS snaps only respond to NURBS objects. The Osnap class has a method that allows it to tell the Osnap Manager if it wants to snap to the specified object type based on its Super Class ID and Class ID. That is, when 3ds Max is traversing the scene doing a hit test the Osnap Manger will call each of the plugins to snap against a particular node. This class has various methods that allow the system to query it about potential objects to be snapped to. Object snap plugins are derived from class Osnap. At 3ds Max startup it will load any object snap plugins (those with a DLS extension).

The 3ds Max scene has a single object called the Osnap Manager. By deriving a class from Osnap and implement its methods a developer can seamlessly provide this functionality in 3ds Max. Objects snaps are a plug-in type that allow objects to provide the 3ds Max snapping system with additional points that may be snapped to.
