NAP
Public Member Functions | Public Attributes | List of all members
LineFromFile Class Reference

#include <linefromfile.h>

Public Member Functions

 LineFromFile (nap::Core &core)
 
virtual bool init (utility::ErrorState &errorState) override
 
virtual bool isClosed () const override
 
virtual bool isClosed (int shapeIndex) const
 
- Public Member Functions inherited from PolyLine
 PolyLine (nap::Core &core)
 
virtual MeshInstance & getMeshInstance () override
 
virtual const MeshInstance & getMeshInstance () const override
 
Vec3VertexAttribute & getPositionAttr ()
 
const Vec3VertexAttribute & getPositionAttr () const
 
Vec4VertexAttribute & getColorAttr ()
 
const Vec4VertexAttribute & getColorAttr () const
 
Vec3VertexAttribute & getNormalAttr ()
 
const Vec3VertexAttribute & getNormalAttr () const
 
Vec3VertexAttribute & getUvAttr ()
 
const Vec3VertexAttribute & getUvAttr () 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
 
- Public Member Functions inherited from Resource
 Resource ()
 
- Public Member Functions inherited from Object
 Object ()
 
virtual ~Object ()
 
virtual void onDestroy ()
 
 Object (Object &)=delete
 
Object & operator= (const Object &)=delete
 
 Object (Object &&)=delete
 
Object & operator= (Object &&)=delete
 

Public Attributes

std::string mFile
 
float mTolerance = 1.0f
 
ESVGUnits mUnits = ESVGUnits::PX
 
float mDPI = 96.0f
 
bool mNormalize = true
 
float mScale = 1.0f
 
bool mFlipX = false
 
bool mFlipY = false
 
int mLineIndex = 0
 
- Public Attributes inherited from PolyLine
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...
 

Additional Inherited Members

- Static Public Member Functions inherited from Object
static bool isIDProperty (rtti::Instance &object, const rtti::Property &property)
 
- Static Protected Member Functions inherited from PolyLine
static void createVertexAttributes (MeshInstance &instance)
 
- Protected Attributes inherited from PolyLine
std::unique_ptr< MeshInstance > mMeshInstance
 
RenderService * mRenderService = nullptr
 

Description

Resource that loads a set of lines from an svg file Every line is converted in a polyline. The line vertex reolution can be changed using a difference tolerance value. A lower tolerance results in less vertices. The uv's of the lines are normalized based on the total bounding box of the file, ie: all the lines in the file. The normals are perpendicular to the tangent of the line, the line itself is loaded in the x, y plane. When normalization is turned on the loaded lines will be placed relative to 0, with a default bounding box in the x, y plane of -0.5 to 0.5. Changing the scale will change these bounds.

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

Constructor & Destructor Documentation

◆ LineFromFile()

LineFromFile ( nap::Core &  core)

Member Function Documentation

◆ init()

virtual bool init ( utility::ErrorState &  errorState)
overridevirtual

Loads the svg file and extract all the lines

Reimplemented from PolyLine.

◆ isClosed() [1/2]

virtual bool isClosed ( ) const
overridevirtual
Returns
if the first line is open or closed.

Implements PolyLine.

◆ isClosed() [2/2]

virtual bool isClosed ( int  shapeIndex) const
virtual

Returns if a given line is open or closed, useful when the file contains multiple lines, where each line is converted into a shape.

Returns
if a given line is open or closed.

Member Data Documentation

◆ mDPI

float mDPI = 96.0f

◆ mFile

std::string mFile

◆ mFlipX

bool mFlipX = false

◆ mFlipY

bool mFlipY = false

◆ mLineIndex

int mLineIndex = 0

◆ mNormalize

bool mNormalize = true

◆ mScale

float mScale = 1.0f

◆ mTolerance

float mTolerance = 1.0f

◆ mUnits