BaseTake Manual
A BaseTake object represents a take of the Take System. It stores BaseOverride objects that define how a specific entity is changed in the given take.
BaseTake objects are returned from the BaseDocument via the TakeData 对象。
// get take data TakeData * const takeData = doc-> GetTakeData (); if (takeData == nullptr ) return maxon::UnexpectedError( MAXON_SOURCE_LOCATION );
// get the main take BaseTake * const mainTake = takeData-> GetMainTake (); if (mainTake == nullptr ) return maxon::UnexpectedError( MAXON_SOURCE_LOCATION );
A BaseTake is created and deleted using the TakeData object:
// get the main take BaseTake * const mainTake = takeData-> GetMainTake (); if (mainTake == nullptr ) return maxon::UnexpectedError( MAXON_SOURCE_LOCATION );
// create new take BaseTake * const newTake = takeData-> AddTake ( "this is a new take" , nullptr , nullptr ); if (newTake == nullptr ) return maxon::OutOfMemoryError( MAXON_SOURCE_LOCATION );
Like many other entities takes are organized in a BaseList2D tree. One can use the typical functions to navigate that tree.
// get main take const BaseTake * const mainTake = takeData-> GetMainTake (); // get first child const BaseTake * take = mainTake-> GetDown (); // loop through while (take != nullptr ) { ApplicationOutput ( "Take Name: " + take-> GetName ()); // get next take in the row take = take-> GetNext (); }
Takes can be marked in the Take Manager. This allows to render just a subset of all takes. The API allows to manage this marked state:
A BaseOverride defines the parameter changes for a specific object in a BaseTake . BaseOverrides are managed using methods of BaseTake :
Overrides can also be created automatically:
BaseTake::AutoTake() is especially useful to create the proper overrides when "Auto Take" is enabled. Just an unaltered clone of the changed object or the reference object from the undo stack is required:
// This example edits the given sphere object. // If auto take is enabled, the current take is used.// undo object as reference // alternatively, on could access the undo cache with BaseDocument::GetUndoPtr() if applicable BaseObject * undoObject = static_cast< BaseObject * > (sphereObject->GetClone( COPYFLAGS::NONE , nullptr )); if (undoObject == nullptr ) return maxon::OutOfMemoryError( MAXON_SOURCE_LOCATION );
// edit the object sphereObject->SetParameter( DescID { PRIM_SPHERE_RAD }, GeData (100.0), DESCFLAGS_SET::NONE );
// check for autotake TakeData * const takeData = doc-> GetTakeData ();
// check if auto take mode is enabled if (takeData && takeData-> GetTakeMode () == TAKE_MODE::AUTO ) { BaseTake * const currentTake = takeData-> GetCurrentTake ();
// check if the given take is not the main take if (currentTake && !currentTake-> IsMain ()) { currentTake-> AutoTake (takeData, sphereObject, undoObject); } }
// free the clone BaseObject::Free (undoObject);
Override groups act like virtual null objects. They allow to add certain tags to a selection of objects.
// new take BaseTake * const take = takeData-> AddTake ( "Green Objects" , nullptr , nullptr ); if (take == nullptr ) return maxon::OutOfMemoryError( MAXON_SOURCE_LOCATION );
// create override group BaseOverrideGroup * const group = take-> AddOverrideGroup (); if (group == nullptr ) return maxon::UnexpectedError( MAXON_SOURCE_LOCATION ); group-> SetName ( "Green Material" _s);
// if the material was found a texture tag should be added BaseMaterial * const mat = doc-> SearchMaterial ( "Green" _s); if (mat != nullptr ) group-> AddTag (takeData, Ttexture , mat);
// loop through all selected objects for ( Int32 i = 0; i < selectedObjects-> GetCount (); ++i) { BaseList2D * const element = static_cast< BaseList2D * > (selectedObjects-> GetIndex (i)); group-> AddToGroup (takeData, element); }
Takes also manage the camera currently in use. These functions allow to set and get the camera used for a certain take:
nullptr
if the parent take's camera should be used.
nullptr
means the parent take's settings should apply.
// loop through all selected objects for ( Int32 i = 0; i < selectedObjects-> GetCount (); ++i) { C4DAtom * const element = selectedObjects-> GetIndex (i); if (element == nullptr ) return maxon::UnexpectedError( MAXON_SOURCE_LOCATION );
// check if the object is a camera object if (element-> GetType () == Ocamera ) { CameraObject * const camera = static_cast< CameraObject * > (element);
// create a take for this camera object const String takeName { "Take for camera " + camera-> GetName () }; BaseTake * const cameraTake = takeData-> AddTake (takeName, nullptr , nullptr ); if (cameraTake == nullptr ) return maxon::OutOfMemoryError( MAXON_SOURCE_LOCATION );
// set this camera object as this take's camera cameraTake-> SetCamera (takeData, camera); } }
Takes also manage render settings. As with the camera, it is possible to assign specific render settings to each take.
nullptr
, if the parent take's render settings should be used.
nullptr
is used to reset.
// set this RenderData as this take's RenderData renderDataTake-> SetRenderData (takeData, renderData);
// get next element in the list renderData = renderData-> GetNext (); }
A BaseTake can host userdata that can help to identify the take along the production pipeline. This userdata is managed using the default BaseList2D methods:
// This example adds a new Boolean userdata parameter to the given BaseTake.// accesses the userdata of the given take DynamicDescription * const desc = take-> GetDynamicDescription (); if (desc == nullptr ) return maxon::UnexpectedError( MAXON_SOURCE_LOCATION );
// defines a new Boolean parameter BaseContainer bc = GetCustomDataTypeDefault ( DTYPE_BOOL ); bc. SetString ( DESC_NAME , "Enable" _s); // creates the new userdata parameter const DescID userData = desc-> Alloc (bc);
// sets the value const GeData data { true }; take-> SetParameter (userData, data, DESCFLAGS_SET::NONE );
另请参阅 DynamicDescription Manual .