About
InstanceObject represents an instance object in Cinema 4D. Such an instance object references another scene object. Additionally, it can store multiple matrices for multi-instances.
InstanceObject objects are an instance of Oinstance
.
Creation
InstanceObject objects are created with the usual tools (Entity Creation and Destruction Manual (Classic)):
Properties
The parameters of an InstanceObject are edited as usual using C4DAtom::GetParameter() and C4DAtom::SetParameter(). The parameter IDs are defined in Oinstance.h
.
The referenced object can be accessed with the INSTANCEOBJECT_LINK parameter or with these functions:
Multi-Instances
An InstanceObject can store multiple instance positions. So it can represent not only one but many instances. To turn on the multi-instance mode set the parameter INSTANCEOBJECT_RENDERINSTANCE_MODE to INSTANCEOBJECT_RENDERINSTANCE_MODE_MULTIINSTANCE.
if (instance == nullptr)
doc->InsertObject(instance,
nullptr,
nullptr);
Bool SetParameter(const DescID &id, const GeData &t_data, DESCFLAGS_SET flags)
Definition: lib_instanceobject.h:37
static InstanceObject * Alloc()
maxon::Result< void > SetReferenceObject(BaseObject *refObj)
#define MAXON_SOURCE_LOCATION
Definition: memoryallocationbase.h:67
#define ConstDescID(...)
Definition: lib_description.h:594
@ INSTANCEOBJECT_RENDERINSTANCE_MODE
Definition: oinstance.h:7
@ INSTANCEOBJECT_MULTIPOSITIONINPUT
Definition: oinstance.h:11
@ INSTANCEOBJECT_RENDERINSTANCE_MODE_MULTIINSTANCE
Definition: oinstance.h:10
const char * doc
Definition: pyerrors.h:226
#define iferr_return
Definition: resultbase.h:1521
Represents a level within a DescID.
Definition: lib_description.h:298
For each multi-instance a matrix and a color (maxon::Color64) is stored:
{
const Vector colorHSV { hue, 1.0, 1.0 };
hue += hueStep;
}
Py_ssize_t i
Definition: abstract.h:645
Py_ssize_t count
Definition: abstract.h:640
maxon::Result< void > SetInstanceMatrices(const maxon::BaseArray< Matrix > &matrices)
maxon::Result< void > SetInstanceColors(const maxon::BaseArray< maxon::Color64 > &colors)
Definition: basearray.h:415
ResultMem Resize(Int newCnt, COLLECTION_RESIZE_FLAGS resizeFlags=COLLECTION_RESIZE_FLAGS::DEFAULT)
Definition: basearray.h:1209
maxon::Vec3< maxon::Float64, 1 > Vector
Definition: ge_math.h:145
maxon::Float Float
Definition: ge_sys_math.h:66
maxon::Int Int
Definition: ge_sys_math.h:64
Col3< Float64, 1 > Color64
Definition: vector.h:80
PyObject PyObject * step
Definition: sliceobject.h:34
The InstanceObject can also store unique IPs to identify an instance (see Generating).
Multi-instance information can also be accessed with a MultiInstanceData object:
{
if (cube == nullptr)
doc->InsertObject(cube,
nullptr,
nullptr);
}
Definition: c4d_baseobject.h:248
void SetMg(const Matrix &m)
Definition: c4d_baseobject.h:516
static BaseObject * Alloc(Int32 type)
#define Ocube
Cube.
Definition: ge_prepass.h:1110
Definition: lib_instanceobject.h:245
maxon::Result< void > ExtractInfo(const InstanceObject *obj)
Definition: lib_instanceobject.h:263
maxon::BaseArray< Matrix > instanceMatrices
Global matrices, one for each instance.
Definition: lib_instanceobject.h:298
Further Reading