About

The MotionTrackerObject class represents a Cinema 4D motion tracker object. It provides read-only access to properties of the loaded video footage and the created 2D tracks.

MotionTrackerObject objects are an instance of Omotiontracker.

Access

A MotionTrackerObject object can be accessed like any other object.

// This example accesses the Motion Tracker object
// to print the used footage filename to the console.
// check if an object is selected and if it is a Motion Tracker object
BaseObject* const obj = doc->GetActiveObject();
if (obj == nullptr || !obj->IsInstanceOf(Omotiontracker))
return maxon::IllegalArgumentError(MAXON_SOURCE_LOCATION);
const MotionTrackerObject* const moTrackObject = static_cast<MotionTrackerObject*>(obj);
MtFootageData* footage = moTrackObject->GetFootageData();
if (footage == nullptr)
return maxon::UnexpectedError(MAXON_SOURCE_LOCATION);
const Filename footageName = footage->GetFootageName();
ApplicationOutput("Footage: " + footageName.GetString());
// do not forget to free the copy
Definition: c4d_baseobject.h:248
Manages file and path names.
Definition: c4d_file.h:94
String GetString() const
Definition: lib_motiontracker.h:358
MtFootageData * GetFootageData() const
Definition: lib_motiontracker.h:274
static void Free(MtFootageData *&p)
Filename GetFootageName() const
PyObject * obj
Definition: complexobject.h:60
#define Omotiontracker
Motion tracker.
Definition: ge_prepass.h:1103
#define MAXON_SOURCE_LOCATION
Definition: memoryallocationbase.h:67
#define ApplicationOutput(formatString,...)
Definition: debugdiagnostics.h:204
const char * doc
Definition: pyerrors.h:226

Allocation/Deallocation

MotionTrackerObject objects are created with the usual tools:

// This example creates a new motion tracker object and adds it to the scene.
if (moTrackObj == nullptr)
return maxon::OutOfMemoryError(MAXON_SOURCE_LOCATION);
moTrackObj->SetName("New Motion Tracker"_s);
doc->InsertObject(moTrackObj, nullptr, nullptr);
void SetName(const maxon::String &name, Bool setDirty=true)
Definition: c4d_baselist.h:2549
static MotionTrackerObject * Alloc()

Parameters

The standard object parameters of the Motion Tracker object can be accessed with C4DAtom::GetParameter() and C4DAtom::SetParameter(). The parameter IDs are defined in omotiontracker.h.

Additionally, footage information can be accessed with MotionTrackerObject::GetFootageData() (see below).

Access Data

Internal data of a MotionTrackerObject can be accessed by acquiring specialised data containers that store information on the footage and the 2D tracking data.

See MtFootageData Manual and Mt2dTrackData / Mt2dTrack / MtData Manual.

// This example accesses both footage data and track data
// from the given MotionTrackerObject.
// access MtFootageData
MtFootageData* footage = moTrackObject->GetFootageData();
if (footage == nullptr)
return maxon::UnexpectedError(MAXON_SOURCE_LOCATION);
const Int32 firstFrame = footage->GetFirstFrameNumber();
const Int32 lastFrame = footage->GetLastFrameNumber();
const String firstFrameStr = String::IntToString(firstFrame);
const String lastFrameStr = String::IntToString(lastFrame);
ApplicationOutput("Footage Range: " + firstFrameStr + " - " + lastFrameStr);
// do not forget to free the copy
// access Mt2dTrackData
Mt2dTrackData* trackData = moTrackObject->Get2dTrackData();
if (trackData == nullptr)
return maxon::UnexpectedError(MAXON_SOURCE_LOCATION);
const Int32 trackCount = trackData->GetTrackCount();
ApplicationOutput("Track Count: " + String::IntToString(trackCount));
// do not forget to free the copy
Mt2dTrackData::Free(trackData);
Mt2dTrackData * Get2dTrackData() const
Definition: lib_motiontracker.h:71
Int32 GetTrackCount() const
static void Free(Mt2dTrackData *&p)
Int32 GetLastFrameNumber() const
Int32 GetFirstFrameNumber() const
Definition: c4d_string.h:41
static String IntToString(Int32 v)
Definition: c4d_string.h:497
maxon::Int32 Int32
Definition: ge_sys_math.h:56

Further Reading