After a selection is performed, it is usually necessary to provide visual feedback to the user regarding what was selected. This typically involves applying the concept of highlighting to higher-level model structure. For example, the scene might contain a picture of an airplane wing which is represented by several pieces of HOOPS/3dGS geometry (probably shells). However, HOOPS/3dGS knows nothing about the airplane wing. Therefore, if you wanted to highlight the entire wing after the user selects on any part of it, you would need to figure out all the associated pieces of HOOPS geometry and highlight them all. This section will focus on some of the ways in which HOOPS/3dGS objects (segments and geometry) can be highlighted. Note that the details of how to represent highlighting is up to the developer. You could choose to modify the objects color, line weight, face pattern, vertex/edge/face visibilities, shading mode, or any combination of these and other attributes.
Highlighting at a segment level simply involves modifying the attributes in the segment. Recall that all objects in a segment are affected by that segment's attributes. Note that this will affect the open segment, as well as any subsegments which do not have their own opinion about the attributes being modified. If you want all subsegments to have the same highlight attributes, regardless of local explicit settings, you can use the attribute lock in Rendering_Option:
HC_Set_Rendering_Options("attribute lock = color"); /* lock the value of color down the tree */
This comes in useful when you want to highlight an entire piece of the segment tree. For examples, let's say the HOOPS/3dGS database was representing an AEC drawing with multiple layers, representing various systems such as HVAC, piping, electrical, etc... If the GUI is in 'layer highlight' mode, you could highlight a selected layer by setting the desired highlight attributes at a top-level 'layer' parent segment, and then setting 'attribute lock' in that segment.
A segment will commonly contain graphical primitives that represent discrete pieces of the model. Let's say we have an 'asteroid' segment which contains a HOOPS/3dGS shell for each asteroid. If the GUI is in 'single asteroid selection mode', then we need to highlight a single asteroid. Setting highlight attributes at the segment-level won't work since all the asteroids will be affected by that new attribute. So, we need to modify the database so that only the selected object will be drawn with the new highlight attributes.
A brute force way to achieve this is to move the object (Move_By_Key) to a highlight segment, and move it back to the original segment to unhighlight. However, this has a major performance implication, since changing the contents of a segment segment will cause HOOPS to trigger a full screen redraw. To avoid such a full screen redraw and provide very fast highlighting/unhighlighting, an approach called 'quickmoves include/reference highlighting' should be used.
The scene-interaction section reviews how only making changes to the contents of a quickmoves segment between updates will not cause HOOPS to perform a full update. Instead, HOOPS will only clear/redraw the graphical primitives in the segments that have the 'quickmoves' attribute. We can leverage this capability in conjunction with HOOPS 'include' and 'reference' capabilities, to perform fast highlighting/unhighlighting.
To prepare for highlighting, we would first create a 'highlight' segment that contains the 'quickmoves' setting and desired highlight attributes (color, line-pattern, etc...) When a segment, segment tree, or list of graphical primitives needs to be highlighted, either Include_Segment or Reference_Geometry can be called in the highlight segment. The documentation for Include Segments and Reference Geometry will help you determine which one may be appropriate. But simply stated, Include_Segment would be used to highlight a whole segment tree, while Reference_Geometry would be used to highlight a single segment or set of graphical primitives.
/* setup the highlighting attributes segment */ HC_KEY style_key = HC_KOpen_Segment("my_highlight_attributes"); HC_Set_Color("lines = red, faces = yellow"); HC_Set_Edge_Weight(3.0); HC_Set_Rendering_Options("general displacement = -8"); HC_Close_Segment(); /* let's define a sample model */ HC_KEY fuselage = HC_KOpen_Segment("airplane_fuselage"); HC_KEY fuse1 = HC_KInsert_Shell (<data>); HC_KEY fuse2 = HC_KInsert_Shell (<data>); HC_KEY fuse3 = HC_KInsert_Shell (<data>); HC_KEY fuse4 = HC_KInsert_Shell (<data>); HC_Close_Segment(); /* Here's an example of highlighting the entire model, which might be used if your application's 'selection mode' was 'part selection' */ HC_Open_Segment("highlight"); HC_Set_Heuristics ("quick moves"); HC_Style_Segment_By_Key(style_key); include_key = HC_KInclude_Segment_By_Key(fuselage); HC_Close_Segment(); /* And here's an example of highlighting just one piece of the fuselage, which might be used if your application's 'selection mode' was 'sub-object selection' */ HC_Open_Segment("highlight"); HC_Set_Heuristics ("quick moves"); HC_Style_Segment_By_Key(style_key); reference_key = HC_KReference_Geometry_By_Key (fuse3); HC_Close_Segment();
Because we have 'quickmoves' set in the highlight segment(s), making changes to those segments to effectively 'unhighlight' (such as deleting the Reference or Include by deleting the include_key and reference_key, respectively) will not cause HOOPS to redraw the entire scene. HOOPS will simply 'undraw' the quickmoves geometry.
There is one caveat with the highlighting technique above. We're highlighting by drawing a new instance (reference/include) of the geometry, and that instance would have the same position. That means it will come out directly 'superimposed' on top of the original, unhighlighted geometry, resulting in geometry that 'bleeds' together. To address that, we can set the 'general displacement' value in the highlight-attributes segment to -8. This will 'pull' the highlighted copy forward a bit in the z-buffer, and avoid superimposition and thus any edge/face bleeding.
The HOOPS/MVO Classes contain a class called HSelectionSet which provides higher level highlighting support. This class is intended to be used along with the other HOOPS/MVO classes, but it's methods can be referred to for a reference implementation of segment and single object highlighting. The code handles other issues that were not mentioned above, such as dealing with include segments, and storing away a segment's original set of attributes (so that they can be restored later!). It manages a selection array, and provides methods to Select, DeSelect, DeSelectAll and to query if an object IsSelected.
Next | Previous | Index |