Maxon Developers Maxon Developers
    • Documentation
      • Cinema 4D Python API
      • Cinema 4D C++ API
      • Cineware API
      • ZBrush GoZ API
      • Code Examples on Github
    • Forum
    • Downloads
    • Support
      • Support Procedures
      • Registered Developer Program
      • Plugin IDs
      • Contact Us
    • Categories
      • Overview
      • News & Information
      • Cinema 4D SDK Support
      • Cineware SDK Support
      • ZBrush 4D SDK Support
      • Bugs
      • General Talk
    • Unread
    • Recent
    • Tags
    • Users
    • Login

    Custom Lasso Selection

    SDK Help
    0
    23
    12.1k
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • H
      Helper
      last edited by

      On 08/07/2016 at 09:11, xxxxxxxx wrote:

      @Kent: Actually we are not sad at all, if you do our job 😉

      @Scott: It's exactly as Kent said, internally Bool is (yet) an integer, so it can return more than just true and false. And this is still sometimes used for historic and internal reasons. But you (in the sense of every 3rd party developer) really should handle it as a Bool, so you don't run into troubles, when this might change at some point in future. So just check the return value of Test() on (in-)equality to zero.

      1 Reply Last reply Reply Quote 0
      • H
        Helper
        last edited by

        On 08/07/2016 at 09:34, xxxxxxxx wrote:

        Ok. Thanks.
        I just wanted to be sure I wasn't doing it wrong.

        Although targeting a specific point with the Text(x,y) is working (aside from the random int values).
        I'm having a hard time getting it to work properly on each point, of each object, in the scene.
        I'm using a C4DObjectList to grab all the objects. And then I'm using LassoSelection code similar to what I posted on them. But I'm getting inconsistent results.

        This is going to be a fight. 😠
        But I'll keep working on it.

        -ScottA

        1 Reply Last reply Reply Quote 0
        • H
          Helper
          last edited by

          On 09/07/2016 at 10:34, xxxxxxxx wrote:

          Can you please ask the developers about this?
          The TestPolygon() function is not working properly for me in the Parallel & Perspective views.

          //This code will generate a lasso selection in a tooldata plugin  
          //But the lasso selects polygons even if the lasso is not over them, when not using an orthographic view!! (top,bottom,left,right)  
          //Is there a bug in the TestPolygon() function? Or is there a special way to use it in the Parallel & Perspective views?  
            
          Bool MyTool::MouseInput(BaseDocument *doc, BaseContainer &data, BaseDraw *bd, EditorWindow *win, const BaseContainer &msg)  
          {  
            AutoAlloc<LassoSelection> ls;  
            ls->Start(win, MOUSESELECT_FREE);  
            
            BaseObject *obj = doc->GetActiveObject();  
            if (!obj) return false;  
            
            PolygonObject *p_obj = ToPoly(obj);  
            Vector *points = p_obj->GetPointW();  
            LONG polygonCount = p_obj->GetPolygonCount();  
            BaseSelect *polyS = p_obj->GetPolygonS();  
            BaseSelect *pointS = p_obj->GetPointS();  
            Matrix mg = p_obj->GetMg();  
              
            //Start off with nothing selected  
            polyS->DeselectAll();  
            
            for(LONG i=0; i < polygonCount; ++i)  
            {  
                CPolygon poly = p_obj->GetPolygonW()[i];  
            
                //Convert the points of the polygon to Screen space coords (only works in ortho views!!?)  
                //NOTE: The z component can be used to get the distance the point is away from the active camera  
                Vector pa = bd->WS(mg * points[poly.a]);  
                Vector pb = bd->WS(mg * points[poly.b]);  
                Vector pc = bd->WS(mg * points[poly.c]);  
                Vector pd = bd->WS(mg * points[poly.d]);  
             
                Bool test = ls->TestPolygon(pa, pb, pc, pd);  
                GePrint(LongToString(test));  
                if(test == true) polyS->Select(i);     //Select the polygons hit by the lasso  
                else continue;  
            }  
            
            DrawViews(DRAWFLAGS_ONLY_ACTIVE_VIEW|DRAWFLAGS_NO_THREAD|DRAWFLAGS_NO_ANIMATION);  
            SpecialEventAdd(EVMSG_UPDATEHIGHLIGHT);  
            
            return TRUE;  
          }
          

          Thanks,
          -ScottA

          1 Reply Last reply Reply Quote 0
          • H
            Helper
            last edited by

            On 12/07/2016 at 13:37, xxxxxxxx wrote:

            FYI, I'll look into it as soon as possible.

            1 Reply Last reply Reply Quote 0
            • H
              Helper
              last edited by

              On 12/07/2016 at 16:01, xxxxxxxx wrote:

              Thanks Andreas,
              I'm thinking that maybe the camera's matrix might need to be included in the mix somehow?

              Also - The clipping params. are not doing anything.
              I tried setting them to all kinds of values, and no matter what values I used it does nothing. !Confused[URL-REMOVED]

              -ScottA


              [URL-REMOVED] @maxon: This section contained a non-resolving link which has been removed.

              1 Reply Last reply Reply Quote 0
              • H
                Helper
                last edited by

                On 15/07/2016 at 08:36, xxxxxxxx wrote:

                Hi Scott,

                I looked into it, the answer won't make you happy.

                First of all, in my tests, I can't say it doesn't work at all in perspective view. But I agree, it sometimes selects polys the lasso wasn't actually drawn upon.
                The thing is by default TestPolygon uses the bounding box of the drawn lasso. This has historical reasons. Internally the function has an additional parameter to change this behavior, which unfortunately never surfaced to the SDK. So there's currently no way for you to change this behavior.
                The good news is, you did everything correctly 😉

                I filed a bug report on this topic.

                Regarding the clipping, I haven't had the time to look into it. Unfortunately I'll be on vacation until July, 26th and the others in the team are currently pretty loaded. So this will have to wait until I'm back, sorry.

                1 Reply Last reply Reply Quote 0
                • H
                  Helper
                  last edited by

                  On 15/07/2016 at 10:38, xxxxxxxx wrote:

                  OK. Thanks. I had a feeling that this thing was buggered. 😠

                  While I was waiting. I manged to write my own custom lasso tool from scratch.
                  It's not as efficient as the one in C4D. Probably due to me not caching things as much.
                  But it works. So I'll keep working on it rather than try to use the one in the SDK.

                  -ScottA

                  1 Reply Last reply Reply Quote 0
                  • H
                    Helper
                    last edited by

                    On 29/07/2016 at 09:12, xxxxxxxx wrote:

                    Hi Scott,

                    just wanted to add info on the clipping parameters, even if you don't need it anymore.
                    The clipping parameters are completely ignored for the editor window.

                    I'll have a note on this added to the docs.

                    I haven't had the time to test it, but I think, these work only in your own GeUserArea.
                    I'd rather not invest more time into investigating this, as I probably already have disappointed some other community members, by not focusing on their threads (hey, mp5gosu, sorry, you are not forgotten) and you seem to have moved on and don't need it anymore.

                    1 Reply Last reply Reply Quote 0
                    • H
                      Helper
                      last edited by

                      On 29/07/2016 at 12:00, xxxxxxxx wrote:

                      Ok thanks.
                      I gave up on the SDK functions since they are not working correctly. And wrote one from scratch.
                      I'll bet I'm the only person that has even tried using them since they were written decades ago.

                      Yeah. The forum did explode with lots of  hard questions this week.
                      Sucks to be you buddy.😉

                      -ScottA

                      1 Reply Last reply Reply Quote 0
                      • H
                        Helper
                        last edited by

                        On 30/07/2016 at 00:36, xxxxxxxx wrote:

                        Nah, actually it's fun to work with you guys. No, need to worry about us 🙂

                        And I wouldn't say, the SDK functions do not work correctly, actually they do. They are just somewhat limited and we need to document the special cases better. Which is on my list.

                        1 Reply Last reply Reply Quote 0
                        • First post
                          Last post