3ds Max C++ API Reference
HitMesh Class Reference

#include <osnaphit.h>

+ Inheritance diagram for HitMesh:

Public Member Functions

CoreExport HitMesh ()
 
CoreExport ~HitMesh ()
 
CoreExport HitMesh (const HitMesh &h)
 
CoreExport HitMesh (int n)
 
Point3 operator[] (int i)
 
int getNumVerts ()
 
CoreExport void setNumVerts (int n)
 
void setVert (int i, const Point3 &xyz)
 
Point3getVert (int i)
 
Point3getVertPtr ()
 

Additional Inherited Members

- Static Public Member Functions inherited from MaxHeapOperators
static UtilExport voidoperator new (size_t size)
 Standard new operator used to allocate objects If there is insufficient memory, an exception will be thrown. More...
 
static UtilExport voidoperator new (size_t size, const std::nothrow_t &e)
 Standard new operator used to allocate objects if there is insufficient memory, NULL will be returned. More...
 
static UtilExport voidoperator new (size_t size, const char *filename, int line)
 New operator used to allocate objects that takes the filename and line number where the new was called If there is insufficient memory, an exception will be thrown. More...
 
static UtilExport voidoperator new (size_t size, int block_type, const char *filename, int line)
 New operator used to allocate objects that takes the type of memory, filename and line number where the new was called If there is insufficient memory, an exception will be thrown. More...
 
static UtilExport voidoperator new (size_t size, const std::nothrow_t &e, const char *filename, int line)
 New operator used to allocate objects that takes the filename and line number where the new was called If there is insufficient memory, NULL will be returned. More...
 
static UtilExport voidoperator new (size_t size, unsigned long flags)
 New operator used to allocate objects that takes extra flags to specify special operations If there is insufficient memory, an exception will be thrown. More...
 
static UtilExport voidoperator new (size_t size, const std::nothrow_t &e, unsigned long flags)
 New operator used to allocate objects that takes extra flags to specify special operations If there is insufficient memory, NULL will be returned. More...
 
static UtilExport voidoperator new[] (size_t size)
 New operator used to allocate arrays of objects If there is insufficient memory, an exception will be thrown. More...
 
static UtilExport voidoperator new[] (size_t size, const std::nothrow_t &e)
 New operator used to allocate arrays of objects If there is insufficient memory, NULL will be returned. More...
 
static UtilExport voidoperator new[] (size_t size, const char *filename, int line)
 New operator used to allocate arrays of objects If there is insufficient memory, an exception will be thrown. More...
 
static UtilExport voidoperator new[] (size_t size, int block_type, const char *filename, int line)
 New operator used to allocate arrays of objects. More...
 
static UtilExport voidoperator new[] (size_t size, const std::nothrow_t &e, const char *filename, int line)
 New operator used to allocate arrays of objects If there is insufficient memory, NULL will be returned. More...
 
static UtilExport voidoperator new[] (size_t size, unsigned long flags)
 New operator used to allocate arrays of objects If there is insufficient memory, an exception will be thrown. More...
 
static UtilExport voidoperator new[] (size_t size, const std::nothrow_t &e, unsigned long flags)
 New operator used to allocate arrays of objects If there is insufficient memory, NULL will be returned. More...
 
static UtilExport void operator delete (void *ptr)
 Standard delete operator used to deallocate an object If the pointer is invalid, an exception will be thrown. More...
 
static UtilExport void operator delete (void *ptr, const std::nothrow_t &e)
 Standard delete operator used to deallocate an object If the pointer is invalid, nothing will happen. More...
 
static UtilExport void operator delete (void *ptr, const char *filename, int line)
 Delete operator used to deallocate an object that takes the filename and line number where the delete was called If the pointer is invalid, an exception will be thrown. More...
 
static UtilExport void operator delete (void *ptr, int block_type, const char *filename, int line)
 Delete operator used to deallocate an object that takes the type of memory, filename and line number where the delete was called If the pointer is invalid, an exception will be thrown. More...
 
static UtilExport void operator delete (void *ptr, const std::nothrow_t &e, const char *filename, int line)
 Delete operator used to deallocate an object that takes the filename and line number where the delete was called If the pointer is invalid, nothing will happen. More...
 
static UtilExport void operator delete (void *ptr, unsigned long flags)
 Delete operator used to deallocate an object that takes extra flags to specify special operations If the pointer is invalid, an exception will be thrown. More...
 
static UtilExport void operator delete (void *ptr, const std::nothrow_t &e, unsigned long flags)
 Delete operator used to deallocate an object that takes extra flags to specify special operations If the pointer is invalid, nothing will happen. More...
 
static UtilExport void operator delete[] (void *ptr)
 Standard delete operator used to deallocate an array of objects If the pointer is invalid, an exception will be thrown. More...
 
static UtilExport void operator delete[] (void *ptr, const std::nothrow_t &e)
 Standard delete operator used to deallocate an array of objects If the pointer is invalid, nothing will happen. More...
 
static UtilExport void operator delete[] (void *ptr, const char *filename, int line)
 Delete operator used to deallocate an array of objects that takes the filename and line number where the delete was called If the pointer is invalid, an exception will be thrown. More...
 
