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