A
c4d.LodObject
represents a LOD object generator. This generator creates geometry based on various parameters e.g. camera distance. The
c4d.LodObject
class provides access to the parameters of the dynamically defined levels.
A
c4d.LodObject
object is a
c4d.BaseObject
an can be accessed like any other object.
c4d.LodObject
objects are created with
LodObject.__init__()
/
()
.
# This example creates a new LOD object and adds it to the active BaseDocument import c4d lodObject = c4d.LodObject() lodObject.SetName("New LOD Object") doc.InsertObject(lodObject) c4d.EventAdd()
The standard parameters of a
c4d.LodObject
can be accessed with the
[]
operator
GeListNode.__getitem__()
/
GeListNode.__setitem__()
or
C4DAtom.SetParameter()
/
C4DAtom.GetParameter()
.
# This example checks the current criteria of the active LOD object 'op'. # If it is "User LOD Level" the current level is set to the maximum level. import c4d # get current criteria from active LOD object criteria = op[c4d.LOD_CRITERIA] # check if User LOD Level if criteria == c4d.LOD_CRITERIA_MANUAL: # get maximum level maxLevel = op.GetLevelCount() - 1 # set current level to max level op[c4d.LOD_CURRENT_LEVEL] = maxLevel c4d.EventAdd()
A
c4d.LodObject
handles multiple levels. The current level is used to define the geometry it should create.
LodObject.GetLevelCount()
: Returns the number of levels.
LodObject.GetCurrentLevel()
: Returns the index of the current level.
# This example hides the objects of the active LOD object 'op' current level. import c4d # get active LOD object current level currentLevel = op.GetCurrentLevel() # hide current level showControlID = op.GetShowControlDescID(currentLevel) if showControlID is not None: op[showControlID] = False c4d.EventAdd()
Each level contains multiple parameters that configure that level. The
c4d.DescID
for these parameters can be obtained with these functions.
In every mode a level defines various display parameters:
LodObject.GetShowControlDescID()
: Returns the
c4d.DescID
for the display mode.
LodObject.GetDisplayBFCDescID()
: Returns the
c4d.DescID
for the backface culling mode.
LodObject.GetDisplayTexDescID()
: Returns the
c4d.DescID
for the texture mode.
LodObject.GetDisplayEOGLDescID()
: Returns the
c4d.DescID
for the Enhanced OpenGL mode.
LodObject.GetDisplayStModeDescID()
: Returns the
c4d.DescID
for the shading style.
LodObject.GetDisplayShModeDescID()
: Returns the
c4d.DescID
for the shading settings.
# This example configures the display settings for each level of the active LOD object 'op'. import c4d # get active LOD object number of levels levelCount = op.GetLevelCount() for level in xrange(levelCount): descID = op.GetDisplayBFCDescID(level) # enable backface culling if descID is not None: op[descID] = True # currently GetDisplayStModeDescID() and GetDisplayShModeDescID() are switched up # use "Lines" shading descID = op.GetDisplayStModeDescID(level) if descID is not None: op[descID] = c4d.DISPLAYTAG_SDISPLAY_NOSHADING # use "Wireframe" style descID = op.GetDisplayShModeDescID(level) if descID is not None: op[descID] = c4d.DISPLAYTAG_WDISPLAY_WIREFRAME c4d.EventAdd()
In “Manual Groups” mode a list of objects can be accessed:
LodObject.GetManualModeObjectListDescID()
: Returns the
c4d.DescID
of the InExclude list.
# This example configures the active LOD object to use "Manual Groups". # The selected objects referenced in the objects list are moved under the LOD object and are referenced in each group. # Use "Manual Groups" and a manually defined number of groups. import c4d def main(): activeObjects = doc.GetActiveObjects(c4d.GETACTIVEOBJECTFLAGS_0) if len(activeObjects) <= 1: return lodObject = doc.GetTargetObject() if lodObject.GetType() != c4d.Olod: return lodObject[c4d.LOD_MODE] = c4d.LOD_MODE_MANUAL_GROUPS lodObject[c4d.LOD_CRITERIA] = c4d.LOD_CRITERIA_MANUAL lodObject[c4d.LOD_LEVEL_COUNT_DYN] = len(activeObjects) - 1 for level, object in enumerate(activeObjects): if object == lodObject: continue # make object a child object of the LOD object object.Remove() doc.InsertObject(object, lodObject) # insert object into "Objects" list of the given level listID = lodObject.GetManualModeObjectListDescID(level) if listID is not None: # create InEx data inExData = c4d.InExcludeData() if inExData is not None: # insert object into list inExData.InsertObject(object, 1) # set parameter lodObject[listID] = inExData c4d.EventAdd() if __name__=='__main__': main()
In “Simplify” mode these settings are available:
LodObject.GetSimplifyModeDescID()
: Returns the
c4d.DescID
of the “Simplify Mode” parameter.
LodObject.GetDecimateStrengthDescID()
: Returns the
c4d.DescID
of the strength parameter.
LodObject.GetPerObjectControlDescID()
: Returns the
c4d.DescID
of the “Per Object” option.
LodObject.GetNullDisplayDescID()
: Returns the
c4d.DescID
of the null display mode.
LodObject.GetNullRadiusDescID()
: Returns the
c4d.DescID
of the null radius parameter.
LodObject.GetNullAspectRatioDescID()
: Returns the
c4d.DescID
of the null aspect radius parameter.
LodObject.GetNullOrientationDescID()
: Returns the
c4d.DescID
of the null orientation parameter.
# This example configures the active LodObject 'op' 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. import c4d op[c4d.LOD_MODE] = c4d.LOD_MODE_SIMPLIFY op[c4d.LOD_CRITERIA] = c4d.LOD_CRITERIA_MANUAL op[c4d.LOD_LEVEL_COUNT_DYN] = 2 # first level descID = op.GetSimplifyModeDescID(0) if descID is not None: # set mode to "Convex Hull" op[descID] = c4d.LOD_SIMPLIFY_CONVEXHULL descID = op.GetPerObjectControlDescID(0) if descID is not None: # set "Per Object" to True op[descID] = True # second level descID = op.GetSimplifyModeDescID(1) if descID is not None: # set mode to "Null" op[descID] = c4d.LOD_SIMPLIFY_NULL descID = op.GetNullDisplayDescID(1) if descID is not None: # set "Display" to "Circle" op[descID] = c4d.NULLOBJECT_DISPLAY_CIRCLE c4d.EventAdd()