THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED
On 16/06/2011 at 02:20, xxxxxxxx wrote:
I'm using this script to check out the GeRayCollider - class.
But there are some things I don't understand.
1. Even when I set the Rays length to 1 in ray.Intersection(), there is an intersection, although there are elss intersections, there shouldn't be any !
2. I get multiple intersections for each "real" intersection. Testing on a cube, I get 4 Intersections, with only 2 expected. The other 2 Intersections are at the same point as the original ones.
Testing on a Sphere i get 6 Intersections, but I do expect onl 2.
3. The object's rotation is not recognized. How do I prevent from this ?
Thanks, Niklas !
import c4d from c4d.utils import GeRayCollider def main() : if not op: print "No object selected." return if not op.CheckType(c4d.Opolygon) : print "Must be a Polygon Object." return ray = GeRayCollider() ray.Init(op) v1 = c4d.Vector(300,0,0) v2 = c4d.Vector(-300,0,0) print ray.Intersect(v1, v2, 20) cnt = ray.GetIntersectionCount() for i in xrange(cnt) : obj = c4d.BaseObject(c4d.Osphere) obj[c4d.PRIM_SPHERE_RAD] = 5 sct = ray.GetIntersection(i) pos = sct["hitpos"] obj.SetAbsPos(pos) doc.InsertObject(obj) obj.Message(c4d.MSG_UPDATE) print pos main()