# LODNode¶

class LODNode

Bases: PandaNode

A Level-of-Detail node. This selects only one of its children for rendering, according to the distance from the camera and the table indicated in the associated LOD object.

Inheritance diagram

explicit LODNode(std::string const &name)
void add_switch(PN_stdfloat in, PN_stdfloat out)

Adds a switch range to the LODNode. This implies that the corresponding child node has been parented to the node.

The sense of in vs. out distances is as if the object were coming towards you from far away: it switches “in” at the far distance, and switches “out” at the close distance. Thus, “in” should be larger than “out”.

void clear_force_switch(void)

Undoes the effect of a previous call to force_switch() and releases the LODNode to once again display the normal level.

void clear_switches(void)

Removes the set of switching ranges for the LODNode, presumably in conjunction with removing all of its children. See add_switch().

void force_switch(int index)

Forces the LODNode to show the indicated level instead of the level that would normally be shown based on the distance from the camera.

LPoint3 const &get_center(void) const

Returns the center of the LOD. This is the point that is compared to the camera (in camera space) to determine the particular LOD that should be chosen.

static TypeHandle get_class_type(void)
int get_highest_switch(void) const

Returns the index number of the child with the highest level of detail; that is, the one that is designed to be seen from the closest to the camera. This is usually the last child, but it is not necessarily so.

PN_stdfloat get_in(int index) const

Returns the “in” distance of the indicated switch range. This should be larger than the “out” distance of the same range.

PN_stdfloat get_lod_scale(void) const

Returns the multiplier for lod distances

int get_lowest_switch(void) const

Returns the index number of the child with the lowest level of detail; that is, the one that is designed to be seen from the farthest away. This is usually the first child, but it is not necessarily so.

int get_num_switches(void) const

Returns the number of switch ranges added to the LODNode. This should correspond to the number of children of the node in order for the LODNode to function correctly.

PN_stdfloat get_out(int index) const

Returns the “out” distance of the indicated switch range. This should be smaller than the “in” distance of the same range.

void hide_all_switches(void)

Hides all levels, restoring the LODNode to normal operation.

void hide_switch(int index)

Disables a previous call to show_switch().

bool is_any_shown(void) const

Returns true if any switch has been shown with show_switch(), indicating the LODNode is in debug show mode; or false if it is in the normal mode.

static PointerTo<LODNode> make_default_lod(std::string const &name)

Creates a new LODNode of the type specified by the default-lod-type config variable.

void set_center(LPoint3 const &center)

Specifies the center of the LOD. This is the point that is compared to the camera (in camera space) to determine the particular LOD that should be chosen.

void set_lod_scale(PN_stdfloat value)

for performance tuning, increasing this value should improve performance at the cost of model quality

for performance tuning, increasing this value should improve performance at the cost of model quality

Sets the multiplier for lod distances. A higher value means you’ll see farther switchs than normal

bool set_switch(int index, PN_stdfloat in, PN_stdfloat out)

Changes the switching range of a particular child of the LODNode. See add_switch().

void show_all_switches(void)

Shows all levels in their default colors.

void show_switch(int index)
void show_switch(int index, LColor const &color)

This is provided as a debugging aid. show_switch() will put the LODNode into a special mode where rather than computing and drawing the appropriate level of the LOD, a ring is drawn around the LODNode center indicating the switch distances from the camera for the indicated level, and the geometry of the indicated level is drawn in wireframe.

Multiple different levels can be visualized this way at once. Call hide_switch() or hide_all_switches() to undo this mode and restore the LODNode to its normal behavior.

bool verify_child_bounds(void) const

Returns true if the bounding volumes for the geometry of each fhild node entirely fits within the switch_in radius for that child, or false otherwise. It is almost always a mistake for the geometry of an LOD level to be larger than its switch_in radius.