calculate globalmatrix for GeRayCollider

  • 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],marr[i], 300) == True:
                marr[i].off =  ray.GetNearestIntersection()["hitpos"]
        md.SetArray(c4d.MODATA_MATRIX, marr, True)
        return True

  • 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:

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


    The explanation and script source code in the following post should help you:

Log in to reply