| 663 | |
| 664 | /* called by the C++ code for initialization */ |
| 665 | extern "C" void device_init (char* cfg) |
| 666 | { |
| 667 | instanceIntersectFuncPtr = GET_FUNCTION_POINTER(instanceIntersectFunc); |
| 668 | instanceOccludedFuncPtr = GET_FUNCTION_POINTER(instanceOccludedFunc ); |
| 669 | sphereIntersectFuncPtr = GET_FUNCTION_POINTER(sphereIntersectFunc); |
| 670 | sphereOccludedFuncPtr = GET_FUNCTION_POINTER(sphereOccludedFunc ); |
| 671 | sphereFilterFuncPtr = GET_FUNCTION_POINTER(sphereFilterFunction); |
| 672 | |
| 673 | /* create scene */ |
| 674 | TutorialData_Constructor(&data); |
| 675 | g_scene = data.g_scene = rtcNewScene(g_device); |
| 676 | |
| 677 | /* create scene with 4 analytical spheres */ |
| 678 | data.g_scene0 = rtcNewScene(g_device); |
| 679 | rtcSetSceneBuildQuality(data.g_scene0,RTC_BUILD_QUALITY_LOW); |
| 680 | data.g_spheres = createAnalyticalSpheres(data.g_scene0,4); |
| 681 | data.g_spheres[0].p = Vec3fa( 0, 0,+1); data.g_spheres[0].r = 0.5f; |
| 682 | data.g_spheres[1].p = Vec3fa(+1, 0, 0); data.g_spheres[1].r = 0.5f; |
| 683 | data.g_spheres[2].p = Vec3fa( 0, 0,-1); data.g_spheres[2].r = 0.5f; |
| 684 | data.g_spheres[3].p = Vec3fa(-1, 0, 0); data.g_spheres[3].r = 0.5f; |
| 685 | rtcCommitScene(data.g_scene0); |
| 686 | |
| 687 | /* create scene with 4 triangulated spheres */ |
| 688 | data.g_scene1 = rtcNewScene(g_device); |
| 689 | createTriangulatedSphere(data.g_scene1,Vec3fa( 0, 0,+1),0.5f); |
| 690 | createTriangulatedSphere(data.g_scene1,Vec3fa(+1, 0, 0),0.5f); |
| 691 | createTriangulatedSphere(data.g_scene1,Vec3fa( 0, 0,-1),0.5f); |
| 692 | createTriangulatedSphere(data.g_scene1,Vec3fa(-1, 0, 0),0.5f); |
| 693 | rtcCommitScene(data.g_scene1); |
| 694 | |
| 695 | /* create scene with 2 triangulated and 2 analytical spheres */ |
| 696 | data.g_scene2 = rtcNewScene(g_device); |
| 697 | createTriangulatedSphere(data.g_scene2,Vec3fa( 0, 0,+1),0.5f); |
| 698 | data.g_sphere0 = createAnalyticalSphere (data.g_scene2,Vec3fa(+1, 0, 0),0.5f); |
| 699 | createTriangulatedSphere(data.g_scene2,Vec3fa( 0, 0,-1),0.5f); |
| 700 | data.g_sphere1 = createAnalyticalSphere (data.g_scene2,Vec3fa(-1, 0, 0),0.5f); |
| 701 | rtcCommitScene(data.g_scene2); |
| 702 | |
| 703 | /* instantiate geometry */ |
| 704 | data.g_instance[0] = createInstance(data.g_scene,data.g_scene0,0,Vec3fa(-2,-2,-2),Vec3fa(+2,+2,+2)); |
| 705 | data.g_instance[1] = createInstance(data.g_scene,data.g_scene1,1,Vec3fa(-2,-2,-2),Vec3fa(+2,+2,+2)); |
| 706 | data.g_instance[2] = createInstance(data.g_scene,data.g_scene2,2,Vec3fa(-2,-2,-2),Vec3fa(+2,+2,+2)); |
| 707 | data.g_instance[3] = createInstance(data.g_scene,data.g_scene2,3,Vec3fa(-2,-2,-2),Vec3fa(+2,+2,+2)); |
| 708 | createGroundPlane(data.g_scene); |
| 709 | rtcCommitScene(data.g_scene); |
| 710 | |
| 711 | /* set all colors */ |
| 712 | data.colors[4*0+0] = Vec3fa(0.25f, 0.00f, 0.00f); |
| 713 | data.colors[4*0+1] = Vec3fa(0.50f, 0.00f, 0.00f); |
| 714 | data.colors[4*0+2] = Vec3fa(0.75f, 0.00f, 0.00f); |
| 715 | data.colors[4*0+3] = Vec3fa(1.00f, 0.00f, 0.00f); |
| 716 | |
| 717 | data.colors[4*1+0] = Vec3fa(0.00f, 0.25f, 0.00f); |
| 718 | data.colors[4*1+1] = Vec3fa(0.00f, 0.50f, 0.00f); |
| 719 | data.colors[4*1+2] = Vec3fa(0.00f, 0.75f, 0.00f); |
| 720 | data.colors[4*1+3] = Vec3fa(0.00f, 1.00f, 0.00f); |
| 721 | |
| 722 | data.colors[4*2+0] = Vec3fa(0.00f, 0.00f, 0.25f); |
nothing calls this directly
no test coverage detected