adds a ground plane to the scene */
| 72 | |
| 73 | /* adds a ground plane to the scene */ |
| 74 | unsigned int addGroundPlane (RTCScene scene_i) |
| 75 | { |
| 76 | /* create a triangulated plane with 2 triangles and 4 vertices */ |
| 77 | RTCGeometry mesh = rtcNewGeometry (g_device, RTC_GEOMETRY_TYPE_TRIANGLE); |
| 78 | |
| 79 | /* set vertices */ |
| 80 | Vertex* vertices = (Vertex*) rtcSetNewGeometryBuffer(mesh,RTC_BUFFER_TYPE_VERTEX,0,RTC_FORMAT_FLOAT3,sizeof(Vertex),4); |
| 81 | vertices[0].x = -10; vertices[0].y = -2; vertices[0].z = -10; |
| 82 | vertices[1].x = -10; vertices[1].y = -2; vertices[1].z = +10; |
| 83 | vertices[2].x = +10; vertices[2].y = -2; vertices[2].z = -10; |
| 84 | vertices[3].x = +10; vertices[3].y = -2; vertices[3].z = +10; |
| 85 | |
| 86 | /* set triangles */ |
| 87 | Triangle* triangles = (Triangle*) rtcSetNewGeometryBuffer(mesh,RTC_BUFFER_TYPE_INDEX,0,RTC_FORMAT_UINT3,sizeof(Triangle),2); |
| 88 | triangles[0].v0 = 0; triangles[0].v1 = 1; triangles[0].v2 = 2; |
| 89 | triangles[1].v0 = 1; triangles[1].v1 = 3; triangles[1].v2 = 2; |
| 90 | |
| 91 | rtcCommitGeometry(mesh); |
| 92 | unsigned int geomID = rtcAttachGeometry(scene_i,mesh); |
| 93 | rtcReleaseGeometry(mesh); |
| 94 | return geomID; |
| 95 | } |
| 96 | |
| 97 | /* called by the C++ code for initialization */ |
| 98 | extern "C" void device_init (char* cfg) |
no test coverage detected