A call to InsertDistantLight returns a DistantLightKey instance but later calling instance.Delete() (and/or instance.Dispose()) does not remove the distant light - the lighting of my geometry does not change.
In fact, further calls to InsertDistantLight seem to add more and more distant lights, brightening the scene towards saturation, hinting that the Delete/Dispose had no effect.
I wonder if this is a subwindow issue? The doc here ( Subwindows — HOOPS Visualize HPS Documentation ) hints at putting the triad in a subwindow (I presume that’s what the AxisTriadControl does) but does not show how to use this idea in conjunction with Canvas.GetFrontView().GetAxisTriadControl()… so I’m stuck on how to implement this (and whether it would fix the triad lighting issue anyway!)
Adding a distant light to the triad segment affects the lighting of the overall scene, so maybe the triad subwindow is lightweight? According to the subwindow docs:
A distant light is typically added to the scene hierarchy under the view. You can see this by examining the segment browser. The light “illuminates all geometry in the same scene, irrespective of its location in the segment tree.”
So am I correct to say, in summary there is no way to illuminate using distant lights the triad independently of the model because:
a) adding/removing a distant light to the model segment affects the lighting of the triad segment
b) and adding/removing a distant light to the triad segment affects the lighting of the model segment
I have a use-case where the model needs to be unlit (for a particular rendering effect) but the triad should remain lit (for UX consistency). Do you have any thoughts on how to achieve this?
Yes, regarding (a) & (b) lights apply to all geometry everywhere within the standard subwindow. This means everything under the model and the triad segment as they are both in the same subwindow (defined at the root level). The triad is in a lightweight subwindow.
You can achieve lighting independence as you describe but changing the traid subwindow to a standard subwindow and adding a distant light.
You can add the following to try this in the MFC Sandbox (i.e. CHPSView.cpp).
void CHPSView::OnUserCode2()
{
// enable axis triad
_canvas.GetFrontView().GetAxisTriadControl().SetVisibility(true).SetLocation(HPS::AxisTriadControl::Location::BottomRight);
Update();
}
void CHPSView::OnUserCode3()
{
// get the axis triad segment key
HPS::SegmentKey triadKey = _canvas.GetFrontView().GetAxisTriadControl().GetSegmentKey();
if (triadKey.Type() != HPS::Type::None)
{
HPS::Rectangle position;
HPS::IntRectangle offsets;
HPS::Subwindow::Type type;
// Change the subwindow type to standard
triadKey.GetSubwindowControl().ShowSubwindow(position, offsets, type);
triadKey.GetSubwindowControl().
SetBackground(HPS::Subwindow::Background::Transparent).
SetSubwindow(position, offsets, HPS::Subwindow::Type::Standard);
// duplicate the existing distant light within this subwindow
if (_mainDistantLight.Type() != HPS::Type::None)
{
HPS::DistantLightKit light;
HPS::Vector dir;
bool relative = true;
_mainDistantLight.ShowDirection(dir);
_mainDistantLight.ShowCameraRelative(relative);
light.SetDirection(dir);
light.SetCameraRelative(relative);
triadKey.InsertDistantLight(light);
}
// else insert some distant light
// adjust the text size for the new subwindow
HPS::SegmentKey xAxisKey = triadKey.Subsegment("x", false);
HPS::SegmentKey yAxisKey = triadKey.Subsegment("y", false);
HPS::SegmentKey zAxisKey = triadKey.Subsegment("z", false);
HPS::TextAttributeKit textAttKit;
xAxisKey.ShowTextAttribute(textAttKit);
float size;
HPS::Text::SizeUnits units;
textAttKit.ShowSize(size, units);
textAttKit.SetSize(size * 5, units);
if (xAxisKey.Type() != HPS::Type::None)
{
xAxisKey.SetTextAttribute(textAttKit);
}
if (yAxisKey.Type() != HPS::Type::None)
{
yAxisKey.SetTextAttribute(textAttKit);
}
if (zAxisKey.Type() != HPS::Type::None)
{
zAxisKey.SetTextAttribute(textAttKit);
}
}
else
TRACE("missed triad key\n");
Update();
}
After loading a model, choosing User Code 2 and then 3 and then deleting the distant light under the view, the rendering of the model does not have a distant light but the axis triad still has its own distant light.