static UtilExport void operator delete[] (void *ptr, int block_type, const char *filename, int line)
 Delete operator used to deallocate an array of objects that takes the type of memory, filename and line number where the delete was called If the pointer is invalid, an exception will be thrown. More...
 
static UtilExport void operator delete[] (void *ptr, const std::nothrow_t &e, const char *filename, int line)
 Delete operator used to deallocate an array of objects that takes the filename and line number where the delete was called If the pointer is invalid, nothing will happen. More...
 
static UtilExport void operator delete[] (void *ptr, unsigned long flags)
 Delete operator used to deallocate an array of objects that takes extra flags to specify special operations If the pointer is invalid, an exception will be thrown. More...
 
static UtilExport void operator delete[] (void *ptr, const std::nothrow_t &e, unsigned long flags)
 Delete operator used to deallocate an array of objects that takes extra flags to specify special operations If the pointer is invalid, an exception will be thrown. More...
 
static UtilExport voidoperator new (size_t size, void *placement_ptr)
 Placement new operator. More...
 
static UtilExport void operator delete (void *ptr, void *placement_ptr)
 Placement delete operator. More...
 
static UtilExport voidaligned_malloc (size_t size, size_t alignment)
 Allocates memory on a specified alignment boundary. More...
 
static UtilExport voidaligned_realloc (void *ptr, size_t size, size_t alignment)
 Reallocates memory on a specified alignment boundary. More...
 
static UtilExport void aligned_free (void *ptr)
 Frees a block of memory that was allocated with aligned_malloc/aligned_realloc. More...
 

Detailed Description

See also
Class Osnap, The Advanced Topics section on Snapping..

Description:
This is a class to hold a list of object space points for highlighting the geometry associated with a hit. One oddity of this class is that you need to allocate one point more than the number of points you actually need. This additional storage is used for clipping against the viewport at display time. For example the "endpoint" snap would alocate a three-point hitmesh to highlight the edge which was hit (See the example below) .

The class has data members for the number of points and a pointer to the actual Point3 list.

In practice, developers need only use the first two methods shown below.

Constructor & Destructor Documentation

◆ HitMesh() [1/3]

Remarks
Constructor. The number of points is set to zero and the point list is set to NULL.

◆ ~HitMesh()

Remarks
Destructor. If point list is allocated it is freed.

◆ HitMesh() [2/3]

CoreExport HitMesh ( const HitMesh h)
Remarks
Constructor. The number of points and the points are initialized from the HitMesh passed.
Parameters:
const HitMesh& h

The HitMesh to init from.

◆ HitMesh() [3/3]

Remarks
Constructor. The number of vertices is set to the value n passed and the points array is allocated with that size. This is the constructor that plugin developers will typically use in conjunction with the setVert() method described below.
Parameters:
int n

The number of points to allocate.

Member Function Documentation

◆ operator[]()

Point3 operator[] ( int  i)
inline
Remarks
Access operator. Return the 'i-th' point.
Parameters:
int i

Specifies the point to return.
245 {return m_pverts[i];}

◆ getNumVerts()

int getNumVerts ( )
inline
Remarks
Returns the number of points in this HitMesh.
247 {return m_numverts;}

◆ setNumVerts()

CoreExport void setNumVerts ( int  n)
Remarks
Sets the number of vertices. This frees any existing verts and allocates new ones.
Parameters:
int n

The number of points to allocate.

◆ setVert()

void setVert ( int  i,
const Point3 xyz 
)
inline
Remarks
Sets the 'i-th' vertex to the specified value.
Parameters:
int i

The vertex to set.

const Point3 &xyz

The value to set.

In practice, developers need only use the two previous methods. The following code segment from the mesh snap exemplifies their use.

//add the hit points based on the active subsnaps
if(GetActive(EDGE_SUB)) // The edge snapping is active and we have a hit on the edge defined by from and to.
{
HitMesh *hitmesh = new HitMesh(3); //Allocate one more than we need.
hitmesh->setVert(0, from);
hitmesh->setVert(1, to);
float dap = Length(cursor - sf2);
assert(Length(st2 - sf2)>=0.0f);
float pct = (float)sqrt(fabs(dap*dap - distance*distance)) / Length(st2 - sf2);
Point3 cand;
float pctout = gw->interpWorld(&xyz[0],&xyz[1],pct,&cand);
theman->RecordHit(new EdgeHit(cand, this, EDGE_SUB, hitmesh, ifrom, ito, pct));
}
Definition: osnaphit.h:216
void setVert(int i, const Point3 &xyz)
Definition: osnaphit.h:277
CoreExport HitMesh()
Definition: point3.h:56
float Length(const Color &v)
Definition: color.h:465
#define assert(expr)
Definition: assert1.h:81
277 { m_pverts[i] = xyz; }

◆ getVert()

Point3& getVert ( int  i)
inline
Remarks
Returns the 'i-th' vertex.
279 {return m_pverts[i];}

◆ getVertPtr()

Point3* getVertPtr ( )
inline
Remarks
Returns a pointer to the array of points.
Operators:
283 {return m_pverts;}