About
A NormalTag stores normal vectors for a (polygon) object. For each polygon a set of four vectors is stored (NormalStruct). The class NormalTag is based on VariableTag so the typical workflows on handling tags apply, see BaseTag and VariableTag Manual.
NormalTag objects are an instance of Tnormal.
Allocation/Deallocation
NormalTag instances are created with the usual tools.
- NormalTag::Alloc(): Creates a new NormalTag.
- NormalTag::Free(): Destroys the given NormalTag.
NormalTag* normalTag =
static_cast<NormalTag*
>(polyObject->GetTag(
Tnormal));
if (normalTag == nullptr)
{
const Int32 polyCnt = polyObject->GetPolygonCount();
normalTag = NormalTag::Alloc(polyCnt);
if (normalTag == nullptr)
polyObject->InsertTag(normalTag);
}
#define MAXON_SOURCE_LOCATION
Definition: memoryallocationbase.h:69
#define Tnormal
Definition: ge_prepass.h:1453
maxon::Int32 Int32
Definition: ge_sys_math.h:51
Edit
The normal vectors stored in a NormalTag are accessed by obtaining data handles that are used with static functions:
- NormalTag::GetDataAddressR(): Returns a handle to the read-only normal vectors.
- NormalTag::GetDataAddressW(): Returns a handle to the writeable normal vectors.
- NormalTag::Get(): Returns the normal vectors for the given polygon index.
- NormalTag::Set(): Sets the normal vectors for the given polygon index.
- NormalTag::Copy(): Copies the normal vectors from the given handle to the other handle.
if (polyObject->GetTag(
Tphong) ==
nullptr)
{
BaseTag* phongTag = polyObject->MakeTag(
Tphong);
if (phongTag == nullptr)
}
Random random;
for (
Int32 i = 0; i < polygonCount; ++i)
{
const CPolygon polygon = polygons[i];
NormalStruct normals;
normal.x += ((random.Get01() * 0.2) - 0.1);
normal.y += ((random.Get01() * 0.2) - 0.1);
normal.z += ((random.Get01() * 0.2) - 0.1);
normal.Normalize();
normals.a = normal;
normals.b = normal;
normals.c = normal;
normals.d = normal;
NormalTag::Set(handle, i, normals);
}
#define MSG_UPDATE
Must be sent if the bounding box has to be recalculated. (Otherwise use MSG_CHANGE....
Definition: c4d_baselist.h:372
#define Tphong
Phong.
Definition: ge_prepass.h:1421
void * NormalHandle
Handle for normal data. See also: NormalTag.
Definition: operatingsystem.h:461
Vector CalcFaceNormal(const Vector *padr, const CPolygon &v)
Definition: c4d_baseobject.h:2432
maxon::Vec3< maxon::Float64, 1 > Vector
Definition: ge_math.h:140
Further Reading