MoData Class Reference

#include <c4d_baseeffectordata.h>

Detailed Description

Class for handling MoGraph motion data.

Public Member Functions

Bool SetWithEx (const MoDataEx &md)
 
void Clear (Bool reset)
 
Int GetMemorySize () const
 
AutoLockGetAutoLock ()
 

Private Member Functions

 MoData ()
 
 ~MoData ()
 
MoDataoperator= (const MoData &d)
 
MoDataoperator= (MoData *d)
 

Alloc/Free

static MoDataAlloc ()
 
static void Free (MoData *&d)
 

Dirty

UInt32 GetDirty (MDDIRTY mask=MDDIRTY::NONE) const
 
void SetDirty (MDDIRTY mask=MDDIRTY::NONE)
 

Read/Write

Bool Read (HyperFile *hf)
 
Bool Write (HyperFile *hf) const
 

Arrays Length & Number

Bool SetCount (Int cnt)
 
Int GetCount () const
 
Int32 GetArrayCount () const
 

Array Information

DescID GetArrayDescID (Int32 index) const
 
Int32 GetArrayID (Int32 index) const
 
Int32 GetArrayIndexType (Int32 index)
 
Int32 GetArrayType (Int32 id)
 
Int GetArrayIndex (const DescID &id)
 
Int GetArrayIndex (Int32 id)
 

Get/Set Data Container

BaseContainerGetDataInstance (const DescID &id)
 
BaseContainerGetDataInstance (Int32 id=-1)
 
BaseContainerGetDataIndexInstance (Int32 index)
 
BaseContainer GetData (Int32 id=-1)
 
void SetData (const BaseContainer &bc, Int32 id=-1)
 

Add/Remove Array

Int32 AddArray (const DescID &id, const maxon::String &name=maxon::String(), Int32 default_flags=0)
 
Int32 AddArray (Int32 id, Int32 type, const maxon::String &name=maxon::String(), Int32 default_flags=0)
 
Bool RemoveArray (const DescID &id)
 
Bool RemoveArray (Int32 id)
 

Array Flags

Int32 GetFlags (const DescID &id)
 
Int32 GetFlags (Int32 id)
 
Int32 GetIndexFlags (Int32 index)
 
void SetFlags (const DescID &id, Int32 flags)
 
void SetFlags (Int32 id, Int32 flags)
 
void SetIndexFlags (Int32 index, Int32 flags)
 
void SetFlag (const DescID &id, Int32 flag)
 
void SetFlag (Int32 id, Int32 flag)
 
void SetIndexFlag (Int32 index, Int32 flag)
 
void DelFlag (const DescID &id, Int32 flag)
 
void DelFlag (Int32 id, Int32 flag)
 
void DelIndexFlag (Int32 index, Int32 flag)
 

Array name

void SetName (const DescID &id, const maxon::String &name)
 
void SetName (Int32 id, const maxon::String &name)
 
void SetIndexName (Int32 index, const maxon::String &name)
 
String GetName (const DescID &id)
 
String GetName (Int32 id)
 
String GetIndexName (Int32 index)
 

Get Array By DescID

void * GetArray (const DescID &id) const
 
MDArray< CharGetCharArray (const DescID &id, Char default_value=0) const
 
MDArray< UCharGetUCharArray (const DescID &id, UChar default_value=0) const
 
MDArray< Int32GetLongArray (const DescID &id, Int32 default_value=0) const
 
MDArray< UInt32GetULongArray (const DescID &id, UInt32 default_value=0) const
 
MDArray< BoolGetBoolArray (const DescID &id, Bool default_value=true) const
 
MDArray< Int64GetLLongArray (const DescID &id, Int64 default_value=0) const
 
MDArray< FloatGetRealArray (const DescID &id, Float default_value=1.0) const
 
MDArray< MatrixGetMatrixArray (const DescID &id, Matrix default_value=Matrix()) const
 
MDArray< VectorGetVectorArray (const DescID &id, Vector default_value=Vector()) const
 

Get Array By ID

void * GetArray (Int32 id, MD_TYPE type=MD_TYPE::MD_NONE) const
 
MDArray< CharGetCharArray (Int32 id, Char default_value=0) const
 
MDArray< UCharGetUCharArray (Int32 id, UChar default_value=0) const
 
