Build Better Software. Faster.
Visit our company site at: www.techsoft3d.com
 

White Papers Index

Hidden Line Removal / Hidden Line Display
Gavin

Many applications use methods, other than a standard shaded view, to render a model. One of the most widely used is called Hidden Line Removal (HLR). In this mode only the visible edges of the model are drawn while the obscured edges are either not drawn at all or are drawn with different attributes. This mode is of particular use for hardcopy output where shaded 3D objects do not have good visual clarity.

HOOPS/3dGS is one of the few graphics systems to include a true HLR algorithm and it is turned on with a simple call to HOOPS/3dGS.

HC_Open_Segment("MyView") 
  HC_Set_Rendering_Options("hsra=hidden line"); 
  HC_Include_Segment("MyModel"); 
HC_Close_Segment();                                
m_pHView->Update(); 

One of the primary downsides of using HLR algorithms is that they are inherently expensive as they need to sort and clip all the edges against all the facets in the scene (an n*log(n) algorithm at best). Thus, the time to create a HLR rendering increases exponentially in relation to the amount of geometry in the scene. This makes HLR practically unusable for larger models or for use in cases where there is a lot of dynamic interaction.

Because of the expensive nature of HLR many developers reserve HLR usage for hardcopy export and use tricks to fake HLR rendering for desktop display. The purpose of this paper is to review the different ways of faking hidden line output with HOOPS/3dGS.

The standard way of faking HLR is to use standard frame-buffer rendering, which is normally hardware accelerated, and simply turn the visibility of edges on and set the color of the facets to the color of the window background. In this case you use the attribute lock capabilities of HOOPS/3dGS to force the color and visibility attributes throughout your scene graph. The code for doing this is:

HColor WindowColor; 
HC_Open_Segment("MyView") 
  HC_Show_Color_By_Value("faces", "RGB", WindowColor.r, & WindowColor.g, WindowColor.b); 
  HC_Set_Color_By_Value("faces", "RGB", WindowColor.r, & WindowColor.g, WindowColor.b); 
  HC_Set_Visibility("edges=on");    
  HC_Set_Rendering_Options ("attribute lock = (visibility, color=(faces))"); 
  HC_Include_Segment("MyModel");    
HC_Close_Segment(); 
m_pHView->Update(); 

One of the problems with this approach is you cannot draw the hidden lines. However, with another trick you can render the hidden lines and get this affect if you restrict the attributes of the hidden lines to differ from the visible lines in pattern alone. This is done by using the 'Instancing' and 'Bring To Front' capabilities of HOOPS/3dGS. To do this we create a segment with attributes similar to those outlined in our first 'fake' HLR and then create a second sibling segment, which includes the same model. In this second segment we turn the visibility of facets off and set the pattern of the edges to the desired pattern for the hidden lines. Now we tell HOOPS/3dGS to draw the new segment on top of the other segment via a call to HC_Bring_To_Front. The result will be that the patterned lines of the second segment will blend in with the visible edges in the first segment leaving only the patterned edges visible at the locations of the hidden lines. The code for doing this would be:

  HColor WindowColor;
  HC_Open_Segment("MyView");
    HC_Show_Color_By_Value("faces", "RGB", WindowColor.r, & WindowColor.g, WindowColor.b);
    HC_Set_Color_By_Value("faces", "RGB", WindowColor.r, & WindowColor.g, WindowColor.b);
    HC_Set_Heuristics("no hidden surfaces");  // requirement for Bring to Front
    HC_Set_Visibility("edges=on");

    HC_Open_Segment("FullModel");
      HC_Set_Heuristics("hidden surfaces");
      HC_Set_Rendering_Options ("attribute lock = (visibility, color=(faces))");
      HC_Include_Segment("MyModel");
    HC_Close_Segment();

    HC_Open_Segment("HiddenLines");
      HC_Set_Visibility("faces=off");
      HC_Set_Edge_Pattern("-.-.");
      HC_Set_Rendering_Options ("attribute lock = (visibility, color=(faces))");
      HC_Include_Segment("MyModel");
    HC_Close_Segment();

    HC_Bring_To_Front("HiddenLines");
  HC_Close_Segment();

  m_pHView->Update();

In this case the rendering speed will be nearly twice that of the first 'fake' HLR, however it allows you to display the hidden lines in a different pattern than those of the visible edges.

Mixed Usage of 'Fake' and 'True' HLR

Since framebuffer techniques of rendering result in an image being rendered to the screen and many developers still feel that the final rendering from a fake HLR is not of a high enough quality. To work around this some developers have a mixed mode where they switch into fake HLR during dynamic rotations and then back into true HLR when the user finishes manipulating the model. This is the method used in the various HOOPS based Part Viewers.

 
 

 

 

 

 

©2004-06 Tech Soft 3D All Rights Reserved. Privacy | Legal