THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED
On 07/04/2011 at 03:57, xxxxxxxx wrote:
User Information:
Cinema 4D Version: 12
Platform: Windows ;
Language(s) : C++ ;
---------
Hi everyone.
I am using teh following code to detect for collisions with the mouse and objects behind it. If it is true, the object in my plugin highlights to show that the mouse is over that part of the tool. The problem is that this limits the user to only being able to select the tool if the mouse is exactly over the handles which are drawn with DrawPolygonObject().
Using this method for detecting if the mouse is over the tool is fine but I would like to be able to set a radius for the tool and if the tool is within that radius it is also selected. Does anyone know how I coiuld acheive this while incorporating the code below. :)
Thanks,
Shawn
//CHECK FOR COLLISIONS
//=============================================//
Bool UniversalManipulator::IsCollision(PolygonObject *pObj, BaseDraw *bd){
AutoAlloc<GeRayCollider> cRay;
if (!cRay) return FALSE;
GeRayColResult res;
Real x = cursorX;
Real y = cursorY;
// Make sure RayCollider is there
if (!cRay)
{
GePrint("ERROR - RayCollider not Initialized");
return FALSE;
}
Vector wtail = bd->SW(Vector(x, y, 0));
Vector whead = bd->SW(Vector(x, y, 1000000));
Vector otail = (!pObj->GetMg()) * wtail;
Vector oray = (whead - wtail) ^ (!pObj->GetMg());
cRay->Init(pObj, TRUE);
cRay->Intersect(otail, !oray, 1000000.0);
if (cRay->GetNearestIntersection(&res))
{
//GePrint("A COLLISION HAS OCCURED");
return TRUE;
}
return FALSE;
}