* Add instances to a scene. * This function also writes normal transforms to the given map. */
| 138 | * This function also writes normal transforms to the given map. |
| 139 | */ |
| 140 | void addInstances(RTCDevice device, |
| 141 | RTCScene scene, |
| 142 | RTCScene exemplar, |
| 143 | const Instances& instances, |
| 144 | LinearSpace3fa* normalTransforms) |
| 145 | { |
| 146 | for (unsigned int i = 0; i < instances.numInstances; ++i) |
| 147 | { |
| 148 | const unsigned int idx = 3*i; |
| 149 | auto M = buildMatrix(instances.localX + idx, |
| 150 | instances.localY + idx, |
| 151 | instances.localZ + idx, |
| 152 | instances.position + idx); |
| 153 | |
| 154 | RTCGeometry geom = rtcNewGeometry(device, RTC_GEOMETRY_TYPE_INSTANCE); |
| 155 | rtcSetGeometryInstancedScene(geom, exemplar); |
| 156 | rtcSetGeometryTimeStepCount(geom, 1); |
| 157 | rtcSetGeometryTransform(geom, |
| 158 | 0, |
| 159 | RTC_FORMAT_FLOAT4X4_COLUMN_MAJOR, |
| 160 | reinterpret_cast<float*>(&M)); |
| 161 | rtcCommitGeometry(geom); |
| 162 | |
| 163 | rtcAttachGeometryByID(scene, geom, i); |
| 164 | rtcReleaseGeometry(geom); |
| 165 | normalTransforms[i] = transposed(rcp(M.l)); |
| 166 | } |
| 167 | } |
| 168 | |
| 169 | /* |
| 170 | * Initialize the main scene. Note that we store complex geometry in |
no test coverage detected