内容表

关于

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.

// This example checks if the given object hosts a Normal tag. // If not, a Normal tag is created.
NormalTag * normalTag = static_cast< NormalTag * > (polyObject-> GetTag ( Tnormal )); if (normalTag == nullptr ) { const Int32 polyCnt = polyObject-> GetPolygonCount (); normalTag = NormalTag::Alloc (polyCnt); if (normalTag == nullptr ) return maxon::OutOfMemoryError( MAXON_SOURCE_LOCATION ); polyObject-> InsertTag (normalTag); }

编辑

The normal vectors stored in a NormalTag are accessed by obtaining data handles that are used with static functions:

// This example calculates normal vectors, changes them and stores them in the given Normal tag.

// make sure a Phong tag exists if (polyObject-> GetTag ( Tphong ) == nullptr ) { BaseTag * phongTag = polyObject-> MakeTag ( Tphong ); if (phongTag == nullptr ) return maxon::OutOfMemoryError( MAXON_SOURCE_LOCATION ); } Random random; NormalHandle handle = normalTag-> GetDataAddressW (); for ( Int32 i = 0; i < polygonCount; ++i) { const CPolygon polygon = polygons[i];

// calculate default face normal 向量 normal = CalcFaceNormal (points, polygon); NormalStruct normals;

// add random variation 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 ();

// define polygon normals normals. a = normal; normals. b = normal; normals. c = normal; normals. d = normal; NormalTag::Set (handle, i, normals); } polyObject-> 消息 ( MSG_UPDATE );

延伸阅读

Tnormal
#define Tnormal
定义: ge_prepass.h:1266
maxon::Vec3::Normalize
constexpr void Normalize()
Normalizes this vector, so that GetLength()==1.0.
定义: vec.h:431
Tphong
#define Tphong
Phong.
定义: ge_prepass.h:1234
CPolygon
Represents a polygon that can be either a triangle or a quadrangle.
定义: c4d_baseobject.h:43
BaseTag
定义: c4d_basetag.h:46
MAXON_SOURCE_LOCATION
#define MAXON_SOURCE_LOCATION
定义: memoryallocationbase.h:66
NormalTag::Set
static void Set(NormalHandle dataptr, Int32 i, const NormalStruct &s)
定义: c4d_basetag.h:627
BaseObject::MakeTag
BaseTag * MakeTag(Int32 type, BaseTag *pred=nullptr)
maxon::Vec3::z
T z
定义: vec.h:34
MSG_UPDATE
#define MSG_UPDATE
Must be sent if the bounding box has to be recalculated. (Otherwise use MSG_CHANGE....
定义: c4d_baselist.h:340
NormalStruct::d
Vector d
The vertex normal for the fourth point.
定义: operatingsystem.h:625
maxon::Vec3< maxon::Float64, 1 >
maxon::Vec3::x
T x
定义: vec.h:32
PolygonObject::GetPolygonCount
Int32 GetPolygonCount(void) const
定义: c4d_baseobject.h:1752
NormalTag::Alloc
static NormalTag * Alloc(Int32 count)
NormalTag
Represents a Point Normal tag.
定义: c4d_basetag.h:557
NormalStruct::b
Vector b
The vertex normal for the second point.
定义: operatingsystem.h:623
maxon::Vec3::y
T y
定义: vec.h:33
Int32
maxon::Int32 Int32
定义: ge_sys_math.h:58
C4DAtom::Message
Bool Message(Int32 type, void *data=nullptr)
定义: c4d_baselist.h:1394
NormalStruct::a
Vector a
The vertex normal for the first point.
定义: operatingsystem.h:622
BaseObject::GetTag
BaseTag * GetTag(Int32 type, Int32 nr=0)
定义: c4d_baseobject.h:674
NormalTag::GetDataAddressW
NormalHandle GetDataAddressW(void)
Random::Get01
Float Get01(void)
NormalHandle
void * NormalHandle
Handle for normal data. See also: NormalTag.
定义: operatingsystem.h:454
Random
定义: c4d_tools.h:811
NormalStruct
定义: operatingsystem.h:591
BaseObject::InsertTag
void InsertTag(BaseTag *tp, BaseTag *pred=nullptr)
NormalStruct::c
Vector c
The vertex normal for the third point.
定义: operatingsystem.h:624
CalcFaceNormal
Vector CalcFaceNormal(const Vector *padr, const CPolygon &v)
定义: c4d_baseobject.h:2185

Copyright  © 2014-2025 乐数软件    

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