Carna  Version 3.0.1
Public Member Functions | Static Public Member Functions | Public Attributes | Static Public Attributes | List of all members
Carna::helpers::PointMarkerHelper Class Reference

Simplifies the creation and maintenance of point markers. More...

#include <PointMarkerHelper.h>

Public Member Functions

 PointMarkerHelper (unsigned int geometryType, unsigned int pointSize=DEFAULT_POINT_SIZE)
 Instantiates.
 
 PointMarkerHelper (unsigned int geometryType, unsigned int meshRole, unsigned int materialRole, unsigned int pointSize=DEFAULT_POINT_SIZE)
 
 ~PointMarkerHelper ()
 Releases all previously acquired materials.
 
void releaseGeometryFeatures ()
 Releases all previously acquired materials. Invoke this method when it is sure that no further markers will be created. More...
 
base::GeometrycreatePointMarker () const
 Creates new point marker of preferred pixel size, colored differently than the last point marker created by any PointMarkerHelper instance. More...
 
base::GeometrycreatePointMarker (unsigned int pointSize) const
 Creates new point marker of pointSize colored differently than the last point marker created by any PointMarkerHelper instance. This method creates a new material each time it is used.
 
base::GeometrycreatePointMarker (const base::Color &color) const
 Creates new point marker of preferred pixel size with color. This method creates a new material each time it is used.
 
base::GeometrycreatePointMarker (const base::Color &color, unsigned int pointSize) const
 Creates new point marker of pointSize with color. This method creates a new material each time it is used.
 

Static Public Member Functions

static void resetDefaultColor ()
 Resets the color that the next invocation to the argument-less version of createPointMarker uses.
 

Public Attributes

const unsigned int geometryType
 Holds the markers' geometry type.
 
const unsigned int meshRole
 Holds the role used to attach the mesh to the markers.
 
const unsigned int materialRole
 Holds the role used to attach the material to the markers.
 
const unsigned int pointSize
 Holds the preferred pixel size of the markers.
 

Static Public Attributes

static const unsigned int DEFAULT_POINT_SIZE = 6
 Holds the default point marker pixel size.
 

Detailed Description

Simplifies the creation and maintenance of point markers.

A point marker is considered a 2D shape of fixed pixel size that is yet positioned in 3D space. Point markers are rendered as point-primitives and using the pointmarker material shader. That material shader produces the white edge around the markers.

Each instance of this class creates point markers of a preferred pixel size. It provides basically two methods for the creation of point markers. The first type takes no arguments and creates point markers from a predefined color palette and using the preferred pixel size. This method is a little faster in theory because it recycles materials once they have been instantiated for a particular color. The other methods take the color, the pixel size, or both as arguments and repeat the instantiation of a material every time they are used.

The following example creates a sequence of marker points in rotating colors:

helpers::PointMarkerHelper markers( GEOMETRY_TYPE_OPAQUE );
const float maxOffset = 300;
const unsigned int markersCount = 10;
for( unsigned int i = 0; i < markersCount; ++i )
{
const float x = -maxOffset + i * 2 * maxOffset / ( markersCount - 1 );
base::Geometry* const marker = markers.createPointMarker();
marker->localTransform = base::math::translation4f( x, 0, 0 );
root->attachChild( marker );
}
multiple.png
exemplary rendering from code above
Author
Leonid Kostrykin
Date
31.3.15

Definition at line 60 of file PointMarkerHelper.h.

Constructor & Destructor Documentation

Carna::helpers::PointMarkerHelper::PointMarkerHelper ( unsigned int  geometryType,
unsigned int  meshRole,
unsigned int  materialRole,
unsigned int  pointSize = DEFAULT_POINT_SIZE 
)
explicit

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

Member Function Documentation

base::Geometry* Carna::helpers::PointMarkerHelper::createPointMarker ( ) const

Creates new point marker of preferred pixel size, colored differently than the last point marker created by any PointMarkerHelper instance.

This method cycles through a predefined palette of colors. It recycles the materials instantiates once per color.

void Carna::helpers::PointMarkerHelper::releaseGeometryFeatures ( )

Releases all previously acquired materials. Invoke this method when it is sure that no further markers will be created.

Invoking this method and than instantiating markers will cause redundant base::Material instantiations.


The documentation for this class was generated from the following file: