diff --git a/ovr/devices/ospray/device_impl.cpp b/ovr/devices/ospray/device_impl.cpp index 85a7111..2947a8e 100644 --- a/ovr/devices/ospray/device_impl.cpp +++ b/ovr/devices/ospray/device_impl.cpp @@ -248,6 +248,18 @@ DeviceOSPRay::Impl::create_ospray_geometry(scene::Geometry::GeometryTriangles ha return mesh; } +OSPGeometry +DeviceOSPRay::Impl::create_ospray_geometry(scene::Geometry::GeometrySpheres handler) { + OSPGeometry sphere = ospNewGeometry("sphere"); + assert(handler.position->type == ovr::VALUE_TYPE_FLOAT3); + auto position = ospNewSharedData1D(handler.position->data(), OSP_VEC3F, handler.position->dims.v); + ospSetObject(sphere, "sphere.position", position); + ospSetFloat(sphere, "radius", handler.radius); + ospCommit(sphere); + ospRelease(position); + return sphere; +} + OSPGeometry DeviceOSPRay::Impl::create_ospray_geometry(scene::Geometry::GeometryIsosurfaces handler) { OSPGeometry geom = ospNewGeometry("isosurface"); @@ -262,6 +274,7 @@ OSPGeometry DeviceOSPRay::Impl::create_ospray_geometry(scene::Geometry handler) { switch (handler.type) { case scene::Geometry::TRIANGLES_GEOMETRY: return create_ospray_geometry(handler.triangles); + case scene::Geometry::SPHERES_GEOMETRY: return create_ospray_geometry(handler.spheres); case scene::Geometry::ISOSURFACE_GEOMETRY: return create_ospray_geometry(handler.isosurfaces); default: throw std::runtime_error("unknown geometry type"); } diff --git a/ovr/devices/ospray/device_impl.h b/ovr/devices/ospray/device_impl.h index c5d02f9..79a8361 100644 --- a/ovr/devices/ospray/device_impl.h +++ b/ovr/devices/ospray/device_impl.h @@ -62,6 +62,7 @@ struct DeviceOSPRay::Impl { OSPGeometry create_ospray_geometry(scene::Geometry::GeometryTriangles handler); OSPGeometry create_ospray_geometry(scene::Geometry::GeometryIsosurfaces handler); + OSPGeometry create_ospray_geometry(scene::Geometry::GeometrySpheres handler); OSPGeometry create_ospray_geometry(scene::Geometry handler); OSPTexture create_ospray_texture(scene::Texture::TransferFunctionTexture handler); diff --git a/ovr/scene.h b/ovr/scene.h index c741df1..74d1fa3 100644 --- a/ovr/scene.h +++ b/ovr/scene.h @@ -273,7 +273,7 @@ struct Material { vec3f kd = vec3f(0.8f); // diffuse reflectivity vec3f ks = vec3f(0.0f); // specular reflectivity float ns = 10.f; // specular exponent - float d = 1.f; // opacity + float d = 2.f; // opacity vec3f tf = vec3f(1.f); // transparency filter // texture maps int32_t map_kd = -1; @@ -284,6 +284,7 @@ struct Material { struct Geometry { enum { TRIANGLES_GEOMETRY, + SPHERES_GEOMETRY, ISOSURFACE_GEOMETRY, } type; @@ -297,6 +298,11 @@ struct Geometry { } verts, faces; } triangles; + struct GeometrySpheres { + array_1d_float3_t position; + float radius = 0.01f; + } spheres; + struct GeometryIsosurfaces { int32_t volume_texture; std::vector isovalues;