NAP
Public Member Functions | Public Attributes | Static Protected Member Functions | Protected Attributes | List of all members
PolyLine Class Referenceabstract

#include <polyline.h>

Public Member Functions

 PolyLine (nap::Core &core)
 
virtual bool init (utility::ErrorState &errorState) override
 
virtual MeshInstancegetMeshInstance () override
 
virtual const MeshInstancegetMeshInstance () const override
 
Vec3VertexAttributegetPositionAttr ()
 
const Vec3VertexAttributegetPositionAttr () const
 
Vec4VertexAttributegetColorAttr ()
 
const Vec4VertexAttributegetColorAttr () const
 
Vec3VertexAttributegetNormalAttr ()
 
const Vec3VertexAttributegetNormalAttr () const
 
Vec3VertexAttributegetUvAttr ()
 
const Vec3VertexAttributegetUvAttr () const
 
template<typename T >
void getValue (const VertexAttribute< T > &attr, float location, T &outValue) const
 
template<typename T >
void getValue (const std::map< float, int > &distanceMap, const VertexAttribute< T > &attr, float location, T &outValue) const
 
void getNormal (const std::map< float, int > &distanceMap, const Vec3VertexAttribute &attr, float location, glm::vec3 &outValue) const
 
float getDistances (std::map< float, int > &outDistances) const
 
virtual bool isClosed () const =0
 
- Public Member Functions inherited from Resource
 Resource ()
 
- Public Member Functions inherited from Object
 Object ()
 
virtual ~Object ()
 
virtual void onDestroy ()
 
 Object (Object &)=delete
 
Objectoperator= (const Object &)=delete
 
 Object (Object &&)=delete
 
Objectoperator= (Object &&)=delete
 

Public Attributes

PolyLineProperties mLineProperties
 
- Public Attributes inherited from Object
std::string mID
 Property: 'mID' unique name of the object. Used as an identifier by the system. More...
 

Static Protected Member Functions

static void createVertexAttributes (MeshInstance &instance)
 

Protected Attributes

std::unique_ptr< MeshInstancemMeshInstance
 
RenderServicemRenderService = nullptr
 

Additional Inherited Members

- Static Public Member Functions inherited from Object
static bool isIDProperty (rtti::Instance &object, const rtti::Property &property)
 

Description

Base class for all line specific mesh types. A PolyLine is a mesh that is always drawn using: LINE_STRIP. It also has a fixed set of (initial) vertex attributes: Position, Color0, UV0 and Normal.

Inheritance diagram for PolyLine:
[legend]
Collaboration diagram for PolyLine:
[legend]

Constructor & Destructor Documentation

◆ PolyLine()

PolyLine ( nap::Core core)

Member Function Documentation

◆ createVertexAttributes()

static void createVertexAttributes ( MeshInstance instance)
staticprotected

Utility function, creates all the default line attributes: Position, Normal, UV0 and Color0.

Parameters
instancethe instance to add the attributes to.

◆ getColorAttr() [1/2]

Vec4VertexAttribute& getColorAttr ( )
Returns
The line color vertex data

◆ getColorAttr() [2/2]

const Vec4VertexAttribute& getColorAttr ( ) const
Returns
The line color vertex data

◆ getDistances()

float getDistances ( std::map< float, int > &  outDistances) const

Utility function that retrieves the distance along the line for every vertex Note that this call is relatively heavy

Returns
the length of the line
Parameters
outDistancesa list of distances that will be populated with the length at every vertex

◆ getMeshInstance() [1/2]

virtual const MeshInstance& getMeshInstance ( ) const
overridevirtual
Returns
The polygon line mesh

Implements IMesh.

◆ getMeshInstance() [2/2]

virtual MeshInstance& getMeshInstance ( )
overridevirtual
Returns
The polygon line mesh

Implements IMesh.

◆ getNormal()

void getNormal ( const std::map< float, int > &  distanceMap,
const Vec3VertexAttribute attr,
float  location,
glm::vec3 &  outValue 
) const

Returns the interpolated normal value along the line, where the normal is correctly interpolated (rotated) based on it's location along the line This method is more accurate but requires a distance map that contains the distance of every vertex along the line You can acquire this map by calling the getDistances function

Parameters
distanceMapthe map that contains the distance of every vertex along the line
attrthe normal attribute to get the interpolated (rotated) value for
locationthe location on the line to get the value for, needs to be within the 0-1 range
outValuethe interpolated output normal

◆ getNormalAttr() [1/2]

Vec3VertexAttribute& getNormalAttr ( )
Returns
The line normal vertex data

◆ getNormalAttr() [2/2]

const Vec3VertexAttribute& getNormalAttr ( ) const
Returns
The line normal vertex data

◆ getPositionAttr() [1/2]

Vec3VertexAttribute& getPositionAttr ( )
Returns
The line position vertex data

◆ getPositionAttr() [2/2]

const Vec3VertexAttribute& getPositionAttr ( ) const
Returns
The line position vertex data

◆ getUvAttr() [1/2]

Vec3VertexAttribute& getUvAttr ( )
Returns
The line uv vertex data

◆ getUvAttr() [2/2]

const Vec3VertexAttribute& getUvAttr ( ) const
Returns
The line uv vertex data

◆ getValue() [1/2]

void getValue ( const std::map< float, int > &  distanceMap,
const VertexAttribute< T > &  attr,
float  location,
T &  outValue 
) const
Returns
the interpolated (accurate) value of an attribute along the line based on the given location This method is more accurate but requires a map that contains the distance along the line for every vertex You can acquire this map by calling the getDistances function
Parameters
distanceMapmap that contains the distance of every vertex along the line
attrthe attribute to get the value for
locationthe location on the line to get the value for, needs to be within the 0-1 range
outValuethe interpolated output value

◆ getValue() [2/2]

void getValue ( const VertexAttribute< T > &  attr,
float  location,
T &  outValue 
) const

This call does not accurately interpolate the vertex attribute, therefore this function works best with equally distributed vertices

Parameters
attrthe attribute to get the value for
locationthe location on the line to get the value for, needs to be within the 0-1 range
outValuethe interpolated output value
Returns
the interpolated value of an attribute along the line based on the given location

◆ init()

virtual bool init ( utility::ErrorState errorState)
overridevirtual

Create the mesh instance and required vertex attributes (P, Cd, N, Uv) When implementing a derived PolyLine, make sure to call this init first.

Parameters
errorStatecontains the error if the line could not be created.
Returns
if the line is created successfully.

Reimplemented from Object.

Reimplemented in TriangleLine, Hexagon, Circle, Rectangle, Line, and LineFromFile.

◆ isClosed()

virtual bool isClosed ( ) const
pure virtual
Returns
if the line is closed or not

Implemented in TriangleLine, Hexagon, Circle, Rectangle, Line, and LineFromFile.

Member Data Documentation

◆ mLineProperties

PolyLineProperties mLineProperties

◆ mMeshInstance

std::unique_ptr<MeshInstance> mMeshInstance
protected

◆ mRenderService

RenderService* mRenderService = nullptr
protected