LodObject Manual

About

A LodObject represents a LOD (level of detail) object generator. This generator creates geometry based on various parameters e.g. camera distance. The LodObject class provides access to the parameters of the dynamically defined levels. It is defined in the lib_lodobject.h header file.

LodObject objects are an instance of Olod.

Access

A LodObject object is a BaseObject and can be accessed like any other object. See BaseObject Manual.

Allocation/Deallocation

LodObject objects are created with the usual tools, see Entity Creation and Destruction Manual (Classic).

// This example creates a new LOD object and adds it to the given BaseDocument.
LodObject* const lodObject = LodObject::Alloc();
if (lodObject == nullptr)
return maxon::OutOfMemoryError(MAXON_SOURCE_LOCATION);
lodObject->SetName("New LOD Object"_s);
doc->InsertObject(lodObject, nullptr, nullptr);
void SetName(const maxon::String &name, Bool setDirty=true)
Definition: c4d_baselist.h:2549
Definition: lib_lodobject.h:38
static LodObject * Alloc()
#define MAXON_SOURCE_LOCATION
Definition: memoryallocationbase.h:67
const char * doc
Definition: pyerrors.h:226

Properties

The standard parameters of a LodObject can be obtained and changed with C4DAtom::SetParameter()/ C4DAtom::GetParameter(). The parameter IDs are defined in olod.h.

// This example checks the current criteria of the given LOD object.
// If it is "User LOD Level" the current level is set to the maximum level.
// get current criteria
GeData data;
const Int32 criteria = data.GetInt32();
// check if User LOD Level
if (criteria == LOD_CRITERIA_MANUAL)
{
// get max level
const Int32 maxLevel = lodObject->GetLevelCount() - 1;
// set current level to max level
}
Bool SetParameter(const DescID &id, const GeData &t_data, DESCFLAGS_SET flags)
Bool GetParameter(const DescID &id, GeData &t_data, DESCFLAGS_GET flags) const
Definition: c4d_gedata.h:83
Int32 GetInt32() const
Definition: c4d_gedata.h:456
Int32 GetLevelCount() const
maxon::Int32 Int32
Definition: ge_sys_math.h:56
#define ConstDescID(...)
Definition: lib_description.h:594
@ LOD_CRITERIA
Definition: olod.h:7
@ LOD_CURRENT_LEVEL
Definition: olod.h:9
@ LOD_CRITERIA_MANUAL
Definition: olod.h:28
Represents a level within a DescID.
Definition: lib_description.h:298

Levels

A LodObject object handles multiple levels. The current level is used to define the geometry it should create.

// This example hides the objects of the current level.
// get current level
const Int32 currentLevel = lodObject->GetCurrentLevel();
// hide current level
DescID showControlID;
if (!lodObject->GetShowControlDescID(currentLevel, showControlID))
return maxon::UnexpectedError(MAXON_SOURCE_LOCATION);
lodObject->SetParameter(showControlID, false, DESCFLAGS_SET::NONE);
Definition: lib_description.h:355
Bool GetShowControlDescID(Int32 level, DescID &resultId) const
Int32 GetCurrentLevel() const

Dynamic Parameter IDs

Each level contains multiple parameters that configure that level. The DescID for these parameters can be obtained with these functions.

In every mode a level defines various display parameters:

The IDs of the shading modes and styles are defined in tdisplay.h.

// This example configures the display settings for each level.
const Int32 maxLevel = lodObject->GetLevelCount();
for (Int32 level = 0; level < maxLevel; ++level)
{
DescID descID;
// enable backface culling
if (!lodObject->GetDisplayBFCDescID(level, descID))
return maxon::UnexpectedError(MAXON_SOURCE_LOCATION);
lodObject->SetParameter(descID, true, DESCFLAGS_SET::NONE);
// use "Lines" shading
if (!lodObject->GetDisplayShModeDescID(level, descID))
return maxon::UnexpectedError(MAXON_SOURCE_LOCATION);
// use "Wireframe" style
if (!lodObject->GetDisplayStModeDescID(level, descID))
return maxon::UnexpectedError(MAXON_SOURCE_LOCATION);
}
Bool GetDisplayBFCDescID(Int32 level, DescID &resultId) const
Bool GetDisplayShModeDescID(Int32 level, DescID &resultId) const
Bool GetDisplayStModeDescID(Int32 level, DescID &resultId) const
PyObject PyObject PyObject int level
Definition: import.h:58
@ DISPLAYTAG_WDISPLAY_WIREFRAME
Definition: tdisplay.h:31
@ DISPLAYTAG_SDISPLAY_NOSHADING
Definition: tdisplay.h:13

