On 29/04/2014 at 01:20, xxxxxxxx wrote:
Using the ray collider, I get some results that I don't understand.
The order of face/backface changes when the ray is running through 4 polygons in comparison to 2 polygons.
Any ideas?
Thanks,
M
import c4d
def SetGlobalPosition(obj, pos) :
m = obj.GetMg()
m.off = pos
obj.SetMg(m)
def main() :
if op==None: return None
doc.StartUndo()
doc.AddUndo(c4d.UNDOTYPE_CHANGE, op)
HitList=[]
boundingbox = op.GetRad()*2
dim=boundingbox.x/10
collider = c4d.utils.GeRayCollider()
collider.Init(op,True)
offsetZ=op.GetMp().z-boundingbox.z/2-0.1
y= -50
inter = collider.Intersect(c4d.Vector(0,y,offsetZ),c4d.Vector(0,0,1), boundingbox.z+0.2)
print y
if inter ==True:
count= collider.GetIntersectionCount()
c=0
while c<count:
collpos = collider.GetIntersection(c)["hitpos"]
if collpos.z not in HitList:
back = collider.GetIntersection(c)["backface"]
print back
target = c4d.BaseObject(c4d.Onull)
SetGlobalPosition(target,collpos)
target.InsertUnder(op)
target.Message(c4d.MSG_UPDATE)
target.SetBit(c4d.BIT_ACTIVE)
HitList.append(collpos.z)
print c,"HitCount"
c+=1
op.DelBit(c4d.BIT_ACTIVE)
c4d.EventAdd()
if __name__=='__main__':
main()