Tool plugin - select edges?
-
THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED
On 16/12/2008 at 08:32, xxxxxxxx wrote:
User Information:
Cinema 4D Version: 9.1+
Platform: Windows ; Mac ; Mac OSX ;
Language(s) : C++ ;---------
Howdy,I'm trying to create a tool similar to the live selection tool, but I have a problem. How do you detect when an edge is within the radius if the mouse pointer is off the object? GeRayCollider is useless in this situation. :o(
Adios,
Cactus Dan -
THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED
On 16/12/2008 at 08:36, xxxxxxxx wrote:
Have you checked the ViewPortSelect class?
cheers,
Matthias -
THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED
On 16/12/2008 at 08:44, xxxxxxxx wrote:
Howdy,
Wow! I wasn't aware of that class. Thanks!
BTW, this would be a good one to add to your "more examples" list you're compiling. ;o)
Adios,
Cactus Dan -
THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED
On 16/12/2008 at 09:33, xxxxxxxx wrote:
Yeah, the class is indeed nicely tucked away I will change this for the next update of the SDK documentation.
cheers,
Matthias -
THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED
On 16/12/2008 at 12:11, xxxxxxxx wrote:
Howdy,
I already have a question for you. I'm calling ShowHotspot() from the while loop in MouseInput(), but it seems to flicker even when the mouse is not moving. How do you get it to not flicker when the mouse is still?
Adios,
Cactus Dan -
THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED
On 17/12/2008 at 01:32, xxxxxxxx wrote:
This seems to work fine for me:
>
\> Bool EdgeCutTool::MouseInput(BaseDocument \*doc, BaseContainer &data;, BaseDraw \*bd, EditorWindow \*win, const BaseContainer &msg;) \> { \> if (!doc) return FALSE; \> \> BaseObject \*op = NULL; \> op = doc->GetActiveObject(); \> if(!op) return TRUE; \> \> Real dx, dy, len = data.GetReal(MDATA_EDGECUTSDK_OFFSET, 0.0); \> BaseContainer device; \> Real mousex = msg.GetLong(BFM_INPUT_X); \> Real mousey = msg.GetLong(BFM_INPUT_Y); \> win->MouseDragStart(KEY_MLEFT, mousex, mousey, MOUSEDRAG_NOMOVE); \> \> AutoAlloc<ViewportSelect> vps; \> if(!vps) return FALSE; \> \> LONG left, top, right, bottom, width, height; \> bd->GetFrame(&left;, ⊤, &right;, ⊥); \> width = right - left + 1; \> height = bottom - top + 1; \> \> if(!vps->Init(width, height, bd, op, doc->GetMode(), TRUE, VIEWPORT_IGNORE_HIDDEN_SEL)) return FALSE; \> \> vps->SetBrushRadius(50); \> \> LONG x = mousex; \> LONG y = mousey; \> \> vps->ShowHotspot(win, x, y); \> \> while (win->MouseDrag(&dx;, &dy;, &device;) == MOUSEDRAG_CONTINUE) \> { \> if (dx == 0 && dy == 0) \> continue; \> \> x += dx; \> y += dy; \> \> DrawViews(DA_ONLY_ACTIVE_VIEW|DA_NO_THREAD|DA_NO_ANIMATION); \> vps->ShowHotspot(win, x, y); \> } \> \> vps->ShowHotspot(win, x, y); \> \> win->MouseDragEnd(); \> \> return TRUE; \> } \>
I called ShowHotspot() before and after the while loop to draw and clear the circle. In the while loop I called it after the redraw.
cheers,
Matthias -
THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED
On 17/12/2008 at 08:02, xxxxxxxx wrote:
Howdy,
Well, this is another DOH! I forgot to add the line:
>
\> if(dx == 0 && dy == 0) continue; \>
OK, with that solved, on to the next question:
There seems to be a problem if the view angle is not straight on and it's more evident with a larger brush size:
Select too soonYou can see in the video that with the view straight on it behaves as expected, but when the view is rotated so that it's looking down from above, the polygons get selected before they're within the brush radius, and the first polygon to be selected is not actually the closest one to the brush.
Here's the code:
>
\> case Mpolygons: \> { \> LONG x = mx, y = my; \> ViewportPixel \*vp = vps->GetNearestPolygon(op,x,y,rad); \> if(vp) \> { \> if(ctrl) bs->Deselect(vp->i); \> else bs->Select(vp->i); \> } \> break; \> } \>
Is this the correct way to do it? Since there isn't much example code for the ViewPortSelect class, I'm sort of winging it. :o(
Adios,
Cactus Dan -
THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED
On 17/12/2008 at 08:42, xxxxxxxx wrote:
Howdy,
OK, never mind. I figured it out. I needed to compare the altered x,y pixel coordinates with the mouse coordinates, and see if the distance was less than the brush radius. ;o)
New code:
>
\> case Mpolygons: \> { \> LONG x = mx, y = my; \> ViewportPixel \*vp = vps->GetNearestPolygon(op,x,y,rad); \> if(vp) \> { \> Vector mpt = Vector(mx,my,0.0); \> Vector pxl = Vector(x,y,0.0); \> \> if(Len(pxl - mpt) < rad) \> { \> if(ctrl) bs->Deselect(vp->i); \> else bs->Select(vp->i); \> } \> } \> break; \> } \>
Looks like I'm having a "DOH!" coding week here. :oD
Adios,
Cactus Dan