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

addVertex(vertex: EggVertex) EggVertex

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

applyFirstAttribute()

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.

applyLastAttribute()

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

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 removeNonuniqueVerts(). Returns true if the primitive is valid, or false if it is degenerate.

clear()

Removes all of the vertices from the primitive.

clearConnectedShading()

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

clearMaterial()

Removes any material from the primitive.

clearTexture()

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

copyAttributes(other: EggAttributes)

Copies the rendering attributes from the indicated primitive.

copyAttributes(other: EggPrimitive)

Copies the rendering attributes from the indicated primitive.

copyVertices(other: EggPrimitive)

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

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

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

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

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

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

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

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

getBfaceFlag() bool

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

static getClassType() panda3d.core.TypeHandle
getConnectedShading() Shading

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

To get the most accurate results, you should first call clearConnectedShading() 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).

getMaterial() EggMaterial

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

getNumTextures() int

Returns the number of textures applied to the primitive.

getNumVertices() int

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

getPool() EggVertexPool

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

getShading() 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 getShading() on each primitive. You may find it easiest to call these methods on the EggData root node (they are defined on EggGroupNode).

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

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

getTexture(n: int) EggTexture

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

getTextures() list
getVertex(index: int) EggVertex

Returns a particular index based on its index number.

getVertices() list
hasMaterial() bool

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

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.

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

hasTexture(texture: EggTexture) bool

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

hasVertexColor() bool

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

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

hasVertexNormal() bool

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

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

insertVertex(index: int, vertex: EggVertex)

Inserts a vertex at the given position.

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.

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

postApplyFlatAttribute()

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.

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

removeNonuniqueVerts()

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.

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

removeVertex(index: int)

Removes the indicated vertex from the primitive.

reverseVertexOrdering()

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.

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

setMaterial(material: EggMaterial)

Applies the indicated material to the primitive.

setTexture(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 addTexture() instead.

setVertex(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 getShading() 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.

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

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