Maxon Developers Maxon Developers
    • Documentation
      • Cinema 4D Python API
      • Cinema 4D C++ API
      • Cineware API
      • ZBrush Python 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
    • Recent
    • Tags
    • Users
    • Login

    Any examples on DetectSnapping Lib ?

    Scheduled Pinned Locked Moved SDK Help
    4 Posts 0 Posters 412 Views
    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 Offline
      Helper
      last edited by

      THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED

      On 17/01/2010 at 03:40, xxxxxxxx wrote:

      User Information:
      Cinema 4D Version:   9.6-11.5 
      Platform:   Windows  ; Mac  ;  
      Language(s) :     C++  ;

      ---------
      Hi,

      i want to add some snapping functionality to my Tool plugin, so I'm currently asking myself if i have to compute everything myself, or if I can use the DetectSnapping lib.

      So I included the standart snapping tab in my toolPlugin.res, and alloc'd a DetectSnapping object.
      Also I added the 'PLUGINFLAG_TOOL_SNAPSETTINGS' flag when registering the ToolPlugin.

      Then I try to detect a snap in my MouseInput function, like this:

        
      BaseObject* obj = doc->GetActiveObject();   
      .   
      .   
      AutoAlloc<DetectSnapping> detect;   
      detect->Init(doc,bd,obj,NULL,0,TRUE,TRUE,TRUE);   
      Vector delta;   
      .   
      .   
      if(button==KEY_MLEFT){   
                     if(detect->IsEnabled(doc)){   
                          GePrint("snap is on");   
                          detect->SnapTo(res.hitpos,δ);   
                          Utils::printVec("",delta);   
                     }   
                     else GePrint("Snap is off!");   
      .   
      .   
      

      res.hitpos is the rayCollider hit position on obj, that i click with the mouse.

      'IsEnabled' works as it should, it gives me TRUE when its enabled in my snapping tab, but the result in delta seems to be incorrect.

      When i set mode to 'Snap3D' and enable point-snap, delta is off like 100-200 units even though i click directly onto a point of obj, in the perspective view.

      So my question is how to use the DetectSnapping.lib and does it provide the complete snapping functionality that for example the move tool has ?
      Am I on the right track with the above code, or does it not work like that ?

      When i call SnapTo() does it take into account all the settings i did in the snapping tab of my plugin automatically,as it is the standart c4d snapping tab, and i set the snapping flag in registerToolPlugin(..) ?

      There dont seem to be any examples on how to use it, so the above code is actually just my guess on how to use it.

      greetings,
      Daniel

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

        THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED

        On 22/01/2010 at 03:08, xxxxxxxx wrote:

        so nobody has any experience with this ?
        (aka bump ..)

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

          THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED

          On 25/01/2010 at 09:19, xxxxxxxx wrote:

          does anbody know what delta exactly returns ?
          i always assumed it was the difference between the argument vector of SnapTo, and the nearest possible snap point, according to the snap settings.

          seems to give me some unrealistic values though in my tests..

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

            THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED

            On 26/01/2010 at 00:41, xxxxxxxx wrote:

            The delta is indeed the difference between the position to check for snapping and the snap position. Check if SnapTo returns TRUE and if so a snapping was found and delta filled accordingly.

            This is the code I used in one of my plugins.

              
            AutoAlloc<DetectSnapping> snap;  
            if (!snap) return FALSE;  
            snap->Init(doc, bd, NULL, Vector(), 0, FALSE, TRUE, TRUE);  
              
            Vector pos = ...; //pos is the position i want to check for snapping  
            Vector delta;  
              
            if (snap->SnapTo(pos, &delta))  
            {  
              pos += delta; //if pos can be snapped it is set accordingly  
            }  
            

            cheers,
            Matthias

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