BaseContainer
& data = multipass->
GetDataInstanceRef
();
data.
SetInt32
(
MULTIPASSOBJECT_TYPE
,
VPBUFFER_OBJECTBUFFER
);
data.
SetInt32
(
MULTIPASSOBJECT_OBJECTBUFFER
, 99);
renderData->
InsertMultipass
(multipass);
Read-Only Properties
The following properties can be accessed:
// This example prints the name and type name of the active object.
BaseObject
*
const
object
= doc->
GetActiveObject
();
if
(
object
==
nullptr
)
return
maxon::IllegalArgumentError(
MAXON_SOURCE_LOCATION
);
ApplicationOutput
(
"The object: \""
+ object->
GetName
() +
"\" is a \""
+ object->
GetTypeName
() +
"\""
);
特性
数据
BaseList2D
based objects store an internal
BaseContainer
. This
BaseContainer
can store various information, like for example (but not restricted to) the values of parameters of an object or tag.
见
BaseContainer Manual
.
// This example implements NodeData::Init() in a plugin class.
// It sets the default values of the plugin's parameters.
virtual
Bool
Init(
GeListNode
* node)
{
if
(node ==
nullptr
|| !SUPER::Init(node))
return
false
;
// get the "real" object
BaseObject
*
const
obj =
static_cast<
BaseObject
*
>
(node);
// get data container
BaseContainer
& data = obj->
GetDataInstanceRef
();
// set default parameter values
data.
SetBool
(EXAMPLE_GENERATOR_PARAMETER_BOOL,
true
);
data.
SetInt32
(EXAMPLE_GENERATOR_PARAMETER_VALUE, 123);
-
注意
-
Typically one should use
C4DAtom::SetParameter()
and
C4DAtom::GetParameter()
to access parameters, instead of accessing the
BaseContainer
directly. See
C4DAtom
参数
.
Bits
Various properties are not stored in parameters but are set using bits. See
BIT
.
// This example disables the first video post.
RenderData
*
const
rd = doc->
GetActiveRenderData
();
if
(rd ==
nullptr
)
return
maxon::UnexpectedError(
MAXON_SOURCE_LOCATION
);
BaseVideoPost
*
const
vp = rd->
GetFirstVideoPost
();
if
(vp !=
nullptr
)
vp->
SetBit
(
BIT_VPDISABLED
);
另请参阅
GeListNode
NBits
.
名称
A
BaseList2D
based element can have a name. Often this name is used in
Cinema 4D
's UI, like names of objects in the Object Manager:
// This example changes the name of the selected object.
BaseObject
*
const
object
= doc->
GetActiveObject
();
if
(
object
==
nullptr
)
return
maxon::IllegalArgumentError(
MAXON_SOURCE_LOCATION
);
object
->SetName(
"This is the selected object"
_s);
-
注意
-
While
BaseDocument
is as well derived from
BaseList2D
, the "name" of a document is a
Filename
set with
BaseDocument::SetDocumentName()
。见
BaseDocument
Document Name and Path
.
着色器
By default a
BaseList2D
based element can host a list of shaders. If a new shader is created and used by the element, it must be inserted into the element's shader list.
// This example creates a shader and adds it to the given material.
BaseShader
*
const
shader =
BaseShader::Alloc
(
Xbrick
);
if
(shader ==
nullptr
)
return
maxon::OutOfMemoryError(
MAXON_SOURCE_LOCATION
);
material->
InsertShader
(shader);
material->
SetParameter
(
DescID
{
MATERIAL_COLOR_SHADER
}, shader,
DESCFLAGS_SET::NONE
);
另请参阅
GeListNode
Lists and Trees
.
Marker
A
BaseList2D
based element owns a
GeMarker
对象。
见
GeMarker Manual
了解更多信息。
// This example gets the name and the marker of the given BaseObject.
// The name is used to search for an object with the same name in the document.
// The marker is used to check if the found object is also the original object.
const
String
objectName =
object
->GetName();
const
GeMarker
& marker =
object
->GetMarker();
// search object with the same name
const
BaseObject
*
const
foundObject = doc->
SearchObject
(objectName);
if
(foundObject !=
nullptr
)
{
// check if it is the same object
const
GeMarker
& foundObjectMarker = foundObject->
GetMarker
();
// compare if the markers are equal
if
(foundObjectMarker.
比较
(marker) == 0)
ApplicationOutput
(
"The found object is the original object"
_s);
else
ApplicationOutput
(
"The found object is not the original object"
_s);
}
Unique ID
BaseList2D
based elements can store an array of unique IDs. These IDs are typically used to identify scenes and elements written by external applications using the Melange library.
// This example adds a new ID to the given object.
// After that all stored IDs are checked.
// adding a new ID
const
Int32
ID = 1111111;
Int32
value = 123456;
object
->AddUniqueID(ID, (
Char
*)&value,
sizeof
(
Int32
));
Int32
appID = 0;
const
Char
* memory =
nullptr
;
Int
bytes = 0;
// looping through all IDs
for
(
Int32
i = 0; i <
object
->GetUniqueIDCount(); ++i)
{
// get the unique ID data stored at the given index
if
(object->
GetUniqueIDIndex
(i, appID, memory, bytes))
{
ApplicationOutput
(
"ID: "
+
String::IntToString
(appID));
// check if the memory block has the size of an Int32 number
if
(bytes ==
sizeof
(
Int32
))
{
const
Int32
data = *(
Int32
*)memory;
ApplicationOutput
(
"Value: "
+
String::IntToString
(data));
}
}
}
Animation Tracks
BaseList2D
based elements store a list of
CTrack
objects (see also
Heads and Branches
). A
CTrack
stores the animation data for a given parameter.
// This example checks if an animation track for the given parameter exists.
// If no track exists it is created.
const
DescID
paramID =
DescLevel
{
PRIM_SPHERE_RAD
,
DTYPE_REAL
, 0 };
// check if track exists
CTrack
* track = sphere->
FindCTrack
(paramID);
if
(track !=
nullptr
)
return
maxon::OK
;
// create track
track =
CTrack::Alloc
(sphere, paramID);
if
(track ==
nullptr
)
return
maxon::OutOfMemoryError(
MAXON_SOURCE_LOCATION
);
// insert track
sphere->
InsertTrackSorted
(track);
见
动画概述
.
Keyframe Selection
Parameters can be part of a so called keyframe selection:
// This example checks if there is a keyframe selection on the given object.
// If yes, all available description IDs are checked if they are part of that selection.
AutoAlloc<Description>
description;
if
(description ==
nullptr
)
return
maxon::OutOfMemoryError(
MAXON_SOURCE_LOCATION
);
// check if any parameters on the object are part of the keyframe selection
if
(object->
KeyframeSelectionContent
())
{
// read description from the object
if
(!object->
GetDescription
(description,
DESCFLAGS_DESC::NONE
))
return
maxon::UnexpectedError(
MAXON_SOURCE_LOCATION
);
void
* handle = description->
BrowseInit
();
const
BaseContainer
* bc =
nullptr
;
DescID
id, gid;
// loop through the description
while
(description->
GetNext
(handle, &bc,
id
, gid))
{
// check if the parameter ID is part of the keyframe selection
if
(object->
FindKeyframeSelection
(
id
) && bc)
{
ApplicationOutput
(
"Parameter \""
+ bc->
GetString
(
DESC_NAME
) +
"\" is part of the keyframe selection"
);
}
}
}
另请参阅
C4DAtom
Parameter Properties
and
动画
.
层
A
BaseList2D
based element can be part of a layer:
// This example gets the LayerObject from the given object
// and checks if it should be visible or not.
// get layer object
LayerObject
*
const
layer =
object
->
GetLayerObject
(doc);
if
(layer !=
nullptr
)
{
// get layer data
const
LayerData
*
const
ld =
object
->GetLayerData(doc);
if
(ld !=
nullptr
)
{
// check if elements should be visible in the Editor
if
(ld->
view
)
ApplicationOutput
(
"visible"
_s);
else
ApplicationOutput
(
"invisible"
_s);
}
}
另请参阅
Layer Manual
.
DescID State
For each parameter ID a certain state can be defined. This is typically managed by the Xref or Take system.
The flags are:
// This example toggles the "locked" state of the sphere's "Radius" parameter.
const
DESCIDSTATE
state = sphere->
GetDescIDState
(
PRIM_SPHERE_RAD
,
true
);
if
(state &
DESCIDSTATE::LOCKED
)
sphere->
SetDescIDState
(
PRIM_SPHERE_RAD
, ~
DESCIDSTATE::LOCKED
& state);
else
sphere->
SetDescIDState
(
PRIM_SPHERE_RAD
,
DESCIDSTATE::LOCKED
| state);
Functionality
BaseList2D
based elements can be edited with these functions:
// This example creates a clone of the given object.
// This clone is scaled and all links pointing to the
// original object are redirected to the clone.
C4DAtom
*
const
atomClone =
object
->
GetClone
(
COPYFLAGS::NONE
,
nullptr
);
BaseObject
*
const
clone =
static_cast<
BaseObject
*
>
(atomClone);
if
(clone ==
nullptr
)
return
maxon::OutOfMemoryError(
MAXON_SOURCE_LOCATION
);
doc->
InsertObject
(clone,
nullptr
,
nullptr
);
// scale the clone's float parameters
clone->
比例
(2.0);
// all links should now refer to the clone
object
->TransferGoal(clone,
false
);
// edit the clone
clone->
编辑
();
延伸阅读
Bool KeyframeSelectionContent()
static CTrack * Alloc(BaseList2D *bl, const DescID &id)
void InsertObject(BaseObject *op, BaseObject *parent, BaseObject *pred, Bool checknames=false)
BaseObject * SearchObject(const maxon::String &str)
定义:
c4d_basedocument.h:245
Bool GetUniqueIDIndex(Int32 idx, Int32 &id, const Char *&mem, Int &bytes) const
定义:
c4d_baselist.h:2413
maxon::Int Int
定义:
ge_sys_math.h:62
@ MULTIPASSOBJECT_TYPE
定义:
zmultipass.h:6
C4DAtom * GetClone(COPYFLAGS flags, AliasTrans *trn)
定义:
c4d_baselist.h:1417
定义:
lib_description.h:327
void SetInt32(Int32 id, Int32 l)
定义:
c4d_basecontainer.h:505
Bool GetDescription(Description *description, DESCFLAGS_DESC flags)
return OK
定义:
apibase.h:2532
const GeMarker & GetMarker() const
定义:
c4d_baselist.h:2365
BaseVideoPost * GetFirstVideoPost()
Bool SetDescIDState(const DescID &id, DESCIDSTATE descidstate)
Int32 Compare(const GeMarker &m) const
定义:
c4d_baselist.h:1294
void InsertTrackSorted(CTrack *track)
#define MAXON_SOURCE_LOCATION
定义:
memoryallocationbase.h:66
CTrack * FindCTrack(const DescID &id)
void SetBit(Int32 mask)
定义:
c4d_baselist.h:2200
void SetBool(Int32 id, Bool b)
定义:
c4d_basecontainer.h:498
@ PRIM_SPHERE_RAD
定义:
osphere.h:6
void InsertMultipass(MultipassObject *obj, MultipassObject *pred=nullptr)
static BaseList2D * Alloc(Int32 type)
#define Xbrick
Brick.
定义:
ge_prepass.h:1165
Represents a C4DAtom that resides in a 4D list.
定义:
c4d_baselist.h:1767
Bool view
Visible in editor view.
定义:
c4d_basedocument.h:346
A unique marker that identifies an object.
定义:
c4d_baselist.h:1256
static String IntToString(Int32 v)
定义:
c4d_string.h:495
Bool GetNext(void *handle, const BaseContainer **bc, DescID &id, DescID &groupid)
Bool SetParameter(const DescID &id, const GeData &t_data, DESCFLAGS_SET flags)
定义:
c4d_basedocument.h:311
LayerObject * GetLayerObject(BaseDocument *doc)
const BaseContainer & GetDataInstanceRef() const
定义:
c4d_baselist.h:2299
@ MATERIAL_COLOR_SHADER
定义:
mmaterial.h:272
static BaseShader * Alloc(Int32 type)
Represents a level within a DescID.
定义:
lib_description.h:286
maxon::Int32 Int32
定义:
ge_sys_math.h:58
#define ApplicationOutput(formatString,...)
定义:
debugdiagnostics.h:207
#define VPBUFFER_OBJECTBUFFER
Object buffer multipass channel.
定义:
c4d_videopostdata.h:140
#define BIT_VPDISABLED
Videopost is disabled.
定义:
ge_prepass.h:873
RenderData * GetActiveRenderData(void)
Bool Scale(Float scale)
定义:
c4d_baselist.h:2483
String GetString(Int32 id, const maxon::String &preset=maxon::String()) const
定义:
c4d_basecontainer.h:387
@ DESC_NAME
String Name for standalone use.
定义:
lib_description.h:91
定义:
c4d_basedocument.h:136
定义:
c4d_basedocument.h:105
maxon::Bool Bool
定义:
ge_sys_math.h:53
BaseObject * GetActiveObject(void)
String GetName() const
定义:
c4d_baselist.h:2318
#define Zmultipass
定义:
ge_prepass.h:1135
@ LOCKED
Description element is locked.
@ DTYPE_REAL
Float
定义:
lib_description.h:68
@ MULTIPASSOBJECT_OBJECTBUFFER
定义:
zmultipass.h:8
Bool FindKeyframeSelection(const DescID &id)
maxon::Char Char
定义:
ge_sys_math.h:54
DESCIDSTATE GetDescIDState(const DescID &id, Bool tolerant) const
定义:
c4d_basecontainer.h:46
void InsertShader(BaseShader *shader, BaseShader *pred=nullptr)
定义:
c4d_baselist.h:2528