Skip to content

Commit

Permalink
Merge pull request #302 from vsg-dev/RegionOfInterest
Browse files Browse the repository at this point in the history
Added --region-of-interest/--roi assignement
  • Loading branch information
robertosfield authored Apr 3, 2024
2 parents 2967b2d + 8d7f888 commit fce40fd
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 fce40fd

Please sign in to comment.