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);

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
}

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);

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);
}

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
InExcludeData* const inExData = static_cast<InExcludeData*>(customData);
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);
}

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);

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

LOD_LEVEL_COUNT_DYN
@ LOD_LEVEL_COUNT_DYN
Definition: olod.h:13
LOD_MODE_MANUAL_GROUPS
@ LOD_MODE_MANUAL_GROUPS
Definition: olod.h:25
LodObject::GetDisplayBFCDescID
Bool GetDisplayBFCDescID(Int32 level, DescID &resultId) const
NULLOBJECT_DISPLAY_CIRCLE
@ NULLOBJECT_DISPLAY_CIRCLE
Definition: onull.h:9
BaseDocument::InsertObject
void InsertObject(BaseObject *op, BaseObject *parent, BaseObject *pred, Bool checknames=false)
LOD_CURRENT_LEVEL
@ LOD_CURRENT_LEVEL
Definition: olod.h:9
LOD_CRITERIA
@ LOD_CRITERIA
Definition: olod.h:7
LodObject::GetNullDisplayDescID
Bool GetNullDisplayDescID(Int32 level, DescID &resultId) const
LodObject::GetPerObjectControlDescID
Bool GetPerObjectControlDescID(Int32 level, DescID &resultId) const
BaseObject
Definition: c4d_baseobject.h:220
DescID
Definition: lib_description.h:315
LodObject::GetDisplayShModeDescID
Bool GetDisplayShModeDescID(Int32 level, DescID &resultId) const
DISPLAYTAG_SDISPLAY_NOSHADING
@ DISPLAYTAG_SDISPLAY_NOSHADING
Definition: tdisplay.h:13
MAXON_SOURCE_LOCATION
#define MAXON_SOURCE_LOCATION
Definition: memoryallocationbase.h:66
LodObject
Definition: lib_lodobject.h:34
LodObject::GetShowControlDescID
Bool GetShowControlDescID(Int32 level, DescID &resultId) const
DESCFLAGS_SET::NONE
@ NONE
None.
CUSTOMDATATYPE_INEXCLUDE_LIST
#define CUSTOMDATATYPE_INEXCLUDE_LIST
InExclude custom data type ID.
Definition: customgui_inexclude.h:21
LodObject::GetDisplayStModeDescID
Bool GetDisplayStModeDescID(Int32 level, DescID &resultId) const
InExcludeData
InExclude custom data type (CUSTOMDATATYPE_INEXCLUDE_LIST).
Definition: customgui_inexclude.h:107
C4DAtom::SetParameter
Bool SetParameter(const DescID &id, const GeData &t_data, DESCFLAGS_SET flags)
InExcludeData::InsertObject
Bool InsertObject(BaseList2D *pObject, Int32 lFlags)
GeData::GetInt32
Int32 GetInt32(void) const
Definition: c4d_gedata.h:411
LodObject::Alloc
static LodObject * Alloc()
LodObject::GetCurrentLevel
Int32 GetCurrentLevel() const
LodObject::GetLevelCount
Int32 GetLevelCount() const
LodObject::GetSimplifyModeDescID
Bool GetSimplifyModeDescID(Int32 level, DescID &resultId) const
GeData
Definition: c4d_gedata.h:77
C4DAtom
Definition: c4d_baselist.h:1325
BaseList2D::SetName
void SetName(const maxon::String &name)
Definition: c4d_baselist.h:2318
Int32
maxon::Int32 Int32
Definition: ge_sys_math.h:45
LodObject::GetManualModeObjectListDescID
Bool GetManualModeObjectListDescID(Int32 level, DescID &resultId) const
LOD_CRITERIA_MANUAL
@ LOD_CRITERIA_MANUAL
Definition: olod.h:28
GeListNode::Remove
void Remove()
Definition: c4d_baselist.h:1848
DEFAULTVALUE
@ DEFAULTVALUE
Dummy value for the default value GeData constructor.
Definition: c4d_gedata.h:60
CustomDataType
Base class for custom data types.
Definition: c4d_customdatatype.h:46
LOD_SIMPLIFY_CONVEXHULL
@ LOD_SIMPLIFY_CONVEXHULL
Definition: olod.h:38
LOD_SIMPLIFY_NULL
@ LOD_SIMPLIFY_NULL
Definition: olod.h:40
LOD_MODE
@ LOD_MODE
Definition: olod.h:6
DESCFLAGS_GET::NONE
@ NONE
None.
GeData::GetCustomDataType
CustomDataType * GetCustomDataType(Int32 datatype) const
Definition: c4d_gedata.h:485
LOD_MODE_SIMPLIFY
@ LOD_MODE_SIMPLIFY
Definition: olod.h:26
C4DAtom::GetParameter
Bool GetParameter(const DescID &id, GeData &t_data, DESCFLAGS_GET flags)
DISPLAYTAG_WDISPLAY_WIREFRAME
@ DISPLAYTAG_WDISPLAY_WIREFRAME
Definition: tdisplay.h:31
AtomArray::GetIndex
C4DAtom * GetIndex(Int32 idx) const
Definition: c4d_baselist.h:1628