adds a ground plane to the scene */
| 509 | |
| 510 | /* adds a ground plane to the scene */ |
| 511 | unsigned int addGroundPlane (RTCScene scene_i) |
| 512 | { |
| 513 | /* create a triangulated plane with 2 triangles and 4 vertices */ |
| 514 | RTCGeometry geom = rtcNewGeometry (g_device, RTC_GEOMETRY_TYPE_TRIANGLE); |
| 515 | |
| 516 | /* set vertices */ |
| 517 | Vertex* vertices = (Vertex*) rtcSetNewGeometryBuffer(geom,RTC_BUFFER_TYPE_VERTEX,0,RTC_FORMAT_FLOAT3,sizeof(Vertex),4); |
| 518 | vertices[0].x = -10; vertices[0].y = -2; vertices[0].z = -10; |
| 519 | vertices[1].x = -10; vertices[1].y = -2; vertices[1].z = +10; |
| 520 | vertices[2].x = +10; vertices[2].y = -2; vertices[2].z = -10; |
| 521 | vertices[3].x = +10; vertices[3].y = -2; vertices[3].z = +10; |
| 522 | |
| 523 | /* set triangles */ |
| 524 | Triangle* triangles = (Triangle*) rtcSetNewGeometryBuffer(geom,RTC_BUFFER_TYPE_INDEX,0,RTC_FORMAT_UINT3,sizeof(Triangle),2); |
| 525 | triangles[0].v0 = 0; triangles[0].v1 = 1; triangles[0].v2 = 2; |
| 526 | triangles[1].v0 = 1; triangles[1].v1 = 3; triangles[1].v2 = 2; |
| 527 | |
| 528 | rtcCommitGeometry(geom); |
| 529 | unsigned int geomID = rtcAttachGeometry(scene_i,geom); |
| 530 | rtcReleaseGeometry(geom); |
| 531 | return geomID; |
| 532 | } |
| 533 | |
| 534 | /* called by the C++ code for initialization */ |
| 535 | extern "C" void device_init (char* cfg) |
no test coverage detected