Class HitRecord

3DS Max Plug-In SDK

Class HitRecord

See Also: Class HitLog, Class HitData.

class HitRecord

Description:

This class provides a data structure used during sub-object hit-testing.

Friend Class:

class HitLog

Data Members:

public:

INode *nodeRef;

Points the node that was hit.

ModContext *modContext;

Points to the ModContext of the modifier.

DWORD distance;

The 'distance' of the hit. To classify as a hit, the sub-object component must be within some threshold distance of the mouse. This distance is recorded in the hit record so that the closest of all the hits can be identified. What the distance actually represents depends on the rendering level of the viewport. For wireframe modes, it refers to the distance in the screen XY plane from the mouse to the sub-object component. In a shaded mode, it refers to the Z depth of the sub-object component. In both cases, smaller values indicate that the sub-object component is 'closer' to the mouse cursor.

ulong hitInfo;

A general unsigned long value. Most modifiers will just need this to identity the sub-object element. The edit mesh modifier uses the value to store the index of the vertex or face that was hit for example.

HitData *hitData;

In case 4 bytes is not enough space to identity the sub-object element, this pointer is available. To use this, a developer would define a class derived from HitData that would contain the necessary data. The HitData class has one member function, a virtual destructor, so the derived class can be properly deleted when the HitRecord instance is deleted.

Methods:

Prototype:

HitRecord();

Remarks:

Constructor. The following initialization is performed: next = NULL; modContext = NULL; distance = 0; hitInfo = 0; hitData = NULL;

Prototype:

HitRecord(INode *nr, ModContext *mc, DWORD d, long inf,

HitData *hitdat)

Remarks:

Constructor. The data members are initialized to the data passed.

Prototype:

HitRecord *Next();

Remarks:

Implemented by the System.

Each HitRecord maintains a pointer to another HitRecord. This method returns the next hit record.

Prototype:

~HitRecord();

Remarks:

Implemented by the System.

Destructor. If HitData has been allocated, it is deleted as well.