Class OsnapHit
See Also: Class IOsnapManager, Class Osnap, Class HitMesh, Class Point3, Class IPoint3, The Advanced Topics section on Snapping.
class OsnapHit : public BaseInterfaceServer
Description:
This class is available in release 2.0 and later only.
This class encapsulates the data required to record a snapped point. Typically a plug-in creates instances of this class and records them with the OsnapManager. The manager is responsible for freeing the memory associated with recorded hits. All the methods of this class are implemented by the system. If a snap plugin needs to record additional data for its hits, it should derive from this class and provide a clone method which copies this additional data and calls the base classes clone method.
Friend Classes:
friend class OsnapManager;
friend class Osnap;
Methods:
Prototype:
OsnapHit(Point3 p3, Osnap* s, int sub, HitMesh *m);
Remarks:
Constructor. The data members are initialized to the values passed.
Parameters:
Point3 p3
The point that was hit in object space.
Osnap* s
Points to the Osnap instance which made this hit.
int sub
The sub-snap index which made this hit.
HitMesh *m
Points to the mesh used to hilite the topology that was hit.
Prototype:
OsnapHit(const OsnapHit& h);
Remarks:
Constructor. The data members are initialized from the OsnapHit passed.
Parameters:
const OsnapHit& h
The data members are copied from this OsnapHit.
Prototype:
virtual ~OsnapHit();
Remarks:
Destructor. If a HitMesh was allocated it is deleted.
Prototype:
virtual OsnapHit* clone();
Remarks:
Returns a pointer to a new instance of the OsnapHit class and initializes it with this instance. Developers deriving from this class should overide this method.
Prototype:
void setscreendata(IPoint3 screen3, int len);
Remarks:
This method is used internally. Sets the data members associated with screen hit data.
Parameters:
IPoint3 screen3
The hit location in screen space.
int len
The distance from the cursor.
Prototype:
boolean display(ViewExp *vpt, TimeValue t, Point3 color, int markersize, boolean markers = TRUE, boolean hilite = TRUE);
Remarks:
This display method is implemented by the system and used internally.
Parameters:
ViewExp *vpt
The viewport to display in.
TimeValue t
The current time.
Point3 color
The color to draw it in.
int markersize
The relative size of the icon.
boolean markers = TRUE
Controls whether or not the hit icon is drawn.
boolean hilite = TRUE
Controls whether or not the mesh part of the hit is drawn.
Prototype:
void erase(ViewExp *vpt, TimeValue t) const;
Remarks:
This method is not currently used.
Prototype:
void GetViewportRect(TimeValue t,ViewExp *vpt,Rect *rect, int marksize)const;
Remarks:
Implemented by the system.
This method determines the damage rectangle for this hit.
Parameters:
TimeValue t
The time at which to compute the rectangle.
ViewExp *vpt
The viewport in which to compute the rectangle.
Rect *rect
Points to storage for the computed result.
int marksize
The size of the icon.
Prototype:
Point3 GetHitpoint();
Remarks:
Returns the hit location in object space.
Prototype:
Point3 GetWorldHitpoint();
Remarks:
Returns the hit location in world space.
Prototype:
IPoint3 GetHitscreen();
Remarks:
Returns the hit location in screen space. IPoint3.z is the depth in screen space.
Prototype:
int GetSubsnap();
Remarks:
Returns the sub-snap index which made this hit.
Prototype:
INode *GetNode();
Remarks:
Returns a pointer to the node which got hit.
Prototype:
void Update(TimeValue t);
Remarks:
This method is not currently implemented.
Prototype:
Point3 ReEvaluate(TimeValue t);
Remarks:
Implemented by the System.
This method updates the internal data to reflect a change in time. For example, if a hit is recorded on the endpoint of a particular edge of a mesh, the node moving would invalidate the hit data and a call to this method would be required before using its data.
Parameters:
TimeValue t
The time at which to reevaluate it.
Return Value:
The updated point in world space.
Prototype:
void Dump()const;
Remarks:
This method is used internally for debugging and is not implemented for plug-in use.
Operators:
Prototype:
virtual OsnapHit& operator=(const OsnapHit& h);
Remarks:
Assignment operator.
Parameters:
const OsnapHit& h
The OsnapHit to assign.
Prototype:
BOOL operator<(OsnapHit& hit);
Remarks:
This comparison operator is used in sorting.
Parameters:
OsnapHit& hit
The OsnapHit to compare.
Return Value:
TRUE if the distance from the cursor is less than hit; otherwise checks if the depth in Z space is less than hit: If so TRUE; otherwise FALSE.
Prototype:
BOOL operator>(OsnapHit& hit);
Remarks:
This comparison operator is used in sorting.
Parameters:
OsnapHit& hit
The OsnapHit to compare.
Return Value:
TRUE if the distance from the cursor is less than hit; otherwise checks if the depth in Z space is less than hit: If so TRUE; otherwise FALSE.