Cogs.Core
|
#include <CADAttributeMap.h>
Public Member Functions | |
CADAttributeMap (bool powerOfTwoTextures=true) | |
CADAttributeMap (const CADAttributeMap &)=delete | |
CADAttributeMap & | operator= (const CADAttributeMap &)=delete |
std::span< const uint8_t > | getAttributeMap () const |
glm::uvec2 | getAttrSize () const |
void | init (glm::uvec3 color, AttributeMapAlpha alpha) |
bool | growToContainIndex (size_t index) |
void | setColor (size_t index, glm::uvec3 color) |
glm::vec3 | getColor (size_t index) const |
void | setAlpha (size_t index, AttributeMapAlpha alpha) |
AttributeMapAlpha | getAlpha (size_t index) |
bool | isValidIndex (size_t index) const |
uint8_t | getAttribute (size_t index, size_t attrOffset) |
void | setAttribute (size_t index, size_t attrOffset, uint8_t attribute) |
void | resize (glm::uvec2 attrSize) |
AttributeMapAlpha | getDefaultAlpha () const |
void | setDefaultAlpha (AttributeMapAlpha alpha) |
Get default Alpha entry. | |
glm::uvec3 | getDefaultColor () const |
Get default color value. | |
void | setDefaultColor (glm::uvec3 color) |
Set default color value. | |
Static Public Member Functions | |
static glm::uvec2 | getAttributeSize (size_t tagCount, bool powerOfTwo) |
static constexpr uint8_t | encodeAlpha (AttributeMapAlpha data) noexcept |
static constexpr AttributeMapAlpha | decodeAlpha (uint8_t alpha) |
Private Attributes | |
bool | powerOfTwoTextures = true |
glm::uvec2 | _attrSize = {} |
std::vector< uint8_t > | _attributeMap |
glm::uvec3 | defaultColor = { 0,0,0 } |
AttributeMapAlpha | defaultAlpha = { AttributeMapPixelTransparency::Off, AttributeMapPixelState::Default, } |
Handles Attribute map used to show a Cogs Asset without coloring, but with 2D Texture given an index into a CAD TAG mapping.
The Attribute map can be fed into a Cogs Texture. Colors are always passed as 8bit unsigned ints. The alpha channel is divided into two parts encoded using
Definition at line 112 of file CADAttributeMap.h.
|
inlineexplicit |
Initialized a new CADAttributeMap.
powerOfTwoTextures | - True if textures must be power of 2 |
Definition at line 118 of file CADAttributeMap.h.
|
inlinestaticconstexpr |
Decodes the given alpha channel data into separate enum values for transparency and state. Any changes to this function need to also be synced with the equivalents in GLSL; CustomPS.es30
Definition at line 341 of file CADAttributeMap.h.
Referenced by getAlpha().
|
inlinestaticconstexprnoexcept |
Combines the given alpha state and the given data state, and returns an alpha number that can be unpacked into both of these later. Any changes to this function need to also be synced with the equivalents in GLSL; CustomPS.es30
Definition at line 325 of file CADAttributeMap.h.
Referenced by setAlpha().
|
inline |
Gets the Alpha value for given Tag index.
index | - Tag Index. |
Definition at line 204 of file CADAttributeMap.h.
References decodeAlpha().
|
inline |
Low level access: Get Specific attribute (RGBA) at given index.
index | - Tag index. |
attrOffset | - Attribute selector R=0..A=3 |
Definition at line 227 of file CADAttributeMap.h.
|
inline |
Gets attribute map that can be passed to a Cogs texture as an array of 4 8bit values per entry.
Definition at line 128 of file CADAttributeMap.h.
Referenced by Cogs::Editor::CADAssetTexture::updateAttributeMap().
|
inlinestatic |
Calculate texture dimensions to ensure NXY*NXY >== tagCount
tagCount | - Number of tags. |
powerOfTwo | - Require texture size to be power ot 2. |
Definition at line 277 of file CADAttributeMap.h.
Referenced by growToContainIndex().
|
inline |
Gets attr size. E.g. Texture dimension in X and Y.
Definition at line 133 of file CADAttributeMap.h.
Referenced by Cogs::Editor::CADAssetTexture::getAttrSize(), and Cogs::Editor::CADAssetTexture::updateAttributeMap().
|
inline |
Get RGB Color (0-255) of the given attribute index.
index | - Tag index. |
Definition at line 184 of file CADAttributeMap.h.
|
inline |
Get default Alpha entry.
Definition at line 301 of file CADAttributeMap.h.
|
inline |
Get default color value.
Definition at line 313 of file CADAttributeMap.h.
Referenced by Cogs::Editor::CADAssetTexture::showAll().
|
inline |
Increase size of attribute map if needed to include the index in the map. can be used for dynamic resizing og the attribute map.
index | - Index to check. |
Definition at line 155 of file CADAttributeMap.h.
References getAttributeSize(), isValidIndex(), and resize().
Referenced by Cogs::Editor::CADAssetTexture::updateAlphaById(), and Cogs::Editor::CADAssetTexture::updateColorById().
|
inline |
Init the Attribute map filling with given values.
color | - Color values to set. |
alpha | - Alpha value to set. |
Definition at line 140 of file CADAttributeMap.h.
References setAlpha(), and setColor().
Referenced by Cogs::Editor::CADAssetTexture::showAll().
|
inline |
Check if index is valid, e.g. if map is large enough to contain index.
index | - Index to check. |
Definition at line 215 of file CADAttributeMap.h.
Referenced by growToContainIndex().
|
inline |
Resize the map, keeping values from the old map.
attrSize | - New Attribute size in X and Y. |
Definition at line 248 of file CADAttributeMap.h.
References setAlpha(), and setColor().
Referenced by Cogs::Editor::CADAssetTexture::CADAssetTexture(), and growToContainIndex().
|
inline |
Set the Alpha value for the given Tag index.
index | - Tag index. |
alpha | - Decoded Alpha |
Definition at line 194 of file CADAttributeMap.h.
References encodeAlpha().
Referenced by init(), resize(), and Cogs::Editor::CADAssetTexture::updateAlphaById().
|
inline |
Low level access: Set Texture CADAttributeMap at given index and offset(RGBA) to Source attribute.
index | - Tag index. |
attrOffset | - Source offset |
attribute | - New Attributes at index |
Definition at line 239 of file CADAttributeMap.h.
|
inline |
Get RGB Color (0-255) of the given attribute index.
index | - Tag index. |
color | - Color to set. |
Definition at line 171 of file CADAttributeMap.h.
Referenced by init(), resize(), and Cogs::Editor::CADAssetTexture::updateColorById().
|
inline |
Get default Alpha entry.
Definition at line 307 of file CADAttributeMap.h.
|
inline |
Set default color value.
Definition at line 316 of file CADAttributeMap.h.
|
private |
Definition at line 353 of file CADAttributeMap.h.
|
private |
Definition at line 352 of file CADAttributeMap.h.
|
private |
Definition at line 355 of file CADAttributeMap.h.
|
private |
Definition at line 354 of file CADAttributeMap.h.
|
private |
Definition at line 351 of file CADAttributeMap.h.