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
    • Admin
    • Login

    calculate globalmatrix for GeRayCollider

    Scheduled Pinned Locked Moved PYTHON Development
    3 Posts 0 Posters 346 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

      On 17/03/2016 at 03:23, xxxxxxxx wrote:

      how do i calculate the correct matrixes for a geraycollide to get the option to move the target and the source? all i see is that geraycollide works with local matrixes and i presume that i need to calculate a global matrix for it. but i don't know how

        
      import c4d
      from c4d.modules import mograph as mo
      from c4d.utils import GeRayCollider
      #Welcome to the world of Python
        
      def main() :
        
          md = mo.GeGetMoData(op)
          if md is None: return False
          
          cnt = md.GetCount()
          marr = md.GetArray(c4d.MODATA_MATRIX)
          fall = md.GetFalloffs()
          ray = GeRayCollider()
          UsrDtColl = op[c4d.ID_USERDATA,1]
          ray.Init(UsrDtColl, True)
          
          ml = gen.GetMl()
          mg = gen.GetMg()
          img = ~mg
          
        
          
          for i in reversed(xrange(0, cnt)) :
                      
              if ray.Intersect(marr[i].off+img.off,marr[i].off+img.off, 300) == True:
                  marr[i].off =  ray.GetNearestIntersection()["hitpos"]
                  
          md.SetArray(c4d.MODATA_MATRIX, marr, True)
          
         
        
          return True
        
      
      
      1 Reply Last reply Reply Quote 0
      • H Offline
        Helper
        last edited by

        On 17/03/2016 at 16:12, xxxxxxxx wrote:

        status update:

        now i can move the source point of the GeRayCollide, rotate won't work atm.
        next step is to make the collider moveable too.

        current file:

        http://postwendend.com/frei/ray2.c4d

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

          On 18/03/2016 at 03:16, xxxxxxxx wrote:

          Hi,

          The explanation and script source code in the following post should help you:
          https://developers.maxon.net/forum/topic/8840/11677_problem-with-geraycollider-solved&PID=46053#46053

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