TextureTag Manual

内容表

关于

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 (); textureTag-> SetParameter ( DescID ( TEXTURETAG_RESTRICTION ), selectionName, DESCFLAGS_SET::NONE ); }

GeData data;

// read "Texture" parameter material-> GetParameter ( DescID ( MATERIAL_COLOR_SHADER ), data, DESCFLAGS_GET::NONE );

// 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);

特性

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 .

材质

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 ( 向量 { rotation, 0.0, 0.0 });

延伸阅读

Xbitmap
#define Xbitmap
Bitmap.
定义: ge_prepass.h:1164
TextureTag
定义: c4d_basetag.h:646
DescID
定义: lib_description.h:327
Float
maxon::Float Float
定义: ge_sys_math.h:64
TextureTag::SetRot
void SetRot(const Vector &v)
BaseDocument::GetActiveMaterial
BaseMaterial * GetActiveMaterial(void)
BaseTag
定义: c4d_basetag.h:46
GeData::GetLink
BaseList2D * GetLink(const BaseDocument *doc, Int32 instanceof=0) const
MAXON_SOURCE_LOCATION
#define MAXON_SOURCE_LOCATION
定义: memoryallocationbase.h:66
DESCFLAGS_SET::NONE
@ NONE
None.
String
定义: 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 >
MATERIAL_COLOR_SHADER
@ MATERIAL_COLOR_SHADER
定义: mmaterial.h:272
TextureTag::GetMaterial
BaseMaterial * GetMaterial(Bool ignoredoc=false)
TEXTURETAG_PROJECTION
@ TEXTURETAG_PROJECTION
定义: ttexture.h:10
GeData
定义: c4d_gedata.h:82
Int32
maxon::Int32 Int32
定义: ge_sys_math.h:58
ApplicationOutput
#define ApplicationOutput(formatString,...)
定义: debugdiagnostics.h:207
TextureTag::Alloc
static TextureTag * Alloc()
Ttexture
#define Ttexture
Texture - TextureTag.
定义: ge_prepass.h:1236
DESCFLAGS_GET::NONE
@ NONE
None.
Tpolygonselection
#define Tpolygonselection
Polygon selection - SelectionTag.
定义: ge_prepass.h:1247
TEXTURETAG_PROJECTION_CUBIC
@ TEXTURETAG_PROJECTION_CUBIC
定义: ttexture.h:14
TEXTURETAG_RESTRICTION
@ TEXTURETAG_RESTRICTION
定义: ttexture.h:24
BaseList2D::GetName
String GetName() const
定义: c4d_baselist.h:2318
TEXTURETAG_PROJECTION_UVW
@ TEXTURETAG_PROJECTION_UVW
定义: ttexture.h:17
BaseMaterial
定义: c4d_basematerial.h:27
C4DAtom::GetParameter
Bool GetParameter(const DescID &id, GeData &t_data, DESCFLAGS_GET flags)
DegToRad
Float32 DegToRad(Float32 r)
定义: apibasemath.h:247

Copyright  © 2014-2025 乐数软件    

工业和信息化部: 粤ICP备14079481号-1