MDArray< Int32GetLongArray (Int32 id, Int32 default_value=0) const
 
MDArray< UInt32GetULongArray (Int32 id, UInt32 default_value=0) const
 
MDArray< BoolGetBoolArray (Int32 id, Bool default_value=true) const
 
MDArray< Int64GetLLongArray (Int32 id, Int64 default_value=0) const
 
MDArray< FloatGetRealArray (Int32 id, Float default_value=1.0) const
 
MDArray< MatrixGetMatrixArray (Int32 id, Matrix default_value=Matrix()) const
 
MDArray< VectorGetVectorArray (Int32 id, Vector default_value=Vector()) const
 

Get Array By Index

void * GetIndexArray (Int32 index) const
 
MDArray< CharGetCharIndexArray (Int32 index) const
 
MDArray< UCharGetUCharIndexArray (Int32 index) const
 
MDArray< Int32GetLongIndexArray (Int32 index) const
 
MDArray< UInt32GetULongIndexArray (Int32 index) const
 
MDArray< BoolGetBoolIndexArray (Int32 index) const
 
MDArray< Int64GetLLongIndexArray (Int32 index) const
 
MDArray< FloatGetRealIndexArray (Int32 index) const
 
MDArray< MatrixGetMatrixIndexArray (Int32 index) const
 
MDArray< VectorGetVectorIndexArray (Int32 index) const
 

Copy/Merge

Bool CopyTo (MoData *dest, Bool merge_data=false, Int max_count=-1) const
 
Bool MergeData (MoData *source, Float percent)
 

Miscellaneous

void Flush ()
 
void SetOffset (Int offset=0)
 
void SetLimit (Int limit=-1)
 
void SetColorMode (Int32 colorMode)
 
Int32 GetColorMode () const
 

Constructor & Destructor Documentation

◆ MoData()

MoData ( )
private

◆ ~MoData()

~MoData ( )
private

Member Function Documentation

◆ operator=() [1/2]

MoData& operator= ( const MoData d)
private

◆ operator=() [2/2]

MoData* operator= ( MoData d)
private

◆ Alloc()

static MoData* Alloc ( )
static

Allocates a motion data. Destroy the allocated motion data with Free(). Use AutoAlloc to automate the allocation and destruction based on scope.

Returns
The allocated motion data, or nullptr if the allocation failed.

◆ Free()

static void Free ( MoData *&  d)
static

Destructs motion data allocated with Alloc(). Use AutoAlloc to automate the allocation and destruction based on scope.

Parameters
[in,out]dThe motion data to destruct. If the pointer is nullptr nothing happens. The pointer is assigned nullptr afterwards.

◆ GetDirty()

UInt32 GetDirty ( MDDIRTY  mask = MDDIRTY::NONE) const

Gets the dirty count. Can be used to check if something has changed.

Parameters
[in]maskThe dirty flag mask. Can be a combination of: DIRTYFLAGS
Returns
The dirty count.

◆ SetDirty()

void SetDirty ( MDDIRTY  mask = MDDIRTY::NONE)

Marks the data as dirty.

Parameters
[in]maskThe dirty flag mask. Can be a combination of: DIRTYFLAGS

◆ SetWithEx()

Bool SetWithEx ( const MoDataEx &  md)

Initializes the data with MoDataEx.

Parameters
[in]mdThe data to use for initializing.
Returns
true if motion data was successfully initialized, otherwise false.

◆ Clear()

void Clear ( Bool  reset)

Clears the data in the arrays.

Parameters
[in]resetIf true, the arrays will be filled with their default values.

◆ Read()

Bool Read ( HyperFile hf)

Reads the data from a hyper file.

Parameters
[in]hfThe hyper file to read from. The caller owns the pointed hyper file.
Returns
true if the data was read, otherwise false.

◆ Write()

Bool Write ( HyperFile hf) const

Writes the data to a hyper file.

Parameters
[in]hfThe hyper file to write to. The caller owns the pointed hyper file.
Returns
true if the data was written, otherwise false.

◆ GetMemorySize()

Int GetMemorySize ( ) const

Gets the size of the data in bytes.

Returns
The size of the data.

◆ SetCount()

Bool SetCount ( Int  cnt)

Sets the length of the arrays.

Parameters
[in]cntThe new length of the arrays.
Returns
true if the length was set, otherwise false.

