EggGroupNode

from panda3d.egg import EggGroupNode
class EggGroupNode

Bases:

Bases: EggNode

A base class for nodes in the hierarchy that are not leaf nodes. (See also EggGroup, which is specifically the “<Group>” node in egg.)

An EggGroupNode is an STL-style container of pointers to EggNodes, like a vector. Functions push_back()/pop_back() and insert()/erase() are provided to manipulate the list. The list may also be operated on (read-only) via iterators and begin()/end().

Inheritance diagram

Inheritance diagram of EggGroupNode

enum TriangulateFlags
enumerator T_polygon = 1
enumerator T_convex = 2
enumerator T_composite = 4
enumerator T_recurse = 8
enumerator T_flat_shaded = 16
__init__(copy: EggGroupNode)
__init__(name: str)
add_child(node: EggNode) EggNode

Adds the indicated child to the group and returns it. If the child node is already a child of some other node, removes it first.

apply_first_attribute(recurse: bool)

Sets the first vertex of the triangle (or each component) to the primitive normal and/or color, if the primitive is flat-shaded. This reflects the DirectX convention of storing flat-shaded properties on the first vertex, although it is not usually a convention in Egg.

This may create redundant vertices in the vertex pool, so it may be a good idea to follow this up with remove_unused_vertices().

apply_last_attribute(recurse: bool)

Sets the last vertex of the triangle (or each component) to the primitive normal and/or color, if the primitive is flat-shaded. This reflects the OpenGL convention of storing flat-shaded properties on the last vertex, although it is not usually a convention in Egg.

This may create redundant vertices in the vertex pool, so it may be a good idea to follow this up with remove_unused_vertices().

assign(copy: EggGroupNode) EggGroupNode
property children
clear()
clear_connected_shading()

Resets the connected_shading information on all primitives at this node and below, so that it may be accurately rederived by the next call to get_connected_shading().

It may be a good idea to call remove_unused_vertices() as well, to establish the correct connectivity between common vertices.

empty() bool
find_child(name: str) EggNode

Returns the child of this node whose name is the indicated string, or NULL if there is no child of this node by that name. Does not search recursively.

force_filenames(directory: panda3d.core.Filename)

Similar to resolve_filenames(), but each non-absolute filename encountered is arbitrarily taken to be in the indicated directory, whether or not the so- named filename exists.

get_children() object
static get_class_type() panda3d.core.TypeHandle
get_connected_shading()

Queries the connected_shading information on all primitives at this node and below, to ensure that it has been completely filled in before we start mucking around with vertices.

get_first_child() EggNode

Returns the first child in the group’s list of children, or NULL if the list of children is empty. Can be used with get_next_child() to return the complete list of children without using the iterator class; however, this is non-thread-safe, and so is not recommended except for languages other than C++ which cannot use the iterators.

get_next_child() EggNode

Returns the next child in the group’s list of children since the last call to get_first_child() or get_next_child(), or NULL if the last child has been returned. Can be used with get_first_child() to return the complete list of children without using the iterator class; however, this is non- thread-safe, and so is not recommended except for languages other than C++ which cannot use the iterators.

It is an error to call this without previously calling get_first_child().

has_absolute_pathnames() bool

Returns true if any nodes at this level and below include a reference to a file via an absolute pathname, or false if all references are relative.

has_normals() bool

Returns true if any of the primitives (e.g. polygons) defined within this group or below have either face or vertex normals defined, false otherwise.

has_primitives() bool

Returns true if there are any primitives (e.g. polygons) defined within this group or below, false otherwise.

static is_right(v1: panda3d.core.LVector2d, v2: panda3d.core.LVector2d) bool

Returns true if the 2-d v1 is to the right of v2.

joint_has_primitives() bool

Returns true if there are any primitives (e.g. polygons) defined within this group or below, but the search does not include nested joints.

make_point_primitives()

Creates PointLight primitives to reference any otherwise unreferences vertices discovered in this group or below.

mesh_triangles(flags: int)

Combine triangles together into triangle strips, at this group and below.

post_apply_flat_attribute(recurse: bool)

Intended as a followup to apply_last_attribute(), this also sets an attribute on the first vertices of the primitive, if they don’t already have an attribute set, just so they end up with something.

recompute_polygon_normals(cs: panda3d.core.CoordinateSystem)

Recomputes all the polygon normals for polygon geometry at this group node and below so that they accurately reflect the vertex positions. Normals are removed from the vertices and defined only on polygons, giving the geometry a faceted appearance.

This function also removes degenerate polygons that do not have enough vertices to define a normal. It does not affect normals for other kinds of primitives like Nurbs or Points.

