public int FindFirstRay(RayBundle rayBundle, int rayIndexToStartCheckingFrom) { // check if first ray hits bounding box if (rayBundle.rayArray[rayIndexToStartCheckingFrom].Intersection(Aabb)) { return(rayIndexToStartCheckingFrom); } int count = rayBundle.rayArray.Length; // check if all bundle misses if (!rayBundle.CheckIfBundleHitsAabb(Aabb)) { return(-1); } // check each ray until one hits or all miss for (int i = rayIndexToStartCheckingFrom + 1; i < count; i++) { if (rayBundle.rayArray[i].Intersection(Aabb)) { return(i); } } return(-1); }
public void GetClosestIntersections(RayBundle rayBundle, int rayIndexToStartCheckingFrom, IntersectInfo[] intersectionsForBundle) { var intersection = GetClosestIntersection(rayBundle.rayArray[rayIndexToStartCheckingFrom]); if (intersection == null) { intersectionsForBundle[rayIndexToStartCheckingFrom].hitType = IntersectionType.None; } }
public void TracePrimaryRayBundle(RayBundle rayBundle, IntersectInfo[] intersectionsForBundle, Scene scene) { if (scene.shapes.Count != 1) { throw new Exception("You can only trace a ray bundle into a single shape, usually a BoundingVolumeHierachy."); } scene.shapes[0].GetClosestIntersections(rayBundle, 0, intersectionsForBundle); }
public void GetClosestIntersections(RayBundle rayBundle, int rayIndexToStartCheckingFrom, IntersectInfo[] intersectionsForBundle) { int startRayIndex = FindFirstRay(rayBundle, rayIndexToStartCheckingFrom); if (startRayIndex != -1) { IPrimitive checkFirst = nodeA; IPrimitive checkSecond = nodeB; if (rayBundle.rayArray[startRayIndex].directionNormal[splittingPlane] < 0) { checkFirst = nodeB; checkSecond = nodeA; } checkFirst.GetClosestIntersections(rayBundle, startRayIndex, intersectionsForBundle); if (checkSecond != null) { checkSecond.GetClosestIntersections(rayBundle, startRayIndex, intersectionsForBundle); } } }
public void FullyTraceRayBundle(RayBundle rayBundle, IntersectInfo[] intersectionsForBundle, Scene scene) { TracePrimaryRayBundle(rayBundle, intersectionsForBundle, scene); for (int i = 0; i < rayBundle.rayArray.Length; i++) { try { IntersectInfo primaryInfo = TracePrimaryRay(rayBundle.rayArray[i], scene); if (intersectionsForBundle[i].HitType != IntersectionType.None) { intersectionsForBundle[i].TotalColor = CreateAndTraceSecondaryRays(primaryInfo, rayBundle.rayArray[i], scene, 0); } else { intersectionsForBundle[i].TotalColor = scene.background.Color; } } catch { } } }
public override int FindFirstRay(RayBundle rayBundle, int rayIndexToStartCheckingFrom) { throw new NotImplementedException(); }
public void TracePrimaryRayBundle(RayBundle rayBundle, IntersectInfo[] intersectionsForBundle, Scene scene) { if (scene.shapes.Count != 1) { throw new Exception("You can only trace a ray bundle into a sigle shape, usually a BoundingVolumeHierachy."); } scene.shapes[0].GetClosestIntersections(rayBundle, 0, intersectionsForBundle); }
public virtual void GetClosestIntersections(RayBundle rayBundle, int rayIndexToStartCheckingFrom, IntersectInfo[] intersectionsForBundle) { throw new NotImplementedException("Implement this for the class you want."); }
public abstract int FindFirstRay(RayBundle rayBundle, int rayIndexToStartCheckingFrom);
public void GetClosestIntersections(RayBundle rayBundle, int rayIndexToStartCheckingFrom, IntersectInfo[] intersectionsForBundle) { int startRayIndex = FindFirstRay(rayBundle, rayIndexToStartCheckingFrom); if (startRayIndex != -1) { IPrimitive checkFirst = nodeA; IPrimitive checkSecond = nodeB; if (rayBundle.rayArray[startRayIndex].directionNormal[splitingPlane] < 0) { checkFirst = nodeB; checkSecond = nodeA; } checkFirst.GetClosestIntersections(rayBundle, startRayIndex, intersectionsForBundle); if (checkSecond != null) { checkSecond.GetClosestIntersections(rayBundle, startRayIndex, intersectionsForBundle); } } }
public int FindFirstRay(RayBundle rayBundle, int rayIndexToStartCheckingFrom) { // check if first ray hits bounding box if (rayBundle.rayArray[rayIndexToStartCheckingFrom].Intersection(Aabb)) { return rayIndexToStartCheckingFrom; } int count = rayBundle.rayArray.Length; // check if all bundle misses if (!rayBundle.CheckIfBundleHitsAabb(Aabb)) { return -1; } // check each ray until one hits or all miss for (int i = rayIndexToStartCheckingFrom + 1; i < count; i++) { if (rayBundle.rayArray[i].Intersection(Aabb)) { return i; } } return -1; }
public void GetClosestIntersections(RayBundle rayBundle, int rayIndexToStartCheckingFrom, IntersectInfo[] intersectionsForBundle) { intersectionsForBundle[rayIndexToStartCheckingFrom] = GetClosestIntersection(rayBundle.rayArray[rayIndexToStartCheckingFrom]); }
public override void GetClosestIntersections(RayBundle rayBundle, int rayIndexToStartCheckingFrom, IntersectInfo[] intersectionsForBundle) { throw new NotImplementedException(); }
public void FullyTraceRayBundle(RayBundle rayBundle, IntersectInfo[] intersectionsForBundle, Scene scene) { TracePrimaryRayBundle(rayBundle, intersectionsForBundle, scene); for (int i = 0; i < rayBundle.rayArray.Length; i++) { IntersectInfo primaryInfo = TracePrimaryRay(rayBundle.rayArray[i], scene); if (intersectionsForBundle[i].hitType != IntersectionType.None) { intersectionsForBundle[i].totalColor = CreateAndTraceSecondaryRays(primaryInfo, rayBundle.rayArray[i], scene, 0); } intersectionsForBundle[i].totalColor = scene.background.Color; } }