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

    Collision within a Radius

    Scheduled Pinned Locked Moved SDK Help
    17 Posts 0 Posters 1.2k 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 07/04/2011 at 14:52, xxxxxxxx wrote:

      (0,0,0) is correct.

      Because you calculate the distance between your 'intersection line' and a hit point of the intersection.

      A Point at a line = distance = 0. 😉

      You should do it maybe with points of a polygon near the hit point.

      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 07/04/2011 at 16:16, xxxxxxxx wrote:

        Like this?

        Vector distance = PointLineDistance(wtail, oray, pObj->GetMg().off);

        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 07/04/2011 at 16:25, xxxxxxxx wrote:

          How does the vector returned by PointLineDistance() represent the distance,,,  what does each Real in the Vector represent?

          for example   when I use the above line I get a bunch of different numbers and those numbers do not seem to be the same when the camera is in different places..

          Hopefully that makes sense..  lol

          ~Shawn

          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 07/04/2011 at 16:44, xxxxxxxx wrote:

            The ray should be in the same space as the object and the shortest distance is the length of the returned vector.

            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 07/04/2011 at 17:27, xxxxxxxx wrote:

              okay I've got it work using

                
                
              Vector distance = PointLineDistance(wtail, whead, pObj->GetMg().off);  
                Real disX = distance.x;  
                Real disY = distance.y;  
                Real disZ = distance.z;  
                
                //if (cRay->GetNearestIntersection(&res))  
                if((disX > -20 && disX < 20) && (disY > -20 && disY < 20) && (disZ > -20 && disZ < 20))    
                {  
                    //GePrint("A COLLISION HAS OCCURRED");  
                    return TRUE;  
                }  
                
              

              now in order to make this whole thing work the right way I need to be able to capture the initial mouse location when the mouse is clicked and dragged and then not get the mouse location while it is dragging..   So basically I want the mouse location where the user clicks but then I don't want the location while the mouse is dragging.

              Is this possible...  I currently use BFM_INPUT_X & BFM_INPUT_Y  to get the mouse location but this value changes as the mouse is dragging.

              Thanks,

              Shawn

              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 07/04/2011 at 18:24, xxxxxxxx wrote:

                Just use GetLength(), e.g.

                const Real threshold = 10.0;   
                Real dist = result.GetLength();   
                if(dist <= threshold) return TRUE;
                
                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 07/04/2011 at 18:35, xxxxxxxx wrote:

                  Thank you David that is much cleaner..  🙂

                    
                    Vector distance = PointLineDistance(wtail, whead, pObj->GetMg().off);  
                    const Real threshold = 20.0;  
                    Real dist = distance.GetLength();  
                      
                    if(dist <= threshold)    
                    {  
                        //GePrint("A COLLISION HAS OCCURED");  
                        return TRUE;  
                    }  
                  

                  Anyone know about getting the mouse position of the initial click when doing a mouse drag?

                  Thanks,

                  Shawn

                  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 07/04/2011 at 23:12, xxxxxxxx wrote:

                    Hello,
                    a question where you perform this?
                    if you hare in mouse input you can use ViewPortSelect::PickObject()
                    this will fill a c4dobjectlist with all obj in the radius in z order.
                    it will have not very good performance but can solve the situation.

                    try it

                    all the best
                    Franz

                    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 08/04/2011 at 02:50, xxxxxxxx wrote:

                      Hi Franz.   Thanks,   I am able to select within a set radius now.  See the last code I posted.  Now I am trying to figure out how to capture the screen coordinates of the first initial mouse click when the user drags the mouse.  I do not want to keep storing the mouse position after that first click so I need to figure out how to store only that first click.  🙂

                      Thanks,

                      Shawn

                      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 08/04/2011 at 07:40, xxxxxxxx wrote:

                        This is from the liquid draw example in the SDK.
                        Seems to work.

                        Real mx = msg.GetReal(BFM_INPUT_X);  
                        Real my = msg.GetReal(BFM_INPUT_Y);  
                        GePrint(RealToString(mx));  
                        GePrint(RealToString(my));  
                        

                        -ScottA

                        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 08/04/2011 at 08:27, xxxxxxxx wrote:

                          Howdy,

                          Originally posted by xxxxxxxx

                          ...Now I am trying to figure out how to capture the screen coordinates of the first initial mouse click when the user drags the mouse.  I do not want to keep storing the mouse position after that first click so I need to figure out how to store only that first click....

                          If you store the mouse x and y in local variables startx and starty, and do that before the while loop, those variables won't change during the dragging.  😉

                          Adios,
                          Cactus Dan

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