This function does not remove or adjust vertices in the vertex pool; it only adds new vertices with the normals removed. Thus, it is a good idea to call remove_unused_vertices() after calling this.

recompute_tangent_binormal(uv_name: panda3d.core.GlobPattern) bool

This function recomputes the tangent and binormal for the named texture coordinate set for all vertices at this level and below. Use the empty string for the default texture coordinate set.

It is necessary for each vertex to already have a normal (or at least a polygon normal), as well as a texture coordinate in the named texture coordinate set, before calling this function. You might precede this with recompute_vertex_normals() to ensure that the normals exist.

Like recompute_vertex_normals(), this function does not remove or adjust vertices in the vertex pool; it only adds new vertices with the new tangents and binormals computed. Thus, it is a good idea to call remove_unused_vertices() after calling this.

recompute_tangent_binormal(names: panda3d.core.vector_string) bool

This function recomputes the tangent and binormal for the named texture coordinate sets. Returns true if anything was done.

recompute_tangent_binormal_auto() bool

This function recomputes the tangent and binormal for any texture coordinate set that affects a normal map. Returns true if anything was done.

recompute_vertex_normals(threshold: float, cs: panda3d.core.CoordinateSystem)

Recomputes all the vertex normals for polygon geometry at this group node and below so that they accurately reflect the vertex positions. A shared edge between two polygons (even in different groups) is considered smooth if the angle between the two edges is less than threshold degrees.

This function also removes degenerate polygons that do not have enough vertices to define a normal. It does not affect normals for other kinds of primitives like Nurbs or Points.

This function does not remove or adjust vertices in the vertex pool; it only adds new vertices with the correct normals. Thus, it is a good idea to call remove_unused_vertices() after calling this.

remove_child(node: EggNode) EggNode

Removes the indicated child node from the group and returns it. If the child was not already in the group, does nothing and returns NULL.

remove_invalid_primitives(recurse: bool) int

Removes primitives at this level and below which appear to be degenerate; e.g. polygons with fewer than 3 vertices, etc. Returns the number of primitives removed.

remove_unused_vertices(recurse: bool) int

Removes all vertices from VertexPools within this group or below that are not referenced by at least one primitive. Also collapses together equivalent vertices, and renumbers all vertices after the operation so their indices are consecutive, beginning at zero. Returns the total number of vertices removed.

Note that this operates on the VertexPools within this group level, without respect to primitives that reference these vertices (unlike other functions like strip_normals()). It is therefore most useful to call this on the EggData root, rather than on a subgroup within the hierarchy, since a VertexPool may appear anywhere in the hierarchy.

rename_nodes(strip_prefix: panda3d.core.vector_string, recurse: bool) int

Rename by stripping out the prefix

resolve_filenames(searchpath: panda3d.core.DSearchPath)

Walks the tree and attempts to resolve any filenames encountered. This looks up filenames along the specified search path; it does not automatically search the model_path for missing files.

reverse_vertex_ordering()

Reverses the vertex ordering of all polygons defined at this node and below. Does not change the surface normals, if any.

size() int
steal_children(other: EggGroupNode)

Moves all the children from the other node to this one. This is especially useful because the group node copy assignment operator does not copy children.

strip_normals()

Removes all normals from primitives, and the vertices they reference, at this node and below.

This function does not remove or adjust vertices in the vertex pool; it only adds new vertices with the normal removed. Thus, it is a good idea to call remove_unused_vertices() after calling this.

triangulate_polygons(flags: int) int

Replace all higher-order polygons at this point in the scene graph and below with triangles. Returns the total number of new triangles produced, less degenerate polygons removed.

If flags contains T_polygon and T_convex, both concave and convex polygons will be subdivided into triangles; with only T_polygon, only concave polygons will be subdivided, and convex polygons will be largely unchanged.

unify_attributes(use_connected_shading: bool, allow_per_primitive: bool, recurse: bool)

Applies per-vertex normal and color to all vertices, if they are in fact per-vertex (and different for each vertex), or moves them to the primitive if they are all the same.

After this call, either the primitive will have normals or its vertices will, but not both. Ditto for colors.

If use_connected_shading is true, each polygon is considered in conjunction with all connected polygons; otherwise, each polygon is considered individually.

If allow_per_primitive is false, S_per_face or S_overall will treated like S_per_vertex: normals and colors will always be assigned to the vertices. In this case, there will never be per-primitive colors or normals after this call returns. On the other hand, if allow_per_primitive is true, then S_per_face means that normals and colors should be assigned to the primitives, and removed from the vertices, as described above.

This may create redundant vertices in the vertex pool, so it may be a good idea to follow this up with remove_unused_vertices().