TextureTag Manual

About

A TextureTag is used to assign a material (BaseMaterial) to a BaseObject. The class TextureTag is based on BaseTag so the typical workflows of handling tags apply, see BaseTag and VariableTag Manual.

TextureTag objects are an instance of Ttexture.

// This example creates and configures a TextureTag.
// create the texture tag
TextureTag* const textureTag = static_cast<TextureTag*>(object->MakeTag(Ttexture));
if (textureTag == nullptr)
return maxon::OutOfMemoryError(MAXON_SOURCE_LOCATION);
// apply material
textureTag->SetMaterial(material);
// check if there is a polygon selection tag on the given object
// if a selection tag is found, restrict the material to that selection
BaseTag* const polygonSelection = object->GetTag(Tpolygonselection);
if (polygonSelection)
{
const String selectionName = polygonSelection->GetName();
}
GeData data;
// read "Texture" parameter
// if the material uses a bitmap shader, use UVW projection
if (data.GetLink(doc, Xbitmap))
{
const DescID projectionParam { TEXTURETAG_PROJECTION };
const Int32 projectionUVW = TEXTURETAG_PROJECTION_UVW;
textureTag->SetParameter(projectionParam, projectionUVW, DESCFLAGS_SET::NONE);
}

Allocation/Deallocation

TextureTag instances are created with the usual tools.

// This example creates a new texture tag and assigns it to the given BaseObject.
BaseMaterial* const mat = doc->GetActiveMaterial();
if (mat == nullptr)
return maxon::IllegalArgumentError(MAXON_SOURCE_LOCATION);
TextureTag* const textureTag = TextureTag::Alloc();
if (textureTag == nullptr)
return maxon::OutOfMemoryError(MAXON_SOURCE_LOCATION);
textureTag->SetMaterial(mat);
const DescID projectionParam { TEXTURETAG_PROJECTION };
const Int32 projectionUVW = TEXTURETAG_PROJECTION_UVW;
textureTag->SetParameter(projectionParam, projectionUVW, DESCFLAGS_SET::NONE);
object->InsertTag(textureTag);

Properties

The parameters of a TextureTag can be edited with C4DAtom::SetParameter() and C4DAtom::GetParameter(). The parameter IDs of a TextureTag are defined in ttexture.h.

Material

A TextureTag stores a reference to a BaseMaterial based material.

// This example accesses the texture tag on the given BaseObject.
// The texture tag returns the linked material.
TextureTag* const ttag = static_cast<TextureTag*>(object->GetTag(Ttexture));
if (ttag == nullptr)
return maxon::IllegalArgumentError(MAXON_SOURCE_LOCATION);
BaseMaterial* const material = ttag->GetMaterial();
if (material != nullptr)
{
ApplicationOutput("Used Material: " + material->GetName());
}

Texture Matrix

A TextureTag also stores information on how the referenced material is applied to the host BaseObject. If the projection type is not UVW mapping the texture matrix is applied:

// This example enables cubic projection and rotates the texture.
const DescID projectionParam { TEXTURETAG_PROJECTION };
const Int32 projectionCubic = TEXTURETAG_PROJECTION_CUBIC;
textureTag->SetParameter(projectionParam, projectionCubic, DESCFLAGS_SET::NONE);
const Float rotation = DegToRad(45.0);
textureTag->SetRot(Vector { rotation, 0.0, 0.0 });

Further Reading

Xbitmap
#define Xbitmap
Bitmap.
Definition: ge_prepass.h:1171
MATERIAL_COLOR_SHADER
@ MATERIAL_COLOR_SHADER
Definition: mmaterial.h:272
TextureTag
Definition: c4d_basetag.h:646
DescID
Definition: lib_description.h:328
Float
maxon::Float Float
Definition: ge_sys_math.h:66
TextureTag::SetRot
void SetRot(const Vector &v)
BaseDocument::GetActiveMaterial
BaseMaterial * GetActiveMaterial(void)
BaseTag
Definition: c4d_basetag.h:46
GeData::GetLink
BaseList2D * GetLink(const BaseDocument *doc, Int32 instanceof=0) const
MAXON_SOURCE_LOCATION
#define MAXON_SOURCE_LOCATION
Definition: memoryallocationbase.h:66
DESCFLAGS_SET::NONE
@ NONE
None.
String
Definition: c4d_string.h:38
TextureTag::SetMaterial
void SetMaterial(BaseMaterial *mat)
C4DAtom::SetParameter
Bool SetParameter(const DescID &id, const GeData &t_data, DESCFLAGS_SET flags)
maxon::Vec3< maxon::Float64, 1 >
TEXTURETAG_PROJECTION_CUBIC
@ TEXTURETAG_PROJECTION_CUBIC
Definition: ttexture.h:14
TextureTag::GetMaterial
BaseMaterial * GetMaterial(Bool ignoredoc=false)
TEXTURETAG_PROJECTION_UVW
@ TEXTURETAG_PROJECTION_UVW
Definition: ttexture.h:17
GeData
Definition: c4d_gedata.h:82
Int32
maxon::Int32 Int32
Definition: ge_sys_math.h:60
ApplicationOutput
#define ApplicationOutput(formatString,...)
Definition: debugdiagnostics.h:208
TextureTag::Alloc
static TextureTag * Alloc()
Ttexture
#define Ttexture
Texture - TextureTag.
Definition: ge_prepass.h:1243
DESCFLAGS_GET::NONE
@ NONE
None.
Tpolygonselection
#define Tpolygonselection
Polygon selection - SelectionTag.
Definition: ge_prepass.h:1254
BaseList2D::GetName
String GetName() const
Definition: c4d_baselist.h:2348
BaseMaterial
Definition: c4d_basematerial.h:27
TEXTURETAG_PROJECTION
@ TEXTURETAG_PROJECTION
Definition: ttexture.h:10
TEXTURETAG_RESTRICTION
@ TEXTURETAG_RESTRICTION
Definition: ttexture.h:24
C4DAtom::GetParameter
Bool GetParameter(const DescID &id, GeData &t_data, DESCFLAGS_GET flags)
DegToRad
Float32 DegToRad(Float32 r)
Definition: apibasemath.h:247