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
    • Unread
    • Recent
    • Tags
    • Users
    • Login

    GeRayCollider again

    Scheduled Pinned Locked Moved SDK Help
    2 Posts 0 Posters 242 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 14/08/2006 at 02:42, xxxxxxxx wrote:

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

      ---------
      Hi,

      I already read all the topics concerning geRayCollider but I can't get my code working. The goal is very easy: I have two objects and I want to send a ray to find the nearest point of ojb2 from the originof obj1. So, I did it like that (I adapted a code I found in this forum) :

      AutoAlloc<GeRayCollider> rc;
      if (!rc) return FALSE;
      if(rc->Init(obj2, TRUE))
      {
           Matrix obj1Mat = obj1->GetMg();
           Matrix obj2Mat = obj2->GetMg();
           Matrix invertObj2Mat = !obj2Mat;
           Vector wtail = obj1Mat.off;
           Vector whead = obj2Mat.off;
           Vector otail = invertObj2Mat * wtail;
           Vector oray = (whead-wtail) ^ invertObj2Mat;

      if(rc->Intersect(otail, !oray, 1000000.0))
           {
                GeRayColResult res;
                if (rc->GetNearestIntersection(&res;))
                {
                     GePrint("Collided");
                }
           }
      }
      I call this in the method MouseInput of a ToolData plugin, it is just a test.

      I did something wrong but I can't find what. The both vector otail and oray are correct and in obj2 coordinates. What I don't understand is the call of Intersect with !oray. I tried also without inverting but it doesn't work better... Well if someone has an idea...

      Thanks in advance.

      Vincent

      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 15/08/2006 at 01:23, xxxxxxxx wrote:

        Hi,

        the "!" operator returns a vector of unit length and lets the direction unchanged.

        Beside that, you say that you want to find the nearest point of obj2. This code doesn't really do that. It could even be that the origins are located way off the actual object center.

        If you are sure that there should be an intersection point.. i'm sorry, i can't tell you what's wrong. It looks pretty okay to me.

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