public unsafe Intersection Trace(Point3D from, Vector direction, float near = 0, float far = float.PositiveInfinity, float time = 0) { var p = RTC.RayInterop.Packet1; p->orgX = from.X; p->orgY = from.Y; p->orgZ = from.Z; p->dirX = direction.X; p->dirY = direction.Y; p->dirZ = direction.Z; p->geomID = RTC.InvalidGeometryID; p->primID = RTC.InvalidGeometryID; p->instID = RTC.InvalidGeometryID; p->time = time; p->tnear = near; p->tfar = far; RTC.Intersect1(scenePtr, p); if (p->geomID == RTC.InvalidGeometryID) { return(null); } else { int geomId = (int)p->geomID; IObj obj = null; if (geomId < this.Scene.Objects.Count) { obj = this.Scene.Objects[(int)p->geomID]; } else { obj = geometryIdLights[geomId]; } var face = obj.Faces[(int)p->primID]; float distance = p->tfar; var dr = direction * distance; var r = from + dr; return(new Intersection(obj, face, distance, r)); } }