◆ GetCount()

Int GetCount ( ) const

Gets the length of the arrays.

Returns
The length of the arrays.

◆ GetArrayCount()

Int32 GetArrayCount ( ) const

Gets the number of arrays.

Returns
The number of arrays.

◆ GetArrayDescID()

DescID GetArrayDescID ( Int32  index) const

Gets the description ID for the specified array index.

Parameters
[in]indexThe array index. 0 <= index < GetArrayCount()
Returns
The description ID.

◆ GetArrayID()

Int32 GetArrayID ( Int32  index) const

Gets the ID for the specified array index.

Parameters
[in]indexThe array index. 0 <= index < GetArrayCount()
Returns
The array ID: MODATA_IDS

◆ GetArrayIndexType()

Int32 GetArrayIndexType ( Int32  index)

Gets the data type of the specified array index.

Parameters
[in]indexThe array index. 0 <= index < GetArrayCount()
Returns
The data type: DTYPE

◆ GetArrayType()

Int32 GetArrayType ( Int32  id)

Gets the data type of the specified array id.

Parameters
[in]idThe array ID: MODATA_IDS
Returns
The type: DTYPE

◆ GetArrayIndex() [1/2]

Int GetArrayIndex ( const DescID id)

Gets the array index for the specified description id.

Parameters
[in]idThe description ID.
Returns
The array index.

◆ GetArrayIndex() [2/2]

Int GetArrayIndex ( Int32  id)

Gets the array index for the specified array id.

Parameters
[in]idThe array ID: MODATA_IDS
Returns
The array index.

◆ GetDataInstance() [1/2]

BaseContainer* GetDataInstance ( const DescID id)

Gets a pointer to the container for the specified array description id.

Parameters
[in]idThe description ID.
Returns
A pointer to the internal container. The motion data object owns the pointed container.

◆ GetDataInstance() [2/2]

BaseContainer* GetDataInstance ( Int32  id = -1)

Gets a pointer to the container for the specified array id.

Parameters
[in]idThe array ID: MODATA_IDS
Returns
A pointer to the internal container. The motion data object owns the pointed container.

◆ GetDataIndexInstance()

BaseContainer* GetDataIndexInstance ( Int32  index)

Gets a pointer to the container for the specified array index.

Parameters
[in]indexThe array index. 0 <= index < GetArrayCount()
Returns
A pointer to the internal container. The motion data object owns the pointed container.

◆ GetData()

BaseContainer GetData ( Int32  id = -1)

Gets a copy of the container for the specified array id.

Parameters
[in]idThe array ID: MODATA_IDS
Returns
A copy of the array's container.

◆ SetData()

void SetData ( const BaseContainer bc,
Int32  id = -1 
)

Sets the the container for the specified array id.

Parameters
[in]bcThe container to set.
[in]idThe array ID: MODATA_IDS

◆ GetAutoLock()

AutoLock& GetAutoLock ( )

Must be used to lock the class with AutoLocker prior to accessing the MoData values directly to prevent threading issues and therefore crashes.

AutoLocker al(modata.GetAutoLock());
Definition: c4d_thread.h:330
Returns
The AutoLock used for locking the class.

◆ AddArray() [1/2]

Int32 AddArray ( const DescID id,
const maxon::String name = maxon::String(),
Int32  default_flags = 0 
)

Adds the specified array.

Parameters
[in]idThe description ID of the array.
[in]nameThe name of the array.
[in]default_flagsThe default flags: MOGENFLAG
Returns
The index of the added array or NOTOK if the method failed.

◆ AddArray() [2/2]

Int32 AddArray ( Int32  id,
Int32  type,
const maxon::String name = maxon::String(),
Int32  default_flags = 0 
)

Adds the specified array.

Parameters
[in]idThe array ID: MODATA_IDS
[in]typeThe type: DTYPE
[in]nameThe name of the array.
[in]default_flagsThe default flags: MOGENFLAG
Returns
The index of the added array or NOTOK if the method failed.

◆ RemoveArray() [1/2]

Bool RemoveArray ( const DescID id)

Removes the specified array.

Parameters
[in]idThe description ID of the array.
Returns
true if the array was removed, otherwise false.

◆ RemoveArray() [2/2]

Bool RemoveArray ( Int32  id)

Removes the specified array.

