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)
addChild(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.

applyFirstAttribute(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 removeUnusedVertices().

applyLastAttribute(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 removeUnusedVertices().

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

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 getConnectedShading().

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

empty() bool
findChild(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.

forceFilenames(directory: panda3d.core.Filename)

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

getChildren() object
static getClassType() panda3d.core.TypeHandle
getConnectedShading()

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.

getFirstChild() 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 getNextChild() 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.

getNextChild() EggNode

Returns the next child in the group’s list of children since the last call to getFirstChild() or getNextChild(), or NULL if the last child has been returned. Can be used with getFirstChild() 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 getFirstChild().

hasAbsolutePathnames() 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.

hasNormals() 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.

hasPrimitives() bool

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

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

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

jointHasPrimitives() 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.

makePointPrimitives()

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

meshTriangles(flags: int)

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

postApplyFlatAttribute(recurse: bool)

Intended as a followup to applyLastAttribute(), 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.

recomputePolygonNormals(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 removeUnusedVertices() after calling this.

recomputeTangentBinormal(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 recomputeVertexNormals() to ensure that the normals exist.

Like recomputeVertexNormals(), 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 removeUnusedVertices() after calling this.

recomputeTangentBinormal(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.

recomputeTangentBinormalAuto() bool

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

recomputeVertexNormals(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 removeUnusedVertices() after calling this.

removeChild(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.

removeInvalidPrimitives(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.

removeUnusedVertices(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 stripNormals()). 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.

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

Rename by stripping out the prefix

resolveFilenames(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.

reverseVertexOrdering()

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

size() int
stealChildren(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.

stripNormals()

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 removeUnusedVertices() after calling this.

triangulatePolygons(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.

unifyAttributes(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 removeUnusedVertices().