#include "lvkrn.h"
L_LVKRN_API L_INT L_VecHitTest(pVector, pPoint, pObject)
Performs a hit test using the specified 2D point.
Pointer to a vector handle.
Pointer to a POINT structure that contains the point to test.
Pointer to a VECTOROBJECT structure to be updated with the object found under the specified point, if one exists.
Value | Meaning |
---|---|
SUCCESS | The function was successful and an object was copied into pObject. |
ERROR_VECTOR_OBJECT_NOT_FOUND | No object was found under the specified point. |
< 1 | An error occurred. Refer to Return Codes. |
This function will copy the first object under the specified physical point into pObject.
To set the options to use when performing the hit test, call L_VecSetHitTest.
Camera, view port, rotation, translation and scaling are all considered when determining whether or not an object is under the specified point.
Required DLLs and Libraries
This example will select the object under the mouse cursor.
L_INT VecHitTestExample(
pVECTORHANDLE pVector,
POINT* pptMouse)
{
VECTOROBJECT Object;
VECTOROBJECT TempObject;
L_INT nRet;
nRet = L_VecHitTest( pVector, pptMouse, &Object );
if( nRet == SUCCESS )
{
/* Get the object to edit */
nRet = L_VecGetObject( pVector, &Object, Object.nType, &TempObject );
if(nRet != SUCCESS)
return nRet;
/* Select it */
TempObject.dwFlags |= VECTOR_OBJECT_SELECTED;
/* Apply changes */
nRet = L_VecSetObject( pVector, &Object, Object.nType, &TempObject );
if(nRet != SUCCESS)
return nRet;
/* Must free the temporary object when not used anymore */
nRet = L_VecFreeObject( TempObject.nType, &TempObject );
}
return nRet;
}