Parameters
[in]idThe array ID: MODATA_IDS
Returns
true if the array was removed, otherwise false.

◆ GetFlags() [1/2]

Int32 GetFlags ( const DescID id)

Unused.

◆ GetFlags() [2/2]

Int32 GetFlags ( Int32  id)

Unused.

◆ GetIndexFlags()

Int32 GetIndexFlags ( Int32  index)

Unused.

◆ SetFlags() [1/2]

void SetFlags ( const DescID id,
Int32  flags 
)

Unused.

◆ SetFlags() [2/2]

void SetFlags ( Int32  id,
Int32  flags 
)

Unused.

◆ SetIndexFlags()

void SetIndexFlags ( Int32  index,
Int32  flags 
)

Unused.

◆ SetFlag() [1/2]

void SetFlag ( const DescID id,
Int32  flag 
)

Unused.

◆ SetFlag() [2/2]

void SetFlag ( Int32  id,
Int32  flag 
)

Unused.

◆ SetIndexFlag()

void SetIndexFlag ( Int32  index,
Int32  flag 
)

Unused.

◆ DelFlag() [1/2]

void DelFlag ( const DescID id,
Int32  flag 
)

Unused.

◆ DelFlag() [2/2]

void DelFlag ( Int32  id,
Int32  flag 
)

Unused.

◆ DelIndexFlag()

void DelIndexFlag ( Int32  index,
Int32  flag 
)

Unused.

◆ SetName() [1/2]

void SetName ( const DescID id,
const maxon::String name 
)

Sets the name for the specified array description id.

Parameters
[in]idThe description ID of the array.
[in]nameThe name of the array to set.

◆ SetName() [2/2]

void SetName ( Int32  id,
const maxon::String name 
)

Sets the name for the specified array id.

Parameters
[in]idThe array ID: MODATA_IDS
[in]nameThe name of the array to set.

◆ SetIndexName()

void SetIndexName ( Int32  index,
const maxon::String name 
)

Sets the name for the specified array index.

Parameters
[in]indexThe array index. 0 <= index < GetArrayCount()
[in]nameThe name of the array to set.

◆ GetName() [1/2]

String GetName ( const DescID id)

Gets the name of the specified array description id.

Parameters
[in]idThe description ID of the array.
Returns
The name of the array.

◆ GetName() [2/2]

String GetName ( Int32  id)

Gets the name of the specified array id.

Parameters
[in]idThe array ID: MODATA_IDS
Returns
The name of the array.

◆ GetIndexName()

String GetIndexName ( Int32  index)

Gets the name of the specified array index.

Parameters
[in]indexThe array index. 0 <= index < GetArrayCount()
Returns
The name of the array.

◆ GetArray() [1/2]

void* GetArray ( const DescID id) const

Gets a void pointer to an array.

Parameters
[in]idThe description ID of the array.
Returns
The pointer to the array.

◆ GetCharArray() [1/2]

MDArray<Char> GetCharArray ( const DescID id,
Char  default_value = 0 
) const

Gets a Char array.

Parameters
[in]idThe description ID of the array.
[in]default_valueThe default value of the array.
Returns
The retrieved array.

◆ GetUCharArray() [1/2]

MDArray<UChar> GetUCharArray ( const DescID id,
UChar  default_value = 0 
) const

Gets a UChar array.

Parameters
[in]idThe description ID of the array.
[in]default_valueThe default value of the array.
Returns
The retrieved array.

◆ GetLongArray() [1/2]

MDArray<Int32> GetLongArray ( const DescID id,
Int32  default_value = 0 
) const

Gets an Int32/Long array.

Parameters
[in]idThe description ID of the array.
[in]default_valueThe default value of the array.
Returns
The retrieved array.

◆ GetULongArray() [1/2]

MDArray<UInt32> GetULongArray ( const DescID id,
UInt32  default_value = 0 
) const

Gets a UInt32/ULong array.

Parameters
[in]idThe description ID of the array.
[in]default_valueThe default value of the array.
Returns
The retrieved array.

◆ GetBoolArray() [1/2]

MDArray<Bool> GetBoolArray ( const DescID id,
Bool  default_value = true 
) const

Gets a Bool array.

Parameters
[in]idThe description ID of the array.
[in]default_valueThe default value of the array.
Returns
The retrieved array.

