From 8d7f888684b1c6a341fcda8ff1921d1b674aefb8 Mon Sep 17 00:00:00 2001 From: Robert Osfield Date: Wed, 3 Apr 2024 10:42:06 +0100 Subject: [PATCH] Added --region-of-interest/--roi assignement --- examples/nodes/vsgshadow/vsgshadow.cpp | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/examples/nodes/vsgshadow/vsgshadow.cpp b/examples/nodes/vsgshadow/vsgshadow.cpp index adc0c552..8012d662 100644 --- a/examples/nodes/vsgshadow/vsgshadow.cpp +++ b/examples/nodes/vsgshadow/vsgshadow.cpp @@ -287,6 +287,8 @@ int main(int argc, char** argv) resourceHints = vsg::read_cast(resourceHintsFilename, options); } + bool assignRegionOfInterest = arguments.read({"--region-of-interest", "--roi"}); + if (!resourceHints) resourceHints = vsg::ResourceHints::create(); arguments.read("--shadowMapSize", resourceHints->shadowMapSize); @@ -472,6 +474,26 @@ int main(int argc, char** argv) auto bounds = vsg::visit(scene).bounds; viewingDistance = vsg::length(bounds.max - bounds.min) * 2.0; + if (assignRegionOfInterest) + { + auto group = vsg::Group::create(); + + auto regionOfInterest = vsg::RegionOfInterest::create(); + regionOfInterest->name = "region to cast shadow"; + regionOfInterest->points.emplace_back(bounds.min.x, bounds.min.y, bounds.min.z); + regionOfInterest->points.emplace_back(bounds.max.x, bounds.min.y, bounds.min.z); + regionOfInterest->points.emplace_back(bounds.max.x, bounds.max.y, bounds.min.z); + regionOfInterest->points.emplace_back(bounds.min.x, bounds.max.y, bounds.min.z); + regionOfInterest->points.emplace_back(bounds.min.x, bounds.min.y, bounds.max.z); + regionOfInterest->points.emplace_back(bounds.max.x, bounds.min.y, bounds.max.z); + regionOfInterest->points.emplace_back(bounds.max.x, bounds.max.y, bounds.max.z); + regionOfInterest->points.emplace_back(bounds.min.x, bounds.max.y, bounds.max.z); + group->addChild(regionOfInterest); + group->addChild(scene); + + scene = group; + } + vsg::ref_ptr lookAt; if (earthModel && ellipsoidModel)