Skip to content

Commit

Permalink
Added --region-of-interest/--roi assignement
Browse files Browse the repository at this point in the history
  • Loading branch information
robertosfield committed Apr 3, 2024
1 parent 2967b2d commit 8d7f888
Showing 1 changed file with 22 additions and 0 deletions.
22 changes: 22 additions & 0 deletions examples/nodes/vsgshadow/vsgshadow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -287,6 +287,8 @@ int main(int argc, char** argv)
resourceHints = vsg::read_cast<vsg::ResourceHints>(resourceHintsFilename, options);
}

bool assignRegionOfInterest = arguments.read({"--region-of-interest", "--roi"});

if (!resourceHints) resourceHints = vsg::ResourceHints::create();

arguments.read("--shadowMapSize", resourceHints->shadowMapSize);
Expand Down Expand Up @@ -472,6 +474,26 @@ int main(int argc, char** argv)
auto bounds = vsg::visit<vsg::ComputeBounds>(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<vsg::LookAt> lookAt;

if (earthModel && ellipsoidModel)
Expand Down

0 comments on commit 8d7f888

Please sign in to comment.