◆ GetLLongArray() [1/2]

MDArray<Int64> GetLLongArray ( const DescID id,
Int64  default_value = 0 
) const

Gets an Int64/LLong array.

Parameters
[in]idThe description ID of the array.
[in]default_valueThe default value of the array.
Returns
The retrieved array.

◆ GetRealArray() [1/2]

MDArray<Float> GetRealArray ( const DescID id,
Float  default_value = 1.0 
) const

Gets a Float/Real array.

Parameters
[in]idThe description ID of the array.
[in]default_valueThe default value of the array.
Returns
The retrieved array.

◆ GetMatrixArray() [1/2]

MDArray<Matrix> GetMatrixArray ( const DescID id,
Matrix  default_value = Matrix() 
) const

Gets a Matrix array.

Parameters
[in]idThe description ID of the array.
[in]default_valueThe default value of the array.
Returns
The retrieved array.

◆ GetVectorArray() [1/2]

MDArray<Vector> GetVectorArray ( const DescID id,
Vector  default_value = Vector() 
) const

Gets a Vector array.

Parameters
[in]idThe description ID of the array.
[in]default_valueThe default value of the array.
Returns
The retrieved array.

◆ GetArray() [2/2]

void* GetArray ( Int32  id,
MD_TYPE  type = MD_TYPE::MD_NONE 
) const

Gets a void pointer to an array.

Parameters
[in]idThe ID of the array: MODATA_IDS
[in]typeThe type of the array: MD_TYPE
Returns
The pointer to the array.

◆ GetCharArray() [2/2]

MDArray<Char> GetCharArray ( Int32  id,
Char  default_value = 0 
) const

Gets a Char array.

Parameters
[in]idThe ID of the array: MODATA_IDS
[in]default_valueThe default value of the array.
Returns
The retrieved array.

◆ GetUCharArray() [2/2]

MDArray<UChar> GetUCharArray ( Int32  id,
UChar  default_value = 0 
) const

Gets a UChar array.

Parameters
[in]idThe ID of the array: MODATA_IDS
[in]default_valueThe default value of the array.
Returns
The retrieved array.

◆ GetLongArray() [2/2]

MDArray<Int32> GetLongArray ( Int32  id,
Int32  default_value = 0 
) const

Gets an Int32/Long array.

Parameters
[in]idThe ID of the array: MODATA_IDS
[in]default_valueThe default value of the array.
Returns
The retrieved array.

◆ GetULongArray() [2/2]

MDArray<UInt32> GetULongArray ( Int32  id,
UInt32  default_value = 0 
) const

Gets a UInt32/ULong array.

Parameters
[in]idThe ID of the array: MODATA_IDS
[in]default_valueThe default value of the array.
Returns
The retrieved array.

◆ GetBoolArray() [2/2]

MDArray<Bool> GetBoolArray ( Int32  id,
Bool  default_value = true 
) const

Gets a Bool array.

Parameters
[in]idThe ID of the array: MODATA_IDS
[in]default_valueThe default value of the array.
Returns
The retrieved array.

◆ GetLLongArray() [2/2]

MDArray<Int64> GetLLongArray ( Int32  id,
Int64  default_value = 0 
) const

Gets a Int64/LLong array.

Parameters
[in]idThe ID of the array: MODATA_IDS
[in]default_valueThe default value of the array.
Returns
The retrieved array.

◆ GetRealArray() [2/2]

MDArray<Float> GetRealArray ( Int32  id,
Float  default_value = 1.0 
) const

Gets a Float/Real array.

Parameters
[in]idThe ID of the array: MODATA_IDS
[in]default_valueThe default value of the array.
Returns
The retrieved array.

◆ GetMatrixArray() [2/2]

MDArray<Matrix> GetMatrixArray ( Int32  id,
Matrix  default_value = Matrix() 
) const

Gets a Matrix array.

Parameters
[in]idThe ID of the array: MODATA_IDS
[in]default_valueThe default value of the array.
Returns
The retrieved array.

◆ GetVectorArray() [2/2]

MDArray<Vector> GetVectorArray ( Int32  id,
Vector  default_value = Vector() 
) const

Gets a Vector array.

Parameters
[in]idThe ID of the array: MODATA_IDS
[in]default_valueThe default value of the array.
Returns
The retrieved array.

