Namespaces | |
path | |
Classes | |
class | AutoResetEvent |
class | ErrorState |
class | MemoryStream |
class | UniquePtrConstMapWrapper |
class | UniquePtrConstVectorWrapper |
class | UniquePtrMapIterator |
class | UniquePtrMapWrapper |
class | UniquePtrVectorIterator |
class | UniquePtrVectorWrapper |
Typedefs | |
using | MeshConnectivityMap = std::vector< std::vector< Triangle > > |
Enumerations | |
enum | ETextOrientation : int { Left = 0, Center = 1, Right = 2 } |
Functions | |
float NAPAPI | interval (uint binCount, float nyqist) |
float NAPAPI | freq (uint bin, uint binCount, float nyqist) |
void NAPAPI | cutoff (const FFTBuffer::AmplitudeSpectrum &inAmps, FFTBuffer::AmplitudeSpectrum &outAmps, uint minBin, uint maxBin) |
float NAPAPI | average (const FFTBuffer::AmplitudeSpectrum &s, uint minBin=0, uint maxBin=0) |
float NAPAPI | centroid (const FFTBuffer::AmplitudeSpectrum &s) |
float NAPAPI | flux (const FFTBuffer::AmplitudeSpectrum ¤t, const FFTBuffer::AmplitudeSpectrum &previous, uint minBin, uint maxBin) |
bool NAPAPI | createSignature (const std::string &privkey, const std::string &message, ESigningScheme scheme, std::string &outSignature) |
bool NAPAPI | verifyMessage (const std::string &pubkey, const std::string &message, ESigningScheme scheme, const std::string &signature) |
bool NAPAPI | generateRSAKey (unsigned int bits, std::string &outPrivKey, std::string &outPubKey) |
std::string NAPAPI | sha256 (const std::string &str) |
Generate a SHA256 hash of a string. More... | |
std::string NAPAPI | encode64 (const std::string &str) |
Encode a string to base64. More... | |
std::string NAPAPI | decode64 (const std::string &str) |
Decode a base64 string. More... | |
bool NAPAPI | isTriangleMesh (const nap::MeshInstance &meshInstance) |
int NAPAPI | getTriangleCount (const MeshInstance &meshInstance) |
glm::vec3 NAPAPI | computeTriangleNormal (const TriangleData< glm::vec3 > &vertices) |
void NAPAPI | setTriangleIndices (nap::MeshShape &mesh, EDrawMode drawMode, int number, const std::array< int, 3 > &indices) |
template<typename T > | |
void | computeBoundingBox (const MeshInstance &mesh, math::Box &outBox) |
template<typename T > | |
void | computeBoundingBox (const nap::MeshInstance &mesh, const nap::MeshShape &shape, math::Box &outBox) |
void NAPAPI | computeNormals (const nap::MeshInstance &mesh, const nap::VertexAttribute< glm::vec3 > &vertices, nap::VertexAttribute< glm::vec3 > &outNormals) |
void NAPAPI | reverseWindingOrder (nap::MeshInstance &mesh) |
void NAPAPI | generateIndices (nap::MeshShape &shape, int vertexCount, bool loop=false, int offset=0) |
void NAPAPI | computeConnectivity (const nap::MeshInstance &mesh, MeshConnectivityMap &outConnectivityMap) |
float NAPAPI | computeTriangleArea (const TriangleData< glm::vec3 > &vertices) |
float NAPAPI | computeArea (nap::MeshInstance &mesh, const nap::VertexAttribute< glm::vec3 > &vertices, std::vector< float > &outList) |
bool NAPAPI | intersect (const glm::vec3 &rayOrigin, const glm::vec3 &rayDirection, const TriangleData< glm::vec3 > &vertices, glm::vec3 &outCoordinates) |
glm::vec3 NAPAPI | computeBarycentric (const glm::vec3 &point, const TriangleData< glm::vec3 > &triangle) |
template<typename T > | |
T | interpolateVertexAttr (const TriangleData< T > &vertexValues, const glm::vec3 &barycentricCoordinates) |
bool NAPAPI | createRenderPass (VkDevice device, VkFormat colorFormat, VkFormat depthFormat, VkSampleCountFlagBits samples, VkImageLayout targetLayout, bool consumeDepth, VkRenderPass &renderPass, utility::ErrorState &errorState) |
bool NAPAPI | createRenderPass (VkDevice device, VkFormat colorFormat, VkFormat depthFormat, VkSampleCountFlagBits samples, VkImageLayout targetLayout, VkRenderPass &renderPass, utility::ErrorState &errorState) |
bool NAPAPI | createDepthOnlyRenderPass (VkDevice device, VkFormat depthFormat, VkRenderPass &renderPass, utility::ErrorState &errorState) |
bool NAPAPI | create2DImage (VmaAllocator allocator, uint32 width, uint32 height, VkFormat format, uint32 mipLevels, VkSampleCountFlagBits samples, VkImageTiling tiling, VkImageUsageFlags imageUsage, VmaMemoryUsage memoryUsage, VkImage &outImage, VmaAllocation &outAllocation, VmaAllocationInfo &outAllocationInfo, utility::ErrorState &errorState) |
bool NAPAPI | create2DImageView (VkDevice device, VkImage image, VkFormat format, uint32 mipLevels, VkImageAspectFlags aspectFlags, VkImageView &outImageView, utility::ErrorState &errorState) |
bool NAPAPI | createLayered2DImage (VmaAllocator allocator, uint32 width, uint32 height, VkFormat format, uint32 mipLevels, uint32 layerCount, VkSampleCountFlagBits samples, VkImageTiling tiling, VkImageUsageFlags imageUsage, VmaMemoryUsage memoryUsage, VkImageCreateFlags flags, VkImage &outImage, VmaAllocation &outAllocation, VmaAllocationInfo &outAllocationInfo, utility::ErrorState &errorState) |
bool NAPAPI | createLayered2DImageView (VkDevice device, VkImage image, VkFormat format, uint32 mipLevels, VkImageAspectFlags aspectFlags, uint32 layerIndex, uint32 layerCount, VkImageView &outImageView, utility::ErrorState &errorState) |
bool NAPAPI | createCubeImageView (VkDevice device, VkImage image, VkFormat format, uint32 mipLevels, VkImageAspectFlags aspectFlags, uint32 layerCount, VkImageView &outImageView, utility::ErrorState &errorState) |
void NAPAPI | destroyImageAndView (ImageData &data, VkDevice device, VmaAllocator allocator) |
bool NAPAPI | createBuffer (VmaAllocator allocator, uint32 size, VkBufferUsageFlags bufferUsage, VmaMemoryUsage memoryUsage, VmaAllocationCreateFlags allocationFlags, BufferData &outBuffer, utility::ErrorState &error) |
void NAPAPI | destroyBuffer (VmaAllocator allocator, BufferData &buffer) |
bool NAPAPI | uploadToBuffer (VmaAllocator allocator, uint32 size, const void *data, BufferData &buffer) |
VkFormat NAPAPI | getTextureFormat (ESurfaceDataType dataType, ESurfaceChannels channels, EColorSpace colorSpace) |
VkFormat NAPAPI | getTextureFormat (const SurfaceDescriptor &descriptor) |
void NAPAPI | transitionImageLayout (VkCommandBuffer commandBuffer, VkImage image, VkImageLayout oldLayout, VkImageLayout newLayout, VkAccessFlags srcAccessMask, VkAccessFlags dstAccessMask, VkPipelineStageFlags srcStage, VkPipelineStageFlags dstStage, uint mipLevel, uint mipLevelCount, VkImageAspectFlags aspect) |
void NAPAPI | transitionImageLayout (VkCommandBuffer commandBuffer, VkImage image, VkImageLayout oldLayout, VkImageLayout newLayout, VkAccessFlags srcAccessMask, VkAccessFlags dstAccessMask, VkPipelineStageFlags srcStage, VkPipelineStageFlags dstStage, uint mipLevel, uint mipLevelCount, uint layer, uint layerCount, VkImageAspectFlags aspect) |
void NAPAPI | createMipmaps (VkCommandBuffer buffer, VkImage image, VkFormat imageFormat, VkImageLayout targetLayout, VkImageAspectFlags aspect, uint32 texWidth, uint32 texHeight, uint32 mipLevels) |
void NAPAPI | createMipmaps (VkCommandBuffer buffer, VkImage image, VkFormat imageFormat, VkImageLayout targetLayout, VkImageAspectFlags aspect, uint32 texWidth, uint32 texHeight, uint32 mipLevels, uint layer, uint layerCount) |
void NAPAPI | blit (VkCommandBuffer commandBuffer, const Texture2D &srcTexture, const Texture2D &dstTexture) |
bool | listDir (const char *directory, std::vector< std::string > &outFilenames, bool absolute=true) |
bool | isAbsolutePath (const std::string &path) |
std::string | getAbsolutePath (const std::string &relPath) |
std::string | getFileExtension (const std::string &filename) |
std::string | getFileName (const std::string &file) |
std::string | getFileDir (const std::string &file) |
std::string | getFileNameWithoutExtension (const std::string &file) |
void | stripFileExtension (std::string &file) |
std::string | stripFileExtension (const std::string &file) |
std::string | appendFileExtension (const std::string &file, const std::string &ext) |
bool | hasExtension (const std::string &file, const std::string &extension) |
bool | fileExists (const std::string &filename) |
bool | dirExists (const std::string &dirName) |
bool | ensureDirExists (const std::string &dirName) |
bool | makeDirs (const std::string &directory) |
bool | deleteFile (const std::string &path) |
void | writeStringToFile (const std::string &filename, const std::string &contents) |
std::string | toComparableFilename (const std::string &filename) |
bool | isFilenameEqual (const std::string &filenameA, const std::string &filenameB) |
bool | getFileModificationTime (const std::string &path, uint64_t &modTime) |
std::string | getExecutablePath () |
std::string | getExecutableDir () |
bool | changeDir (const std::string &newDir) |
std::string | getCWD () |
bool | readFileToString (const std::string &filename, std::string &outBuffer, utility::ErrorState &err) |
std::string | findFileInDirectories (const std::string &filename, const std::vector< std::string > &dirs) |
std::string | joinPath (const std::vector< std::string > &parts) |
std::string | forceSeparator (const std::string &path) |
void | splitString (const std::string &string, const char delim, std::vector< std::string > &ioParts) |
std::vector< std::string > | splitString (const std::string &string, const char delim) |
template<typename T > | |
std::string | joinString (const T &list, const char *delim) |
void | writeString (std::ostream &stream, const std::string &text) |
std::string | readString (std::istream &stream) |
void | toLower (std::string &ioString) |
std::string | toLower (const std::string &string) |
void | toUpper (std::string &ioString) |
std::string | toUpper (const std::string &string) |
std::string | stripNamespace (const std::string &str) |
void | tokenize (const std::string &str, std::list< std::string > &tokens, const std::string &delims, bool omitTokens=false) |
bool | startsWith (const std::string &string, const std::string &subString, bool caseSensitive=true) |
bool | endsWith (const std::string &string, const std::string &subString, bool caseSensitive=true) |
bool | contains (const std::string &string, const std::string &subString, bool caseSensitive=true) |
std::string | trim (const std::string &string) |
std::string | lTrim (const std::string &string) |
std::string | rTrim (const std::string &string) |
template<typename T > | |
std::string | addresStr (T thing) |
void | namedFormat (std::string &subject, const std::unordered_map< std::string, std::string > &rep) |
void | namedFormat (std::vector< std::string > &subjects, const std::unordered_map< std::string, std::string > &rep) |
std::string | replaceTemplateType (const std::string &typeName, const std::string &templateTypeName) |
void | replaceAllInstances (std::string &inString, const std::string &find, const std::string &replace) |
std::string | replaceAllInstances (const std::string &inString, const std::string &find, const std::string &replace) |
int | getLine (const std::string &buffer, size_t offset) |
template<typename... Args> | |
std::string | stringFormat (const char *format, Args &&... args) |
String utilities not offered by std::string
using MeshConnectivityMap = std::vector<std::vector<Triangle> > |
|
strong |
Controls the horizontal text draw orientation, vertical alignment is based on the character origin line This enum is serializable and can be used as a property
Enumerator | |
---|---|
Left | Draws text to the right of the horizontal coordinate. |
Center | Centers the text around the horizontal coordinate. |
Right | Draws the text to the left of the horizontal coordinate. |
std::string addresStr | ( | T | thing | ) |
Converts T in to a string using an std stringstream.
thing | the object to convert into a string |
std::string nap::utility::appendFileExtension | ( | const std::string & | file, |
const std::string & | ext | ||
) |
file | the file to add extension to |
ext | extension without preceding '.' |
float NAPAPI nap::utility::average | ( | const FFTBuffer::AmplitudeSpectrum & | amps, |
uint | minBin = 0 , |
||
uint | maxBin = 0 |
||
) |
Computes spectral average of amplitude spectrum
amps | input amplitude spectrum |
minBin | minimum bin to cutoff |
maxBin | maximum bin to cutoff |
void NAPAPI nap::utility::blit | ( | VkCommandBuffer | commandBuffer, |
const Texture2D & | srcTexture, | ||
const Texture2D & | dstTexture | ||
) |
Pushes a full-size blit to the command buffer. Must be called inside a render pass, in onDraw(). Assumes a color texture without mip-maps. The layouts of srcTexture and dstTexture are transferred to SHADER_READ after the blit operation.
commandBuffer | the command buffer to push the blit operation to |
srcTexture | the source texture |
dstTexture | the destination texture |
float NAPAPI nap::utility::centroid | ( | const FFTBuffer::AmplitudeSpectrum & | amps | ) |
Computes spectral centroid of amplitude spectrum
amps | input amplitude spectrum |
bool nap::utility::changeDir | ( | const std::string & | newDir | ) |
Change current working directory
newDir | The working directory to change to |
float NAPAPI nap::utility::computeArea | ( | nap::MeshInstance & | mesh, |
const nap::VertexAttribute< glm::vec3 > & | vertices, | ||
std::vector< float > & | outList | ||
) |
Computes the area of every triangle in the mesh and stores the results in outList. The total is returned This call assumes the mesh has position vertex attribute data!
mesh | the mesh that contains the triangles |
vertices | the mesh vertex positions |
outList | a vector that contains the individual area of every triangle in the mesh |
glm::vec3 NAPAPI nap::utility::computeBarycentric | ( | const glm::vec3 & | point, |
const TriangleData< glm::vec3 > & | triangle | ||
) |
Computes the barycentric coordinates for a point with respect to a triangle
point | the position of the point in respect to the triangle |
triangle | the vertices of the triangle |
void computeBoundingBox | ( | const MeshInstance & | mesh, |
math::Box & | outBox | ||
) |
Computes the bounding box of a mesh using its associated position data. Note that indices are not considered. This call loops over all available points regardless of whether if they're drawn or not
the | data type of the position attribute |
mesh | the mesh to get the bounding box for |
outBox | the computed bounding box |
void computeBoundingBox | ( | const nap::MeshInstance & | mesh, |
const nap::MeshShape & | shape, | ||
math::Box & | outBox | ||
) |
Computes the bounding box of a single shape within a mesh using its associated position data. Note that the given shape must be part of the mesh.
the | data type of the position attribute |
mesh | the mesh that contains position data |
shape | the shape to compute the bounding box for |
outBox | the computed bounding box |
void NAPAPI nap::utility::computeConnectivity | ( | const nap::MeshInstance & | mesh, |
MeshConnectivityMap & | outConnectivityMap | ||
) |
Builds a 'map' that binds points (mesh index values) to faces The index in the array corresponds to a mesh vertex index (point). This call only works for meshes that have indices. When the mesh does not have indices this call asserts Try to avoid building the map regularly, it's a heavy operation This call asserts when the mesh is not a triangular mesh or has no indices associated with it
mesh | the mesh to get build the array from |
outConnectivityMap | the array that is populated with the triangles associated with a single index |
void NAPAPI nap::utility::computeNormals | ( | const nap::MeshInstance & | mesh, |
const nap::VertexAttribute< glm::vec3 > & | vertices, | ||
nap::VertexAttribute< glm::vec3 > & | outNormals | ||
) |
Automatically re-computes all the normals of a mesh When the mesh has indices the normal is computed based on connectivity Meshes without indices receive the triangular face normal
mesh | the triangular mesh |
vertices | the vertex position attribute |
outNormals | the recomputed normals, the normals have to be initialized and of the same length as the vertices |
float NAPAPI nap::utility::computeTriangleArea | ( | const TriangleData< glm::vec3 > & | vertices | ) |
vertices | the triangle vertex position data |
glm::vec3 NAPAPI nap::utility::computeTriangleNormal | ( | const TriangleData< glm::vec3 > & | vertices | ) |
Computes the normal that is associated with a triangular face. The normal is weighted (not normalized) This call asserts when the index is out of bounds.
vertices | mesh vertices |
bool nap::utility::contains | ( | const std::string & | string, |
const std::string & | subString, | ||
bool | caseSensitive = true |
||
) |
Checks if subString is present in string
string | the full string that could contain substring |
subString | part of the string that could be present in string |
caseSensitive | if the lookup is case sensitive or not |
bool NAPAPI nap::utility::create2DImage | ( | VmaAllocator | allocator, |
uint32 | width, | ||
uint32 | height, | ||
VkFormat | format, | ||
uint32 | mipLevels, | ||
VkSampleCountFlagBits | samples, | ||
VkImageTiling | tiling, | ||
VkImageUsageFlags | imageUsage, | ||
VmaMemoryUsage | memoryUsage, | ||
VkImage & | outImage, | ||
VmaAllocation & | outAllocation, | ||
VmaAllocationInfo & | outAllocationInfo, | ||
utility::ErrorState & | errorState | ||
) |
Creates a Vulkan image based on the described image usage and given properties.
bool NAPAPI nap::utility::create2DImageView | ( | VkDevice | device, |
VkImage | image, | ||
VkFormat | format, | ||
uint32 | mipLevels, | ||
VkImageAspectFlags | aspectFlags, | ||
VkImageView & | outImageView, | ||
utility::ErrorState & | errorState | ||
) |
Creates a Vulkan image view based on the described image usage and given properties.
bool NAPAPI nap::utility::createBuffer | ( | VmaAllocator | allocator, |
uint32 | size, | ||
VkBufferUsageFlags | bufferUsage, | ||
VmaMemoryUsage | memoryUsage, | ||
VmaAllocationCreateFlags | allocationFlags, | ||
BufferData & | outBuffer, | ||
utility::ErrorState & | error | ||
) |
Creates a Vulkan buffer
bool NAPAPI nap::utility::createCubeImageView | ( | VkDevice | device, |
VkImage | image, | ||
VkFormat | format, | ||
uint32 | mipLevels, | ||
VkImageAspectFlags | aspectFlags, | ||
uint32 | layerCount, | ||
VkImageView & | outImageView, | ||
utility::ErrorState & | errorState | ||
) |
Creates a Vulkan cube image view based on the described image usage and given properties.
bool NAPAPI nap::utility::createDepthOnlyRenderPass | ( | VkDevice | device, |
VkFormat | depthFormat, | ||
VkRenderPass & | renderPass, | ||
utility::ErrorState & | errorState | ||
) |
Creates a single or multi-sample depth-only renderpass based depth format.
bool NAPAPI nap::utility::createLayered2DImage | ( | VmaAllocator | allocator, |
uint32 | width, | ||
uint32 | height, | ||
VkFormat | format, | ||
uint32 | mipLevels, | ||
uint32 | layerCount, | ||
VkSampleCountFlagBits | samples, | ||
VkImageTiling | tiling, | ||
VkImageUsageFlags | imageUsage, | ||
VmaMemoryUsage | memoryUsage, | ||
VkImageCreateFlags | flags, | ||
VkImage & | outImage, | ||
VmaAllocation & | outAllocation, | ||
VmaAllocationInfo & | outAllocationInfo, | ||
utility::ErrorState & | errorState | ||
) |
Creates a Vulkan layered image based on the described image usage and given properties.
bool NAPAPI nap::utility::createLayered2DImageView | ( | VkDevice | device, |
VkImage | image, | ||
VkFormat | format, | ||
uint32 | mipLevels, | ||
VkImageAspectFlags | aspectFlags, | ||
uint32 | layerIndex, | ||
uint32 | layerCount, | ||
VkImageView & | outImageView, | ||
utility::ErrorState & | errorState | ||
) |
Creates a Vulkan layered image view based on the described image usage and given properties.
void NAPAPI nap::utility::createMipmaps | ( | VkCommandBuffer | buffer, |
VkImage | image, | ||
VkFormat | imageFormat, | ||
VkImageLayout | targetLayout, | ||
VkImageAspectFlags | aspect, | ||
uint32 | texWidth, | ||
uint32 | texHeight, | ||
uint32 | mipLevels | ||
) |
Creates mip maps for the specified Vulkan image.
void NAPAPI nap::utility::createMipmaps | ( | VkCommandBuffer | buffer, |
VkImage | image, | ||
VkFormat | imageFormat, | ||
VkImageLayout | targetLayout, | ||
VkImageAspectFlags | aspect, | ||
uint32 | texWidth, | ||
uint32 | texHeight, | ||
uint32 | mipLevels, | ||
uint | layer, | ||
uint | layerCount | ||
) |
Creates mip maps for the specified Vulkan image.
bool NAPAPI nap::utility::createRenderPass | ( | VkDevice | device, |
VkFormat | colorFormat, | ||
VkFormat | depthFormat, | ||
VkSampleCountFlagBits | samples, | ||
VkImageLayout | targetLayout, | ||
bool | consumeDepth, | ||
VkRenderPass & | renderPass, | ||
utility::ErrorState & | errorState | ||
) |
Creates a single or multi-sample renderpass based on rasterization samples and color/depth formats.
bool NAPAPI nap::utility::createRenderPass | ( | VkDevice | device, |
VkFormat | colorFormat, | ||
VkFormat | depthFormat, | ||
VkSampleCountFlagBits | samples, | ||
VkImageLayout | targetLayout, | ||
VkRenderPass & | renderPass, | ||
utility::ErrorState & | errorState | ||
) |
Creates a single or multi-sample renderpass based on rasterization samples and color/depth formats.
bool NAPAPI nap::utility::createSignature | ( | const std::string & | privkey, |
const std::string & | message, | ||
ESigningScheme | scheme, | ||
std::string & | outSignature | ||
) |
Create a signature for a given message. outSignature is encoded in base64.
privkey | The private key to use |
message | The message to sign |
scheme | The signing scheme to use |
outSignature | The signature encoded in base64 |
void NAPAPI nap::utility::cutoff | ( | const FFTBuffer::AmplitudeSpectrum & | inAmps, |
FFTBuffer::AmplitudeSpectrum & | outAmps, | ||
uint | minBin, | ||
uint | maxBin | ||
) |
Negates amplitudes outside of cutoff frequency
inAmps | input amplitude spectrum |
outAmps | output amplitude spectrum where amplitudes outside of cutoff frequency are negated |
minBin | minimum bin to cutoff |
maxBin | maximum bin to cutoff |
std::string NAPAPI nap::utility::decode64 | ( | const std::string & | str | ) |
Decode a base64 string.
str | The string to decode |
bool nap::utility::deleteFile | ( | const std::string & | path | ) |
Delete the file at the specified path.
path | The path to the file to delete |
void NAPAPI nap::utility::destroyBuffer | ( | VmaAllocator | allocator, |
BufferData & | buffer | ||
) |
Destroys a Vulkan buffer
void NAPAPI nap::utility::destroyImageAndView | ( | ImageData & | data, |
VkDevice | device, | ||
VmaAllocator | allocator | ||
) |
Destroys a Vulkan image and Vulkan ImageView if present in data
bool nap::utility::dirExists | ( | const std::string & | dirName | ) |
Check if a directory exists or not
dirName | name of the directory to check for |
std::string NAPAPI nap::utility::encode64 | ( | const std::string & | str | ) |
Encode a string to base64.
str | The string to encode |
bool nap::utility::endsWith | ( | const std::string & | string, |
const std::string & | subString, | ||
bool | caseSensitive = true |
||
) |
Checks if string ends with subString
string | the string to check |
subString | the part of the string to check for |
caseSensitive | if the lookup is case sensitive or now |
bool nap::utility::ensureDirExists | ( | const std::string & | dirName | ) |
Makes sure the given directory exists, attempts to create the directory if it does not exist, recursively
dirName | name of the directory to check for |
bool nap::utility::fileExists | ( | const std::string & | filename | ) |
Check whether a file exists or not.
filename | The absolute or relative file path to check for |
std::string nap::utility::findFileInDirectories | ( | const std::string & | filename, |
const std::vector< std::string > & | dirs | ||
) |
Find a file in one of the given directories.
filename | The file to look for, including extension |
dirs | The directories to search in |
float NAPAPI nap::utility::flux | ( | const FFTBuffer::AmplitudeSpectrum & | current, |
const FFTBuffer::AmplitudeSpectrum & | previous, | ||
uint | minBin, | ||
uint | maxBin | ||
) |
Computes spectral flux of amplitude spectrum
current | the amplitude spectrum of the current frame |
previous | the amplitude spectrum of the previous frame |
minBin | minimum bin to cutoff |
maxBin | maximum bin to cutoff |
std::string nap::utility::forceSeparator | ( | const std::string & | path | ) |
Returns a file path with the correct path separator for the current platform.
path | path name to correct |
bin | the bin to retrieve the frequency from |
binCount | the number of frequency bins |
nyqist | nyqist frequency in Hz (e.g. 44100 Hz) |
void NAPAPI nap::utility::generateIndices | ( | nap::MeshShape & | shape, |
int | vertexCount, | ||
bool | loop = false , |
||
int | offset = 0 |
||
) |
Generates a list of sequential indices from offset up to vertexCount + offset.
shape | The shape to generate indices for. |
vertexCount | number of indices to generate. |
loop | an extra index is added at the end, pointing to the the first one. Useful when creating a line loop. |
offset | The first index value. |
bool NAPAPI nap::utility::generateRSAKey | ( | unsigned int | bits, |
std::string & | outPrivKey, | ||
std::string & | outPubKey | ||
) |
Generate a RSA public-private key pair.
bits | number of bits |
outPrivKey | string will be filled with the private key |
outPubKey | string will be filled with the public key |
std::string nap::utility::getAbsolutePath | ( | const std::string & | relPath | ) |
Given a relative path, return an absolute path.
relPath | The path to convert |
std::string nap::utility::getCWD | ( | ) |
Returns the current working directory
std::string nap::utility::getExecutableDir | ( | ) |
std::string nap::utility::getExecutablePath | ( | ) |
std::string nap::utility::getFileDir | ( | const std::string & | file | ) |
file | the filename |
std::string nap::utility::getFileExtension | ( | const std::string & | filename | ) |
Return the extension of the given filename. Eg. "my.directory/myFile.tar.gz" -> "gz"
filename | The filename to get the extension from |
bool nap::utility::getFileModificationTime | ( | const std::string & | path, |
uint64_t & | modTime | ||
) |
Get the modification time of the specified path
path | The path to the file |
modTime | The modification time of the file |
std::string nap::utility::getFileName | ( | const std::string & | file | ) |
file | the file to extract the name frame |
std::string nap::utility::getFileNameWithoutExtension | ( | const std::string & | file | ) |
file | path that is stripped |
int nap::utility::getLine | ( | const std::string & | buffer, |
size_t | offset | ||
) |
Based on a string and a character offset into this string, return the line number
buffer | The string to search |
offset | Character offset into the provided buffer |
VkFormat NAPAPI nap::utility::getTextureFormat | ( | const SurfaceDescriptor & | descriptor | ) |
VkFormat NAPAPI nap::utility::getTextureFormat | ( | ESurfaceDataType | dataType, |
ESurfaceChannels | channels, | ||
EColorSpace | colorSpace | ||
) |
int NAPAPI nap::utility::getTriangleCount | ( | const MeshInstance & | meshInstance | ) |
Returns the total number of triangles associated with a mesh.
meshInstance | the mesh to inspect. |
bool nap::utility::hasExtension | ( | const std::string & | file, |
const std::string & | extension | ||
) |
file | the file to check extension for |
extension | the file extension without preceding '.' |
T interpolateVertexAttr | ( | const TriangleData< T > & | vertexValues, |
const glm::vec3 & | barycentricCoordinates | ||
) |
Interpolates triangle vertex values based on barycentric u and v coordinates
vertexValues | the values associated with the triangle vertices |
barycentricCoordinates | the triangle barycentric coordinates (u,v,w) |
bool NAPAPI nap::utility::intersect | ( | const glm::vec3 & | rayOrigin, |
const glm::vec3 & | rayDirection, | ||
const TriangleData< glm::vec3 > & | vertices, | ||
glm::vec3 & | outCoordinates | ||
) |
Calculates the intersection of a ray and a triangle in 3 dimensions Based on the Moller Trumbore intersection algorithm: https://en.wikipedia.org/wiki/M%C3%B6ller%E2%80%93Trumbore_intersection_algorithm Back-facing triangles relative to the ray direction are not considered
rayOrigin | the origin of the ray, often the world space position of a camera |
rayDirection | the direction of the ray from it's origin |
vertices | the triangle vertex positions |
outCoordinates | barycentric coordinates of point of intersection, where z is the scalar factor for the ray. |
float NAPAPI nap::utility::interval | ( | uint | binCount, |
float | nyqist | ||
) |
binCount | the number of frequency bins |
nyqist | nyqist frequency in Hz (e.g. 44100 Hz) |
bool nap::utility::isAbsolutePath | ( | const std::string & | path | ) |
Check if the given path is absolute
path | The path to check |
bool nap::utility::isFilenameEqual | ( | const std::string & | filenameA, |
const std::string & | filenameB | ||
) |
filenameA | filename to compare against filenameB. |
filenameB | filename to comapre against filenameA. |
bool NAPAPI nap::utility::isTriangleMesh | ( | const nap::MeshInstance & | meshInstance | ) |
Returns if the mesh is of type: TRIANGLES, TRIANGLE_STRIP or TRIANGLE_FAN
meshInstance | the mesh to check |
std::string nap::utility::joinPath | ( | const std::vector< std::string > & | parts | ) |
Join parts path parts using the correct path separator for the current platform
std::string joinString | ( | const T & | list, |
const char * | delim | ||
) |
Joins a list of strings together. For example: joinString({"one", "two", "three"}, ", ") -> becomes: "one, two, three"
list | The list of strings to join |
delim | The delimiter to inject between the elements |
bool nap::utility::listDir | ( | const char * | directory, |
std::vector< std::string > & | outFilenames, | ||
bool | absolute = true |
||
) |
List all files in a directory
directory | The directory to search in |
outFilenames | A vector of files to populate with filenames |
absolute | Whether to populate absolute filenames |
std::string nap::utility::lTrim | ( | const std::string & | string | ) |
Strips white space characters from the start(left) of a string
string | the string to remove white space characters from |
bool nap::utility::makeDirs | ( | const std::string & | directory | ) |
Attempts to create a directory with the given name, recursively. Creation will fail if the path is invalid or the directory already exists.
directory | path to the directory to create, absolute or relative. |
void nap::utility::namedFormat | ( | std::string & | subject, |
const std::unordered_map< std::string, std::string > & | rep | ||
) |
Replace all occurrences of the provided keys with their associated values in the given subject string. The keys in the subject string are to be wrapped in curly braces. Example: subject: My {animal}'s name is {name}, it's a good {animal}. replacement: {{"animal", "snake"}, {"name", "Donald"}} result: My snake's name is Donald, it's a good snake.
subject | The string to search and replace keys in. |
rep | The keys and values used in the replacement operation. |
void nap::utility::namedFormat | ( | std::vector< std::string > & | subjects, |
const std::unordered_map< std::string, std::string > & | rep | ||
) |
Replace all occurrences of the provided keys with their associated values in the given subject strings. The keys in the subject string are to be wrapped in curly braces. Example: subject: My {animal}'s name is {name}, it's a good {animal}. replacement: {{"animal", "snake"}, {"name", "Donald"}} result: My snake's name is Donald, it's a good snake.
subjects | The strings to search and replace keys in. |
rep | The keys and values used in the replacement operation. |
bool nap::utility::readFileToString | ( | const std::string & | filename, |
std::string & | outBuffer, | ||
utility::ErrorState & | err | ||
) |
Read the contents of a file into a string.
filename | Name of the file to read from |
outBuffer | The string in which the contents will be stored |
err | Will contain the error details if there were any problems. |
std::string nap::utility::readString | ( | std::istream & | stream | ) |
Reads a string form an input stream
stream | the stream to read the string from |
std::string nap::utility::replaceAllInstances | ( | const std::string & | inString, |
const std::string & | find, | ||
const std::string & | replace | ||
) |
Replace all instances of a string with a replacement string.
inString | The input string to search in |
find | The string to replace |
replace | The replacement string |
void nap::utility::replaceAllInstances | ( | std::string & | inString, |
const std::string & | find, | ||
const std::string & | replace | ||
) |
Replace all instances of search string with replacement
inString | The input string to search in |
find | The search string |
replace | The replacement string |
std::string nap::utility::replaceTemplateType | ( | const std::string & | typeName, |
const std::string & | templateTypeName | ||
) |
Given a templated type name, replace its template parameter with the provided template type.
typeName | The original templated type name, eg. "nap::MyType<SomeClass<float>>" |
templateTypeName | A replacement type name, eg. "float" |
void NAPAPI nap::utility::reverseWindingOrder | ( | nap::MeshInstance & | mesh | ) |
Reverses the winding order of all the triangle vertices in a mesh When a triangle has vertices A, B, C the new order will be C, B, A This call only works for triangle meshes that have indices associated with it This call asserts when the mesh is not a triangular mesh or the mesh has no indices
mesh | the mesh to reverse the index winding order for |
std::string nap::utility::rTrim | ( | const std::string & | string | ) |
Strips white space characters from the end(right) of a string string
string | the string to remove white space characters from |
void NAPAPI nap::utility::setTriangleIndices | ( | nap::MeshShape & | mesh, |
EDrawMode | drawMode, | ||
int | number, | ||
const std::array< int, 3 > & | indices | ||
) |
Sets the vertex indices associated with a triangle. Note that this function only works for meshes that are of type: TRIANGLES, TRIANGLE_STRIP or TRIANGLE_FAN This call asserts when the triangle number is out of bounds, the mesh has no indices or the draw mode is not of type triangle
mesh | the mesh to get the indices from |
drawMode | mesh topology |
number | the triangle number to get the for |
indices | the new indices |
std::string NAPAPI nap::utility::sha256 | ( | const std::string & | str | ) |
Generate a SHA256 hash of a string.
str | The string to hash |
std::vector<std::string> nap::utility::splitString | ( | const std::string & | string, |
const char | delim | ||
) |
void nap::utility::splitString | ( | const std::string & | string, |
const char | delim, | ||
std::vector< std::string > & | ioParts | ||
) |
bool nap::utility::startsWith | ( | const std::string & | string, |
const std::string & | subString, | ||
bool | caseSensitive = true |
||
) |
Checks if string starts with subString
string | the string to check |
subString | the part of the string to check for |
caseSensitive | if the lookup is case sensitive or not |
std::string nap::utility::stringFormat | ( | const char * | msg, |
Args &&... | args | ||
) |
Formats a string based on the incoming arguments example: utility::stringFormat("%s contains %d number of items", object.name().c_str(), i)
msg | the string to format |
args | the arguments to replace |
std::string nap::utility::stripFileExtension | ( | const std::string & | file | ) |
file | the file to string the extension from |
void nap::utility::stripFileExtension | ( | std::string & | file | ) |
file | the file to strip the extension from |
std::string nap::utility::stripNamespace | ( | const std::string & | str | ) |
Strips all name space related identifiers from the given string.
str | the string to remove the namespace from |
std::string nap::utility::toComparableFilename | ( | const std::string & | filename | ) |
TODO: This may well be a platform independent 'toCanonicalFilename' or 'URI' as described here: https://en.wikipedia.org/wiki/File_URI_scheme
filename | the source filename. |
void nap::utility::tokenize | ( | const std::string & | str, |
std::list< std::string > & | tokens, | ||
const std::string & | delims, | ||
bool | omitTokens = false |
||
) |
Tokenize str into tokens.
str | the string to tokenize |
tokens | the tokens used to process the string |
delims | the delimiters used for the the tokenization process |
omitTokens | if the tokens are discarded from the result |
std::string nap::utility::toLower | ( | const std::string & | string | ) |
Converts all upper case characters in ioString to lower case characters
string | the input string that is converted |
void nap::utility::toLower | ( | std::string & | ioString | ) |
Converts all upper case characters in ioString to lower case characters
ioString | the input string that is converted to a lower case string |
std::string nap::utility::toUpper | ( | const std::string & | string | ) |
Converts all lower case characters in ioString to upper case characters
string | the input string that is converted |
void nap::utility::toUpper | ( | std::string & | ioString | ) |
Converts all lower case characters in ioString to upper case characters
ioString | the input string that is converted to an upper case string |
void NAPAPI nap::utility::transitionImageLayout | ( | VkCommandBuffer | commandBuffer, |
VkImage | image, | ||
VkImageLayout | oldLayout, | ||
VkImageLayout | newLayout, | ||
VkAccessFlags | srcAccessMask, | ||
VkAccessFlags | dstAccessMask, | ||
VkPipelineStageFlags | srcStage, | ||
VkPipelineStageFlags | dstStage, | ||
uint | mipLevel, | ||
uint | mipLevelCount, | ||
uint | layer, | ||
uint | layerCount, | ||
VkImageAspectFlags | aspect | ||
) |
Transition image to a new layout using an image barrier.
void NAPAPI nap::utility::transitionImageLayout | ( | VkCommandBuffer | commandBuffer, |
VkImage | image, | ||
VkImageLayout | oldLayout, | ||
VkImageLayout | newLayout, | ||
VkAccessFlags | srcAccessMask, | ||
VkAccessFlags | dstAccessMask, | ||
VkPipelineStageFlags | srcStage, | ||
VkPipelineStageFlags | dstStage, | ||
uint | mipLevel, | ||
uint | mipLevelCount, | ||
VkImageAspectFlags | aspect | ||
) |
Transition image to a new layout using an image barrier.
std::string nap::utility::trim | ( | const std::string & | string | ) |
Strips white space characters from a string
string | the string to remove white space characters from |
bool NAPAPI nap::utility::uploadToBuffer | ( | VmaAllocator | allocator, |
uint32 | size, | ||
const void * | data, | ||
BufferData & | buffer | ||
) |
Uploads data into a staging buffer
bool NAPAPI nap::utility::verifyMessage | ( | const std::string & | pubkey, |
const std::string & | message, | ||
ESigningScheme | scheme, | ||
const std::string & | signature | ||
) |
Verify a message against a signature. Signature is expected to be encoded in base64.
pubkey | The public key to use |
message | The message to verify |
scheme | The signing scheme to use |
signature | The signature encoded in base64 |
void nap::utility::writeString | ( | std::ostream & | stream, |
const std::string & | text | ||
) |
Writes a string to an output stream
stream | the output stream to write to |
text | the string to write |
void nap::utility::writeStringToFile | ( | const std::string & | filename, |
const std::string & | contents | ||
) |
Dump a string to a file.
filename | The name of the file to write to. |
contents | The string to write |