BaseOverrideGroup Manual
A BaseOverrideGroup acts like a virtual null object. It can have multiple child objects. Tags applied to the group are applied to the child objects.
// get the active object BaseObject * const object = doc-> GetActiveObject (); if ( object == nullptr ) return maxon::IllegalArgumentError( MAXON_SOURCE_LOCATION );
// get all active materials AutoAlloc<AtomArray> materials; if (materials == nullptr ) return maxon::OutOfMemoryError( MAXON_SOURCE_LOCATION );
// loop through all active materials for ( Int32 i = 0; i < materials-> GetCount (); ++i) { C4DAtom * const mat = materials-> GetIndex (i); BaseMaterial * const material = static_cast< BaseMaterial * > (mat);
// create a new take const String materialName = material-> GetName (); BaseTake * const take = takeData-> AddTake (materialName, nullptr , nullptr ); if (take == nullptr ) return maxon::OutOfMemoryError( MAXON_SOURCE_LOCATION );
// create an override group BaseOverrideGroup * const group = take-> AddOverrideGroup (); if (group == nullptr ) return maxon::OutOfMemoryError( MAXON_SOURCE_LOCATION );
// add the object to the group group-> AddToGroup (takeData, object );
// create a texture tag referencing this material BaseTag * const tag = group-> AddTag (takeData, Ttexture , material); if (tag == nullptr ) return maxon::OutOfMemoryError( MAXON_SOURCE_LOCATION );
// set projection to UVW tag-> SetParameter ( DescID ( TEXTURETAG_PROJECTION ), TEXTURETAG_PROJECTION_UVW , DESCFLAGS_SET::NONE ); }
Existing override groups are accessed from the host BaseTake :
// loop through all BaseOverrideGroups for ( Int32 i = 0; i < overrideGroups-> GetCount (); ++i) { BaseOverrideGroup * const group = static_cast< BaseOverrideGroup * > (overrideGroups-> GetIndex (i)); if (group == nullptr ) return maxon::UnexpectedError( MAXON_SOURCE_LOCATION );
// check if the override group contains the given object if (group-> Find (takeData, activeObject)) ApplicationOutput ( "Override Group " + group-> GetName () + " contains the active object!" ); }
A BaseOverrideGroup is created using the host BaseTake .
BaseOverrideGroup instances are organized in a simple BaseList2D 列表。
nullptr
.
nullptr
.
// check if override group is selected if (overrideGroup-> GetBit ( BIT_ACTIVE )) ApplicationOutput ( "This is an active group." ); overrideGroup = overrideGroup-> GetNext (); }
A BaseOverrideGroup acts like a null object. Different scene objects can be added to this group.
// loop through all active objects for ( Int32 i = 0; i < objects-> GetCount (); ++i) { BaseObject * const object = static_cast< BaseObject * > (objects-> GetIndex (i)); group-> AddToGroup (takeData, object ); }
Override groups act as virtual null objects that can host different tags. If a take is applied, this tag is added to the objects in question.
nullptr
.
With these modes it is possible to control the visibility of the assigned objects when rendering and in the viewport.
The modes are:
// get all active objects AutoAlloc<AtomArray> objects; if (objects == nullptr ) return maxon::OutOfMemoryError( MAXON_SOURCE_LOCATION ); doc-> GetActiveObjects (objects, GETACTIVEOBJECTFLAGS::NONE );
// create an override group BaseOverrideGroup * const group = take-> AddOverrideGroup (); if (group == nullptr ) return maxon::OutOfMemoryError( MAXON_SOURCE_LOCATION ); group-> SetName ( "Render Objects" _s); group-> SetEditorMode ( MODE_OFF ); // invisible in editor group-> SetRenderMode ( MODE_ON ); // visible in renderer
// loop through all active objects for ( Int32 i = 0; i < objects-> GetCount (); ++i) { // add object to group BaseObject * const object = static_cast< BaseObject * > (objects-> GetIndex (i)); group-> AddToGroup (takeData, object ); }