◆ GetIndexArray()

void* GetIndexArray ( Int32  index) const

Gets a void pointer to an array.

Parameters
[in]indexThe index of the array: 0 <= index < GetArrayCount()
Returns
The pointer to the array.

◆ GetCharIndexArray()

MDArray<Char> GetCharIndexArray ( Int32  index) const

Gets a Char array.

Parameters
[in]indexThe index of the array: 0 <= index < GetArrayCount()
Returns
The retrieved array.

◆ GetUCharIndexArray()

MDArray<UChar> GetUCharIndexArray ( Int32  index) const

Gets a UChar array.

Parameters
[in]indexThe index of the array: 0 <= index < GetArrayCount()
Returns
The retrieved array.

◆ GetLongIndexArray()

MDArray<Int32> GetLongIndexArray ( Int32  index) const

Gets an Int32/Long array.

Parameters
[in]indexThe index of the array: 0 <= index < GetArrayCount()
Returns
The retrieved array.

◆ GetULongIndexArray()

MDArray<UInt32> GetULongIndexArray ( Int32  index) const

Gets a UInt32/ULong array.

Parameters
[in]indexThe index of the array: 0 <= index < GetArrayCount()
Returns
The retrieved array.

◆ GetBoolIndexArray()

MDArray<Bool> GetBoolIndexArray ( Int32  index) const

Gets a Bool array.

Parameters
[in]indexThe index of the array: 0 <= index < GetArrayCount()
Returns
The retrieved array.

◆ GetLLongIndexArray()

MDArray<Int64> GetLLongIndexArray ( Int32  index) const

Gets a Int64/LLong array.

Parameters
[in]indexThe index of the array: 0 <= index < GetArrayCount()
Returns
The retrieved array.

◆ GetRealIndexArray()

MDArray<Float> GetRealIndexArray ( Int32  index) const

Gets a Float/Real array.

Parameters
[in]indexThe index of the array: 0 <= index < GetArrayCount()
Returns
The retrieved array.

◆ GetMatrixIndexArray()

MDArray<Matrix> GetMatrixIndexArray ( Int32  index) const

Gets a Matrix array.

Parameters
[in]indexThe index of the array: 0 <= index < GetArrayCount()
Returns
The retrieved array.

◆ GetVectorIndexArray()

MDArray<Vector> GetVectorIndexArray ( Int32  index) const

Gets a Vector array.

Parameters
[in]indexThe index of the array: 0 <= index < GetArrayCount()
Returns
The retrieved array.

◆ CopyTo()

Bool CopyTo ( MoData dest,
Bool  merge_data = false,
Int  max_count = -1 
) const

Copies the MoGraph data to dest.

Parameters
[in]destThe destination MoGraph data. The caller owns the pointed data.
[in]merge_dataIf true the source and destination data are merged. If false a straight one-to-one copy is made.
For instance if the source contains a matrix array and the destination a matrix and a real array the real array will still exist after the merge action.
[in]max_countThe maximum number of array elements to copy. This limits the array size of the copy.
Returns
true if the MoGraph data was copied, otherwise false.

◆ MergeData()

Bool MergeData ( MoData source,
Float  percent 
)

Merges the MoGraph data with another.

Parameters
[in]sourceThe source MoGraph data. The caller owns the pointed data.
[in]percentThe blend factor for the merge of the data, going from 0.0 to 1.0 (0 to 100%).
Returns
true if the MoGraph data was merged, otherwise false.

◆ Flush()

void Flush ( )

Flushes the MoGraph data.
All data is cleared and the arrays are freed.

◆ SetOffset()

void SetOffset ( Int  offset = 0)

Sets an offset from the beginning of the arrays, for example array[0] becomes array[offset].

Parameters
[in]offsetThe array offset: 0 <= offset < GetCount()

◆ SetLimit()

void SetLimit ( Int  limit = -1)

Sets a limit for the array. All data is kept internally. Can be useful for certain cases for instance merging.

Parameters
[in]limitThe array limit: 0 <= limit < GetCount()

◆ SetColorMode()

void SetColorMode ( Int32  colorMode)

Sets the color mode.

Parameters
[in]colorModeThe new color mode.

◆ GetColorMode()

Int32 GetColorMode ( ) const

Gets the color mode.

Returns
The new color mode.