EggPrimitive

from panda3d.egg import EggPrimitive
class EggPrimitive

Bases:

Bases: EggNode, EggAttributes, EggRenderMode

A base class for any of a number of kinds of geometry primitives: polygons, point lights, nurbs patches, parametrics curves, etc. Things with a set of vertices and some rendering properties like color.

An EggPrimitive is an STL-style container of pointers to EggVertex’s. In fact, it IS a vector, and can be manipulated in all the ways that vectors can. However, it is necessary that all vertices belong to the same vertex pool.

Inheritance diagram

Inheritance diagram of EggPrimitive

enum Shading
enumerator S_unknown = 0

The order here is important. The later choices are more specific than the earlier ones.

enumerator S_overall = 1
enumerator S_per_face = 2
enumerator S_per_vertex = 3
add_texture(texture: EggTexture)

Applies the indicated texture to the primitive.

Note that, in the case of multiple textures being applied to a single primitive, the order in which the textures are applied does not affect the rendering order; use EggTexture::set_sort() to specify that.

add_vertex(vertex: EggVertex) EggVertex

Adds the indicated vertex to the end of the primitive’s list of vertices, and returns it.

apply_first_attribute()

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 introduce redundant vertices to the vertex pool.

apply_last_attribute()

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 introduce redundant vertices to the vertex pool.

assign(copy: EggPrimitive) EggPrimitive
property bface_flag bool
Getter

Retrieves the backfacing flag of the polygon. See set_bface_flag().

Setter

Sets the backfacing flag of the polygon. If this is true, the polygon will be rendered so that both faces are visible; if it is false, only the front face of the polygon will be visible.

cleanup() bool

Cleans up modeling errors in whatever context this makes sense. For instance, for a polygon, this calls remove_doubled_verts(true). For a point, it calls remove_nonunique_verts(). Returns true if the primitive is valid, or false if it is degenerate.

clear()

Removes all of the vertices from the primitive.

clear_connected_shading()

Resets the connected_shading member in this primitive, so that get_connected_shading() will recompute a new value.

clear_material()

Removes any material from the primitive.

clear_texture()

Removes any texturing from the primitive.

property connected_shading Shading

Determines what sort of shading properties this primitive’s connected neighbors have.

To get the most accurate results, you should first call clear_connected_shading() on all connected primitives (or on all primitives in the egg file). It might also be a good idea to call remove_unused_vertices() to ensure proper connectivity.

You may find it easiest to call these other methods on the EggData root node (they are defined on EggGroupNode).

copy_attributes(other: EggAttributes)

Copies the rendering attributes from the indicated primitive.

copy_attributes(other: EggPrimitive)

Copies the rendering attributes from the indicated primitive.

copy_vertices(other: EggPrimitive)

Replaces the current primitive’s list of vertices with a copy of the list of vertices on the other primitive.

determine_alpha_mode() EggRenderMode

Walks back up the hierarchy, looking for an EggGroup or EggPrimitive or some such object at this level or above this primitive that has an alpha_mode other than AM_unspecified. Returns a valid EggRenderMode pointer if one is found, or NULL otherwise.

determine_bin() EggRenderMode

Walks back up the hierarchy, looking for an EggGroup or EggPrimitive or some such object at this level or above this primitive that has a bin specified. Returns a valid EggRenderMode pointer if one is found, or NULL otherwise.

determine_depth_offset() EggRenderMode

Walks back up the hierarchy, looking for an EggGroup or EggPrimitive or some such object at this level or above this primitive that has a depth_offset specified. Returns a valid EggRenderMode pointer if one is found, or NULL otherwise.

determine_depth_test_mode() EggRenderMode

Walks back up the hierarchy, looking for an EggGroup or EggPrimitive or some such object at this level or above this node that has a depth_test_mode other than DTM_unspecified. Returns a valid EggRenderMode pointer if one is found, or NULL otherwise.

determine_depth_write_mode() EggRenderMode

Walks back up the hierarchy, looking for an EggGroup or EggPrimitive or some such object at this level or above this node that has a depth_write_mode other than DWM_unspecified. Returns a valid EggRenderMode pointer if one is found, or NULL otherwise.

determine_draw_order() EggRenderMode

Walks back up the hierarchy, looking for an EggGroup or EggPrimitive or some such object at this level or above this primitive that has a draw_order specified. Returns a valid EggRenderMode pointer if one is found, or NULL otherwise.

determine_visibility_mode() EggRenderMode

Walks back up the hierarchy, looking for an EggGroup or EggPrimitive or some such object at this level or above this node that has a visibility_mode other than VM_unspecified. Returns a valid EggRenderMode pointer if one is found, or NULL otherwise.

get_bface_flag() bool

Retrieves the backfacing flag of the polygon. See set_bface_flag().

static get_class_type() panda3d.core.TypeHandle
get_connected_shading() Shading

Determines what sort of shading properties this primitive’s connected neighbors have.

To get the most accurate results, you should first call clear_connected_shading() on all connected primitives (or on all primitives in the egg file). It might also be a good idea to call remove_unused_vertices() to ensure proper connectivity.

You may find it easiest to call these other methods on the EggData root node (they are defined on EggGroupNode).

get_material() EggMaterial

Returns a pointer to the applied material, or NULL if there is no material applied.

get_num_textures() int

Returns the number of textures applied to the primitive.

get_num_vertices() int

These are shorthands if you don’t want to use the iterators.

get_pool() EggVertexPool

Returns the vertex pool associated with the vertices of the primitive, or NULL if the primitive has no vertices.

get_shading() Shading

