Skip to content

Commit

Permalink
enable sphere object for ospray device
Browse files Browse the repository at this point in the history
  • Loading branch information
wilsonCernWq committed Apr 11, 2024
1 parent 6a6787d commit 51f6526
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 1 deletion.
13 changes: 13 additions & 0 deletions ovr/devices/ospray/device_impl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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");
Expand All @@ -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");
}
Expand Down
1 change: 1 addition & 0 deletions ovr/devices/ospray/device_impl.h
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
8 changes: 7 additions & 1 deletion ovr/scene.h
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -284,6 +284,7 @@ struct Material {
struct Geometry {
enum {
TRIANGLES_GEOMETRY,
SPHERES_GEOMETRY,
ISOSURFACE_GEOMETRY,
} type;

Expand All @@ -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<float> isovalues;
Expand Down

0 comments on commit 51f6526

Please sign in to comment.