In "Manual Groups" mode a list of objects can be accessed:

// This example configures the given LodObject to use "Manual Groups".
// The objects referenced in the "objects" AtomArray are moved under
// the LodObject and are referenced in each group.
// use "Manual Groups" and a manually defined number of groups
// add objects to groups
for (Int32 level = 0; level < objectCount; ++level)
{
// get object
C4DAtom* const atom = objects->GetIndex(level);
BaseObject* const baseObject = static_cast<BaseObject*>(atom);
if (baseObject == nullptr)
return maxon::UnexpectedError(MAXON_SOURCE_LOCATION);
// make object a child object of the LOD object
baseObject->Remove();
doc->InsertObject(baseObject, lodObject, nullptr);
// insert into "Objects" list of the given level
DescID listID;
if (!lodObject->GetManualModeObjectListDescID(level, listID))
return maxon::UnexpectedError(MAXON_SOURCE_LOCATION);
// create InEx data
if (inExData == nullptr)
return maxon::UnexpectedError(MAXON_SOURCE_LOCATION);
// insert object into list
inExData->InsertObject(baseObject, 1);
// set parameter
lodObject->SetParameter(listID, data, DESCFLAGS_SET::NONE);
}
@ DEFAULTVALUE
Dummy value for the default value GeData constructor.
Definition: c4d_gedata.h:65
Definition: c4d_baseobject.h:248
Definition: c4d_baselist.h:1520
DATATYPE * GetCustomDataTypeWritable()
Definition: c4d_gedata.h:547
void Remove()
Definition: c4d_baselist.h:2066
InExclude custom data type (CUSTOMDATATYPE_INEXCLUDE_LIST).
Definition: customgui_inexclude.h:115
Bool InsertObject(BaseList2D *pObject, Int32 lFlags)
Bool GetManualModeObjectListDescID(Int32 level, DescID &resultId) const
#define CUSTOMDATATYPE_INEXCLUDE_LIST
InExclude custom data type ID.
Definition: customgui_inexclude.h:25
#define atom
Definition: graminit.h:72
@ LOD_MODE
Definition: olod.h:6
@ LOD_LEVEL_COUNT_DYN
Definition: olod.h:13
@ LOD_MODE_MANUAL_GROUPS
Definition: olod.h:25

In "Simplify" mode these settings are available:

The null display mode setting IDs are defined in onull.h.

// This example configures the given LodObject to use the "Simplify" mode.
// The first level uses the "Convex Hull" mode, the second the "Null" mode.
// use "Simplify" mode and a manual number of levels
DescID descID;
// first level
// set mode to "Convex Hull"
if (!lodObject->GetSimplifyModeDescID(0, descID))
return maxon::UnexpectedError(MAXON_SOURCE_LOCATION);
// set "Per Object" to true
if (!lodObject->GetPerObjectControlDescID(0, descID))
return maxon::UnexpectedError(MAXON_SOURCE_LOCATION);
lodObject->SetParameter(descID, true, DESCFLAGS_SET::NONE);
// second level
// set mode to "Null"
if (!lodObject->GetSimplifyModeDescID(1, descID))
return maxon::UnexpectedError(MAXON_SOURCE_LOCATION);
// set "Display" to "Circle"
if (!lodObject->GetNullDisplayDescID(1, descID))
return maxon::UnexpectedError(MAXON_SOURCE_LOCATION);
Bool GetPerObjectControlDescID(Int32 level, DescID &resultId) const
Bool GetSimplifyModeDescID(Int32 level, DescID &resultId) const
Bool GetNullDisplayDescID(Int32 level, DescID &resultId) const
@ LOD_SIMPLIFY_NULL
Definition: olod.h:40
@ LOD_SIMPLIFY_CONVEXHULL
Definition: olod.h:38
@ LOD_MODE_SIMPLIFY
Definition: olod.h:26
@ NULLOBJECT_DISPLAY_CIRCLE
Definition: onull.h:9

Dirty Checksums

The dirty checksum of levels and the cache can be obtained with:

  • LodObject::GetLevelDirty(): Returns the checksum for the level switch. Every time the level changes, the counter is increased.
  • LodObject::GetCacheDirty(): Returns the checksum for the cache creation. Every time the cache is rebuilt, the counter is increased.

Further Reading