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

    SnapCore and Intersect

    Cinema 4D SDK
    2
    4
    572
    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.
    • RenatoTR
      RenatoT
      last edited by

      Hi all,
      I tried the code described in this thread: https://developers.maxon.net/forum/topic/6626/7199_r14-snap-system/10
      This code inside the liquitool example work as expected.
      But if i try to use SnapCore::Intersect instead SnapCore::Snap, to get the normal at point, this code don't work.

      This is the line that I changed to:
      if (snap->Intersect(pos, norm, false, res)) instead if (snap->Snap(pos, res))

      Seem that the intersection don't work anymore.

      Any help?
      Thanks in advance
      Renato T.

      Real mx = msg.GetReal(BFM_INPUT_X);
      Real 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<SnapCore> snap;  // Allocate snap
      if (!snap) return FALSE;
        
      snap->Init(doc, bd);
        
      Real dx, dy;
      BaseContainer bc;
      BaseContainer device;
      Vector pos;
      SnapResult res;
        
      BaseObject *active = doc->GetActiveObject();
        
      win->MouseDragStart(button, mx, my, MOUSEDRAGFLAGS_DONTHIDEMOUSE|MOUSEDRAGFLAGS_NOMOVE);
      while (win->MouseDrag(&dx,&dy,&device)==MOUSEDRAGRESULT_CONTINUE) // Start drag
      {
          // Increment mouse position during drag
          mx += dx;
          my += dy;
          pos = bd->SW(Vector(mx, my, 500)); // Update pos
        
          if (snap->Snap(pos, res)) // If point snap anywhere 
          {
              pos += res.delta; // Pos will be updated with snapped delta
          }
        
          if (active)
              active->SetAbsPos(pos); // Set the object position to the new one!
        
          DrawViews(DRAWFLAGS_ONLY_ACTIVE_VIEW|DRAWFLAGS_NO_THREAD|DRAWFLAGS_NO_ANIMATION); // Update viewport
      }
        
      win->MouseDragEnd(); // Reset viewport status
        
      EventAdd();
      
      1 Reply Last reply Reply Quote 0
      • RenatoTR
        RenatoT
        last edited by

        Seem that the normal is returned by SnapCore::Snap in SnapResult::mat.v2. I'm verifying

        1 Reply Last reply Reply Quote 0
        • M
          m_adam
          last edited by

          Hi @RenatoT, I don't think there is an issue,

          just in case Intersect is supposed to work only for guide and spline see Modeling Settings - Intersection Snap. So maybe you are looking for GeRayCollider::Interesct.

          Cheers,
          Maxime.

          MAXON SDK Specialist

          Development Blog, MAXON Registered Developer

          1 Reply Last reply Reply Quote 0
          • RenatoTR
            RenatoT
            last edited by

            Hi Maxime. Thanks for reply. At last I used the BVHTree for that.

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