Hierarchy Class Reference

abstract

#include <c4d_basedocument.h>

详细描述

This class allows to perform some functions on all of the objects in a hierarchy.
范例:

struct ExampleStruct { Int32 parent_state; };
class ExampleHierarchy : public 层次结构 { public : virtual void * Alloc ( void ) { return NewObjPtr (ExampleStruct); } virtual void Free ( void *data) { ExampleStruct *es = (ExampleStruct*)data; DeleteObj (es); } virtual void CopyTo ( void * src , void *dst) { *((ExampleStruct*)dst) = *((ExampleStruct*) src ); } virtual Bool Do ( void *data, BaseObject *op, const 矩阵 &mg, Bool controlobject); }; Bool ExampleHierarchy::Do( void *data, BaseObject *op, const 矩阵 &mg, Bool controlobject) { ExampleStruct* dt = (ExampleStruct*)data; Int32 mode = op-> GetRenderMode (); if (mode != MODE_UNDEF ) // if mode is MODE_ON or MODE_OFF d->parent_state = mode;

// Important: Do this parent-data inheritance always, even if you do not evaluate an object // Reason: A child of an invisible control object might be visible again...

if (controlobject) return true ; // This object is not visible, has been used by generator if (op-> GetType () != Opolygon ) return true ; // We cannot use this

// Do something with polygonized object op // The object has matrix mg and local data dt

return true ; }

公共成员函数

virtual void *  Alloc (void)=0
virtual void  Free (void *data)=0
virtual void  CopyTo (void *src, void *dst)=0
virtual Bool   Do (void *data, BaseObject *op, const 矩阵 &mg, Bool controlobject)=0
Bool   Run ( BaseDocument * doc , Bool spheres, Float lod, Bool uselod, BUILDFLAGS flags, void *startdata, BaseThread * bt )

Private Attributes

BaseDocument doc
BaseThread bt

成员函数文档编制

◆  Alloc()

virtual void* Alloc ( void  )
pure virtual

Override the method to allocate the private data for a single level in the hierarchy.
Cinema 4D itself will pass the parent matrix but all other data that might be needed must be passed down the hierarchy using a private data structure and this is where it is allocated.

返回
The private data that is allocated.

◆  Free()

virtual void Free ( void *  data )
pure virtual

Override the method so that the private data allocated in Alloc() can be freed.

参数
[in,out] data The private data to free.

◆  CopyTo()

virtual void CopyTo ( void *  src ,
void *  dst  
)
pure virtual

Override the method so that the private data can be copied.

参数
[in] src The source private data to copy from.
[out] dst The destination private data to copy to.

◆  Do()

virtual Bool Do ( void *  data ,
BaseObject op ,
const 矩阵 mg ,
Bool   controlobject  
)
pure virtual

Override the method to be called for every object, virtual and non-virtual, in the hierarchy run.

参数
[in] data The private data allocated in Alloc() .
[in] op The object the function is being called for.
[in] mg The global matrix for this object down the hierarchy chain.
[in] controlobject true then the object has been used by a generator and usually will no longer be used (but the routine goes through all objects in any case).
返回
true if the function was successful and the run through the hierarchy should continue, otherwise false .

◆  Run()

Bool Run ( BaseDocument doc ,
Bool   spheres ,
Float   lod ,
Bool   uselod ,
BUILDFLAGS   flags ,
void *  startdata ,
BaseThread bt  
)

Performs Do() on all objects (virtual and non-virtual) in the hierarchy.
Using this class will build all caches for dirty objects for the entire hierarchy, this can be time intensive and should be used carefully.
If a polygon object is needed it is generally faster to call SendModelingCommand() with MCOMMAND_CURRENTSTATETOOBJECT .

参数
[in] doc The document with the objects you want to process.
[in] spheres true the process will not polygonize perfect spheres.
[in] lod The level of detail to use.
[in] uselod true the level of detail lod should be evaluated.
[in] flags The build flags are: BUILDFLAGS 注意: Either BUILDFLAGS::INTERNALRENDERER or BUILDFLAGS::EXTERNALRENDERER must be set because some generators check for these flags and generate different results.
For example the Metaball object has different settings in the edit dialog for internal and external rendering.
[in] startdata The initial private data to pass into the hierarchy.
[in] bt The custom thread, or nullptr if called from the main Cinema 4D thread.
返回
The success of calling Do() for each object.

Member Data Documentation

◆  doc

BaseDocument * doc
private

◆  bt

BaseThread * bt
private
Opolygon
#define Opolygon
Polygon - PolygonObject.
定义: ge_prepass.h:975
Hierarchy::Alloc
virtual void * Alloc(void)=0
DeleteObj
#define DeleteObj(obj)
定义: newobj.h:159
BaseObject
定义: c4d_baseobject.h:224
maxon::Mat3< maxon::Vector64 >
NewObjPtr
#define NewObjPtr(T,...)
Deprecated.
定义: newobj.h:113
Hierarchy::Free
virtual void Free(void *data)=0
BaseObject::GetRenderMode
Int32 GetRenderMode(void) const
maxon::src
const T & src
定义: apibase.h:2525
Hierarchy::Do
virtual Bool Do(void *data, BaseObject *op, const Matrix &mg, Bool controlobject)=0
MODE_UNDEF
#define MODE_UNDEF
The object is enabled by default, but the state of any parent object is used if it is enabled or disa...
定义: c4d_baseobject.h:37
Int32
maxon::Int32 Int32
定义: ge_sys_math.h:58
Hierarchy::CopyTo
virtual void CopyTo(void *src, void *dst)=0
Bool
maxon::Bool Bool
定义: ge_sys_math.h:53
层次结构
定义: c4d_basedocument.h:1477
C4DAtom::GetType
Int32 GetType() const
定义: c4d_baselist.h:1348