Returns the shading properties apparent on this particular primitive. This returns S_per_vertex if the vertices have colors or normals (and they are not all the same values), or for a simple primitive, S_overall otherwise. A composite primitive may also return S_per_face if the individual component primitives have colors or normals that are not all the same values.

To get the most accurate results, you should call clear_shading() on all connected primitives (or on all primitives in the egg file), followed by get_shading() on each primitive. You may find it easiest to call these methods on the EggData root node (they are defined on EggGroupNode).

get_sort_name() str

Returns the name of the primitive for the purposes of sorting primitives into different groups, if there is one.

Presently, this is defined as the primitive name itself, unless it begins with a digit.

get_texture() EggTexture

Returns the first texture on the primitive, if any, or NULL if there are no textures on the primitive.

Deprecated: This method is used in support of single-texturing only.

New code should be written to use the multitexture variants instead.

get_texture(n: int) EggTexture

Returns the nth texture that has been applied to the primitive.

get_textures() list
get_vertex(index: int) EggVertex

Returns a particular index based on its index number.

get_vertices() list
has_material() bool

Returns true if the primitive is materiald (and get_material() will return a real pointer), false otherwise (and get_material() will return NULL).

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.

has_texture() bool

Returns true if the primitive has any textures specified, false otherwise.

Deprecated: This method is used in support of single-texturing only.

New code should be written to use the multitexture variants instead.

has_texture(texture: EggTexture) bool

Returns true if the primitive has the particular indicated texture, false otherwise.

has_vertex_color() bool

Returns true if any vertex on the primitive has a specific color set, false otherwise.

If you call unify_attributes() first, this will also return false even if all the vertices were set to the same value (since unify_attributes() removes redundant vertex properties).

has_vertex_normal() bool

Returns true if any vertex on the primitive has a specific normal set, false otherwise.

If you call unify_attributes() first, this will also return false even if all the vertices were set to the same value (since unify_attributes() removes redundant vertex properties).

insert_vertex(index: int, vertex: EggVertex)

Inserts a vertex at the given position.

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_copy() EggPrimitive
property material EggMaterial
Getter

Returns a pointer to the applied material, or NULL if there is no material applied.

Setter

Applies the indicated material to the primitive.

property pool EggVertexPool

Returns the vertex pool associated with the vertices of the primitive, or NULL if the primitive has no vertices.

post_apply_flat_attribute()

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.

remove_doubled_verts(closed: bool)

Certain kinds of primitives, particularly polygons, don’t like to have the same vertex repeated consecutively. Unfortunately, some modeling programs (like MultiGen) make this an easy mistake to make.

It’s handy to have a function to remove these redundant vertices. If closed is true, it also checks that the first and last vertices are not the same.

This function identifies repeated vertices by position only; it does not consider any other properties, such as color or UV, significant in differentiating vertices.

remove_nonunique_verts()

Removes any multiple appearances of the same vertex from the primitive. This primarily makes sense for a point primitive, which is really a collection of points and which doesn’t make sense to include the same point twice, in any order.

remove_vertex(vertex: EggVertex) EggVertex

Removes the indicated vertex from the primitive and returns it. If the vertex was not already in the primitive, does nothing and returns NULL.

remove_vertex(index: int)

Removes the indicated vertex from the primitive.

reverse_vertex_ordering()

Reverses the ordering of the vertices in this primitive, if appropriate, in order to change the direction the polygon appears to be facing. Does not adjust the surface normal, if any.

set_bface_flag(flag: bool)

Sets the backfacing flag of the polygon. If this is true, the polygon will be rendered so that both faces are visible; if it is false, only the front face of the polygon will be visible.

set_material(material: EggMaterial)

Applies the indicated material to the primitive.

set_texture(texture: EggTexture)

Replaces the current list of textures with the indicated texture.

Deprecated: This method is used in support of single-texturing only.

Please use the multitexture variant add_texture() instead.

set_vertex(index: int, vertex: EggVertex)

Replaces a particular vertex based on its index number in the list of vertices. This is just a convenience function for people who don’t want to mess with the iterators.

property shading Shading

Returns the shading properties apparent on this particular primitive. This returns S_per_vertex if the vertices have colors or normals (and they are not all the same values), or for a simple primitive, S_overall otherwise. A composite primitive may also return S_per_face if the individual component primitives have colors or normals that are not all the same values.

To get the most accurate results, you should call clear_shading() on all connected primitives (or on all primitives in the egg file), followed by get_shading() on each primitive. You may find it easiest to call these methods on the EggData root node (they are defined on EggGroupNode).

property sort_name string

Returns the name of the primitive for the purposes of sorting primitives into different groups, if there is one.

Presently, this is defined as the primitive name itself, unless it begins with a digit.

test_vref_integrity()
property textures Sequence[EggTexture]

Returns the first texture on the primitive, if any, or NULL if there are no textures on the primitive.

Deprecated: This method is used in support of single-texturing only.

New code should be written to use the multitexture variants instead.

Returns the nth texture that has been applied to the primitive.

unify_attributes(shading: Shading)

If the shading property is S_per_vertex, ensures that all vertices have a normal and a color, and the overall primitive does not.

If the shading property is S_per_face, and this is a composite primitive, ensures that all components have a normal and a color, and the vertices and overall primitive do not. (If this is a simple primitive, S_per_face works the same as S_overall, below).

If the shading property is S_overall, ensures that no vertices or components have a normal or a color, and the overall primitive does (if any exists at all).

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

This may create redundant vertices in the vertex pool.

property vertices Sequence[EggVertex]
Getter

Returns a particular index based on its index number.

Setter

Replaces a particular vertex based on its index number in the list of vertices. This is just a convenience function for people who don’t want to mess with the iterators.

write(out: panda3d.core.ostream, indent_level: int)