2.7 Markers

2.7.1 Marker size
2.7.2 Editing markers
2.7.3 Marker color and visibility
2.7.4 Other considerations

The simplest geometric primitive in HOOPS Visualize is a marker, which is used to represent a point in space. Markers are two-dimensional geometry with the marker always oriented to face the camera, but can be positioned anywhere in 3D space.

A marker is visually represented by a marker symbol, or glyph, which is a segment-level attribute. A set of default glyphs are provided.

The default marker symbol is a small filled circle, and the default marker visibility setting is off (see section 2.7.3 for instructions on enabling marker visibility). The marker symbol is set using HPS::MarkerAttributeControl::SetSymbol as demonstrated in this snippet:

[snippet 2.7.a]
// set the marker symbol (optional)
mySegmentKey.GetMarkerAttributeControl().SetSymbol("myMarkerName");
// insert a marker at the origin
mySegmentKey.InsertMarker(Point(0, 0, 0));
// set the marker symbol (optional)
mySegmentKey.GetMarkerAttributeControl().SetSymbol("myMarkerName");
// insert a marker at the origin
mySegmentKey.InsertMarker(new Point(0, 0, 0));

Like other geometry, markers can be inserted using a HPS::MarkerKit. However, the benefit to doing this is limited as there is only one parameter to set, the position. It should be noted that a segment's active marker symbol is also used to draw geometry vertices for shells and meshes.

2.7.1 Marker size

Marker size is controlled by calling HPS::MarkerAttributeControl::SetSize. Note the default size is fixed - the marker will not change size due to camera or modelling matrix changes. If no marker size-unit parameter is given when calling HPS::MarkerAttributeControl::SetSize, the marker is linearly scaled by the default marker size. Note that several of the marker size-units will result in 'view-dependent' sizing, where the marker size will change as the camera or modelling matrices change.

For example, to set the marker size to 5 pixels, use the HPS::Marker::SizeUnits::Pixels enum. To scale the marker in world coordinates, use HPS::Marker::SizeUnits::WorldSpace.

[snippet 2.7.1.a]
// since markers are segment-level attributes, the size examples below must go in different segments
HPS::SegmentKey segKey1 = mySegmentKey.Down("marker1", true);
HPS::SegmentKey segKey2 = mySegmentKey.Down("marker2", true);
HPS::SegmentKey segKey3 = mySegmentKey.Down("marker3", true);
// if second parameter to SetSize is omitted, the marker is scaled relative to its default size
segKey1.GetMarkerAttributeControl().SetSize(5);
HPS::MarkerKey markerKey1 = segKey1.InsertMarker(Point(0, 0.35f, 0));
// marker2 is 10 pixels in size
segKey2.GetMarkerAttributeControl().SetSize(10, HPS::Marker::SizeUnits::Pixels);
HPS::MarkerKey markerKey2 = segKey2.InsertMarker(Point(0, 0, 0));
// marker3 is 0.1 world space units in size
segKey3.GetMarkerAttributeControl().SetSize(0.1f, HPS::Marker::SizeUnits::WorldSpace);
HPS::MarkerKey markerKey3 = segKey3.InsertMarker(Point(0, -0.35f, 0));
// since markers are segment-level attributes, the size examples below must go in different segments
HPS.SegmentKey segKey1 = mySegmentKey.Down("marker1", true);
HPS.SegmentKey segKey2 = mySegmentKey.Down("marker2", true);
HPS.SegmentKey segKey3 = mySegmentKey.Down("marker3", true);
// if second parameter to SetSize is omitted, the marker is scaled relative to its default size
segKey1.GetMarkerAttributeControl().SetSize(5);
HPS.MarkerKey markerKey1 = segKey1.InsertMarker(new HPS.Point(0, 0.35f, 0));
// marker2 is 10 pixels in size
segKey2.GetMarkerAttributeControl().SetSize(10, HPS.Marker.SizeUnits.Pixels);
HPS.MarkerKey markerKey2 = segKey2.InsertMarker(new HPS.Point(0, 0, 0));
// marker3 is 0.1 world space units in size
segKey3.GetMarkerAttributeControl().SetSize(0.1f, HPS.Marker.SizeUnits.WorldSpace);
MarkerKey markerKey3 = segKey3.InsertMarker(new HPS.Point(0, -0.35f, 0));
[figure 2.7.1.a] Marker size is controlled using the MarkerAttributeControl

NOTE: The "Dot" marker symbol is a special case and cannot be resized.

2.7.2 Editing markers

As with other geometry, markers can be modified after insertion by using the marker's key. However, the actions available for modifying a marker are limited:

[snippet 2.7.2.a]
// ... continuing from the above example
markerKey2.SetPoint(Point(-0.25f, 0, 0));
// delete a marker
someOtherMarkerKey.Delete();
// ... continuing from the above example
markerKey2.SetPoint(new HPS.Point(-0.25f, 0, 0));
// delete a marker
someOtherMarkerKey.Delete();
[figure 2.7.2.a] 'marker2' has been edited using the code above

2.7.3 Marker color and visibility

Marker color is controlled at the segment level using the HPS::MaterialMappingControl (for a discussion on materials, see section 5.1). To toggle the visibility of markers, use the HPS::VisibilityControl of the segment key:

[snippet 2.7.3.a]
mySegmentKey.GetVisibilityControl().SetMarkers(false); // turn off markers
mySegmentKey.GetVisibilityControl().SetMarkers(true); // turn on markers
// sets marker color to red
mySegmentKey.GetMaterialMappingControl().SetMarkerColor(RGBColor(1, 0, 0));
mySegmentKey.GetVisibilityControl().SetMarkers(false); // turn off markers
mySegmentKey.GetVisibilityControl().SetMarkers(true); // turn on markers
// sets marker color to red
mySegmentKey.GetMaterialMappingControl().SetMarkerColor(new HPS.RGBAColor(1, 0, 0));

2.7.4 Other considerations when using markers

For applications that require markers in a grid pattern, it is possible to insert multiple markers using a mesh with face and edge visibility turned off. This technique is slightly more efficient in terms of space, and produces identical results. The mesh primitive is discussed in section 2.2.

If you have inserted a large number of markers into your scene (on the order of 10,000 or more), we suggest that you explore using vertex markers as an alternative way to represent your data. This approach will result in more efficient rendering and lower memory usage.