adds a cube to the scene */
| 102 | |
| 103 | /* adds a cube to the scene */ |
| 104 | unsigned int addCube (RTCScene scene_i) |
| 105 | { |
| 106 | /* create a triangulated cube with 6 quads and 8 vertices */ |
| 107 | RTCGeometry geom = rtcNewGeometry(g_device, RTC_GEOMETRY_TYPE_SUBDIVISION); |
| 108 | |
| 109 | rtcSetSharedGeometryBuffer(geom, RTC_BUFFER_TYPE_VERTEX, 0, RTC_FORMAT_FLOAT3, cube_vertices, 0, sizeof(Vec3fa), 8); |
| 110 | rtcSetSharedGeometryBuffer(geom, RTC_BUFFER_TYPE_INDEX, 0, RTC_FORMAT_UINT, cube_indices, 0, sizeof(unsigned int), NUM_INDICES); |
| 111 | rtcSetSharedGeometryBuffer(geom, RTC_BUFFER_TYPE_FACE, 0, RTC_FORMAT_UINT, cube_faces, 0, sizeof(unsigned int), NUM_FACES); |
| 112 | |
| 113 | /* edge and vertex creases disabled */ |
| 114 | #if 0 |
| 115 | rtcSetSharedGeometryBuffer(geom, RTC_BUFFER_TYPE_EDGE_CREASE_INDEX, 0, RTC_FORMAT_UINT2, cube_edge_crease_indices, 0, 2*sizeof(unsigned int), 12); |
| 116 | rtcSetSharedGeometryBuffer(geom, RTC_BUFFER_TYPE_EDGE_CREASE_WEIGHT, 0, RTC_FORMAT_FLOAT, cube_edge_crease_weights, 0, sizeof(float), 12); |
| 117 | rtcSetSharedGeometryBuffer(geom, RTC_BUFFER_TYPE_VERTEX_CREASE_INDEX, 0, RTC_FORMAT_UINT, cube_vertex_crease_indices, 0, sizeof(unsigned int), 8); |
| 118 | rtcSetSharedGeometryBuffer(geom, RTC_BUFFER_TYPE_VERTEX_CREASE_WEIGHT, 0, RTC_FORMAT_FLOAT, cube_vertex_crease_weights, 0, sizeof(float), 8); |
| 119 | #endif |
| 120 | |
| 121 | rtcSetGeometryVertexAttributeCount(geom,1); |
| 122 | rtcSetSharedGeometryBuffer(geom, RTC_BUFFER_TYPE_VERTEX_ATTRIBUTE, 0, RTC_FORMAT_FLOAT3, cube_colors, 0, sizeof(Vec3fa), 8); |
| 123 | |
| 124 | float* level = (float*) rtcSetNewGeometryBuffer(geom, RTC_BUFFER_TYPE_LEVEL, 0, RTC_FORMAT_FLOAT, sizeof(float), NUM_INDICES); |
| 125 | for (unsigned int i=0; i<NUM_INDICES; i++) |
| 126 | level[i] = EDGE_LEVEL; |
| 127 | |
| 128 | rtcCommitGeometry(geom); |
| 129 | unsigned int geomID = rtcAttachGeometry(scene_i, geom); |
| 130 | rtcReleaseGeometry(geom); |
| 131 | return geomID; |
| 132 | } |
| 133 | |
| 134 | /* adds a ground plane to the scene */ |
| 135 | unsigned int addGroundPlane (RTCScene scene_i) |
no test coverage detected