THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED
On 21/10/2005 at 18:39, xxxxxxxx wrote:
User Information:
Cinema 4D Version: 9.5
Platform: Windows ; Mac ; Mac OSX ;
Language(s) : C++ ;
---------
Howdy,
I have a problem with my tool plugin and the GeRayCollider in the perspective view. It's not detecting a collision when one part of the mesh is behind another part if there is a lot of distance between the parts.
When the foot is below the hand in the perspective view it picks up points of the foot:
But when the the polygons of the foot are moved closer to the hand then it is detecting a collision.
It works fine in the Top View no matter how much distance is between the hand and foot:
Here is the code:
Bool TestTool::MouseInput(BaseDocument *doc, BaseContainer &data;, BaseDraw *bd,EditorWindow *win, const BaseContainer &msg;)
{
opActive = doc->GetActiveObject(); if(!opActive) return TRUE;
Vector rayEnd, rayStart, opt, mpt, *padr = ToPoint(opActive)->GetPoint();
LONG index, ptCount = ToPoint(opActive)->GetPointCount();
Matrix rayMatrix;
mx = msg.GetReal(BFM_INPUT_X);
my = msg.GetReal(BFM_INPUT_Y);
LONG button;
switch (msg.GetLong(BFM_INPUT_CHANNEL))
{
case BFM_INPUT_MOUSELEFT : button=KEY_MLEFT; break;
case BFM_INPUT_MOUSERIGHT: button=KEY_MRIGHT; break;
default: return TRUE;
}
AutoAlloc<GeRayCollider> rc;
if (!rc) return FALSE;
rc->Init(opActive, TRUE);
Real dx, dy, rad=data.GetReal(1000);
mDrag = FALSE;
BaseContainer bc, device;
BaseSelect *bs = ToPoint(opActive)->GetPointS(); if (!bs) return TRUE;
win->MouseDragStart(button,mx,my,MOUSEDRAG_DONTHIDEMOUSE|MOUSEDRAG_NOMOVE);
while (win->MouseDrag(&dx;,&dy;,&device;)==MOUSEDRAG_CONTINUE)
{
mx+=dx;
my+=dy;
mDrag = TRUE;
for(index=0; index<ptCount; index++)
{
opt = bd->WS(opActive->GetMg() * padr[index]);
opt.z = 0.0;
mpt.x = mx;
mpt.y = my;
mpt.z = 0.0;
if(Len(opt - mpt) < rad)
{
if(data.GetBool(1001))
{
rayEnd = bd->SW(Vector(mx,my,0));
rayStart = bd->SW(Vector(mx,my,10000.0));
rayDir = !opActive->GetMg() * (rayEnd - rayStart);
rayPt = padr[index] + !rayDir*0.1;
if(!rc->Intersect(rayPt, !rayDir, 10000.0))
{
bs->Select(index);
}
}
else
{
bs->Select(index);
}
}
}
DrawViews(DA_ONLY_ACTIVE_VIEW|DA_NO_THREAD|DA_NO_ANIMATION);
}
mDrag = FALSE;
DrawViews(DA_ONLY_ACTIVE_VIEW|DA_NO_THREAD|DA_NO_ANIMATION);
return TRUE;
}
I'm not sure exactly what's wrong. Any ideas?
Adios,
Cactus Dan