add point geometry */
| 17 | |
| 18 | /* add point geometry */ |
| 19 | void addPoints (RTCScene scene, RTCGeometryType gtype, const Vec3fa& pos) |
| 20 | { |
| 21 | RandomSampler rng; |
| 22 | RandomSampler_init(rng, 42); |
| 23 | |
| 24 | #define COORD RandomSampler_get1D(rng) * 4.f - 2.f |
| 25 | #define RADIUS RandomSampler_get1D(rng) * 0.13f + 0.02f |
| 26 | #define COLOR RandomSampler_get1D(rng) |
| 27 | #define NORMAL RandomSampler_get1D(rng) * 2.f - 1.f |
| 28 | |
| 29 | RTCGeometry geom = rtcNewGeometry (g_device, gtype); |
| 30 | Vec4f* point_vertices = (Vec4f*)rtcSetNewGeometryBuffer(geom,RTC_BUFFER_TYPE_VERTEX, 0, RTC_FORMAT_FLOAT4, sizeof(Vec4f), NUM_POINTS); |
| 31 | |
| 32 | for (int i = 0; i < NUM_POINTS; i++) |
| 33 | { |
| 34 | const float vx = COORD; |
| 35 | const float vy = COORD; |
| 36 | const float vz = COORD; |
| 37 | const float vr = RADIUS; |
| 38 | point_vertices[i] = Vec4f(pos.x,pos.y,pos.z,0.0f) + Vec4f(vx, vy, vz, vr); |
| 39 | const float cr = COLOR; |
| 40 | const float cg = COLOR; |
| 41 | const float cb = COLOR; |
| 42 | data.point_colors[i] = Vec3fa(cr,cg,cb); |
| 43 | } |
| 44 | |
| 45 | if (gtype == RTC_GEOMETRY_TYPE_ORIENTED_DISC_POINT) { |
| 46 | Vec3fa* point_normals = (Vec3fa*)rtcSetNewGeometryBuffer(geom,RTC_BUFFER_TYPE_NORMAL, 0, RTC_FORMAT_FLOAT3, sizeof(Vec3fa), NUM_POINTS); |
| 47 | for (int i = 0; i < NUM_POINTS; i++) { |
| 48 | const float nx = NORMAL; |
| 49 | const float ny = NORMAL; |
| 50 | const float nz = NORMAL; |
| 51 | point_normals[i] = Vec3fa(nx,ny,nz); |
| 52 | point_normals[i] = normalize(point_normals[i]); |
| 53 | } |
| 54 | } |
| 55 | |
| 56 | rtcCommitGeometry(geom); |
| 57 | rtcAttachGeometry(scene,geom); |
| 58 | rtcReleaseGeometry(geom); |
| 59 | } |
| 60 | |
| 61 | /* adds a ground plane to the scene */ |
| 62 | unsigned int addGroundPlane (RTCScene scene_i) |
no test coverage detected