About
The VertexColorTag is used to add additional color information to a polygon object. The tag can be either in point mode or polygon mode. In point mode it will store color information for each vertex of the object. In polygon mode it will store color information for each vertex of each polygon of the object.
A VertexColorTag is based on VariableTag and is an instance of Tvertexcolor
.
Access
An existing VertexColorTag can be accessed from its host object.
Allocation/Deallocation
VertexColorTag instances are created with the usual tools:
- Note
- The VertexColorTag is always allocated in point mode.
See also Tags and BaseTag and VariableTag Manual.
if (tag == nullptr)
{
if (tag == nullptr)
}
Mode
A VertexColorTag can either be in point mode or polygon mode.
- Warning
- The mode of a tag must be changed with VertexColorTag::SetPerPointMode(). It is not enough to change the parameter ID_VERTEXCOLOR_VERTEXCOLORMODE.
- Note
- In point mode VariableTag::GetDataCount() returns the number of points, in polygon mode the number of polygons.
const Bool pointMode = vcTag->IsPerPointColor();
vcTag->SetPerPointMode(!pointMode);
Data Access
The data stored in the VertexColorTag can be accessed using a read or write handle:
- Warning
- These handles become invalid after changing the mode (see Mode).
- Note
- It is possible to set values greater than 1.0.
These two functions can only be used in polygon mode. They access the polygon vertex colors of the given polygon index.
if (vcTag->IsPerPointColor())
for (
Int32 i = 0; i < polyCount; ++i)
{
const Vector hsv { hue, 1.0, 1.0 };
hue += stepSize;
for (
Int32 p = 0; p < 4; ++p)
}
The following functions can be used to access vertex colors in both point and polygon mode.
- Warning
- In point mode one must not hand over the pointers for the Neighbor object and the polygon array.
These functions access the RGB color as a maxon::Color32 value:
These functions access the alpha part as a Float32 value:
if (!neighbor.
Init(pointCount, polys, polyCount,
nullptr))
for (
Int32 i = 0; i < pointCount; ++i)
{
if (vcTag->IsPerPointColor())
{
}
else
{
}
}
These functions handle the RGBA values in form of a maxon::ColorA32 structure.
for (
Int32 i = 0; i < pointCount; ++i)
{
if (vcTag->IsPerPointColor())
else
}
Further Reading
static String FloatToString(Float32 v, Int32 vvk=-1, Int32 nnk=-3)
Definition: c4d_string.h:529
static VertexColorTag * Alloc(Int32 count)
static void Get(ConstVertexColorHandle dataptr, Int32 i, VertexColorStruct &res)
Definition: c4d_basetag.h:867
maxon::Float Float
Definition: ge_sys_math.h:66
Int32 GetPointCount(void) const
Definition: c4d_baseobject.h:1460
const CPolygon * GetPolygonR(void) const
Definition: c4d_baseobject.h:1759
static maxon::Color32 GetColor(ConstVertexColorHandle dataptr, Neighbor *nb, const CPolygon *vadr, Int32 pIndex)
maxon::Float32 Float32
Definition: ge_sys_math.h:68
Represents a polygon that can be either a triangle or a quadrangle.
Definition: c4d_baseobject.h:43
Definition: c4d_basetag.h:46
return OK
Definition: apibase.h:2620
#define MAXON_SOURCE_LOCATION
Definition: memoryallocationbase.h:67
const typedef void * ConstVertexColorHandle
Handle for read-only vertex color data. See also VertexColorTag.
Definition: operatingsystem.h:466
#define MSG_UPDATE
Must be sent if the bounding box has to be recalculated. (Otherwise use MSG_CHANGE....
Definition: c4d_baselist.h:340
Definition: c4d_string.h:38
A color consisting of three components R, G, B and an alpha.
Definition: col4.h:14
maxon::Vec3< maxon::Float32, 1 > Vector32
Definition: ge_math.h:139
Int32 GetPolygonCount(void) const
Definition: c4d_baseobject.h:1773
maxon::Int32 Int32
Definition: ge_sys_math.h:60
#define ApplicationOutput(formatString,...)
Definition: debugdiagnostics.h:210
Bool Message(Int32 type, void *data=nullptr)
Definition: c4d_baselist.h:1424
Definition: c4d_basetag.h:816
A color consisting of three components R, G and B.
Definition: col.h:14
static Float32 GetAlpha(ConstVertexColorHandle dataptr, Neighbor *nb, const CPolygon *vadr, Int32 pIndex)
Definition: operatingsystem.h:658
BaseTag * GetTag(Int32 type, Int32 nr=0)
Definition: c4d_baseobject.h:674
void * VertexColorHandle
Handle for vertex color data. See also VertexColorTag.
Definition: operatingsystem.h:465
static void Set(VertexColorHandle dataptr, Int32 i, const VertexColorStruct &s)
Definition: c4d_basetag.h:889
virtual Bool Init(Int32 pcnt, const CPolygon *vadr, Int32 vcnt, BaseSelect *bs)
Definition: c4d_baseobject.h:2491
maxon::Bool Bool
Definition: ge_sys_math.h:55
void InsertTag(BaseTag *tp, BaseTag *pred=nullptr)
#define Tvertexcolor
Vertex color.
Definition: ge_prepass.h:1322
String ToString(const FormatStatement *formatStatement=nullptr) const
Definition: col.h:368