NAP
Public Member Functions | Public Attributes | Protected Member Functions | List of all members
VertexAttribute< ELEMENTTYPE > Class Template Reference

#include <vertexattribute.h>

Public Member Functions

virtual void reserve (size_t numElements) override
 
virtual size_t getCapacity () const override
 
void resize (size_t numElements)
 
void clear ()
 
const std::vector< ELEMENTTYPE > & getData () const
 
std::vector< ELEMENTTYPE > & getData ()
 
void addData (const ELEMENTTYPE &element)
 
void addData (const ELEMENTTYPE *elements, int numElements)
 
void setData (const std::vector< ELEMENTTYPE > &values)
 
void setData (const ELEMENTTYPE *elements, int numElements)
 
virtual VkFormat getFormat () const override
 
virtual int getCount () const override
 
ELEMENTTYPE & operator[] (std::size_t index)
 
const ELEMENTTYPE & operator[] (std::size_t index) const
 
- Public Member Functions inherited from BaseVertexAttribute
 BaseVertexAttribute ()
 
- Public Member Functions inherited from Resource
 Resource ()
 
- Public Member Functions inherited from Object
 Object ()
 
virtual ~Object ()
 
virtual bool init (utility::ErrorState &errorState)
 
virtual void onDestroy ()
 
 Object (Object &)=delete
 
Objectoperator= (const Object &)=delete
 
 Object (Object &&)=delete
 
Objectoperator= (Object &&)=delete
 

Public Attributes

std::vector< ELEMENTTYPE > mData
 Actual typed data of the attribute. More...
 
- Public Attributes inherited from BaseVertexAttribute
std::string mAttributeID
 Name/ID of the attribute. More...
 
- Public Attributes inherited from Object
std::string mID
 Property: 'mID' unique name of the object. Used as an identifier by the system. More...
 

Protected Member Functions

virtual void * getRawData () override
 

Additional Inherited Members

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

Description

template<typename ELEMENTTYPE>
class nap::VertexAttribute< ELEMENTTYPE >

Typed interface for vertex attributes. CPU data can be read by using getValues(). CPU data can be updated by using the various other functions. Make sure to call MeshInstance::update() after edits are performed. Notice that all known vertex attribute types have specializations for GetType and GetNumComponents.

Inheritance diagram for VertexAttribute< ELEMENTTYPE >:
[legend]
Collaboration diagram for VertexAttribute< ELEMENTTYPE >:
[legend]

Member Function Documentation

◆ addData() [1/2]

void addData ( const ELEMENTTYPE &  element)

Adds a single element to the end of the buffer. Data is copied.

Parameters
elementto add.

◆ addData() [2/2]

void addData ( const ELEMENTTYPE *  elements,
int  numElements 
)

Adds data to the existing data in the buffer. Data is copied.

Parameters
elementspointer to the elements to add.
numElementsnumber of elements in buffer to add.

◆ clear()

void clear ( )

Clears all data associated with this attribute

◆ getCapacity()

virtual size_t getCapacity ( ) const
overridevirtual
Returns
The internally allocated memory size.

Implements BaseVertexAttribute.

◆ getCount()

virtual int getCount ( ) const
overridevirtual
Returns
the number vertices in the buffer

Implements BaseVertexAttribute.

◆ getData() [1/2]

std::vector<ELEMENTTYPE>& getData ( )
Returns
Types interface toward the internal values. Use this function to read CPU data.

◆ getData() [2/2]

const std::vector<ELEMENTTYPE>& getData ( ) const
Returns
Types interface toward the internal values. Use this function to read CPU data.

◆ getFormat()

NAPAPI VkFormat getFormat ( ) const
overridevirtual
Returns
the VK_FORMAT of this vertex attribute

Implements BaseVertexAttribute.

◆ getRawData()

void * getRawData
overrideprotectedvirtual

Implementation for all typed buffer, returns data.

Implements BaseVertexAttribute.

◆ operator[]() [1/2]

ELEMENTTYPE& operator[] ( std::size_t  index)

Array subscript overload

Parameters
indexthe index of the attribute value
Returns
the vertex attribute value at index

◆ operator[]() [2/2]

const ELEMENTTYPE& operator[] ( std::size_t  index) const

Const array subscript overload

Parameters
indexthe index of the attribute value
Returns
the vertex attribute value at index

◆ reserve()

virtual void reserve ( size_t  numElements)
overridevirtual

Reserves a certain amount of CPU memory to hold the given number of elements

Parameters
numElementsthe number of elements to reserve memory for.

Implements BaseVertexAttribute.

◆ resize()

void resize ( size_t  numElements)

Resizes the data container to hold the given number of elements.

Parameters
numElementsthe new number of elements.

◆ setData() [1/2]

void setData ( const ELEMENTTYPE *  elements,
int  numElements 
)

Sets the entire vertex attribute buffer.

Parameters
elementspointer to the elements to copy.
numElementsamount of elements to copy.

◆ setData() [2/2]

void setData ( const std::vector< ELEMENTTYPE > &  values)

Sets the internal values based on the contained type

Parameters
valuesthe values that will be copied over

Member Data Documentation

◆ mData

std::vector<ELEMENTTYPE> mData

Actual typed data of the attribute.